Skip to content

fix(preview): stop early with no build or no matching shot (#227) - #250

Merged
juancguerrerodev merged 14 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/preview-pick-227
Dec 6, 2026
Merged

juancguerrerodev merged 14 commits into
DojoCodingLabs:mainfrom
saurabhbhoir456:test/preview-pick-227

Conversation

@saurabhbhoir456

@saurabhbhoir456 saurabhbhoir456 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #227

The preview harness in apps/mobile/preview takes the screenshots every UI pull request needs. Two easy mistakes gave
a confusing result: running pnpm shoot before pnpm build crashed the server on the first request with a file error,
far from the real cause; and a filter that matches nothing (like a typo) opened Chromium, took no picture, and ended as
if all went well.

What this PR does

  • Adds apps/mobile/preview/pick.mjs with a pure pickShots(shots, filter) that returns the list of
    { shot, theme, lang, file } the loop in shoot.mjs would shoot, using the same file name rule
    (${shot.file}-${theme}-${lang}.png, kept when it contains the filter).
  • shoot.mjs now loops over pickShots(...). Before starting the server or Chromium: if dist/index.html is missing
    it prints "No build found. Run pnpm build first." and exits 1; if the list is empty it prints that no shot matches
    the filter, with three example names from shots.mjs, and exits 1.
  • clips.mjs is left alone, as agreed there; it can follow later.

Tests

  • apps/mobile/preview/pick.test.mjs (node:test, like browser.test.mjs), with a few made-up shots: no filter keeps
    all; an empty filter is no filter; a filter keeps only matching files (the whole file name, theme and language
    included); a filter that matches nothing gives an empty list.
  • pick.test.mjs is added to the test script in apps/mobile/preview/package.json.

How to check

cd apps/mobile/preview
pnpm install --ignore-workspace
pnpm test
pnpm shoot; echo "exit $?"
pnpm build && pnpm shoot nothing-matches-this; echo "exit $?"
pnpm shoot about

Verified here: with no dist/, shoot exits 1 with the message above and opens nothing; after pnpm build,
shoot nothing-matches-this exits 1 saying no shot matches and naming examples; shoot about still takes the four
About shots with no errors.

Keep in mind

  • The harness is dev-only and nothing in the app imports it. No new dependency.
  • Messages in plain English, with no em or en dashes.

Pull request template

What and why

Closes #227.

Preview shoot stops early with a clear message when there is no build or no shot matches the filter.

Vision fit

Principle 4, honest about limits: a typo'd filter or a missing build now says so instead of ending as if all went well.

Non-negotiables

  • This keeps every non-negotiable in AGENTS.md as it is.
  • Or it changes one, and this is the accepted RFC: n/a

Checklist

  • It closes one issue, linked above, or it's a small fix (a typo, a broken link, a wrong comment). A feature has an accepted proposal.
  • I wrote the failing test first. It fails without this change and passes with it. pick.test.mjs was written first and failed on the missing pick.mjs, then passed.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. Gate note: privacy and guard pass on this checkout today; the rest was run per package as listed under AI agents, not as one root gate on this Windows machine, where unrelated pre-existing failures appear in the site badges, the devices table and mobile source scans.
  • No new network call, telemetry, analytics, ads or crash reporting. (A new request in an app adapter is explained below, with its host, skill and risk.)
  • No new dependency, or the reason for each one is below.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes.
  • Tests, fixtures and screenshots use made-up data only.

Model path

  • This doesn't touch the model path: packages/model, agent, skills or eval, the prompt, the router, tool descriptions, normalizers, examples or the model file.
  • It does. The eval numbers from before and after are below, run as docs/evals.md says. No held-out case was tuned on.

Screenshots

  • No UI change.
  • UI change. Each changed screen is below, in both themes and both languages, with made-up data.

New dependencies and network calls

None. No new dependency and no new network call.

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Tinsel Alpha, an AI coding agent running in OpenCode, drafted the change and this description and ran the checks below, in a session directed by the author, who reviewed each step's report before it was pushed.
  • I read and ran everything in this pull request, and I can explain it.

What was run: pnpm test in apps/mobile/preview (26/26); manual shoot checks: no dist exits 1 with the message, a bad filter exits 1 naming examples, and shoot about takes 4 shots with 0 errors.

@juancguerrerodev

Copy link
Copy Markdown
Contributor

Ready to merge once the pull request template is filled in, including the "I read and ran everything" box (details on #234). 🦀

@juancguerrerodev
juancguerrerodev merged commit b6510d4 into DojoCodingLabs:main Dec 6, 2026
4 checks passed
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.

Preview: stop early when there is no build or no shot matches

3 participants