Skip to content

docs: product screenshots from a committed, deterministic pipeline - #189

Merged
fylorn merged 4 commits into
devfrom
docs/product-screenshots
Sep 25, 2026
Merged

fylorn merged 4 commits into
devfrom
docs/product-screenshots

Conversation

@fylorn

@fylorn fylorn commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The screenshot pipeline behind docs/screenshots/ lived in an ignored local directory and was lost, and the images still show the old navigation. This PR puts the pipeline in the repository and uses it to add screenshots of the current interface: dev at 3b8638e, after the redesign of every page (#187, #188, #190–#197) and #198, #199. When later changes land, one pnpm shots run brings the images up to date.

  • One command: pnpm shots regenerates every image (macOS only; documented in CONTRIBUTING under "Product screenshots").
  • Checked in CI: pnpm typecheck, which the Frontend job runs, now also checks scripts/shots/. A change to a type the mock answers fails the check instead of producing pages with error states. It already caught the Overview redesign (Overview page: design kit, skeleton and error states, live edge, clickable breakdowns #196) dropping history from Dashboard.
  • Not in the app build: scripts/shots/ is a separate Vite entry. src/index.css keeps scripts/ out of Tailwind's source scan; without that, a word such as grow in the mock added a rule to the app's stylesheet. vite build produces byte-identical assets with and without scripts/shots/.
  • Old images and READMEs untouched: the copy change that moves the READMEs to the new files will delete the old ones.

Two images depend on #195

The English menu images (en/menubar-menu-{light,dark}.png and web/menubar-menu-en.webp) were drawn with the menu bar layout fix from #195 applied locally; this branch does not contain it. Without the fix, "Resets in 3 days" and "4 failed" run into the text beside them. Every other image, including the Chinese menus and the menu bar item, is byte-identical with or without it. Until #195 is merged, pnpm shots on this branch draws those two English menus with the overlap.

How it works

  • The real UI on mocked IPC: scripts/shots/main.tsx mounts src/main.tsx with every Tauri command and control-plane endpoint answered from fixed data. Each Tauri command handler returns the type the interface reads (KeyUsage, UpstreamStats, Dashboard, ConnView, …, from src/generated/ or the page's API module), and endpoint handlers are typed from src/generated/tw-api.ts. At capture time, a command the mock does not answer, or one called without the arguments it expects, is logged as an error and stops the run.
  • Core's own answers: the configuration views (upstreams, keys, routes, security rules, prices, dry runs) are what core v0.47.0 returns for scripts/shots/core/config.{en,zh}.yaml. They are stored as JSON, checked against the core types, and regenerated by bash scripts/shots/core/oracle.sh <core checkout>, which runs oracle.rs inside a git archive of the pinned tag. Masking (sk-an…Q3xA, tw-5a…qmg8), detected protocols, origin-only base URLs, rule flags, prices and dry-run traces are therefore core's, not hand-written. The demo secrets are obviously fake: each keeps the first 5 and last 4 characters shown when masked, with EXAMPLE in the middle (zeros for the hexadecimal control key).
  • Demo configuration: four keys (default, claude-code, codex, cursor), three routes and two groups. Cursor's key has its own route, which sends Sonnet to a cheapest group, so the discounted relay is tried first; the dry-run scene shows that decision.
  • Real sentences: errors, security log entries, client adoption costs and steps, scan findings and notices carry their real message codes and English text, copied from core, tw-adopt, tw-scan and notices/rules.rs. The Chinese UI translates them through core.zh.json as it does in the app.
  • Deterministic: the clock is fixed at Fri 2026-09-25 16:42:07 local, traffic comes from a fixed seed, infinite animations are paused on their first frame, and a page is captured only once two snapshots in a row are identical. The menu bar images use the page's clock (--now), not the system clock. Two complete runs produce byte-identical files.
  • macOS rendering: capture.swift renders each scene in the system WKWebView (the engine the app uses on macOS), in a window placed off-screen with occlusion detection off. It frames each image as a macOS 26 window: 16 pt corners and 14 pt traffic lights at the positions measured from NSWindow. The sidebar is drawn in its solid color, because the translucent material is drawn by the window server and cannot be captured off-screen.
  • No clipped tables: a scene with a table that does not fit the 1100 pt window fails instead of being captured with its last columns cut off. The MCP scene collapses the sidebar, so the six client columns of the server matrix fit; the other scenes keep the sidebar open and the image size is unchanged.
  • Menu bar: src-tauri/examples/menubar_shots.rs draws the item and its menu with menubar::macos, at exactly 2×. It does not use write_png, which gives 4× on a Retina Mac. "Today" is the same figure the Overview computes. Standard items in the menu image are drawn approximately (preview_image).
  • Output: finish.mjs (sharp 0.34.5, the same version as the website; new dev dependency, install script disabled via allowBuilds) writes 256-color PNGs and the website's WebP variants.

What is added

Files
docs/screenshots/{zh,en}/<scene>-{light,dark}.png 2360×1540 (1100×690 pt window at 2× with frame), 144 dpi, 8-bit palette. Scenes: overview (7-day range), traffic, clients, keys, upstreams, routing, security, mcp (sidebar collapsed), settings, dry-run, remote-switcher (connected to a server, switcher open), remote-add (Add remote connection, test succeeded), remote-clients (Clients page with the remote banner)
docs/screenshots/menubar-{light,dark}.png Menu bar item (mark + today's tokens and cost), 178×64
docs/screenshots/{zh,en}/menubar-menu-{light,dark}.png The menu, 664×1120
docs/screenshots/web/ Website variants, following public/lite/ naming: <scene>.webp / <scene>-en.webp from the dark image at quality 85 (2360×1540), plus menubar.png (dark item) and menubar-menu(-en).webp

87 files, 9.8 MB.

Old → new

Old (docs/screenshots/) New
overview-{light,dark} / overview-en-* zh/overview-* / en/overview-*
requests-* {zh,en}/traffic-*
dry-run-* {zh,en}/dry-run-*
upstreams-* {zh,en}/upstreams-*
clients-* {zh,en}/clients-*
findings-* (page no longer exists) {zh,en}/security-* (security log) and {zh,en}/mcp-* (MCP servers and scan findings)
menubar-cost-*, menubar-quota-* (420×64) menubar-{light,dark} (178×64) and {zh,en}/menubar-menu-* (quota, in-flight request, today)
(none) keys, routing, settings, remote-switcher, remote-add, remote-clients

Verification

  • pnpm shots run twice from scratch: all 87 files identical. menubar_shots gives the same images for the same --now whatever the system date.
  • Every scene loads with no console errors and no failed IPC calls, and no table is wider than its container (checked by the capture for every image). Every light image is light and every dark image is dark.
  • Negative checks: returning the old key_usage shape, or removing a field from a stored core answer, fails pnpm typecheck; capturing the MCP scene with the sidebar open fails with "976 > 864".
  • pnpm typecheck, pnpm test, pnpm build, cargo fmt --check, cargo clippy --all-targets -D warnings and cargo test pass locally (the new example is macOS-only and compiles to an empty main elsewhere).

🤖 Generated with Claude Code

fylorn and others added 3 commits September 25, 2026 08:52
The screenshots in docs/screenshots/ were taken with a pipeline that
lived in an ignored local directory and was lost. This one is in the
repository and runs with one command, `pnpm shots` (macOS only):

- scripts/shots/ is a separate Vite entry that mounts src/main.tsx on
  mocked IPC. It is not part of the app build, and src/index.css now
  keeps scripts/ out of Tailwind's source scan, so the app bundle is the
  same with or without it.
- The configuration views (upstreams, keys, routes, security rules,
  prices, dry runs) are what the pinned core answers for a demo
  configuration, stored in scripts/shots/core/ and regenerated by
  oracle.sh. Masking, detected protocols, rule flags and prices are
  therefore core's own, and sentences carry their real message codes.
- The clock is fixed and the traffic comes from a fixed seed, so two
  runs write byte-identical files.
- capture.swift renders each scene in the system WKWebView, the engine
  the app uses on macOS, and frames it as a macOS 26 window.
- examples/menubar_shots.rs draws the menu bar item and its menu with
  the app's own rendering code, at exactly 2x.
- finish.mjs writes 256-colour PNGs to docs/screenshots/ and the
  website's WebP variants to docs/screenshots/web/. sharp is a new dev
  dependency; its install script is not needed and not allowed to run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Keys and Clients redesign (#190) changed `key_usage` to take
`{sinceMs, bucketMs}` and return `KeyUsage`, and `upstream_stats` gained
hourly buckets. The mock still answered the old shapes, and nothing
failed: its command handlers returned `unknown`, so the pages rendered
error states that the capture accepted.

- Every Tauri command handler now returns the type the interface reads
  (`KeyUsage`, `UpstreamStats`, `Dashboard`, `ConnView`, ...), and the
  stored core answers are checked against the core types. `pnpm
  typecheck`, which CI runs, now includes `scripts/shots/`, so a changed
  generated type fails the Frontend job. It already caught the Overview
  redesign (#196) dropping `history` from `Dashboard`.
- At capture time, a command the mock does not answer or one called
  without the arguments it expects is logged as an error and stops the
  run, instead of falling back to a default time window.
- `key_usage` and `upstream_stats` return totals plus sparse buckets, as
  tw-store's `cost_by` / `cost_buckets_by` do; `input_tokens` in the
  totals no longer includes cache reads and writes. `dashboard` computes
  latency over the same window as the summary, with tw-store's
  percentile rule, as dashboard.rs now asks for.
- The menu bar images take the page's fixed clock (`--now`) instead of
  the system clock, so runs on different days are byte-identical. Run on
  its own, `menubar_shots` uses the same instant.
- A scene with a table that does not fit the window fails instead of
  being captured with its last columns cut off. The MCP scene collapses
  the sidebar so the six client columns fit.
- Demo configuration: every secret keeps the first 5 and last 4
  characters shown in the masked views, with EXAMPLE in the middle (zeros
  for the hex control key). Cursor's key gets its own route to a
  `cheapest` group, so the routing page has three routes and three
  groups; the core answers are regenerated with oracle.sh (core v0.47.0).
- Review fixes: the hidden-text event counts 74 characters, the length of
  the text it reveals; the remote MCP finding uses tw-scan's rule id
  `remote-mcp`; CONTRIBUTING names `fetch-core.sh` and uses US spelling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated with `pnpm shots` on dev at 3b8638e (after the Keys, Clients,
Routing, Upstreams, Settings, Traffic and Overview redesigns, #190-#199),
core v0.47.0. Two complete runs produce byte-identical files.

- `{zh,en}/<scene>-{light,dark}.png`: 13 scenes, 2360x1540.
- `menubar-{light,dark}.png` (178x64) and `{zh,en}/menubar-menu-*.png`
  (664x1120).
- `web/`: the website variants (WebP from the dark images, and the dark
  menu bar item as PNG).

The English menu images were drawn with the menu bar layout fix from
#195 applied, which this branch does not contain: without it, "Resets in
3 days" and "4 failed" run into the text beside them. Every other image,
including the Chinese menus, is the same with or without that fix.

The old images and the README references are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn force-pushed the docs/product-screenshots branch from 0109697 to 578a4cf Compare September 25, 2026 01:05
The table body renders through useDeferredValue; on a busy machine the
capture's idle and stable-snapshot checks pass before that render commits,
and the scene is shot with only the in-flight row while the run succeeds.
Wait until the table has its rows. Images are unchanged at normal speed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit ac57512 into dev Sep 25, 2026
4 checks passed
@fylorn
fylorn deleted the docs/product-screenshots branch September 25, 2026 01:57
@fylorn fylorn mentioned this pull request Sep 25, 2026
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