Skip to content

fix(website): remove the layout shift on docs pages; close the onboarding plan - #176

Merged
lg2m merged 2 commits into
mainfrom
fix/eng-926-site-layout-shift
Sep 25, 2026
Merged

lg2m merged 2 commits into
mainfrom
fix/eng-926-site-layout-shift

Conversation

@lg2m

@lg2m lg2m commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Linear: ENG-926. Closes the onboarding plan (ENG-875 tree).

Lighthouse on the live site

Desktop preset against https://retsu-ai.github.io/qq/:

Page Perf A11y Best practices SEO CLS
/ 100 100 100 100 0
/docs/install/ 85–94 100 100 100 0.19–0.29
/docs/configuration/ 100 100 100 100 0

The one problem was a layout shift on docs pages on cold loads. Lighthouse's trace named the culprit: the fixed right sidebar and every paragraph moved when the web font arrived. Two causes compounding: Inter's fallback (Arial) breaks lines differently, and Starlight positions the fixed sidebar from --sl-content-width, which we had set to 76ch — a unit that changes width with the font.

Fix

  • --sl-content-width: 50rem (same measure, font-independent).
  • scrollbar-gutter: stable — the first layout (short document, no scrollbar yet) and the final one now agree on viewport width.
  • A metric-matched Inter Fallback @font-face (size-adjust: 107%, ascent/descent overrides against Arial/Liberation Sans) so line breaks are identical before and after the swap.
  • sync-docs copies the three Latin font files (Inter variable, JetBrains Mono 400/500 — 91 KB total) to public/_fonts under stable names, the @font-face rules point at them (base path substituted from site.config.mjs), and the head <link rel=preload>s the two every page paints with. Fonts now arrive with the HTML instead of a round-trip after the CSS. The five non-Latin Inter subsets the fontsource import pulled in are gone.

After, against the built dist/: five consecutive runs of /docs/install/ at CLS 0; 100 / 100 / 100 / 100 on /, /docs/install/, /docs/configuration/, /docs/tui/.

Method note for the ledger: a CDP probe sampling the sidebar's rect never reproduced the shift — the observer itself delayed first paint past the font load. Lighthouse's trace was the reliable instrument.

Plan closed

docs/plans/onboarding-ux.md status → Complete; every slice row → Shipped (the plan table had never been updated as slices landed; the ledger had). Closing ledger entry records what worked (one audit every slice cited; one ledger, stacked merges; docs-truth + generated site landing together) and what to carry forward (shared CARGO_TARGET_DIR; ADR-first saved a protocol bump). Homebrew tap and token confirmed in place — no owner setup outstanding.

Verification

nub run build (sync, astro check 0 errors, 476 links resolve), Lighthouse as above. Site-only change; no Rust.

…ding plan

Lighthouse on the live site scored docs pages 85-94 on performance from a
0.19-0.29 layout shift on cold loads: the web font arrived after first
paint, Arial broke lines differently, and the fixed right sidebar was
positioned from `--sl-content-width: 76ch`, a unit that changes with the
font. Now: the content width is in rem; `scrollbar-gutter: stable` keeps
the first and final layouts on the same viewport width; a metric-matched
`Inter Fallback` face (size-adjust and ascent/descent overrides against
Arial) breaks lines identically before and after the swap; and sync-docs
copies the three Latin font files to public/_fonts under stable names so
the head preloads them with the HTML. Five consecutive runs of
/docs/install/ at CLS 0; 100 in every category on every page measured.

The plan's slice table and ledger now record every slice as shipped, with
a closing entry (what worked, what to carry forward, Lighthouse method).

Closes ENG-926.
lg2m added a commit that referenced this pull request Sep 25, 2026
`SessionStore::push_message`, `complete_streamed_turns`, `warm_empty`,
`mark_focused`, and `evict_cold_bodies` mutate body state only, but went
through `get_mut`, which drops the derived tree index. Every
`AssistantMessageStarted` and `TextAppended` therefore rebuilt the sidebar
order — exactly the per-frame rebuild `body_mut` exists to avoid. They
now use `body_mut`.

The test guarding this compared the order `Vec`'s pointer before and
after, which passes whenever the allocator hands the rebuilt index the
freed block; it failed on CI for main at 536a817 and for #176. The store
now counts index rebuilds under `cfg(test)` and the test asserts exactly
one, which fails deterministically against the old code (2 vs 1).

Closes ENG-927.
@lg2m
lg2m merged commit 9f2d82d into main Sep 25, 2026
6 checks passed
@lg2m
lg2m deleted the fix/eng-926-site-layout-shift branch September 25, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant