Skip to content

refactor(ui): extract the scanner camera lifetime - #53

Merged
yujiym merged 1 commit into
chore/void-1.6.2from
refactor/scanner-camera
Nov 5, 2026
Merged

yujiym merged 1 commit into
chore/void-1.6.2from
refactor/scanner-camera

Conversation

@yujiym

@yujiym yujiym commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Why

Move fuda's frontends from Solid to Preact through the owner's void-preact adapter to adopt their preferred structure and dogfood their library.

This layer stacks on #52. Extract the shared camera lifetime while every view still uses Solid, so the next layer can port Scanner without copying its camera loop.

What changed

  • Move the camera loop and constants into renderer-free camera.ts. CameraInput carries the video and callbacks. CameraSession returns release.
  • Preserve the 120 ms throttle, 960 px frame cap, hidden-page pause, first-result track cleanup, late-stream cleanup, visibility AbortController, and pending-decode teardown check.
  • Fix three defects reproduced against the original loop. Playback failure leaked tracks. Playback completing after teardown notified a disposed view. Visibility changes could overlap a pending decode.
  • Add 16 behavior tests with fake media, video, canvas, and timers. Four cases fail against the original implementation. All 14 deliberate mutations are caught.
  • Document the lifecycle guarantees in the canonical pass-flow specification.

Scope

Four files in shared UI and its specification. Scanner props, all renderers, and checked-in E2E assertions stay unchanged. The camera module remains internal because no other package imports it yet.

Blast Radius

The gate and the member app's Enter view both use Scanner. Normal scanning keeps its existing behavior. Failure and teardown paths now release resources and discard late callbacks. Returning to a visible page cannot start a second concurrent decode.

Verification

All pnpm commands used mise x node@24 -- corepack pnpm.

  • pnpm check passes. All 846 files correctly formatted; no warnings, lint errors, or type errors in 1019 files.
  • pnpm test passes. 2,424 Vitest tests and 70 Solidity tests.
  • pnpm fallow:audit passes. No issues in 19 changed files; dead code, complexity, and duplication findings are all zero.
  • PLAYWRIGHT_BROWSERS_PATH=/tmp/fuda-pw pnpm e2e passes. Gate 7, dash 6, app 6.
  • pnpm --filter @fuda/ui test passes. 47 tests in 8 files, including all 16 new camera cases.
  • Local app /signed smoke passes with Chromium's fake camera and a fictional session in the isolated E2E database. One decoded code releases the tracks, removes the video, and shows the rejection message. No page errors.
  • git diff --check passes. E2E-generated Void lock changes are restored.

Local evidence is under /home/yuji/code/github.com/oboroxyz/fuda-sh/artifacts/2026-11-05-preact-migration/scanner-camera/, including original defect failures, mutation logs and script, full gate logs, and the app smoke script and output.

Deploy and manual checks

No deployment. All local verification servers are stopped.

Owner checks remain on real iPhone and iPad Safari cameras in gate and Enter. Confirm rear-camera selection, permission denial, hide/show, release after a scan, and navigation during acquisition. Confirm the physical gate keyboard reader. Automated fake media does not verify real devices or hardware timing.

Signed-off-by: yujiym <1409395+yujiym@users.noreply.github.com>
@yujiym
yujiym merged commit 4ffec7e into chore/void-1.6.2 Nov 5, 2026
12 checks passed
@yujiym
yujiym deleted the refactor/scanner-camera branch November 5, 2026 14:11
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