← Back to Pull requests

feat(mobile): manual add form that learns the scanned barcode (#109) #424

Closed
unknown closed this pull request without merging on Oct 23, 2026 05:15 UTC
View on GitHub
unknown unknown commented on Oct 23, 2026 04:42 UTC
Author

Summary

A bottle the catalog doesn't know no longer dead-ends on mobile. New Expo screen /polishes/new, Add a polish, which mirrors the web's /polishes/new:

  • Fields: brand, shade name, finish chips from GET /api/reference/finishes, picked in order with the first one as the main finish (falls back to CANONICAL_FINISHES), and color. Color uses the By color palette (12 hue stops + neutral, then five lightness steps) or a typed hex, plus an optional color name. Then I own it / Wishlist, bottles (owned only), 0–5 star rating and notes.

  • Prefill: params barcode, barcodeFormat, brand and name fill the form, with the same rules as the web's scanPrefillFromParams. A scanned barcode is shown read-only and sent with POST /api/polishes, so the API remembers it for this user (user_shade_barcode).

  • Add guard: before saving, owned near-dupes of the entered color are checked on device with the shared dupe rule (a port of the web's dupesForNewShade). The user picks Add anyway / Wishlist instead / Cancel. The prompt is the existing confirmDupes (pulled out of confirmAddWithDupes). A slow or failed load of the owned list (2 s timeout) never blocks the add.

  • After saving: the app opens the new polish (router.replace to /polishes/[id]). The Collection tab and Home panel refetch through a small collection-events signal, which also rewrites their offline cache.

  • Entry points: Rapid Add's Not in the catalog verdict gets Add manually, carrying the GTIN, its format and any typed brand/shade hints. Search's empty result gets Can't find it? Add it manually, carrying the query as the name.

  • Pure logic and client: the form logic lives in src/lib/manual-add.ts: params, validation, request building, finish options and the new-shade dupe check. The client gets createPolish and listReferenceFinishTypes, both additive.

  • Docs: mobile README (structure, routes table, Rapid Add section) and the CLAUDE.md "Mobile app" paragraph.
  • Refs #109

    Test plan

  • npm run build, npm run lint, npm run typecheck (root): clean

  • npm run lint --workspace=apps/mobile and npm run typecheck --workspace=apps/mobile: clean, no warnings in the touched files

  • npm run test --workspace=apps/mobile: 97/97 pass. 25 of them are new: 23 in manual-add.test.ts and 2 in collection-events.test.ts

  • npx expo export --platform ios (from apps/mobile): succeeds

  • Live against the local Functions host (dev bypass Bearer dev:1): the exact body buildCreateRequest builds (UPC-A 036000291452, upc_a) gave 201 / shade 525. psql on 55432 shows a user_shade_barcode row: user 1, gtin 0036000291452, UPC_A. A malformed barcode returns 400 barcode must be a valid EAN/UPC barcode.

  • Not tried on a device or simulator. Owner: scan an unknown bottle, tap Add manually, save, then scan it again and expect You own this.
  • Decisions needed

    1. Color is optional, and there is no black default. The web form requires a color name and always sends a hex (default #000000). Mobile sends vendorHex only when a color was picked or typed, so an untouched form never writes black to a new shade. The color name is optional and defaults to the color family label of the hex ("Teal"), or "" without a hex. The add guard is skipped when no color is given (nothing to compare).
    2. Wishlist sends no quantity. The web form sends the form's quantity with every status. Mobile sends status always (D5) and quantity only for owned (1–99), matching statusChangePatch. "Wishlist instead" from the guard drops the quantity too.
    3. Brand/name prefill from Rapid Add comes from the user's typed hints, not OCR. POST /api/capture/{id}/check returns no OCR'd brand/name (only candidates), so the Add manually button carries the brand/shade hint fields. Feeding label OCR text in would need an API change (out of scope).
    4. The Search query goes in as the shade name (not split into brand + name).
    5. Fields left out compared with the web: collection, size, purchase price/currency and tags (not in the brief). Editing existing polishes and photos are also out of scope.
    6. Collection refresh uses an in-process event, src/lib/collection-events.ts, instead of a refetch on focus. The Collection refetches page 1 (rewriting its AsyncStorage cache) and the Home panel recounts.
    7. The local dev DB keeps the smoke-test shade. Shade 525 "Manual Add Test — Overnight Teal 109" is owned by dev user 1, with barcode 036000291452 learned for that user. Delete it if it gets in the way of other local tests.
    8. Commit trailer: the session brief asked for Claude Fable 5.1; the commits carry Claude Opus 5.5, the model that actually ran this session.

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Added a manual polish form for entering brand, shade, finishes, color, collection status, quantity, rating, and notes.
    You can open the form from an uncatalogued barcode scan or from search results with no matches. Scanned barcode details and search text are carried into the form.
    Before saving, the app can flag potential near-duplicates and lets you choose whether to add the polish to your collection or wishlist.
    Bug Fixes
    Collection views now refresh after a polish is added.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mattmck Review duration: 33m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Real PR Conversation Timeline
    1 comments
    "Review active on #424"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%