Skip to content

feat(preview): render the Device lab screen in the preview harness (#46) - #169

Open
Joaco2603 wants to merge 1 commit into
DojoCodingLabs:mainfrom
Joaco2603:feat/device-lab-preview
Open

Joaco2603 wants to merge 1 commit into
DojoCodingLabs:mainfrom
Joaco2603:feat/device-lab-preview

Conversation

@Joaco2603

@Joaco2603 Joaco2603 commented Nov 30, 2026 •

Copy link
Copy Markdown

What and why

Closes #46

The preview harness can now render and photograph the Device lab (HM-SET-10). It was the only screen in apps/mobile/src/app the harness couldn't render, because src/stubs/adapters.ts lacked the names the screen imports. This adds the route, made-up stand-ins for those names, and five shots. Nothing under apps/mobile/src changes.

Changes, all in apps/mobile/preview:

  • src/routes.ts: the device-lab route.
  • src/stubs/adapters.ts: inTurn, batterySaverOn, copyReport, keepScreenOn, openReportForm, shareReport, labSetup and labPorts. The phone is the made-up Examplecorp EX-1000 from scripts/devices/fixtures/good-report.json. The plan comes from the real initialPlan() and profileForPlan().
    • labPorts().sleep really waits, and ends early when its StopSignal fires, with the same contract as the phone's port. The lab's per-call cap runs on it, so a sleep() that returned at once would cut every call.
    • labPorts().now is a made-up clock. It starts at LAB_CLOCK.now and moves 250 ms on each read, so the report's date (2026-11-12), durations and first-token times come out the same on every run. Two runs of pnpm shoot device-lab gave byte-identical report shots.
    • The engine streams three tokens, waits 40 ms and answers.
    • scene.variant picks the state: battery turns battery saver on, fresh means no model yet (already in the stub), and running holds each engine call open until its signal aborts, so a run in progress can be shot without depending on timing.
  • shots.mjs: five core(...) shots: device-lab-ready, device-lab-battery, device-lab-no-model, device-lab-running and device-lab-report.
  • device-lab.test.mjs: pins the route, checks that every name the screen imports from ../adapters* is exported by the stub (named imports only, so a namespace import can't hide one), and pins the fixed clock, the StopSignal sleep and the allowed cores taken from the made-up phone. The harness has no TypeScript test runner, so these read the source.
  • package.json: a test script (node --test device-lab.test.mjs browser.test.mjs). Without it the new test, and the existing browser.test.mjs, run in no script. Glad to drop it if you'd rather keep the preview's scripts as they were.

Things to know:

  • The new test runs in no CI gate. apps/mobile/preview isn't in the pnpm workspace, so the root pnpm test doesn't reach it. A missing stub name would still break pnpm build in the preview. Wiring the preview into CI touches the workflows, so I left it for its own issue.
  • The report shot's accuracy is low on purpose. The stand-in engine doesn't answer the eval cases correctly, so the shot reads 1 of 12. The numbers are made up, and the shot is there for layout.
  • In the running variant, the lab's own 60 s cap on a speed call ends the run as failed after a minute. The shot is taken in under a second, so it doesn't show.

Alternatives considered

  • A separate stubs/device-lab.ts aliased in build.mjs, like mail.ts. It would keep the shared stub smaller, but the issue asks for adapters.ts, and inTurn is still imported from the shared adapters. Not done.
  • An engine that answers the eval cases correctly. A better-looking report, but it ties the stub to LAB_CASES and breaks whenever they change. Not done.
  • Injecting the finished report from the fixture. Not possible without changing the screen under apps/mobile/src.
  • Shooting the running state on a timer. Flaky: a fast engine finishes before the shot. The running variant waits on the signal instead.
  • A Playwright end-to-end test. It needs a browser, and the harness isn't in CI. The 20 shots cover it by hand.

Vision fit

Every UI change needs screenshots in both themes and both languages. With this, a change to the Device lab can show its shots like any other screen, with made-up data only.

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. Without the change, device-lab.test.mjs fails on the missing route and on 8 missing names (batterySaverOn, copyReport, keepScreenOn, labPorts, labSetup, openReportForm, shareReport, inTurn). With it, node --test device-lab.test.mjs browser.test.mjs passes. A second round after review: three new tests (fixed clock, StopSignal sleep, cores from the phone) failed first, then passed; 22 of 22 now.
  • These pass: pnpm check:privacy, pnpm typecheck, pnpm lint, pnpm test and node scripts/guard/check.mjs --patterns scripts/guard/patterns.txt. The preview isn't in the pnpm workspace, so the root typecheck and lint don't cover its files. pnpm build in the preview bundles the stub, and the 20 shots run it.
  • No new network call, telemetry, analytics, ads or crash reporting.
  • No new dependency.
  • Every UI string is in packages/copy, in es-419 and en, with matching keys and placeholders, and no em or en dashes. No new strings: the shots use the existing HM-SET-10 copy.
  • 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. The stub only calls exported functions from @hermit/model and @hermit/eval.
  • It does.

Screenshots

  • No UI change.
  • UI change. The screen itself doesn't change; these are its first shots from the harness. pnpm shoot device-lab prints 20 shots, 0 with errors, and every shot reports 0 contrast, 0 icons, 0 targets and 0 slips.

Ready

Light Deep sea
es-419
en

Battery saver on

Light Deep sea
es-419
en

No model yet

Light Deep sea
es-419
en

Report, top

Light Deep sea
es-419
en

Report, full page

Light Deep sea
es-419
en

New dependencies and network calls

n/a

AI agents

  • No AI agent wrote any part of this.
  • An AI agent helped. Which one, and what it did: Claude Code (Claude Opus 5.5) read the issue and the Device lab code, wrote the spec, the failing test and the stubs, and ran the gates and the shots. I reviewed each step.
  • I read and ran everything in this pull request, and I can explain it.

Tried on an Apple silicon Mac only.

🤖 Generated with Claude Code

…ojoCodingLabs#46)

Add the device-lab route and the stand-ins its screen imports to the
preview stub adapters: inTurn, batterySaverOn, copyReport, keepScreenOn,
openReportForm, shareReport, labSetup and labPorts. The lab runs on a
made-up Examplecorp EX-1000 and an engine that answers at once; its
sleep() really waits, so the per-call cap behaves as on the phone, and
its clock starts at LAB_CLOCK and steps a set amount, so the report
shot is the same on every run.

Add five HM-SET-10 shots (ready, battery saver on, no model yet, a run
in progress, the finished report) and a node test that pins the route
and every adapter name the screen imports. Nothing under apps/mobile/src
changes.
@Joaco2603
Joaco2603 marked this pull request as ready for review November 30, 2026 17:36
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.

Add the Device lab screen to the preview harness

1 participant