← Back to Pull requests

feat(web): Looks page — vibe-driven look recommendations from owned polishes #370

Closed
unknown closed this pull request without merging on Oct 20, 2026 02:34 UTC
View on GitHub
unknown unknown commented on Oct 19, 2026 01:37 UTC
Author

What

A new Looks page at /polishes/looks. You pick a vibe (occasion, mood, finish, Owned only) and get three complete nail looks (Base / Accent or Tip / Topper) built from the polishes you own. Any step you don't own is filled from the catalog and marked Add. MVP of docs/looks-experience-plan.md.

  • Recommender: apps/web/src/lib/looks.ts. It is pure and seeded like "Pick for me", with 26 unit tests. It has 18 named templates (Glazed Donut, Office Neutral, Soft Chrome, Galaxy Fade, Cyber Violet, Berry Gradient, French Modern, Monochrome Slick, Classic Red, Milk Bath, …).

  • - Base: picked by OKLAB distance plus a finish penalty from the shared finishCompatibility.
    - Accent: must fall within harmony bounds (generateHarmonyColors of the chosen base), and contrast with the base is rewarded.
    - Topper: comes from TOPPER_FINISHES (imported from pick-for-me.ts, not edited).
    - Diversity: no base is reused, and two bases must be at least LOOK_MIN_BASE_DISTANCE apart unless their finish families differ.
    - The module header documents every rule and constant.
  • URL state: lib/looks-url.ts, with ?occasion=&mood=&finish=&owned=1&seed=. Changes use router.push, so back/forward and shared links reproduce the same looks.

  • Cards:

  • - swatch strip
    - steps with Owned ✓ / Add pills
    - "Buy from brand" on catalog steps; steps with no catalog match get a "Find a shade like this" link to color search
    - per-step Swap offering the next 3 owned candidates
    - difficulty/time badge
    - Wear this, which opens the existing ManiLogForm prefilled with the owned polishes and their roles (color/accent/topper)
    - Save to your account (see "Saved looks on the server" below), with a For your vibe / Saved (N) switch to see saved looks and Wear / Remove them
  • Empty and sparse states:

  • - Zero owned: catalog looks, plus a nudge to import or use Rapid Add.
    - Owned-only with fewer than 3 viable looks: the page says so instead of padding.
    - Collection load fails: template looks plus a notice.
  • Telemetry: looks.generated and looks.wear_clicked, sent via metrics-events.ts and documented in docs/observability-plan.md.

  • Entry points: a sidebar/header Looks nav item, and a "Looks" link in the dashboard "Pick for me" card header.

  • Mobile-first: below lg the vibe collapses to a one-line summary that expands on tap. Cards use container queries.
  • Saved looks on the server (the stretch goal)

  • Migration 20261019020500000_user-look (renumbered from 20261019013934159 after dev gained 20261019020000000_enable-signed-off-indie-sources, so it still sorts last; the release runbook is updated to match): a user_look table with user_id FK (cascade), look_key, template_id, name, vibe jsonb, steps jsonb and saved_at. UNIQUE (user_id, look_key), and CHECKs mirror the validator. docs/schema.sql is updated.

  • API GET/POST/DELETE /api/looks (functions/looks.ts, withCors(withAuth(...)), every statement scoped by user_id):

  • - POST is an upsert on the look key and keeps the newest 30 per user in the same transaction. Bodies over 8 KB get 413.
    - DELETE takes ?key= and returns 404 for anyone else's key.
    - 13 unit tests cover auth, validation, the cap and cross-user isolation. The full functions suite (2,059) passes.
  • Shared types/looks.ts: the vibe enums, SavedLook* types, savedLookKey() and the one validation rule validateSavedLookInput(), used by both the API and the web's localStorage parser.

  • Security design: a saved look is an opaque display snapshot the client sends (labels, hexes, shade id/brand/name). It is returned only to its owner and never joined to shade. So saving a look that names someone else's private user_submitted shade id reveals nothing. The access-control-reviewer agent found no access-control issues. It flagged one low-severity bug (multibyte text could pass the validator but trip the DB byte CHECK, giving a 500), which is fixed and tested.

  • Web sync: saves and removes go to the account first.

  • - Saves made offline, or before this endpoint existed (they used the same localStorage key), wait in a pending list and upload on the next visit.
    - The last server list is cached for display only and never uploaded, so a look deleted on your phone doesn't come back from your laptop.
    - If a remove fails, the look is restored and a toast says so.
  • Verified against real Postgres: I migrated an isolated database in the local Postgres container (swatchwatch_looks_verify, dropped afterwards; the shared dev DB was not touched). Up → down → up worked. I ran this branch's Functions host against it and checked with curl and in the browser:

  • - save (201)
    - re-save as an upsert
    - bad body (400)
    - another user's delete (404) and list (empty)
    - no auth (401)
    - a pre-endpoint local save uploading on load
    - a delete made on "another device" not coming back
    - an offline save staying pending, with a "saved on this device" toast, then uploading after the host restarted
    - the Saved tab with Wear / Remove at 375px

    Judgment calls (please review)

    1. Client-side, no /api/looks. This follows the "Pick for me" pattern, as the brief asked. Types live in apps/web/src/lib/looks.ts, not in packages/shared, because nothing server-side uses them yet. The plan's shared Look types can move there when the endpoint lands.
    2. Catalog gap fill. Catalog search results carry no hexes, so gaps come from GET /api/polishes?family=<color family>&pageSize=60, one request per missing color family. The page sends at most 6 family requests plus one for topper finishes. Families are found with the shared classifyHexColorFamily. Results are cached per family for the session. Looks first render from owned polishes only, then re-render once catalog rows arrive.
    3. Default vibe is Everyday + Soft + any finish, with seed 1. There is no "trending" data yet.
    4. Finish preference overrides the base step's preferred finishes. Flake is the exception: it adds or keeps a topper step instead.
    5. Owned only:
    - required steps (base and non-optional accents) must be owned
    - optional accents and toppers are dropped instead of being marked Add
    - templates that can't be built are skipped
    6. Shuffle is one button above the cards that reshuffles all three looks (new seed in the URL). There is no per-card shuffle. Per-step Swap covers changing one look.
    7. Ranking: an owned base gets a strong bonus (OWNED_BASE_BONUS = 4), so a look you can wear outranks a slightly better vibe match you'd have to buy for. A side effect: with a small collection (the local dev DB has about 20 polishes), Shuffle often reorders the same templates.
    8. Rules added after testing on real data:
    - Toppers and flakies are never a base or accent.
    - A look with a topper step never gets a glitter base (no glitter-on-glitter).
    - The finish penalty counts against the base threshold, so a near-miss glitter is not an "Office Neutral".
    - A swap never offers a polish another step of the same look already uses.
    - A polish used by an earlier look is never a later look's base.
    - metallic is listed before chrome in the preferred finishes, because chrome has no built-in finish family and was making clashes grade as "unknown".
    9. ManiLogForm got an optional initialEntries prop ({ shadeId, role }[]). It is a ~5-line change in the state initializer. #349 also touches mani-log role prefill, so watch for a small merge overlap there.
    10. App shell fix, outside the Looks scope: on phones the mobile header icon nav widened every page to about 612px, causing horizontal scroll (/manis too). Fixed with min-w-0 on the main column and the nav. app-shell.tsx also gets the new nav entry.
    11. Saved looks persist per account, with a pending localStorage fallback. The table is user_look (singular, matching wishlist_share), not the plan's user_looks. I dropped the plan's telemetry_context and source columns; a server-side looks.saved event is emitted instead.
    12. Not done from the plan: a recommendation endpoint, skin-tone / nail-shape inputs, Include toppers and Color Lab toggles, Share, shopping-list modal with prices, detail drawer, and the NEXT_PUBLIC_FEATURE_LOOKS flag. The page is linked directly rather than flagged. A status note at the top of docs/looks-experience-plan.md lists these.

    Merge notes

    dev moved three times while this was open (#371/#374, #373, #372). Each sync merged origin/dev into this branch; conflicts were README rows, the two new telemetry events next to other sessions' events (metrics-events.ts, its test, docs/observability-plan.md) and the add-guard surface list. All were kept-both resolutions. Since #374, Looks polish links use detailHref with the page's own returnTo (vibe + seed), and returnToLabel knows "Looks". After each sync: typecheck, lint, all tests and build:web pass.

    Decisions needed

  • Feature flag? The page ships linked from the sidebar and dashboard with no NEXT_PUBLIC_FEATURE_LOOKS flag. My recommendation is to ship it unflagged. This blocks nothing; adding a flag later is small.

  • Route naming: GET /api/looks now means "my saved looks". If a server-side recommendation endpoint is added later, my recommendation is GET /api/looks/recommendations rather than overloading /api/looks. This blocks nothing today.

  • Deploy order: apply migration 20261019013934159_user-look before (or with) the web deploy. My recommendation is the normal migrate-then-deploy. Until it runs, saves keep working on-device (pending) and upload once the table exists, so nothing breaks.
  • Verification

  • npm run typecheck, npm run lint, npm test (web 500, devtools 140, functions 2,059; all pass), npm run build:web (static export) and npm run build:functions all pass. The pre-commit hook ran the full repo test suite on every commit.

  • End to end in dev-bypass mode against a local Functions host and local Postgres, tested in a browser at desktop width and at 375px:

  • - vibe changes
    - Shuffle and Back
    - Swap
    - Save and the saved-looks section
    - Wear this, which opens the mani dialog prefilled as Color / Accent / Topper (cancelled, so nothing was written)
    - owned-only
    - zero-owned account (dev user 2): catalog looks with Buy-from-brand links and the nudge
    - no horizontal scroll at 375px
  • The Functions host was already running (not from this branch) and only allows CORS from :3000. I ran this branch's web app on :3100 behind a throwaway local CORS proxy. No Azure resources were touched.

  • CodeRabbit review addressed in 77363eb:

  • - Back/Forward after a Shuffle is no longer reported as trigger: shuffle; the trigger is now tied to the URL state it produced.
    - hex→OKLAB conversions are memoized on the recommender path: about 150 → 35 ms for a synthetic 2,000-polish collection, with identical results and tests unchanged.
  • Not verified: the telemetry events reaching App Insights. They are a no-op locally without a connection string; the payloads are unit-tested.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: mattmck Review duration: 1496m
    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 #370"
    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%