diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index b55403e2..bc8a7817 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -1,105 +1,112 @@ # TODO — Osteo Report MVP -## Status: Scaffold complete — ready for feature implementation +## Status (2026-05-19): editor flow + PDF roundtrip fully working — closing V1 + +Last 24h: PDF rendering polished (eyebrow/title/severity pill, 2-col SVG grid, +text-area reservation), editor nav (back btn + clickable Brand) + in-place +identity edit dialog, zone-highlight scoped to active obs, detail-popup repaint +on async SVG mount, headers harmonized. + +All 100 tests green, lint 0, typecheck clean. --- -## Phase 1 — Skeleton (DONE) -- [x] Directory structure created -- [x] package.json + tsconfig + vite + vitest config -- [x] ESLint 9 flat config + Prettier -- [x] Zod schemas: report, observation, practitioner, animal, pathology -- [x] Species registry + equine manifest -- [x] Zustand store shape (stubs) -- [x] Anatomy types + empty parsers -- [x] PDF module stubs (export, import, attachment, fonts, render/*) -- [x] Component stubs (ui/*, canvas/*, observation/*, report/*, brand/*) -- [x] App router + ConfigProvider -- [x] Docker: Dockerfile + docker-compose + entrypoint.sh + nginx.conf -- [x] Env injection mechanism (window.__APP_CONFIG__) -- [x] Smoke tests pass -- [x] pnpm build passes +## Phase A — DONE (kept for reference) + +- [x] Scaffold (deps, configs, Docker, schemas, stubs) +- [x] Lib: id, dates, assert +- [x] Anatomy: parseSvgBones, loadSvg, svgToPng raster +- [x] Zustand store: full action set (initReport, hydrateReport, observation CRUD, + conclusion/recommendations/nextAppointment setters, identity setters) +- [x] sessionStorage draft mirror + localStorage practitioner cache +- [x] UI primitives: Button, Card, Dialog, Input, Label, Select, Textarea, Badge, Chip +- [x] Canvas: AnatomyCanvas (data-state highlighting, async-mount safe), DetailModal +- [x] Observation chain: ObservationList, ObservationCard, PathologyPicker, + VertebraPicker (region tabs + chips, preselect region from label), + SeveritySelector, FreeTextPathologyInput +- [x] Report forms: PractitionerForm, AnimalForm, ConclusionPanel, + NextAppointmentPicker, ReportHeader (with edit-infos dialog + home nav) +- [x] Routes: HomeRoute (CTAs + session draft card), NewReportRoute, + EditorRoute (split layout + dialog), NotFoundRoute +- [x] PDF pipeline: fonts (Inter + Fraunces TTF), header, observationPage + (2-col SVG grid, eyebrow/title/severity pill, text-area reservation), + conclusionPage, attachment.ts (embed + extract JSON), export, import +- [x] Docker: Dockerfile multi-stage, docker-compose, entrypoint.sh + (window.__APP_CONFIG__ runtime injection), nginx.conf SPA fallback +- [x] Brand identity via env vars end-to-end (config/env.ts → ConfigProvider) +- [x] Tests: 100/100 pass (schemas, store, anatomy parser, PDF roundtrip, + canvas, pickers, components) --- -## Phase 2 — Core domain (next) +## Phase B — REMAINING for V1/MVP ship -### 2a. Lib utilities -- [ ] `src/lib/id.ts` — generateId: already implemented (crypto.randomUUID) -- [ ] `src/lib/dates.ts` — formatDateFr: implement Intl.DateTimeFormat -- [ ] `src/lib/assert.ts` — already implemented +### B1. Equine pathology database (BLOCKING) +- [ ] `src/domain/species/equine/pathologies.ts` — currently empty (`[]`) +- [ ] Author 40-60 entries with source citations (manual / journal / database / web) +- [ ] Each entry: PathologySchema.parse() + ≥1 source + boneIds (or [] = all zones) +- [ ] Client review of batch before commit +- [ ] Test: `species.equinePathologies.test.ts` already exists — will validate count + source presence once filled -### 2b. Anatomy convention parser -- [ ] `src/anatomy/svgConvention.ts` — parseSvgBones: walk DOM, group by data-anno-id -- [ ] `src/anatomy/svgLoader.ts` — loadSvg: fetch + DOMParser inline -- [ ] Tests: valid SVG fixture → bones map; bad SVG → SvgConventionError +### B2. Stub cleanup (small) +- [ ] `src/components/canvas/ZoneTooltip.tsx` — unused stub. Decide: implement (hover tooltip listing observations owning the bone) or delete +- [ ] `src/components/ui/Toast.tsx` — unused stub. Decide: implement (success/error notifications for PDF export/import) or delete +- [ ] `src/components/observation/ObservationEditor.tsx` — referenced in CLAUDE.md folder map but file does not exist (replaced by inline edit in ObservationCard). Remove from CLAUDE.md structure list -### 2c. Zustand store -- [ ] `src/state/reportStore.ts` — implement all actions -- [ ] `src/state/practitionerCache.ts` — localStorage read/write with Zod validation -- [ ] Tests: initReport, addObservation, updateObservation, hydrateReport +### B3. PDF QA pass (manual) +- [ ] Full flow: HomeRoute → NewReport → fill all fields → editor → 3+ observations + with main + detail SVGs + vertebrae + severity + comment → export PDF +- [ ] Open PDF in Acrobat (or qpdf) → verify: + - Fonts embedded (no system-font substitution) + - JSON attachment present (`pdfdetach -list`) + - SVG rasterization sharp at 1200px target + - Multi-SVG observation: 2-col grid renders, no overflow, text sections visible +- [ ] Re-import same PDF → state hydrated identically (deep equal check) +- [ ] Test in Firefox + Chrome + Safari (DOMParser + canvas behavior) -### 2d. Equine pathology DB -- [ ] `src/domain/species/equine/pathologies.ts` — 40-60 entries, source-cited -- [ ] Tests: all entries pass PathologySchema.parse() + have ≥1 source +### B4. Docker deploy validation +- [ ] `docker build -t osteo-report .` succeeds with current pnpm-lock.yaml +- [ ] `docker compose up --build` boots → http://localhost:8080 serves app +- [ ] env vars (APP_SITE_NAME, APP_BRAND_NAME, APP_FOOTER_NAME, APP_TAGLINE) + reflected in browser via entrypoint.sh-injected env.js +- [ ] nginx PORT envsubst verified (try PORT=9000) +- [ ] SPA deep-link fallback works (refresh on /editor doesn't 404) + +### B5. Documentation final pass +- [ ] README.md — install, dev, build, Docker, env vars, license +- [ ] docs/ANATOMY-SVG-CONVENTION.md — already exists, verify accurate post-LRN-004 +- [ ] docs/ADDING-A-SPECIES.md — verify steps still match registry shape +- [ ] docs/PDF-FORMAT.md — describe attachment schema + version contract +- [ ] CHANGELOG.md — create with V1 entry summarizing scope + +### B6. Production deploy (Scaleway VPS) +- [ ] DNS + TLS (Caddy or nginx + Let's Encrypt) +- [ ] CI: GitHub Actions → build image → push to registry → SSH deploy +- [ ] Backup: VPS snapshot + image registry retention --- -## Phase 3 — UI components +## Phase C — POST-V1 (not in MVP scope) -### 3a. UI primitives -- [ ] Button, Card, Dialog, Input, Label, Select, Textarea, Badge, Chip, Toast +Captured here so they're not lost; do NOT pull into V1 without explicit decision. -### 3b. Canvas -- [ ] AnatomyCanvas: inline SVG, delegated click listener, bone state colorization -- [ ] DetailModal: load detail SVG, click handler with detailSourceId -- [ ] ZoneTooltip: hover tooltip listing all observations owning the bone - -### 3c. Observation panel -- [ ] ObservationList + ObservationCard -- [ ] ObservationEditor -- [ ] PathologyPicker + FreeTextPathologyInput -- [ ] VertebraPicker: region tabs + chip grid -- [ ] SeveritySelector - -### 3d. Report forms -- [ ] PractitionerForm + AnimalForm (prefill from localStorage cache) -- [ ] ConclusionPanel + NextAppointmentPicker -- [ ] ReportHeader +- Mobile delivery: Capacitor wrap (iOS + Android) — pdf-lib + canvg compatible, + Filesystem plugin for download, HashRouter required. See conversation 2026-05-19. +- User accounts + cloud sync (Supabase or self-host Postgres + JWT auth). +- Multi-praticien (move localStorage practitioner cache into server profile). +- Appointment booking + reminders (push notifications via FCM/APNs). +- Additional species (canine, bovine, feline) — registry already polymorphic. +- Pathology DB expansion + community contributions. --- -## Phase 4 — Routes +## Memory cross-refs -- [ ] HomeRoute: CTAs + session draft card -- [ ] NewReportRoute: form → initReport → navigate /editor -- [ ] EditorRoute: split layout canvas + observation panel + export bar -- [ ] sessionStorage draft sync (osteo:draft) +- BDR-001..BDR-008 — decisions registry +- LRN-001..LRN-010 — learnings registry +- BLK-001..BLK-004 — blockers registry (all resolved) ---- - -## Phase 5 — PDF - -- [ ] fonts.ts: fetch Inter + Fraunces TTF, embedFonts -- [ ] render/header + footer -- [ ] render/svgToPng: canvg → canvas → PNG bytes -- [ ] render/observationPage + conclusionPage -- [ ] attachment.ts: attachReportJson + extractReportJson -- [ ] export.ts + import.ts: full roundtrip -- [ ] Tests: attachment write+extract fixture - ---- - -## Phase 6 — Docker deploy - -- [ ] Verify pnpm-lock.yaml committed for --frozen-lockfile -- [ ] docker build smoke test on CI -- [ ] nginx.conf: PORT envsubst verified - ---- - -## Phase 7 — QA - -- [ ] Manual browser test: full report → export PDF → re-import -- [ ] Font embedding verified in PDF viewer -- [ ] Brand identity via env vars verified end-to-end +Latest learnings to apply when implementing remaining items: +- LRN-009: pdf-lib variable-image layout (pre-rasterize → reserve → grid) +- LRN-010: gate DOM-mutate effect on async-mount loaded state +- LRN-006: strip authoring annotations before rasterizing for print