oficina / sheets Public

Sheets's app switcher lists the suite

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

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 2586c65faee2fdeccd4db86a63ab310bf1bbd354 parent 6d700d6
4 files changed, +47 −14
  • go.mod +1 −1
  • go.sum +2 −2
  • internal/sheets/chrome.go +4 −3
  • internal/sheets/chrome_test.go +40 −8

CI passed — run details

diff --git a/go.mod b/go.mod
index 26dc9bd..7603c81 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module amadan.net/oficina/sheets
go 1.25.0
require (
- amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768
+ 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 ddcf78e..659544f 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,5 @@
-amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 h1:bVscoa9fH5LdLDjlyecZhrX7JzWPT0blb57MH0FIm2U=
-amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768/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/sheets/chrome.go b/internal/sheets/chrome.go
index 3bdd9a2..7018e94 100644
--- a/internal/sheets/chrome.go
+++ b/internal/sheets/chrome.go
@@ -223,9 +223,9 @@ func (a *App) offersHomeLink(r *http.Request) 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 Sheets marked
+// current, then "All apps".
func (a *App) switcher() *chrome.Switcher {
if a.directory == "" {
return nil
@@ -233,6 +233,7 @@ func (a *App) switcher() *chrome.Switcher {
return &chrome.Switcher{
Label: "Oficina apps",
CurrentLabel: "(this app)",
+ Apps: chrome.SuiteApps(a.directory, "sheets"),
AllApps: estilomenu.Item{Href: a.directory + "/", Label: "All apps"},
}
}
diff --git a/internal/sheets/chrome_test.go b/internal/sheets/chrome_test.go
index 720aac6..0d43943 100644
--- a/internal/sheets/chrome_test.go
+++ b/internal/sheets/chrome_test.go
@@ -151,9 +151,10 @@ func TestTheSignedOutCorner(t *testing.T) {
}
}
-// §6: the switcher shows only when Home names a hub directory, and then
-// holds "All apps" alone (Paul's §13 answer 2) — no tiles yet.
-func TestTheSwitcherIsAllAppsOnly(t *testing.T) {
+// §6: the switcher shows only when Home names a hub directory. It holds
+// the suite's six apps as tiles at their hosts under the directory's,
+// with Sheets marked current, and "All apps" below a divider.
+func TestTheSwitcherShowsTheSuite(t *testing.T) {
app, cookies := signIn(t)
if body := page(t, app, cookies, "/sheets").Body.String(); strings.Contains(body, "estilo-switcher") {
t.Error("a standalone instance shows a switcher; there is no directory to switch through")
@@ -161,13 +162,44 @@ func TestTheSwitcherIsAllAppsOnly(t *testing.T) {
f := newHomeFixtureWith(t, "https://oficina.example.com")
f.local(t, signedInAddress)
body := f.request(t, "GET", "/sheets", nil, false).Body.String()
- for _, want := range []string{`<details estilo-switcher name="estilo-menus">`, `aria-label="Oficina apps"`, `<a estilo-menu-item href="https://oficina.example.com/"><span estilo-menu-label>All apps</span></a>`} {
- if !strings.Contains(body, want) {
- t.Errorf("the switcher lacks %s", want)
+ if !strings.Contains(body, `aria-label="Oficina apps"`) {
+ t.Error("the switcher is not labelled Oficina apps")
+ }
+ 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.example.com/"><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.example.com/"`
+ if slug == "sheets" {
+ 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[1], "<span estilo-visually-hidden> (this app)</span>") {
+ t.Error("Sheets is not the one current tile", grid)
}
- if strings.Contains(body, "estilo-switcher-app") {
- t.Error("the switcher renders app tiles before Home's /apps/<slug> hop is ready")
+ // Every tile's icon is served here, publicly: no cookies at all.
+ if rec := do(t, app, httptest.NewRequest(http.MethodGet, "/static/estilo/brand/calls.svg", nil)); rec.Code != http.StatusOK {
+ t.Errorf("a tile's icon is %d", rec.Code)
}
}