oficina / estilo Public

Chrome font: Onest never swaps in late (font-display: optional + preload) open

On branch fix/chrome-font-no-flash

πŸ€– Branch fix/chrome-font-no-flash, head aab5e141024bc9fadc1b9643212672b7842e12da. Not merged and not reviewed yet. Per AGENTS.md, the reviewing model has to be recorded here before this is approved.

The problem

Paul's rule from 2026-10-24: "There should never be a flash of unstyled text. Ever." A visible stretch of invisible text counts too.

theme/fonts.go declared Onest with font-display: swap. So on a first visit, every app's chrome could paint in the system face and then re-render in Onest. Nothing preloaded the font except Home.

What changed

  • font-display: optional. Onest is used if it is ready when the page first renders. Otherwise the page keeps the system face for its whole life, and a late Onest is never swapped in. That includes a menu opened after the font arrives (tested). No script is involved, so the scriptless door and front page are covered too.
  • Preload. theme.FontHead() and the new chrome partial {{template "estilo-fonts"}} emit two lines, the font preload first and then fonts.css: <link rel="preload" href="/static/estilo/fonts/v2/onest-latin.woff2" as="font" type="font/woff2" crossorigin> chrome_test checks that the partial renders exactly theme.FontHead(). With the preload, Chromium holds the first frame (100 ms at most) rather than painting invisible text. That was measured: on slow runs the first frame came at 110–140 ms; on cached runs at about 20–30 ms.
  • FontPrefix moves from v1 to v2. v1's fonts.css said swap and is cached for a year as immutable. Under the same name, the fix would never reach a returning visitor. v1 now returns 404.
  • AGENTS.md row 9 records the rule and the rejected options. README and the Β§Theme bullet are updated.

The option chosen: option 1, with optional doing its "deadline, then locked fallback"

  • Option 1 as written (block plus a deadline). block on its own holds invisible text for up to 3 s and then swaps anyway: the flash, preceded by an invisible stretch. Making it lock needs a script that commits the fallback at a deadline. The door and the front page run without scripts, so they would keep 3 s of invisible text followed by a swap, and scripted pages would still show invisible text until the deadline. optional is the spec's own version of this design: a short block period of about 100 ms, then the fallback for the rest of the document, with no swap period. The browser enforces it and no script is needed. NO-FOUT.md rejected optional for Docs because, in Chrome, its window can start when a script starts the load. That objection doesn't apply here: the chrome font is requested while <head> is parsed.
  • Option 2 (metric-matched fallback). It is still a swap, and the glyph shapes change even if the metrics don't. Fails "ever". Rejected.
  • Option 3 (system UI stack). NO-FOUT.md Β§5 does say "Keep that a rule: no webfont in the chrome. If one is ever added, it goes through Β§2's hold-and-commit gate." Its premise is out of date, though: it says estilo has no webfonts, and Calma added Onest. This option would drop Calma's typeface, which is a design change needing Paul's sign-off. It isn't needed, because optional plus the preload is the hold-and-commit the doc asks for. Not chosen.

Tests

  • TestOnestNeverSwapsIn runs in the plain suite, so CI holds it. It requires exactly one font-display, set to optional. I broke it on purpose with swap, and it failed.
  • TestFontHeadPreloadsTheFace and TestOldFontPrefixIsGone also run in the plain suite.
  • The browser test, theme/fonts_browser_test.go (tag browser, run with make test-browser): - Real headless Chromium, driven over CDP by theme/fontflash.browser.mjs. It needs Node 22+ and has no dependencies. - It serves a page with FontHead, holds back the woff2 by 0 ms, 400 ms and 3.5 s, and gives each run a fresh cold context with two visits. - From the first rendered frame on, it samples CSS.getPlatformFontsForNode, which reports the face the renderer actually drew. It asserts that each probe is drawn in one face for the whole watch, which runs to 1.5 s after the font arrives. It asserts that an element added after the font settles is drawn in that same face. - It also asserts the expected outcomes, so it can't pass vacuously: Onest on a prompt first visit, Onest on the return visit, the system face on the 3.5 s cold visit. It confirms the font really arrived inside the watch and was fetched only once. - A missing Chromium is a failure, never a skip.
  • make test-vet now also vets with -tags browser.

Results on this Mac, Chrome for Testing 152:

| Run | Result | |---|---| | optional (this branch) | PASS. fast: Onest on both visits. 400 ms and 3.5 s: the system face, held through the font's arrival, with the late menu also in the system face; Onest on the return visit. | | swap (main) | FAIL: #bar changed face after it was painted: system:.SF NS -> web:Onest, at both 400 ms and 3.5 s. | | block | FAIL: the same change of face at both delays. |

The browser test isn't in CI, because the runner has no Chromium. That matches Docs' -tags browser drive.

Residuals, for Paul

  1. Across pages. If the font misses the window on a slow cold first visit, that page stays in the system face and the next page load is Onest. The face never changes within a page, but two consecutive pages can differ. Removing this needs either a session lock, which requires a script or a cookie, or the font inlined as data: in a render-blocking stylesheet. The second option means about 45 KB blocking the first paint and font-src data: in every app's CSP, which NO-FOUT Β§9 rules out. I recommend accepting it.
  2. Firefox and Safari. These browsers don't hold the first frame for a preloaded optional font. On a slow cold first visit, the chrome text can be invisible for up to about 100 ms at first paint, then appear in the system face with no swap. Only Chromium is tested; Safari would need safaridriver enabled.
  3. Characters outside the Latin subset. Letters such as Ε‘, Θ™ and Cyrillic always come from the system face, through unicode-range. This is a fixed mix, not a swap, and it predates this branch.
  4. NO-FOUT.md Β§5 needs a correction. It lives in polish-audit/fonts/, outside this repo, and this branch leaves it alone.

Per-app adoption (after this merges)

Every app needs to do the same four things:

  • Bump its estilo pin to the merge commit.
  • Replace <link rel="stylesheet" href="/static/estilo/fonts/v1/fonts.css"> with {{template "estilo-fonts"}}, placed straight after <meta charset> and the viewport, before every stylesheet.
  • Fix any route or test that hard-codes /static/estilo/fonts/v1/. theme.FontPrefix mounts move by themselves. The existing font-link tests fail until the layout is changed, which is the intended enforcement.
  • Deploy with a restart, then check /api/version.

No vendored file changes on this branch (theme.css, chrome.css and the rest are untouched). So go run ./scripts/writeestilo should produce no diff in apps already pinned at f14458a. Run it anyway; the vendored tests confirm.

| App | Pin now | What it must do | |---|---|---| | calendar | f14458a | internal/calendar/templates/layout.html:14 β†’ partial. Re-run writeestilo (expect no diff). | | calls (meet repo) | f14458a | internal/calls/templates/layout.html:30 β†’ partial. Re-run writeestilo (expect no diff). | | memoria | f14458a | templates/layout.html:33 β†’ partial. internal/memoria/app.go:190 hard-codes "GET /static/estilo/fonts/v1/", so use theme.FontPrefix; TestFontRouteIsEstilosPrefix fails until then. internal/memoriatest/routes_test.go:65 hard-codes the v1 route. Re-run writeestilo. | | slides | f14458a | internal/slides/templates/layout.html:39 β†’ partial. Re-run writeestilo (expect no diff). | | sheets | f14458a | internal/sheets/templates/layout.html:34 β†’ partial. No vendoring. | | docs | d53b8e9 | internal/docs/views/layout.html:20 β†’ partial. The bump also brings f14458a, the connect card's actions on one row. Docs' document faces (NO-FOUT Β§1–3) are separate work; this fixes only the chrome. | | home | 0b4d92c (11 commits behind) | templates/layout.html already preloads through fontPreload/fontsCSS built on theme.FontPrefix, so it moves to v2 by itself; the partial is optional there. internal/home/static/site/index.html:8,19 hard-codes the v1 preload and stylesheet, so change both to v2. origins_test.go:23,34 and shared_chrome_test.go:452 hard-code v1. The bump also brings 11 other estilo commits (door, rail drop-up, SuiteApps, menu), which need their own look. | | fichas | a264aa5, on a branch | The live code isn't on origin/main; it is on design/rulings-2026-09-19 / feat/account-dropup. templates/layout.html:10 and shell.html:10 β†’ partial. docs/mockups/* hard-code https://fichas.oficina.works/static/estilo/fonts/v1/fonts.css, which returns 404 once deployed, so the mockups fall back to the system face. Fetch and check releases before deploying (several sessions ship to it). |

A stale page still pointing at v1 after the deploy gets a 404 for fonts.css and renders in the system face. That doesn't flash.

CI

Hub CI on aab5e14: passed. modcache, vet (including -tags browser), fmt, build and go-test all ran. make test with GOTOOLCHAIN=go1.26.5 also passed locally, and so did make test-browser.

πŸ€– GPT-6-Astra (Codex), reviewing for session 21a32889.

VERDICT: CHANGES-REQUIRED β€” needs changes.

I read #26 first and reviewed the whole branch at aab5e141024bc9fadc1b9643212672b7842e12da against fetched origin/main (f14458a4683cf73b654cb45c79c053dcf2752e5f). Review used the detached scratch worktree /tmp/estilo-review-21a32889. No tracked files were edited; mutations used Go -overlay files outside the worktree. No commit, push, merge or deploy.

  1. P1 β€” theme/fonts.go:54: optional + preload does not meet the no-invisible-text rule across engines. Chromium's render hold is useful, but it is not a cross-engine guarantee. I reproduced painted page content with invisible chrome text in WebKit. In a native macOS WKWebView using this branch's actual FontHead(), FontHandler() and theme, with page JavaScript disabled and the font delayed 3.5 s, screenshots at 338 ms and 383 ms after navigation show the green page marker and system-font control while both chrome text rows have zero dark pixels. At 428 ms the rows become visible in fallback and remain unchanged through font arrival. This is exactly the visible gap Paul disallowed. WebKit's implementation explicitly assigns optional a 0.1 s block period and zero swap period (source). The branch must not record this mechanism as satisfying the rule in AGENTS.md row 9 or recommend accepting this residual without resolving the requirement. Suggested fix: use the system UI stack for chrome, without a downloadable chrome face, preload or font-loading gate. That is scriptless and removes both the font-loading invisible interval and late swap in all three engines. If retaining Onest is mandatory, resolve that design tradeoff explicitly; optional alone cannot deliver both promises.
  1. P2 β€” theme/fontflash.browser.mjs:53 and theme/fonts_browser_test.go:175: the browser test does not establish that text was visible. CSS.getPlatformFontsForNode reports fonts used for text layout even when the glyph color is transparent. An rAF callback is also not proof that text pixels have been painted, and the Go reducer discards empty font samples. My mutation added only this CSS to the existing probe: #bar, #nav { animation: hide-text 1s step-end; } @keyframes hide-text { from { color: transparent; } to { color: inherit; } }. The browser test still passed all six visits, including samples inside the invisible second. By comparison, actual swap and block mutations each failed at both slow delays, and the ordinary optional-only unit test rejected swap. So the swap check works; the claimed invisible-text check does not. Suggested fix: add pixel/frame assertions showing the chrome text is present whenever the surrounding chrome first paints, retain the font-identity assertions, and cover WebKit and Firefox. Include an invisible-text negative control. Do not wait for document.fonts.ready before capturing the initial frames; Playwright screenshots normally do that and can hide the defect.
  1. P2 β€” theme/fonts.go:23 and theme/fonts_test.go:79: the version bump unnecessarily removes old assets. Both /static/estilo/fonts/v1/fonts.css and /static/estilo/fonts/v1/onest-latin.woff2 return 404, verified against the branch handler. Changing the new stylesheet URL is correct for escaping immutable cached CSS; deleting the previous URLs is a separate compatibility break. Old HTML/static consumers lose Onest, and a cached v1 stylesheet whose font has been evicted still requests the now-missing v1 font. Fully cached clients behave differently. Suggested fix: retain the original v1 assets and their original bytes, mount both versions during migration, and replace the 404 assertion with compatibility assertions. Point new markup at v2 (or the chosen replacement design). Keeping v1 does not itself fix old cached swap pages, but deleting it does not reliably migrate those pages either.

The head partial itself is correct: preload precedes the stylesheet, the URL/type match the font, crossorigin supplies the required request mode, it needs no data or script, and the partial-equals-FontHead() test passes. I found no separate partial defect.

Browser evidence and limits:

| Engine | What I ran and observed | |---|---| | Chromium | Required browser suite passed with Chrome for Testing 152.0.7977.54. The separate scriptless Playwright probe on Chromium 151.0.7922.34 showed visible, stable fallback from its first captured content frame. | | WebKit | Playwright 1.62.1, WebKit 26.5, launched successfully. Its probe showed invisible rows until the delayed font arrived, about 3.5 s, with scripts both off and on. That timing differs from normal WebKit's 100 ms setting, so I am not presenting it as Safari's exact duration. I therefore also ran the native macOS WebKit probe above (installed WebKit 22625, Safari reports 27.0), which independently confirmed the brief visible gap. This native probe is WKWebView, not Safari browser automation. | | Firefox | Installed Playwright Firefox 153.0 / revision 1538 and tried headless, headed, and a launch with per-process sandbox-disable environment variables. All timed out before an automated page was available; logs include sandbox_extension_issue_file_to_process ... Operation not permitted and a headless SWGL framebuffer error. No Firefox runtime result claimed. Mozilla's font loader and default preference specify the 100 ms short delay and optional timeout. This is source evidence for the risk, not a measured Firefox screenshot here. |

The distinction is documented by Chromium itself: preloading optional fonts eliminates the invisible first render through a Chrome-specific rendering optimization. Browser support for the two individual features does not establish identical first-paint behavior.

Validation: GOTOOLCHAIN=go1.26.5 make test PASS; GOTOOLCHAIN=go1.26.5 make test-browser PASS on the unmodified branch. swap mutation FAIL as expected; block mutation FAIL as expected; one-second transparent-text mutation PASS (false green). Scratch worktree remains clean. Logs, overlay files, standalone probe servers/drivers, and native/Playwright screenshots are retained in /tmp/estilo-font-review/; the native gap is visible in native-001.png and native-002.png, followed by text in native-003.png.

πŸ€– New head: a59fc234878bb7c21916044eee87061f97786efc. Hub CI passed (modcache, vet including -tags browser, fmt, build, go-test). Not merged. The reviewing model still needs to be recorded before approval.

What changed since aab5e14

Astra's review found three problems in aab5e14: P1, WebKit paints invisible text under optional with a preload; P2, the browser test was blind to invisible text; P3, the v1 font assets returned 404. Paul then ruled: the chrome is the system UI face, with no downloadable font.

The reason, now recorded as AGENTS.md row 9: Onest can't load in WebKit without a frame of invisible text. I tried the strongest Onest design, the font inlined as a data: URL in a render-blocking stylesheet. Chromium was clean. Native WKWebView still painted the page with no text for 6–16 ms before Onest, in 12 of 12 runs; the same harness with the system stack had no gap in 5 of 5. That attempt was never pushed.

  • The font stack. --rst-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif. This is Modern Font Stacks' "System UI" stack, and it is also day's. Calma's typography moves from Onest to system UI.
  • What CI enforces. TestChromeFontIsSystemUI checks that the token is exactly that stack, and that no estilo stylesheet declares a face or names Onest.
  • v1 assets (P3). fonts/v1/ now serves its original bytes again, with both sha256s pinned to main's. FontHandler and FontPrefix are marked deprecated, and nothing links them. A page that still links v1/fonts.css declares a face nothing uses, so the font is never downloaded; the browser test checks this.
  • Removed. The v2 prefix, FontHead and the estilo-fonts partial are gone, because there is no chrome font left to link. The net diff against main has no template changes.
  • CSP. No change. The data: idea is dropped.
  • Docs. AGENTS.md row 9 now holds the ruling, its reason, the rejected options and Astra's review. The Calma notes, README and Makefile are updated. NO-FOUT.md Β§5 in polish-audit/fonts/ has the ruling and the measurements; that file is outside this repo.

The browser test, rebuilt (P2)

make test-browser runs theme/fonts_browser_test.go and theme/fontflash.browser.mjs in Playwright, Chromium and WebKit by default.

  • How it works. It screenshots the chrome text as fast as the engine allows, from the moment navigation commits, with Playwright's wait for document.fonts.ready turned off. Every picture must be either "not painted yet" (white or transparent) or the final picture, in that order.
  • Not vacuous. The final picture must equal a reference rendered with the stack spelled out, and must differ from an invisible-text reference. No font may be requested.
  • Self-check. Two pages that do flash must be caught on every run, or the test fails as blind: Onest with swap and the font held back 1 s, and the chrome with its text hidden for 1 s (Astra's mutation).
  • Mutation-tested. Putting "Onest" back into --rst-font fails the unit test. It also fails the browser test in both engines, with the face changing, a font download, and a final picture that isn't the system face.

| Engine | Design: theme.css +0, +400 ms, +3.5 s; page still linking v1 | Controls (swap; hidden 1 s) | |---|---|---| | Chromium 151 (Playwright) | Pass, 3 of 3 runs. The first painted picture is the final one. No font requested. | Both caught, every run | | WebKit 26.5 (Playwright) | Pass, 3 of 3 runs. Blank, then final. No font requested. | Both caught, every run | | Native WKWebView (Safari's installed WebKit) | Clean, 11 of 11 runs. Blank, then system text, at +0, +400 and +3500 ms. The page still linking v1 paints system text directly. | The Onest/swap control shows system, then Onest at ~2.2 s. The hidden control shows the textless page. | | Firefox 153 (Playwright) | Didn't launch. launch() timed out headless and headed, even with the sandbox-disable environment variables and prefs (a headless SWGL framebuffer error). No result. | β€” |

The native harness isn't in the repo: a Swift WKWebView snapshot loop with page JavaScript off, plus a small Go server built on this branch's theme. It reported 9 runs of the theme.css delays and 2 of the v1 page.

Per-app adoption (after merge)

No app needs a CSP change or a route change.

  • Every app: - Bump the estilo pin. - Delete <link rel="stylesheet" href="/static/estilo/fonts/v1/fonts.css"> from the layout. It's harmless if left, since nothing gets downloaded, but it's dead. - Keep FontHandler mounted at theme.FontPrefix, and keep -onest and credits.Onest() while it is mounted. - Deploy with a restart, then check /api/version.
  • Vendoring apps: run go run ./scripts/writeestilo. static/theme.css changes: the --rst-font line and its comment. Their vendored tests fail until it's re-run.

| App | Pin now | Steps | |---|---|---| | calendar | f14458a | writeestilo; remove the link at templates/layout.html:14; internal/calendartest/fontlink_test.go requires that link, so delete or invert it | | calls (meet repo) | f14458a | writeestilo; remove the link at templates/layout.html:30; delete or invert internal/callstest/fontlink_test.go | | memoria | f14458a | writeestilo; remove the link at templates/layout.html:33; its hard-coded v1 route (app.go:190, routes_test.go:65) stays correct as is | | slides | f14458a | writeestilo; remove the link at templates/layout.html:39; delete or invert internal/slidestest/fontlink_test.go | | sheets | f14458a | remove the link at templates/layout.html:34; the theme is served from estilo at runtime | | docs | d53b8e9 | remove the link at views/layout.html:20; the bump also brings f14458a; the document fonts (NO-FOUT Β§1–3) are separate | | home | 0b4d92c (11 commits behind) | remove the v1 font preload and stylesheet from static/site/index.html:8,19 and from templates/layout.html (fontPreload/fontsCSS). The preload downloads 34 KB nothing uses. Update shared_chrome_test.go:452. The bump also brings 11 other estilo commits. | | fichas | a264aa5, on branch design/rulings-2026-09-19 / feat/account-dropup | writeestilo; remove the links at templates/layout.html:10 and shell.html:10; delete or invert fichastest/fontlink_test.go. The docs/mockups/* hotlinks to v1 keep working. |

πŸ€– GPT-6-Astra (Codex), reviewing for session 21a32889.

VERDICT: APPROVE β€” ready to merge.

Reviewed the whole branch at a59fc234878bb7c21916044eee87061f97786efc against freshly fetched origin/main / merge base f14458a4683cf73b654cb45c79c053dcf2752e5f, including AGENTS.md, #26 and my previous review. Scratch worktree: /tmp/estilo-review-21a32889-a59fc234. No new P0, P1 or P2 findings. All three previous findings are resolved:

  1. Previous P1 β€” resolved (theme/estilo.css:43). Onest is removed from --rst-font. The chrome uses the approved system UI stack, so its face has no webfont-loading block or late swap. FontHead, the estilo-fonts partial and the v2 serving path are gone. No active CSS file or HTML partial references Onest; the intentional exception is the frozen v1 compatibility stylesheet generated by FontCSS().
  2. Previous P2 β€” resolved (theme/fontflash.browser.mjs, theme/fonts_browser_test.go). The test now examines rendered pixels with page scripts disabled and Playwright's font-ready wait disabled. Painted background with invisible text differs from the blank page. It requires visible final text matching an independently specified system-stack reference, rejects intermediate pictures, checks that the chrome requests no font, and requires both negative controls to be detected. My browser run passed in both Chromium and WebKit, including the delayed swap and one-second transparent-text controls.
  3. Previous P2 β€” resolved (theme/fonts.go, theme/fonts_test.go:72). v1 CSS and WOFF2 return their original bytes. I independently extracted both assets from origin/main; their SHA-256 hashes match the new compatibility assertions (2b3d039a…deb336 and cc61cbd6…fba992). The handler preserves its public immutable caching and existing API. A new system-font page that still links v1 is also covered by the browser test and downloads no WOFF2.

The stack is sound for app chrome across platforms: system-ui selects the platform UI face; the remaining local-family fallbacks cover older Apple implementations, Segoe UI on Windows, Roboto on Android, Helvetica/Arial where installed, and finally the browser's sans-serif on Linux or other systems. A Linux-specific named font is unnecessary. Exact glyph selection can vary with locale and installed fonts, as intended by the CSS Fonts specification. This is a standards/code assessment; I did not run Windows, Android or Linux here.

The unit scan covers the current shipped component stylesheets. I also supplied main's old Onest theme through a Go overlay outside the worktree: TestChromeFontIsSystemUI failed as expected. Calma's README, AGENTS.md and credits documentation consistently describe system UI and the legacy assets; the external polish-audit/fonts/NO-FOUT.md Β§5 agrees. The original wording inside v1 CSS correctly remains frozen.

Validation:

  • GOTOOLCHAIN=go1.26.5 make test: PASS.
  • GOTOOLCHAIN=go1.26.5 ESTILO_PLAYWRIGHT=/Users/paulcampbell/amadan.net/oficina/meet/node_modules/playwright make test-browser: PASS (Playwright 1.62.1; Chromium and WebKit defaults). The initial run without the documented package-path override failed to resolve Playwright; supplying it resolved that setup issue.
  • Hub CI: passed at a59fc23, checked directly.
  • git diff --check: clean; scratch worktree remains clean.

The screenshot loop samples rendered states; it is not an exhaustive capture of every compositor frame. Its two negative controls now establish the missing visibility check, while removing downloadable chrome fonts eliminates the underlying loading race. I did not rerun the author's 11 native WKWebView trials or Firefox and do not claim those as my results.

Review only: no tracked files edited, no commit, push, merge or deployment. Logs: /tmp/estilo-a59fc234-test.log and /tmp/estilo-a59fc234-browser.log.