Skip to content

feat(tooling): capture product screenshots of the real UI without a display - #703

Merged
huichen merged 2 commits into
mainfrom
feat/screenshot-kit
Sep 17, 2026
Merged

huichen merged 2 commits into
mainfrom
feat/screenshot-kit

Conversation

@huichen

@huichen huichen commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

What

Product screenshots previously required a person sitting in front of a running app: the desktop UI is a Tauri webview and the mobile UI is React Native, and both read their content from a local backend a browser cannot reach. That made screenshots impossible in CI, over SSH, or in a session without screen-recording permission.

This adds a harness that renders the real frontends in a local headless Chrome, against fixed demo data:

Real Replaced
desktop/src/** — every component, hook, store, worker, style @tauri-apps/* IPC, answered in-page (desktop/shot/mock/)
mobile/src/**, mobile/App.tsx mobile/src/remote/RemoteContext (the NATS client) + two native modules (mobile/shot/mock/)
Real Chrome rendering the real layout Real data, real network, real agent

Interactions are dispatched as real input events, so a capture reflects what the UI actually does; only the data source is fabricated.

Usage

make screenshots-desktop          # terminal 1: http://localhost:5299/shot/
make screenshots-capture-desktop  # terminal 2 -> .screenshots/
make screenshots-mobile           # terminal 1: Expo web on :8099
make screenshots-capture-mobile   # terminal 2

capture.py also does terminal-frame rendering for CLI output and PDF assembly from captured PNGs plus captions (scripts/screenshots/examples/release-notes-1.1.8.json is the worked example).

Deliberate boundaries

  • Captures are never committed. .screenshots/ and desktop/shot/assets/ (generated demo figures) are gitignored; capture.py regenerates the figures on demand.
  • Harness-only web deps are never saved. They go into the mobile workspace with --no-save, so mobile/package.json and package-lock.json are untouched.
  • Native builds are unaffected. The Metro hook that installs the mobile mocks is gated on SHOT_WEB=1 and the web platform.
  • desktop/shot/main.tsx can pin the UI language (?lang=en), seed app settings (?settings=…), and replay shortcuts the driver cannot send (?press=meta+f).

Also fixes

desktop/eslint.config.mjs scoped the Tailwind plugin's cssConfigPath to src/**. The plugin loads the project's CSS entry for any linted file, so linting a second file scope (the harness) made it fall back to a non-existent src/style.css and the entire eslint run errored out. The setting is now global.

Verification

  • desktop: tsc --noEmit, eslint, vitest run (1141 tests), stylelint — all pass.
  • mobile: tsc --noEmit, eslint, jest (1595 tests) — all pass.
  • scripts/check-docs.py — clean for the new docs (the 4 remaining findings are pre-existing on main under mobile/docs/, confirmed by stashing).
  • Both platforms capture end to end; screenshots were visually verified. Full scenario sets are green (15/15 each) with the driver now failing loudly on an unreachable target.

Docs

docs/guide/screenshots.md (en/zh): when to use this and when not to, the commands, the scenario format, how to extend the mocks, and the failure modes worth knowing.

…isplay

Product screenshots needed a person at a running desktop app: the desktop UI is a
Tauri webview and the mobile UI is React Native, and both draw their content from
a local backend a browser cannot reach. That made screenshot work impossible in
CI, over SSH, or in a session without screen-recording permission.

This adds a harness that renders the **real frontends** in a local headless
Chrome, with fixed demo data standing in for the backend:

- `desktop/shot/` + `desktop/vite.shot.config.ts` mock the `@tauri-apps/*` IPC
  boundary (and the loopback PTY server, via `shot/terminal-server.mjs`).
- `mobile/shot/` mocks `remote/RemoteContext` and two native modules. The Metro
  hook that installs them is gated on `SHOT_WEB=1` *and* the web platform, so
  native builds are untouched.
- `scripts/screenshots/` holds the Chrome DevTools Protocol driver, the scenario
  table, terminal-frame rendering and PDF assembly.

Everything except the data source is the shipped code: components, hooks, stores,
styles and i18n. Interactions are dispatched as real input events, so a capture
reflects what the UI does.

Two rules keep it a tool rather than a pile of binaries: captures and the
generated demo figures are gitignored (never committed), and the harness-only web
dependencies are installed into the mobile workspace with `--no-save`, leaving
`package.json` / `package-lock.json` untouched.

Also fixes a latent config bug this surfaced: `eslint.config.mjs` scoped the
Tailwind plugin's `cssConfigPath` to `src/**`, so linting any second file scope
made the plugin fall back to a non-existent `src/style.css` and the whole run
failed.

Docs: `docs/guide/screenshots.md` (en/zh) covers when to reach for this, the two
commands, the scenario format, and the failure modes worth knowing.
@huichen
huichen enabled auto-merge (squash) September 17, 2026 09:58
@huichen
huichen disabled auto-merge September 17, 2026 09:59
…isplay

Product screenshots needed a person at a running desktop app: the desktop UI is a
Tauri webview and the mobile UI is React Native, and both draw their content from
a local backend a browser cannot reach. That made screenshot work impossible in
CI, over SSH, or in a session without screen-recording permission.

This adds a harness that renders the **real frontends** in a local headless
Chrome, with fixed demo data standing in for the backend:

- `desktop/shot/` + `desktop/vite.shot.config.ts` mock the `@tauri-apps/*` IPC
  boundary (and the loopback PTY server, via `shot/terminal-server.mjs`).
- `mobile/shot/` mocks `remote/RemoteContext` and two native modules. The Metro
  hook that installs them is gated on `SHOT_WEB=1` *and* the web platform, so
  native builds are untouched.
- `scripts/screenshots/` holds the Chrome DevTools Protocol driver, the scenario
  table, terminal-frame rendering and PDF assembly.

Everything except the data source is the shipped code: components, hooks, stores,
styles and i18n. Interactions are dispatched as real input events, so a capture
reflects what the UI does.

It is driven as a script (`scripts/screenshots/capture.py serve-*` / `capture-*`,
`terminal`, `pdf`), not a make target. `docs/guide/screenshots.zh-CN.md` is the
entry point agents are pointed at from CLAUDE.md; it states the use cases
(release notes between two versions, a single feature diagram, a mobile flow
walkthrough), the commands, the scenario format, the document-assembly schema,
and how to extend the mocks when a screen changes.

Two rules keep it a tool rather than a pile of binaries: captures and the
generated demo figures are gitignored (never committed), and the harness-only web
dependencies are installed into the mobile workspace with `--no-save`, leaving
`package.json` / `package-lock.json` untouched.

Also fixes a latent config bug this surfaced: `eslint.config.mjs` scoped the
Tailwind plugin's `cssConfigPath` to `src/**`, so linting any second file scope
made the plugin fall back to a non-existent `src/style.css` and the whole run
failed.
@huichen
huichen force-pushed the feat/screenshot-kit branch from 8362ee7 to df8d9b6 Compare September 17, 2026 10:03
@huichen
huichen enabled auto-merge (squash) September 17, 2026 10:03
@huichen
huichen merged commit 5d80c8e into main Sep 17, 2026
12 checks passed
@huichen
huichen deleted the feat/screenshot-kit branch September 17, 2026 10:06
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