oficina / slides Public

Show the suite's apps as tiles in the switcher

Paul asked for the "All apps" dropdown to be a list of apps rather than
a dropdown holding a single item. The switcher now carries estilo's
chrome.SuiteApps for the configured hub directory: Docs, Sheets,
Slides, Calendar, Memoria and Calls, each at its own host under the
directory's, with Slides marked current, then "All apps" below a
divider. It still appears only when Home's directory is configured.
brand.Handler was already mounted, public and sessionless, so the
tile icons need no new route.

estilo is pinned to 0e40034 on estilo's feat/switcher-tiles branch,
which has not merged yet. Re-pin it to the estilo main commit once it
does. The bump from 0b4d92c broke no existing tests.

TestTheSwitcherShowsTheSuite asserts the six tiles in order with their
hrefs, icons and names, exactly one current tile with its hidden
label, All apps after the divider, no switcher without a directory,
and the icon served with no cookie. It fails with the Apps line removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 8dc3d119faaaf89af38e80fb603b639f6d71291c parent 16b762d
4 files changed, +82 −7
  • go.mod +1 −1
  • go.sum +2 −2
  • internal/slides/chrome.go +4 −3
  • internal/slides/home_test.go +75 −1

CI passed — run details

diff --git a/go.mod b/go.mod
index 67f5bab..b4b6cfd 100644
--- a/go.mod
+++ b/go.mod
@@ -5,7 +5,7 @@ go 1.25.0
toolchain go1.26.5
require (
- amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16
+ amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57
amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489
amadan.net/rastrillo/rastrillo v0.27.1-0.20261006204347-fb806a287060
diff --git a/go.sum b/go.sum
index 5373acd..08ad80a 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16 h1:F5v3x25dEj1rJNnBm71G7shN+fM+T2actUlaGPvoeH8=
-amadan.net/oficina/estilo.git v0.0.0-20261001084202-0b4d92c3dc16/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
+amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57 h1:5z3h+F5H9gpa4gLWxJKFaLFwNiNsI7zDKoRx9VPnwvI=
+amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw=
amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A=
amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI=
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM=
diff --git a/internal/slides/chrome.go b/internal/slides/chrome.go
index e7cc6fa..ed7d2d1 100644
--- a/internal/slides/chrome.go
+++ b/internal/slides/chrome.go
@@ -243,9 +243,9 @@ func (a *app) offersHomeLink(v viewerState) bool {
}
// switcher is the app switcher, or nil when no hub directory is
-// configured. It shows "All apps" alone and no tiles (Paul's §13 answer
-// 2): a tile today still costs an assertion exchange through the
-// directory session.
+// configured: the suite's six apps as tiles, each at its own host under
+// the directory's (estilo's chrome.SuiteApps), with Slides marked
+// current, then "All apps".
func (a *app) switcher(r *http.Request) *chrome.Switcher {
if a.directory == "" {
return nil
@@ -253,6 +253,7 @@ func (a *app) switcher(r *http.Request) *chrome.Switcher {
return &chrome.Switcher{
Label: rastrillo.T(r, "slides.chrome.switcher"),
CurrentLabel: rastrillo.T(r, "slides.chrome.switcher.current"),
+ Apps: chrome.SuiteApps(a.directory, "slides"),
AllApps: estilomenu.Item{Href: a.directory + "/", Label: rastrillo.T(r, "slides.chrome.switcher.all")},
}
}
diff --git a/internal/slides/home_test.go b/internal/slides/home_test.go
index 026a375..5f9a885 100644
--- a/internal/slides/home_test.go
+++ b/internal/slides/home_test.go
@@ -36,6 +36,13 @@ func homeFixture(t *testing.T) (*http.ServeMux, *app, User) {
return mux, a, u
}
func homeFixtureKey(t *testing.T) (*http.ServeMux, *app, User, *assertioncrypto.Keypair) {
+ t.Helper()
+ return homeFixtureDirectory(t, "")
+}
+
+// homeFixtureDirectory is homeFixtureKey with a hub directory origin
+// (HOME_DIRECTORY_ORIGIN) configured, which is what turns the switcher on.
+func homeFixtureDirectory(t *testing.T, directory string) (*http.ServeMux, *app, User, *assertioncrypto.Keypair) {
t.Helper()
d := testDB(t)
key, err := assertioncrypto.Generate()
@@ -43,7 +50,7 @@ func homeFixtureKey(t *testing.T) (*http.ServeMux, *app, User, *assertioncrypto.
t.Fatal(err)
}
raw, _ := json.Marshal(map[string]string{"test": base64.StdEncoding.EncodeToString(key.SignPub())})
- cfg := Config{Mailer: &homeTestMail{}, Env: EnvDevelopment, Origin: homeTestOrigin, Logger: quietLogger(), AllowedAddresses: []string{"owner@example.com"}, Home: &connect.Credentials{Issuer: "https://home.example.com", ConsumerID: "slides-test", KeysBase64: base64.StdEncoding.EncodeToString(raw), DEKBase64: base64.StdEncoding.EncodeToString(bytes.Repeat([]byte{8}, 32))}}
+ cfg := Config{Mailer: &homeTestMail{}, Env: EnvDevelopment, Origin: homeTestOrigin, Logger: quietLogger(), AllowedAddresses: []string{"owner@example.com"}, Home: &connect.Credentials{Issuer: "https://home.example.com", ConsumerID: "slides-test", KeysBase64: base64.StdEncoding.EncodeToString(raw), DEKBase64: base64.StdEncoding.EncodeToString(bytes.Repeat([]byte{8}, 32)), Directory: directory}}
mux, a, err := New(d, cfg)
if err != nil {
t.Fatal(err)
@@ -687,3 +694,70 @@ func TestHomeStartPageActionSaysConnect(t *testing.T) {
t.Error("the start action still says Continue")
}
}
+
+// The switcher appears only with a hub directory configured. It shows the
+// suite's six apps as tiles at their hosts under the directory's, with
+// Slides marked current, and "All apps" below a divider.
+func TestTheSwitcherShowsTheSuite(t *testing.T) {
+ loc, err := rastrillo.NewLocales(Locales, DefaultLocale, rastrillo.BaseCatalog(), LocaleFS)
+ if err != nil {
+ t.Fatal(err)
+ }
+ page := func(mux *http.ServeMux, a *app, u User) string {
+ t.Helper()
+ r := httptest.NewRequest("GET", homeTestOrigin+"/", nil)
+ r.AddCookie(homeSession(t, a, u.Email, "magiclink"))
+ w := httptest.NewRecorder()
+ loc.Middleware(mux).ServeHTTP(w, r)
+ if w.Code != 200 {
+ t.Fatal(w.Code)
+ }
+ return w.Body.String()
+ }
+
+ if body := page(homeFixture(t)); strings.Contains(body, "estilo-switcher") {
+ t.Error("a switcher with no hub directory")
+ }
+
+ mux, a, u, _ := homeFixtureDirectory(t, "https://oficina.works")
+ body := page(mux, a, u)
+ start := strings.Index(body, `<details estilo-switcher name="estilo-menus">`)
+ if start < 0 {
+ t.Fatal("no switcher", body)
+ }
+ panel := body[start:]
+ panel = panel[:strings.Index(panel, "</details>")]
+ grid, allApps, ok := strings.Cut(panel, "<hr>")
+ if !ok || !strings.Contains(allApps, `<a estilo-menu-item href="https://oficina.works/"><span estilo-menu-label>All apps</span></a>`) {
+ t.Error("the switcher does not offer All apps below the tiles", panel)
+ }
+ var tiles []string
+ for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] {
+ tiles = append(tiles, tile[:strings.Index(tile, "</a>")])
+ }
+ want := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"}
+ names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"}
+ if len(tiles) != len(want) {
+ t.Fatalf("%d tiles, want %d: %s", len(tiles), len(want), grid)
+ }
+ for i, slug := range want {
+ head := `href="https://` + slug + `.oficina.works/"`
+ if slug == "slides" {
+ head += ` aria-current="true"`
+ }
+ head += `><img src="/static/estilo/brand/` + slug + `.svg" alt="" width="32" height="32"><span>` + names[i]
+ if !strings.HasPrefix(tiles[i], head) {
+ t.Errorf("tile %d = %s, want it to start %s", i, tiles[i], head)
+ }
+ }
+ if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[2], "<span estilo-visually-hidden> (this app)</span>") {
+ t.Error("Slides is not the one current tile", grid)
+ }
+
+ // The tiles' icons are public: no cookie, no session.
+ w := httptest.NewRecorder()
+ mux.ServeHTTP(w, httptest.NewRequest("GET", homeTestOrigin+"/static/estilo/brand/calls.svg", nil))
+ if w.Code != http.StatusOK {
+ t.Errorf("a tile's icon is %d", w.Code)
+ }
+}