Skip to content

Make handbook diagrams legible in both themes and annotate screenshots - #10

Merged
sodre merged 1 commit into
mainfrom
t3/handbook-visual-review
Nov 18, 2026
Merged

sodre merged 1 commit into
mainfrom
t3/handbook-visual-review

Conversation

@sodre

@sodre sodre commented Nov 18, 2026

Copy link
Copy Markdown
Member

Why

The handbook's visuals had readability problems:

  • Labels in the Mermaid sequence diagrams were struck through by lifelines and overflowed their boxes.
  • access-ends was stretched to roughly 1.5× body-text size.
  • Every diagram was a white slab in dark mode.
  • The approval screenshots were near-identical, so readers had to hunt for the row each one is about.

What changed

Sequence diagrams (first-request, access-ends)

  • Root cause: Mermaid measured text with its default font (trebuchet ms) but drew it in DejaVu. Setting the top-level fontFamily and fontSize fixes the sizing.
  • Message labels get a background-coloured halo, so lifelines no longer cross the text.
  • Steps are grouped into labelled phase bands ("Request and approval", "Case 1: the user quits the Companion", …).
  • Mirrored bottom actors are gone and margins are trimmed. Both diagrams now render at 1:1 within the content column (697 px and 519 px wide).

One palette, light and dark

  • docs/assets/diagrams/palette.json holds every diagram colour. Hand-drawn SVGs reference it only through var(--token), and the script rejects stray hex values.
  • scripts/render_diagrams.py regenerates each light SVG's palette block and writes a -dark.svg. For Mermaid it derives a dark theme by swapping tokens.
  • Pages embed both variants with #gh-light-mode-only / #gh-dark-mode-only. GitHub and Material's theme toggle both honour these suffixes.
  • handbook.css no longer forces display: block (it was overriding Material's hide rule), width: 100% or a white background on diagrams.
  • Architecture, sidecar and shared carry an in-image legend (solid = application traffic, dashed = control). Sidecar routing and a few label collisions are fixed.

Screenshots

  • Raw captures move to docs/assets/screenshots/raw/, which the build excludes.
  • scripts/annotate_screenshots.py (Pillow) draws callouts onto the copies the pages embed.
  • The widget/branding reference gets its own approval-branding.png instead of reusing approval-selected.png.
  • develop.md documents both scripts.

Verification

  • Ran mkdocs build --strict with the pinned requirements-docs.txt; it exits 0.
  • Rendered every diagram in headless Chromium in both variants, plus the built architecture and integrate pages under prefers-color-scheme: light and dark. Exactly one variant shows per theme.
  • Checked each annotated screenshot by eye for callout placement.

Follow-ups (separate PRs)

  • Restyle the demo Integrator as a fictional brand ("Harbor Ledger") and give the widget a default theme.
  • Recapture screenshots with a script (Playwright, including the Electron Companion) in light and dark.

🤖 Generated with Claude Code

Sequence diagrams: Mermaid measured text with its default font while
drawing DejaVu, so labels overflowed and lifelines struck through them.
Match the measuring font, halo message labels, group steps into labelled
phase bands, drop mirrored actors and trim margins so both diagrams fit
the content column at 1:1.

All diagram colours now come from docs/assets/diagrams/palette.json.
Hand-drawn SVGs use var(--token) only, carry an in-image legend, and
scripts/render_diagrams.py writes a -dark variant of every diagram.
Pages embed both with #gh-light-mode-only/#gh-dark-mode-only, which
GitHub and the Material theme toggle both honour; the handbook CSS no
longer stretches diagrams or paints them white.

Screenshots: raw captures move to screenshots/raw/ (excluded from the
build) and scripts/annotate_screenshots.py draws callouts on the copies
the pages embed. The branding reference gets its own annotated copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sodre
sodre merged commit 08a2d95 into main Nov 18, 2026
32 checks passed
sodre added a commit that referenced this pull request Nov 18, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs/assets/screenshots/approval-branding.png
#	docs/assets/screenshots/approval-selected.png
#	docs/assets/screenshots/approval-unselected.png
#	docs/assets/screenshots/branding-alternate.png
#	docs/assets/screenshots/pairing-browser.png
#	docs/assets/screenshots/pairing-companion.png
#	docs/assets/screenshots/raw/approval-selected.png
#	docs/assets/screenshots/raw/approval-unselected.png
#	docs/assets/screenshots/raw/branding-alternate.png
#	docs/assets/screenshots/raw/pairing-browser.png
#	docs/assets/screenshots/raw/pairing-companion.png
#	docs/assets/screenshots/raw/scope-wildcard.png
#	docs/assets/screenshots/raw/widget.png
#	docs/assets/screenshots/scope-wildcard.png
#	docs/assets/screenshots/widget.png
#	docs/develop.md
#	docs/reference/widget.md
#	scripts/annotate_screenshots.py
sodre added a commit that referenced this pull request Nov 18, 2026
From the review of #10:
- Reject every colour that bypasses palette.json: short and long hex,
  rgb()/hsl() and friends, and named colours in fill, stroke and other
  paint properties, in hand-drawn SVGs, .mmd sources and theme.json.
- Name palette tokens as {token} in theme.json and .mmd bands and
  resolve them per mode, instead of reverse-matching hex. Light values
  no longer have to be unique, so surface is plain #ffffff again.
- Turn off Mermaid's default band drop shadow, which glowed in dark mode.
- Insert palette blocks with a function, not a regex template.
- Make --hand and --mermaid mutually exclusive.
- Embed light/dark diagram pairs without link wrappers, so the hidden
  variant no longer leaves an empty, focusable link.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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