oficina / slides Public

Slides's app switcher lists the suite

The bar's switcher now shows Docs, Sheets, Slides, Calendar, Memoria and
Calls as tiles, Slides marked current, above All apps, from estilo's
chrome.SuiteApps (estilo d53b8e9). Reviewed by GPT-6-Astra via Codex (#22).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from feat/switcher-tiles into main.
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 0a098cba6273ee0711e48ea966ac94f5f6609252 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..969daad 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-20261024225350-d53b8e9533a1
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..e8281d7 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-20261024225350-d53b8e9533a1 h1:Xaidrm9rzFyne6PujFYXiY7nGRy+/KzH7kGBM2+D5LQ=
+amadan.net/oficina/estilo.git v0.0.0-20261024225350-d53b8e9533a1/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)
+ }
+}