# TechTitans — New Repair: three starting methods

**Goal:** replace the confusing New Repair layout (Smart Intake pinned above the 3-step manual wizard,
with Create buried at the end) with one clear chooser — **Take Photo / Upload · Speak or Type · Manual** —
all converging on the same editable repair draft + review before create.

**Branch:** `techtitans/repair-r1`. **Commit:** frontend **`0c27a00`** (frontend-only — no backend change;
the existing R1 + Smart-Intake APIs and components are reused unchanged). Not pushed.

## 1. What changed

- **Landing (`/repairs/new`)** now opens on three method cards and **nothing else** — no wizard stacked
  underneath. Picking a card swaps in that method; a **Change method** bar returns to the chooser.
- **Photo-first:** `RepairPhotoCapture` (Choose/Take, multiple photos, previews, remove, labels) + an
  optional "Describe the repair" box + voice; the **primary** action is **Analyze & Prepare Repair** with
  **Enter details manually** secondary. It never jumps straight to manual on upload. When vision is off it
  says so plainly and keeps the manual path.
- **Speak/Type-first:** the existing `SmartIntakePanel` (one instruction, Record Voice, Prepare) + optional
  photos.
- **Convergence:** a unified `prepareIntake()` analyzes whatever inputs exist — photos (when vision is
  configured) and/or the instruction (when drafting is configured) — merges them into one `RepairDraft`,
  maps it into the wizard (`applyDraftToWizard`), matches the customer + device against the CRM
  (`resolveCustomerFromDraft`, ambiguous → confirmation dialog, never auto-select/auto-create), then drops
  into the **3-step wizard at step 1** for review and an **explicit Create** on the Review step.
- **Manual Entry** opens the existing 3-step wizard unchanged.
- Draft state lives on the page, so switching methods never loses photos, the instruction or the draft.
  Create stays gated **only** on customer + repair type (never on AI); the unsaved-changes guard still
  warns before leaving.

## 2. Reused (no new catalogue / ticket engine)

`SmartIntakePanel`, `RepairPhotoCapture`, `RepairVoiceCapture`, `SmartDraftPanel`, `LookupSelect`,
`TechnicianSelect`, `CustomerMatchDialog`, `intakeMatching.ts`, and the R1 APIs (`repairsApi.createTicket`,
`analyzeText` / `analyzeImage` / `transcribe`, `capabilities`, customer/device/technician lookups,
attachment upload) — all unchanged. This task only reorganized `NewRepairPage.tsx` (+ `repairs.css`).

## 3. Files changed

- `frontend/src/pages/repairs/NewRepairPage.tsx` — method gate (`landing | photo | voice | manual`),
  landing cards, method bar, photo-first panel, unified `prepareIntake`, notices carried into the wizard.
- `frontend/src/pages/repairs/repairs.css` — `.repairs-methods`/`.repairs-method`/`.repairs-methodbar`
  (responsive: 3-up desktop, stacked mobile).
- Tests: `NewRepairPage.test.tsx` (+3 new: landing shows 3 methods & no wizard; manual↔change-method;
  photo method offers Analyze & Prepare + honest not-configured + manual fallback), and
  `NewRepairSmartIntake.test.tsx` / `NewRepairIntake.test.tsx` / `NewRepairLookups.test.tsx` updated to
  enter a method first.

## 4. Real AI vs mock

Driven entirely by `GET /repairs/intake/capabilities` (default deployment: **draft = mock**, **vision +
transcription = off**):

- **Draft (Speak/Type):** the deterministic **mock** extractor runs (badged "Development AI (mock) — review
  every field"). Real extraction needs `AI_REPAIR_DRAFT_DRIVER=openai` + `AI_REPAIR_DRAFT_API_KEY`.
- **Vision (Photo analysis):** **not configured** — the UI says "AI photo analysis isn't configured" and
  the operator confirms the device details; no fabricated recognition. Real needs
  `AI_REPAIR_VISION_DRIVER=openai` + `AI_REPAIR_VISION_API_KEY`.
- **Transcription (Record Voice):** **not configured** — honest, offered only when a provider is wired.
  Real needs `AI_REPAIR_TRANSCRIPTION_DRIVER=openai` + `AI_REPAIR_TRANSCRIPTION_API_KEY`.
- **No real provider was exercised** — no AI keys are configured on this machine. The mock draft path and
  the not-configured vision/transcription paths were verified; the live OpenAI adapters are unchanged from
  R1 and remain unverified against a real provider (credentials are the only blocker). Nothing is ever
  presented as real AI when it isn't.

## 5. Tests & browser results

- **Frontend:** `npx tsc --noEmit` ✓, `npx eslint` ✓. `vitest run src/pages/repairs src/components/repairs`
  → **11 files, 56 tests passing** (includes the updated intake/lookup/smart-intake suites and the 3 new
  landing/photo-method tests). Covers: open → three methods; manual create; voice prepare → wizard fill;
  customer match + ambiguous-dialog (no auto-select); device match/new-device; unknown technician; mock
  badge; AI-not-configured fallback; category/brand lookup + create; photo capture/voice components.
- **Backend:** unchanged (no code touched); existing R1 repair tests remain green.
- **Live browser (Playwright, techtitans):** screenshots under `screenshots/repair-methods/`:
  - `landing.png` — the three method cards, no wizard underneath.
  - `photo-method.png` — Choose/Take + optional describe/voice, Analyze & Prepare (primary) + Enter
    manually, honest "not configured" note.
  - `voice-method.png` — instruction box + Record, "Prepare Repair with AI", mock badge.

## 6. Known limitations

- Real photo/vision analysis and voice transcription need provider credentials (see §4) — unverified live.
- After an AI prepare, the flow lands at wizard **step 1** (to confirm the AI-matched customer/device) and
  reaches Create on the Review step; it does not deep-link straight to Review.
- Photo "retake/replace" is remove-then-add (explicit per-photo replace not added).
- Only TechTitans dev data (`techpos` / `techtitans`) used; NH POS and WordPress untouched.

## 7. Commit hash

- Frontend: **`0c27a00`** (branch `techtitans/repair-r1`). Committed locally only — not pushed or deployed.
