feat(mobile): Expo app foundation — auth, API client, collection, Rapid Add camera #376
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.75) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #376"
general
weight: 0.35
mattmck
Refs #109 (and the native remainders of #21 Rapid Add and #105 photo matching it carries). Not
Closes: you decide when #109 is done.What this adds
The Expo app goes from a blank template to a signed-in, API-backed app with native Rapid Add.
(app)holds a Collection / Search / Add / Profile tab bar behindStack.Protected, andsign-insits outside it. TypeScript is strict and extendstsconfig.base.json. ESLint (eslint-config-expo) runs as part ofnpm run lint.npm run dev:mobilebuilds the shared types, then starts Expo. Settings come from.env.local(EXPO_PUBLIC_, see.env.example).- Dev bypass sends
Bearer dev:<id>.- Entra External ID uses
expo-auth-session(authorization code + PKCE) against the same tenant and app registration, so the token has the same shape. Tokens are kept inexpo-secure-storeand refreshed before they expire.- "Not configured" is the third mode.
- In every mode, a session counts as signed in only after
POST /api/auth/validateaccepts it.src/api/client.ts) mirrorsapps/web/src/lib/api.tswithswatchwatch-sharedtypes. It covers polishes (status/untried filters, paging), detail, inventory quick actions, dupes, the mani log, catalog search, capture (start/frame/check/finalize/status/answer) and match-image.- Collection: status presets, untried badge, swatch thumbnails from the image-variant ladder, infinite scroll, pull to refresh.
- Polish detail: gallery, finishes, hexes, status actions following D5, Mark tried, Log today's mani with undo, owned-dupe callout, buy link.
- Search: Add / ♡ behind the #266 add guard, with fuzzy suggestions when nothing matches.
- Profile: who is signed in, API URL, sign-in mode, sign out.
-
expo-camerascans barcodes on the device. GTINs are validated by a new sharedbarcode/gtin.tsthat uses the web scanner's rules.- Photos tagged barcode / label / color are posted to
/api/capture/{id}/frame. Network, 408, 429 and 5xx errors retry automatically, then the photo shows Retry / Remove.- The verdict comes from the read-only
POST /api/capture/{id}/check: you own it / on your wishlist / near-dupe / new to you / pick one / not found.- A photo-library fallback and hints cover simulators and bottles with no barcode.
/match): a camera or library photo goes toPOST /api/polishes/match-image, and the extracted colors work as filter chips.npm run sync:design-tokensgeneratespackages/shared/src/constants/design-tokens.tsfrom the web'sglobals.css(oklch → hex, light + dark). The mobile theme uses it, and CI checks that it doesn't drift.Screenshots
Expo web preview at 375×812, signed in through dev bypass against a local Functions host and the local dev DB. The iOS simulator could not run (see Verification).
| Sign-in | Collection (dark) | Collection (light) | Polish detail |
|---|---|---|---|
|  |  |  |  |
| Search | Rapid Add | Verdict: you own it | Profile |
|---|---|---|---|
|  |  |  |  |
Verification
npm run typecheckandnpm run lintacross the workspace (0 errors; the 13 warnings were already in web).npm run testacross the workspace (runs in the pre-commit hook), including the new mobile suites.node scripts/sync-design-tokens.mjs --check. Brand hexes come out exactly equal toswatchWatchBrandPalette.npm run build --workspace=apps/webpasses with the new root Reactoverrides.:7071through a throwaway CORS proxy, local dev DB):- "Continue as dev user" →
/auth/validate→ Collection lists dev user 1's 20 owned polishes from the API.- The session is restored after a reload.
- Polish detail loads.
- Search returns catalog rows with ownership.
- Rapid Add with hints (OPI / Big Apple Red) →
capture/start→capture/check→ "You own this · 2 bottles · Nothing was added".35d21af:- a barcode scanned into an already-started session was checked before its GTIN arrived
- stale-scan callbacks after Scan next
- two paging races
- a network failure during token refresh signed the user out
- the Android
swatchwatch://authredirect landed on an unmatched routeexpo run:iosnor the simulator was available. Not exercised:- native rendering (iOS / Android)
- expo-camera preview and on-device barcode scanning
-
takePictureAsync→ image-manipulator → frame upload- expo-image-picker
- secure-store persistence (the web preview uses localStorage)
- haptics
- the Entra PKCE sign-in, which needs the redirect URI below and a dev build
capture_sessionrow for dev user 1, so I did not exercise Add / Wishlist / status changes / Log mani / I bought it / Match. Their API calls are the same ones the web makes.Judgment calls
1. Expo SDK 57, not 54.
apps/mobile/package.jsonwas already onexpo ~57.0.26, though dependabot had separately bumpedreact-nativeto 0.88 and leftreactat 19.1. I realigned react-native, react and every Expo package to SDK 57'sbundledNativeModules. CLAUDE.md said SDK 54 and is now corrected.2. One React for the whole repo. The root
package.jsonnow hasoverrides: { react: 19.2.3, react-dom: 19.2.3 }.- Why: the root
nextdevDependency hoisted react 19.2.7 while web and mobile pin 19.2.3. That nested expo-router where the hoisted Expo CLI couldn't find it, soexpo startcrashed. React Native's renderer also needs an exact React match.- 19.2.3 is the version web already pins, and the web build passes.
- Bump the override together with web and Expo React upgrades.
3. Expo SDK 57 + expo-auth-session instead of MSAL React Native. The issue says MSAL RN.
react-native-msalis unmaintained and needs native config.expo-auth-sessionwith PKCE gets the same tenant, scopes and token shape.4. Rapid Add checks before it adds. The web finalizes, which adds the polish to the collection, and then offers an undo. Mobile uses the read-only
/checkendpoint and writes only when the user taps Add (PUT /api/polishes/{shadeId}, orfinalizefor a SKU without a shade). In an aisle that is the safer default. The wishlist and near-dupe verdicts the web'scapture-verdict.tslists as "extension points" exist natively here.5. iOS UPC-A quirk. iOS reports UPC-A as a 13-digit EAN-13 with a leading 0. Because
barcode.gtinlookups are exact, mobile sends the printed 12 digits, as the web scanner and OCR do. Normalizing GTINs on the server would be more robust; see follow-ups.6. Search uses
GET /api/polishes?search=(catalog rows with the caller's status, hexes and images) rather than/catalog/search, whose results carry no color or ownership./catalog/search(pg_trgm) is the fallback when the first returns nothing.7. Dev bypass is the default in development builds without Entra settings, and an explicit
EXPO_PUBLIC_AUTH_DEV_BYPASS=falseturns it off. Mobile dev bypass also still shows a sign-in button that calls/auth/validate, so "auth end-to-end" is exercised; the web auto-signs-in instead.8. No
EXPO_PUBLIC_B2C_SIGNUP_SIGNIN_POLICY+ a tenant id = External ID (nop=). The web would fall back to the legacyB2C_1_signupsigninpath there.9. Shared additions are small and additive:
-
constants/design-tokens.ts(generated)-
barcode/gtin.ts(a copy of the pure rules fromapps/web/src/lib/barcode-scan.ts; I left web untouched because other sessions are editing it)- the Rapid Add frame reducer is copied into mobile, not moved
10. CI:
-
setup-depsgets aninclude-mobileinput with its own cache key, so the existing jobs keep their install.- The existing Lint & Typecheck job now names its workspaces explicitly, because the root scripts now include mobile.
- No device builds.
11. Screenshots are committed under
apps/mobile/docs/screenshots(about 320 KB) so the README and this PR can show them.12. Route groups:
(app)andsign-inonly. There is no(marketing)or(admin)group yet, since neither has native screens.Decisions needed
Each one is parked with my recommendation already applied. Nothing in this PR is blocked on them.
1. Should mobile Rapid Add check first, or add on match like the web?
- Recommended: keep check first (mobile, read-only
/check, add on tap). The web finalizes, which adds immediately, and then offers an undo.- Blocks: nothing. If you want the web's behavior instead, it's a small change in
add.tsx(callfinalizein place ofcheck).- Later, consider moving the web to check-first too, for consistency.
2. Keep the root
overridesthat pin React to 19.2.3?- Recommended: yes, until web, mobile and
nextagree on a React patch. Without itexpo startfails in this monorepo.- Blocks: React upgrades now have to bump the override.
3. Stay on Expo SDK 57?
- Recommended: yes. CLAUDE.md said SDK 54, but
package.jsonwas already on 57.- Blocks: nothing.
4. MSAL React Native vs expo-auth-session?
- Recommended: expo-auth-session. The issue text names MSAL RN.
- Blocks: nothing until you register the redirect URI below.
Owner actions
swatchwatch://auth:- Entra admin center → External ID tenant → App registrations → the web app's registration → Authentication → Add a platform → Mobile and desktop applications.
- Do this for each environment's tenant you want to sign in from.
- No new registration or secret is needed (public client + PKCE).
NEXT_PUBLIC_B2C_apps/mobile/.env.localasEXPO_PUBLIC_B2C_, setEXPO_PUBLIC_AUTH_DEV_BYPASS=false, thennpx expo run:ios. Sign-in needs a dev build: Expo Go's redirect URI can't be registered.sudo xcode-select -s /Applications/Xcode.app/Contents/Developer) to run the simulator checks listed above.http://localhost:8081(func start --cors http://localhost:8081). Native builds need nothing.Follow-ups (not in this PR)
barcode-scan.tsto the sharedbarcode/gtin.ts, and move the frame reducer into shared.expo export) once Xcode/EAS are set up.🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added a mobile app with sign-in, collection browsing, polish search and details, photo matching, and Rapid Add scanning.
Added barcode scanning, photo-based polish matching, and options to add matches to a collection or wishlist.
Added light and dark themes that follow the device setting.
Added support for development and Microsoft sign-in modes.
Documentation
Added mobile setup, configuration, testing, and design-token synchronization guidance.
Chores
Added mobile linting, type checking, unit tests, and design-token checks to CI.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->