oficina / docs Public

Docs' app switcher lists the suite

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

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 ce297034f59d306ef16a6b2f2678739d9c507416 parent 5a4f6de
4 files changed, +44 −14
  • go.mod +1 −1
  • go.sum +2 −2
  • internal/docs/chrome.go +4 −4
  • internal/docs/chrome_test.go +37 −7

CI passed — run details

diff --git a/go.mod b/go.mod
index 47c91b6..f57eaff 100644
--- a/go.mod
+++ b/go.mod
@@ -3,7 +3,7 @@ module github.com/carlosframework/docs
go 1.26.5
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/handoff v0.0.0-20260908102137-481d2d57f489
amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf
amadan.net/rastrillo/native/server v0.0.0-20260923173546-2a5d07b2c8d3
diff --git a/go.sum b/go.sum
index a01869c..3d27146 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/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM=
amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489/go.mod h1:YISpzFJ+iMgrM0rUL032OSzsAQbP4/nozvXLCCOcn1k=
amadan.net/oficina/home/roster v0.0.0-20260908123429-74dda570e0cf h1:SRKjCUgtk42WwR7VSn+V0eLNk20mfiY8dQmzdw13Sbo=
diff --git a/internal/docs/chrome.go b/internal/docs/chrome.go
index ffa37db..1279ad7 100644
--- a/internal/docs/chrome.go
+++ b/internal/docs/chrome.go
@@ -126,10 +126,9 @@ func (h *handlers) account(r *http.Request, address string) *chrome.Account {
}
// switcher is the app switcher, or nil when no hub directory is
-// configured. Until Home's /apps/<slug> changes and the hidden id.*
-// interstitial have merged (spec §6.2 a, b and the §9.3 hide), it shows
-// "All apps" alone and no tiles: a tile today costs two assertion
-// exchanges and flashes an interstitial mid-switch.
+// configured: the suite's six apps as tiles, each at its own host under
+// the directory's (estilo's chrome.SuiteApps), with Docs marked current,
+// then "All apps".
func (h *handlers) switcher(r *http.Request) *chrome.Switcher {
if h.directory == "" {
return nil
@@ -137,6 +136,7 @@ func (h *handlers) switcher(r *http.Request) *chrome.Switcher {
return &chrome.Switcher{
Label: rastrillo.T(r, "docs.chrome.apps"),
CurrentLabel: rastrillo.T(r, "docs.chrome.thisapp"),
+ Apps: chrome.SuiteApps(h.directory, "docs"),
AllApps: estilomenu.Item{Href: h.directory + "/", Label: rastrillo.T(r, "docs.chrome.allapps")},
}
}
diff --git a/internal/docs/chrome_test.go b/internal/docs/chrome_test.go
index 0433ba5..389c566 100644
--- a/internal/docs/chrome_test.go
+++ b/internal/docs/chrome_test.go
@@ -134,9 +134,10 @@ func TestTheSignedOutCorner(t *testing.T) {
}
}
-// The switcher appears only with a hub directory configured, and until
-// Home's /apps/<slug> changes land it is "All apps" alone, with no tiles.
-func TestTheSwitcherIsAllAppsOnly(t *testing.T) {
+// 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
+// Docs marked current, and "All apps" below a divider.
+func TestTheSwitcherShowsTheSuite(t *testing.T) {
plain, _ := docs.NewForTest(t)
if body := get(t, plain, signInCookies(t, plain, "a@example.com"), "/").Body.String(); strings.Contains(body, "estilo-switcher") {
t.Error("a switcher with no hub directory")
@@ -146,11 +147,40 @@ func TestTheSwitcherIsAllAppsOnly(t *testing.T) {
t.Fatal(err)
}
body := get(t, app, signInCookies(t, app, "a@example.com"), "/").Body.String()
- if !strings.Contains(body, `<details estilo-switcher name="estilo-menus">`) || !strings.Contains(body, `<a estilo-menu-item href="https://oficina.works/"><span estilo-menu-label>docs.chrome.allapps</span></a>`) {
- t.Error("the switcher does not offer All apps", body)
+ 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>docs.chrome.allapps</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 == "docs" {
+ 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[0], "<span estilo-visually-hidden> docs.chrome.thisapp</span>") {
+ t.Error("Docs is not the one current tile", grid)
}
- if strings.Contains(body, "estilo-switcher-app") {
- t.Error("the switcher renders tiles before Home can serve them")
+ if res := get(t, app, nil, "/static/estilo/brand/calls.svg"); res.Code != http.StatusOK {
+ t.Errorf("a tile's icon is %d", res.Code)
}
for _, bad := range []string{"http://oficina.works", "https://oficina.works/", "https://Oficina.works", "https://127.0.0.1", "https://localhost", "https://a.b:8443", "https://user@a.b"} {
if _, err := docs.NewForTestWith(t, docs.Config{Directory: bad}); err == nil {