Commit Graph
141 Commits
Author SHA1 Message Date
Bastien Chanot 5093418950 chore(memory): journal line for findings-tree level transition 2026-05-21 07:23:08 +02:00
Bastien ChanotandClaude Opus 4.7 adbab1bc87 feat(editor): directional slide transition between findings-tree levels
Opening a finding category (e.g. "Dysfonction ostéopathique") and
backing out felt abrupt — list content swapped instantly with no
visual continuity. Now the list animates a short slide+fade between
levels:
- Drill down → new list enters from the right (+16px → 0).
- Back / breadcrumb up → new list enters from the left (-16px → 0).

Implementation:
- Wrap the list in `motion.ul` keyed by the path string so React
  remounts when the level changes; motion's `initial`/`animate`
  variants then play on every remount.
- A direction state (1 | -1) feeds the `enter` variant via `custom`
  so forward vs. back have opposite slide directions.
- All path mutations go through `goInto` / `goBack` / `goToDepth`
  helpers that set direction before calling `setPath`.
- 180ms ease-out — perceptible but does not block interaction.

AnimatePresence was deliberately omitted: it defers DOM swap, which
broke the existing synchronous `getByLabelText` assertions in
components.FindingsTreePicker.test.tsx. The key-based remount keeps
the new content reachable immediately while still providing a
direction-aware entrance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 07:22:55 +02:00
Bastien Chanot ef0ef62f2d chore(memory): journal lines for footer + header refactor + editor scroll fix 2026-05-21 07:09:24 +02:00
Bastien ChanotandClaude Opus 4.7 1b01744efc fix(editor): scroll to top on mount instead of restoring prior position
Navigating to /editor (either from /new or by re-importing a PDF)
landed the user at the bottom of the page because the browser
restored its previous scroll position on a long route. Force a
one-shot scroll to (0,0) on mount with an empty-deps effect so the
report opens at the header.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 07:08:59 +02:00
Bastien ChanotandClaude Opus 4.7 06a22aec11 feat(ui): unify page header — tagline left, lang switcher far right
Make the header consistent across Home, New report, and Editor:
- Tagline (cfg.tagline) now sits next to the brand on the left for
  every page, instead of right-aligned on Home only.
- LanguageSwitcher moved to the far right of the action group on
  every page (previously sandwiched between brand and report info on
  Editor).
- Dropped the redundant "← Accueil" ghost button on New report and
  Editor headers; the brand itself is already a link to "/", so two
  controls were doing the same job. Aria label preserved on the
  brand link.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 07:08:56 +02:00
Bastien ChanotandClaude Opus 4.7 caac14904d feat(ui): global footer with copyright + Powered by ZenQuality
Adds a single Footer component mounted in App.tsx via a flex-column
layout so it sticks to the bottom of every route (Home, NewReport,
Editor, NotFound).

Content per locale:
- "© <year> <footerName>. Tous droits réservés. / All rights reserved."
- "Propulsé par / Powered by [ZenQuality logo]" — logo wraps an
  external link to https://zenquality.fr (target=_blank +
  rel=noopener noreferrer).

footerName comes from runtime config (APP_FOOTER_NAME); year is
computed at render time. Two new i18n keys added in parity in
fr.ts + en.ts (footer.all_rights_reserved, footer.powered_by) —
dict parity test stays green (155/155).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:56:03 +02:00
Bastien ChanotandClaude Opus 4.7 0fcc526c46 fix(docker): use plain \${PORT} in nginx template — envsubst can't expand bash defaults
`listen ${PORT:-8080};` in docker/nginx.conf used bash-style default
expansion. envsubst (GNU gettext) does not implement `:-default`; it
either leaves the token literal or substitutes only `${PORT}` and
keeps `:-8080`, producing `listen 8080:-8080;`. Either way nginx
errors with "invalid port in '${PORT:-8080}' of the listen
directive" and the container restart-loops.

entrypoint.sh already exports PORT with a bash default
(`PORT="${PORT:-8080}"`) before calling envsubst, so the template
only needs `${PORT}`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:47:44 +02:00
Bastien ChanotandClaude Opus 4.7 7d214ed586 chore(docker): pin container name to zoosteo-web
Docker Compose v2 always appends a replica index (-1) to container
names by default. Single-instance service doesn't need scaling →
pin container_name for stable references in scripts and docs.
DEPLOY.md log-prune command updated to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:42:03 +02:00
Bastien ChanotandClaude Opus 4.7 dbd2bf30e9 chore(memory): correct BLK-005 + LRN-022 — pnpm 11.x line needs Node 22
Initial hypothesis ("pnpm@latest pulled a newer 11.4+ with new Node
floor") was wrong. Investigation after the second VPS crash showed
the whole pnpm 11.0+ line imports node:sqlite from its store-index
module. Local dev was misleading because pnpm install never re-ran
on the Node 20 host (lockfile already resolved, child scripts don't
load the store module).

Updates:
- BLK-005: replace single-fix line with iteration log
  (@latest → @11.1.3 → @10.13.1, last one resolved).
- LRN-022: rewrite headline + body to reflect pnpm 11 ↔ Node 22.13
  coupling, not just pnpm 11.4. Add pnpm/Node compat matrix.
- journal 2026-05-21: append v2 fix entry referencing commit 990c8e7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:16:08 +02:00
Bastien ChanotandClaude Opus 4.7 990c8e700c fix(docker): downgrade Dockerfile to pnpm@10.13.1 (pnpm 11 needs Node 22)
Prior pin pnpm@11.1.3 was insufficient — pnpm 11.x itself imports
`node:sqlite` and requires Node 22.13+, not just 11.4 as the previous
blocker entry assumed. Local builds passed only because no `pnpm
install` ran on Node 20 (lockfile already resolved). VPS cold build
still crashes `ERR_UNKNOWN_BUILTIN_MODULE: node:sqlite`.

Switch to pnpm 10.13.1 — already cached on the dev host via corepack,
last major before the node:sqlite cache backend, reads lockfile v9.0
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:14:36 +02:00
Bastien ChanotandClaude Opus 4.7 202110ddd2 chore(memory): capitalize zoosteo rename + Docker pnpm pin — BLK-005, LRN-022, journal
- BLK-005: VPS Docker build crash on pnpm@latest pulling pnpm >=11.4
  needing Node 22.13 (node:sqlite import) against node:20-alpine image.
  Resolved by pinning pnpm@11.1.3.
- LRN-022: never use floating pnpm@latest (or any unpinned upstream
  tag) in Dockerfiles — pnpm minor bumps can silently raise Node floor.
  Fix paths: pin exact + mirror in packageManager field; audit CI too.
- journal 2026-05-21: two lines for the rename commit and the Docker
  pin commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:07:28 +02:00
Bastien ChanotandClaude Opus 4.7 7dccde72f8 fix(docker): pin pnpm@11.1.3 to keep Node 20 compatibility
`corepack prepare pnpm@latest` now resolves to pnpm >=11.4, which
imports `node:sqlite` and requires Node 22.13+. The builder stage
runs `node:20-alpine`, so the install crashes with
`ERR_UNKNOWN_BUILTIN_MODULE: node:sqlite`. Pinning to the same
version the host already uses (pnpm 11.1.3) restores a reproducible,
Node-20-safe build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 06:04:35 +02:00
Bastien ChanotandClaude Opus 4.7 7dd4f633f8 chore: rename project from osteo-report to zoosteo
Remote moved to git.bchanot.fr/bchanot/zoosteo.git; brand strings
and production URL updated to match new identity.

- package.json: name → zoosteo
- src/config/env.ts: AppConfig DEFAULTS → "Zoosteo"
- docker/entrypoint.sh: APP_*_NAME fallbacks → "Zoosteo"
- src/i18n/{fr,en}.ts: import error message + PDF title prefix
- src/pdf/attachment.ts: embedded description metadata "state v2"
- index.html: <title> fallback
- scripts/scaffold-species.mjs: console banner
- tests/unit/components.Brand.test.tsx: regex
- README.md, CLAUDE.md, CHANGELOG.md, docs/ADDING-A-SPECIES.md:
  brand headings + intro lines
- DEPLOY.md: env defaults table + osteo.example.com → zoosteo.fr
  (clone URL, paths, certbot, curl, container name references)

PDF attachment FILENAME 'osteo-report.json' and the startsWith
contract in src/pdf/attachment.ts:35,40 are preserved — changing
them would break PDF import for every PDF already exported by the
app. docs/superpowers/** and .claude/audits/** left unchanged as
historical records.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 05:53:12 +02:00
Bastien Chanot fad3cb178a docs: add CHANGELOG.md — v1.0.0 entry (Keep a Changelog format)
First versioned changelog for the project. v1.0.0 entry covers the
shipped state on master at this commit: scaffold + B0..B3 (findings
schema, Report v2, FindingsTreePicker, i18n FR/EN), catalog v2.0
adoption, WinAnsi PDF hotfix, docs refresh, branch rename main →
master, push to https://git.bchanot.fr/bchanot/osteo-report.git.

Added / Changed / Fixed sections + Known limitations + a "Pre-1.0
milestones" appendix referencing git history for the un-tagged
scaffold / editor-polish / findings-tree-pivot / catalog-v2.0
sessions.

Note: package.json `version` field is still 0.1.0 — bump to 1.0.0
deliberately deferred until you're ready to tag the release on the
Gitea remote.
2026-05-21 04:13:37 +02:00
Bastien Chanot 98117b3b7f docs: add DEPLOY.md — VPS deploy guide (Docker + nginx + Certbot)
Production deploy playbook for Osteo Report. Single nginx:alpine
container behind a host reverse proxy; no backend, no database, no
server-side state. Praticien data lives in the browser and in the
exported PDFs themselves.

Sections cover:
- Topology + container/host port table.
- Required environment (.env): APP_SITE_NAME / BRAND_NAME /
  FOOTER_NAME / TAGLINE + optional PORT. No secrets.
- VPS provisioning (Ubuntu 24.04 LTS, 1 vCPU / 1-2 GB RAM, DNS,
  baseline apt packages).
- Firewall — cloud provider security group + UFW on the VM, with
  explicit "do NOT expose 8080" note.
- Docker install + tuned daemon.json (json-file log driver capped
  10MB × 5, live-restore).
- First-time setup, routine deploys via `git fetch + reset --hard
  origin/master + docker compose up --build -d`.
- Data persistence + backups: just the .env file (no volumes).
  Daily cron + retention + off-VPS sync.
- TLS reverse proxy — Option A (host nginx + Certbot with security
  headers HSTS/XFO/XCTO/Referrer-Policy/Permissions-Policy/CSP),
  Option B (Caddy auto-TLS Caddyfile).
- Sanity checks — TLS redirect, env.js cache headers, no-public-8080
  verification via nc + nmap.
- Hardening — non-root deploy user, disable root + password SSH,
  optional SSH port move, unattended security upgrades, fail2ban,
  external lockdown nmap.
- Rollback (git reset + rebuild — no data to restore).
- Health checks table, troubleshooting (9 common failures with
  recipes), operational notes (log destinations, manual prune,
  provider-specific RAM hints).

README.md DEPLOY.md link now points at a real document.
2026-05-21 04:13:28 +02:00
Bastien Chanot 8385b49bbe docs: sync drift after catalog v2.0 + i18n + WinAnsi hotfix
doc-syncer audit applied 10 AUTO patches and 1 HUMAN reword (#5)
across the doc set.

README.md:
- Test count "7 tests pass on skeleton" / "88 tests across 23 files"
  → "155 tests" / "155 tests across 29 files".
- Reword "Observation builder" bullet + add hierarchical findings
  tree + browser-detected locale bullets (HUMAN #5).
- Status paragraph: pathology DB "intentionally empty" → full
  26-zone v2.0 catalog (792 nodes, 612 leaves, 41 vet leaves).
- Documentation section: add PATHOLOGIES-FORMAT.md link; tidy the
  DEPLOY.md mention (DEPLOY.md itself comes in the next commit).

CLAUDE.md:
- Architecture block: "embedFonts (Inter body + Fraunces heading)"
  → reality (Helvetica + TimesRoman / WinAnsi StandardFonts; TTF
  Inter/Fraunces planned).
- PDF convention: "Fonts are TTF" → "Fonts are StandardFonts
  (Helvetica/TimesRoman, WinAnsi)" with the ASCII-surrogate caveat.
- Folder map: add src/anatomy/labels.ts, include zoneMatch.ts in
  src/lib/{...}.ts.
- i18n: locale default "fr" → "navigator-detected fr/en, or 'fr'
  if no match" to match commit 9cf8a66.

docs/PATHOLOGIES-FORMAT.md:
- "PDF surface: snapshot label is prefixed ⚠" → "(!)" in two
  places (after WinAnsi hotfix 143fdc3). Picker ⚠ statement
  kept — browser renders U+26A0 natively.

docs/ADDING-A-SPECIES.md:
- data-anno-category: "Free-form" → enum of 7 valid values per
  ANATOMY-SVG-CONVENTION.md; parser throws SvgConventionError on
  unknown values.
- Section 4 (findings catalog): cross-link to
  docs/PATHOLOGIES-FORMAT.md so authors find the v2.0 contract.
2026-05-21 04:13:13 +02:00
Bastien Chanot f4bb7cf9e0 chore(memory): capitalize ⚠ WinAnsi hotfix — LRN-021 + EVAL-003 + journal
- LRN-021: pdf-lib StandardFonts use WinAnsi (cp1252) — any non-Latin-1
  codepoint throws on measure or draw. Fix paths: ASCII surrogate
  (quick) or embed TTF via pdfDoc.embedFont (right). CLAUDE.md spec
  prescribed TTF; current StandardFonts is a documented drift.
- EVAL-003: bug slipped past 154/154 CI because roundtrip tests had no
  observation with a requires_vet_referral leaf. Regression test now
  measures a prefixed label via widthOfTextAtSize to canary any future
  non-WinAnsi marker reintroduction.
- journal 2026-05-21 appended with the hotfix note and the
  TTF-migration follow-up.
2026-05-21 03:34:56 +02:00
Bastien Chanot 143fdc3208 hotfix(pdf): swap vet-referral marker ⚠ → (!) for WinAnsi compatibility
Root cause: src/pdf/fonts.ts embeds StandardFonts.Helvetica /
HelveticaBold / TimesRoman, which use WinAnsi encoding (Latin-1
only). PDF export threw `WinAnsi cannot encode "⚠" (0x26a0)` the
moment the text-height estimator measured a vet-flagged leaf
label (countSegmentedLines → widthOfTextAtSize).

Fix: replace the PDF prefix "⚠ " with WinAnsi-safe "(!) ". The
picker DOM keeps the original "⚠" since browsers render U+26A0
natively — the limitation is purely on the PDF side.

Regression test exercises embedFonts + widthOfTextAtSize on a
realistic prefixed label; would catch any future non-WinAnsi
marker re-introduction.

Follow-up (not in scope): switch the PDF body to embedded TTF
(Inter / Fraunces per CLAUDE.md spec) so the catalog can carry
arbitrary glyphs. CLAUDE.md states TTFs should be used; current
StandardFonts is a drift from intent.

155/155 tests green, typecheck clean.
2026-05-21 03:33:59 +02:00
Bastien Chanot f5307ce61c chore(memory): /close — BDR-016 + LRN-020 + BLK-002 resolve + journal 2026-05-21
- BDR-016: pathologies.json v2.0 — boolean source of truth, generic
  vet description_fr purged, full 26-zone horse coverage.
- LRN-020: forward-compat Zod schema absorbs catalog version bump
  zero-code (optional fields + boolean-driven logic since B0).
- BLK-002 resolved — catalog no longer empty (612 leaves > 40-60 target).
- journal entry 2026-05-21 logs the in-place v2.0 swap, the hyoïde
  case alignment fix, and the doc refresh.
- TODO refreshed: Phase C item 1 (full horse.json) done,
  PATHOLOGIES-FORMAT.md v2.0 refresh done, B4 PDF observationPage
  marked partially done (scope_disclaimer footer still TBD).
2026-05-21 03:23:38 +02:00
Bastien Chanot 57b58b3af1 docs(species): refresh PATHOLOGIES-FORMAT for v2.0 contract
- schema_version "2.0" everywhere; new Changelog section with
  v1.0 → v2.0 entries highlighting the breaking change.
- New Scope (legal périmètre) section listing inclusions / exclusions
  and the two flag mechanisms (root scope_disclaimer + leaf boolean).
- Clarified SVG ↔ JSON link via strict label equality (not data-anno-id)
  and cranio-caudal zone ordering rule.
- Documented the 3 standardized categories per zone
  (*-dysfunctions / *-observations / anamnesis) and the 5 dysfunctions
  taxonomy patterns (head SSB / head peripheral / articular /
  vertebral hinge / vertebral region).
- Documented structural authoring rules (depth ≤ 4, ≥ 2 children per
  intermediate, sibling-scoped ID uniqueness).
- Spelled out the v2.0 requires_vet_referral / description_fr policy
  (boolean = source of truth; description_fr survives only on
  differential leaves) and the breaking-change notice for any consumer
  relying on description_fr.includes('vétérinaire').
- Rewrote the minimal example using v2.0 contract (boolean only,
  description_fr only when it adds a differential).
- Noted Zod's silent strip of unknown fields (e.g. species.notes,
  per-leaf metadata).
- Added current horse.json stats table (26 zones / 792 nodes /
  612 leaves / 41 vet leaves).
2026-05-21 03:23:30 +02:00
Bastien Chanot 6eda7ebc39 feat(species): adopt horse catalog v2.0 — full 26-zone coverage
Catalog bumped v1.2 → v2.0 by domain expert.

- schema_version "2.0"; 26 zones (9 head + 17 body), 792 nodes,
  612 leaves, 41 requires_vet_referral leaves.
- requires_vet_referral becomes the sole source of truth for the
  vet-orientation flag. Generic "orienter vers vétérinaire" wording
  purged from description_fr on 25 leaves; the 16 leaves carrying a
  clinical differential keep their description_fr.
- Existing Zod schema (findings.ts) and consumers (FindingsTreePicker,
  PDF observationPage) already key off the boolean — zero code change
  required.
- Aligns SVG Horse_head.svg "hyoïde" → "Hyoïde" so all 26
  data-anno-name-fr / -en values match zone.name_fr / name_en
  strictly (v2.0 authoring rule prescribes exact equality;
  src/lib/zoneMatch.ts fuzzy fallback retained as safety net).

154/154 tests green, typecheck clean.
2026-05-21 03:23:15 +02:00
Bastien ChanotandClaude Opus 4.7 9cf8a66dad feat(i18n): navigator-detect default locale + locale-aware bone labels
- localeStore.readInitial now consults navigator.language(s) when
  localStorage is empty (first fr/en hit, FR fallback). Persisted user
  choice still wins.
- New helper src/anatomy/labels.ts (boneLabel(b, locale, fallback))
  with cross-language fallback so missing labels never render blank.
- AnatomyCanvas rewrites native SVG <title> tooltips per locale on
  mount and on locale change (upstream SVG ships titles as "FR / EN"
  concat; we replace with the active-locale label only). Detail-popup
  trigger titles ("🔍 Zoom: …") left intact.
- DetailModal + EditorRoute detail title prefix + vertebra picker
  title now route through useT()/boneLabel.
- ObservationCard.describeZone takes locale, picks bone.fr / bone.en.
- PDF: buildZoneLabels returns Map<id, { fr, en }> instead of FR-only;
  observationPage picks per locale with cross-language fallback.
- Tests: FindingsTreePicker + VertebraPicker reset locale to 'fr' in
  beforeEach (navigator-detect may land on EN in happy-dom).
- pdf.zoneLabels test updated to assert the new pair shape.

154/154 tests pass, lint clean, typecheck clean, build OK.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 07:56:22 +02:00
Bastien ChanotandClaude Opus 4.7 31bd82de58 chore(memory+docs): /ship-feature B3 capitalize — BDR-014/015 + LRN-017..019 + EVAL-002 + journal + TODO
Memory registry capitalization after B3 i18n FR/EN ship.

- decisions.md  +BDR-014 (PDF locale = render preference, store-driven, not Report schema field — dual label snapshot already carried).
- decisions.md  +BDR-015 (typed ImportError discriminant kind + foundVersion; UI resolves message via dict; review caught hardcoded FR in domain layer).
- learnings.md  +LRN-017 (i18n dict parity test: Object.keys().sort() equality + non-empty value assertion — cheapest drift guard).
- learnings.md  +LRN-018 (useT hook pattern: selector subscribe + dict closure-per-render, no prop drilling, missing-key dev-warn + key-literal fallback).
- learnings.md  +LRN-019 (exhaustive-deps trap when closures over store values appear inside useMemo deps — inline or useCallback).
- evals.md      +EVAL-002 (B3 review caught critical FR leak in pdf/import.ts + attachment.ts that grep+analyzer both missed — i18n migrations must enumerate ALL string-emitting files including error paths).
- journal.md    session 3 entry under 2026-05-20.
- TODO.md       B3 subsection rewritten as DONE with checked checkboxes + cross-refs.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 07:43:11 +02:00
Bastien ChanotandClaude Opus 4.7 9916c42484 fix(i18n): localize PDF import error messages
Review surfaced 3 critical paths where hardcoded French leaked into
the EN UI:
- src/pdf/import.ts ImportError default message
- src/pdf/attachment.ts IncompatibleReportVersionError message
- src/app/routes/HomeRoute.tsx propagated err.message verbatim

Refactor:
- ImportError carries a typed `kind` discriminant
  ('invalid_pdf' | 'incompatible_version' | 'no_attachment') plus
  optional `foundVersion`. Removes hardcoded localized strings.
- IncompatibleReportVersionError keeps `foundVersion` only; message
  collapses to an internal sentinel.
- HomeRoute resolves the user-facing message via the active i18n
  dict using `err.kind`, with `{version}` template substitution for
  the incompatible-version case.
- 3 new dict keys (fr+en): home.import.error_invalid_pdf,
  home.import.error_no_attachment, home.import.error_incompatible_version
- pdf.roundtrip v1 case asserts ImportError instance + kind +
  foundVersion instead of grepping the message text.

154/154 tests pass, lint clean, typecheck clean, build OK.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 07:36:34 +02:00
Bastien ChanotandClaude Opus 4.7 fa3eb51394 test(pdf): cover roundtrip under locale=fr and locale=en
3 new cases:
- exports with locale=fr roundtrips
- exports with locale=en roundtrips
- both produce non-empty byte streams and the imported JSON payloads
  match (locale lives outside the Report, so finding labelFr/EnSnapshot
  are byte-identical between exports — only the static dict labels
  rendered into the PDF differ, verified manually since pdf-lib font
  subsets make byte-grep unreliable per LRN-016)

154/154 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 07:12:05 +02:00
Bastien ChanotandClaude Opus 4.7 d6027266bc feat(i18n): migrate site + PDF to locale-aware rendering
- formatDate(iso, locale) replaces formatDateFr in src/lib/dates.ts
- exportReportToPdf(report, { locale }) takes explicit locale option
- LanguageSwitcher segmented FR | EN toggle added; integrated in
  ReportHeader, HomeRoute, NewReportRoute
- All routes (Home, NewReport, Editor, NotFound) + observation
  components (FindingsTreePicker, ObservationCard, FreeTextFindingInput,
  SeveritySelector, VertebraPicker, ObservationList) + report forms
  (PractitionerForm, AnimalForm, ConclusionPanel, NextAppointmentPicker)
  route hardcoded FR via useT()
- PDF render functions (export.ts, header.ts, footer.ts,
  observationPage.ts, conclusionPage.ts) take a locale arg and read
  static labels from the dict snapshot at call time
- Catalog finding leaf labels rendered via labelFr/EnSnapshot per locale
- description_fr / scope_disclaimer stay FR-only (out of scope —
  vet-expert authoring needed for EN copy)
- LanguageSwitcher unit test (2) + lib.dates locale tests (7) cover
  the new behavior

151/151 tests pass, lint 0, typecheck clean, vite build OK
(902KB main + 15KB lazy pathologies chunk).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 07:11:40 +02:00
Bastien Chanot 359104ce88 feat(i18n): add fr/en dicts + useT hook 2026-05-20 07:00:31 +02:00
Bastien Chanot a57047505d feat(i18n): add localeStore with localStorage persistence 2026-05-20 06:55:43 +02:00
Bastien ChanotandClaude Opus 4.7 0a05c479a0 docs(plan): B3 i18n FR/EN implementation plan
12 tasks, TDD per task, file paths + full code shape + verification.
Locale store + dicts + useT separate green commits; PDF + route
migrations land as one atomic green-build commit (formatDate +
exportReportToPdf signature change cross the boundary).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 06:50:15 +02:00
Bastien ChanotandClaude Opus 4.7 d559f565ac docs(spec): B3 i18n FR/EN site + PDF design
Approved design before implementation. Locale = render preference
(store, not Report schema). PDF export takes explicit locale arg.
Finding leaf labels via existing dual snapshot; catalog descriptions
+ scope_disclaimer stay FR-only this iteration.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 06:44:28 +02:00
Bastien ChanotandClaude bffa6fba26 chore(memory): /close — BDR-012/013 + LRN-013..016 + journal 2026-05-20 (session 2)
Capture the second-session findings-tree iteration learnings before
they fade:

Decisions
- BDR-012 species auto-discovery via Vite import.meta.glob default-export
  contract (alternatives: hardcoded registry, runtime registerSpecies()).
- BDR-013 SVG↔JSON zone bridge via fuzzy FR/EN label match (alternatives:
  rename SVG ids, add new data-anno-finding-zone attribute).

Learnings
- LRN-013 import.meta.glob + default-export as a plugin-discovery pattern.
- LRN-014 normalize + Levenshtein recipe for human-string cross-walk.
- LRN-015 per-source try/catch beats wrapping a loop with one outer catch.
- LRN-016 pdf-lib subset-font output: latin1/utf-8 bytes-grep won't find
  user-visible text — extract the JSON attachment or test through a
  refactored helper instead.

Journal
- Logs the 11 commits between b7b0945 and 70f21cc with one-line summaries
  + cross-refs to the new registry entries.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 06:21:39 +02:00
Bastien ChanotandClaude 70f21ccf37 docs: add PATHOLOGIES-FORMAT spec for the findings JSON catalog
Documents the canonical pathologies.json shape next to the existing
ANATOMY-SVG-CONVENTION and PDF-FORMAT guides. Mirrors the Zod
contract in src/domain/schema/findings.ts:

- Top-level frame (schema_version, scope_disclaimer, species, zones).
- ZoneFindings shape and how name_fr/name_en bridge to SVG labels.
- Recursive FindingNode (leaf vs intermediate, optional description,
  vet-referral flag, sources).
- SourceRef enum + URL validation.
- A minimal worked example.
- How leaf selections become persisted Findings, with the labelFr/En
  snapshot contract that protects already-exported reports from
  retroactive catalog edits.
- Authoring workflow that defers to `pnpm scaffold:species` and Vite
  HMR-driven validation.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 06:15:26 +02:00
Bastien ChanotandClaude 70b7f20f6f feat(species): auto-discover species manifests + scaffold script
Registry
--------
src/domain/species/registry.ts previously hard-coded the species list,
which meant adding a new animal forced an edit in two places. The
registry now uses Vite's `import.meta.glob('./*/index.ts', { eager: true })`
and registers every manifest that default-exports a SpeciesManifest.
Duplicate ids log a warn and the first wins. Existing named imports
keep working — equine/index.ts adds `export default equine` next to the
named export.

The species dropdown is also now sorted alphabetically by labelFr (FR
locale) instead of insertion order, so two species don't shuffle
position based on glob ordering.

Scaffold script
---------------
`pnpm scaffold:species` (scripts/scaffold-species.mjs) is an
interactive Node ESM prompt that asks for the id, FR/EN labels, asset
folder, main SVG filename, detail SVG mappings, and the vertebral
formula, then writes:

  src/domain/species/<id>/index.ts        (with `export default`)
  src/domain/species/<id>/vertebrae.ts
  src/domain/species/<id>/pathologies.ts  (Zod-parses the JSON)
  src/domain/species/<id>/pathologies.json (minimal valid skeleton)
  public/species/<assetFolder>/           (directory placeholder)

The script refuses to overwrite existing files, so it's safe to rerun
after typos. SVG assets are not generated — drop them in the public
folder yourself.

Findings JSON updates
---------------------
No runtime hot-reload mechanism is needed in dev: `pathologies.ts`
imports `pathologies.json` and runs `SpeciesFindingsSchema.parse(data)`
at module load, so a JSON edit triggers Vite HMR + an immediate Zod
validation pass. In prod, rebuild and redeploy.

Docs
----
docs/ADDING-A-SPECIES.md rewritten around the new flow: quick start via
the scaffold script first, manual instructions second, and removed the
stale references to the flat `Pathology[]` model and the no-longer-
required registry edit step.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 05:46:33 +02:00
Bastien ChanotandClaude 700567fc4f feat(pdf): render the inter-item separator larger and accent-coloured
ZONES and CONSTATS sections previously joined their entries with a tiny
mid-dot in the same body font. At print scale the separator collapsed
into the surrounding text and made dense lists hard to scan.

Sections that contain " · " are now drawn segment-by-segment:

- Items keep the existing body-regular @10pt ink color.
- The separator is rendered as a heavier "•" in body-bold @14pt in the
  accent color, with 5pt of clear space on either side.
- The bullet's baseline is nudged down 30% of the size delta so it
  visually centers on the surrounding text x-height.

Wrapping is handled per-item: an item that won't fit on the current
line jumps to the next; the separator never lands at the start of a
new line. The height estimator was updated to count the same wrapping
the renderer uses, so the image-area / text-area budget stays
balanced for both single-line and multi-line section values.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 05:31:21 +02:00
Bastien ChanotandClaude 4f8ea9e691 fix(pdf): widen the halo glow so main-view selections read from across the page
Single 6px Gaussian blur was being attenuated to near-invisible by the
SVG → canvas → PNG → pdf-lib pipeline (each stage loses some alpha).
The halo is now built from two stacked passes:

- a wide pass (stdDeviation=18) merged three times for the outer glow,
- a tighter pass (stdDeviation=8) merged twice to keep the selection
  anchored to the original point instead of dissolving into a fog.

Result: zone highlights stay obvious at print scale and from a couple
of feet away. Detail-view rendering is unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 05:21:43 +02:00
Bastien ChanotandClaude add408eee4 feat(pdf): smaller single-SVG layout + halo glow on main-view selections
Single image
------------
When an observation only has one SVG to render (no detail-popup zones),
the image now occupies half the available column width and is centered
horizontally. Two-image observations keep the existing 2-column grid
unchanged. The text-section reservation logic and aspect-driven row
budget still apply, so the layout stays balanced regardless of the
chosen cell size.

Halo glow on whole-animal view
------------------------------
Whole-animal SVGs use small point markers on a large silhouette, so
the previous flat fill was hard to spot at print scale. The colorized
SVG now carries a Gaussian-blur SVG filter ("osteo-halo") which is
applied to every selected zone on main views only — detail views are
already zoomed in and don't need it. The filter widens each selection
into a soft accent-coloured halo while keeping the original shape
crisp on top via feMerge. Fill opacity bumped from 0.65 to 0.85 to
sharpen the focal mark itself.

The filter is injected once into the SVG defs per export, so multiple
selected zones share the same definition with no duplication cost.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 05:18:39 +02:00
Bastien ChanotandClaude de40c5f91e feat(editor+pdf): per-zone PDF sections + collapsible findings pickers
PDF
---
The flat single-line "CONSTATS" section bundled every selected leaf
from every zone plus the free-text additions on one line, which got
hard to read as soon as an observation touched more than one zone.

The export now groups catalog findings by their JSON `zoneId` and
emits one section per zone, labelled with the zone's French name
("CONSTATS — SPHÉNOÏDE", "CONSTATS — ARTICULATION TEMPORO-MANDIBULAIRE
(ATM)", …). Free-text additions move to a dedicated "CONSTATS LIBRES"
section directly below.

The catalog tree is loaded once at the top of exportReportToPdf and
threaded through to addObservationPage, so the per-zone label lookup
costs nothing extra per observation.

Editor
------
Inside an expanded observation, each available zone's
FindingsTreePicker is now wrapped in an accordion header that mirrors
the ObservationCard expand/collapse semantics:

- Click a zone header → that picker opens and any other picker on the
  card closes.
- Click an open zone header → it collapses.
- Each header shows a selected-count badge and a ▼/▲ caret.

Default state is "all closed" so the card stays compact when the user
expands a new observation. Motion-based height/opacity transition
matches the observation card body animation for visual consistency.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 05:07:03 +02:00
Bastien ChanotandClaude 1e12f2252f fix(editor): preload all detail SVGs on mount so re-imported reports render findings
EditorRoute used to populate detailBones lazily, inside the useEffect
that fires when the user opens a detail popup. That was fine for
fresh sessions, but after re-importing a PDF the store can already hold
observations whose zones reference detail-popup bone ids (e.g. an ATM
zone with boneId "point-mpbyo7zq" carried by the head detail SVG).

Without the matching Bone in detailBones, ObservationCard.zonesWithTree
could not resolve bone.fr — matchZoneFindings discarded the zone and
the findings tree picker never appeared on observations whose only
zones came from a detail popup. The findings were already in the store
(read straight from the JSON attachment), so it looked exactly like
"the pathologies don't load on re-upload" from the user side.

Fix: in the species-load useEffect, fire a fetch for every
species.details path in parallel and merge the parsed bones into
detailBones. Each fetch has its own catch so one missing asset does
not block the others. The popup-open useEffect stays as a no-op
safety net (merge is idempotent thanks to the !merged.has(id) guard).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 04:55:47 +02:00
Bastien ChanotandClaude 93294a449b fix(pdf): make buildZoneLabels resilient to per-source failures
The old buildZoneLabels wrapped the main-SVG fetch and every detail-SVG
fetch in a single try/catch. As soon as one source threw — for example
a 404 on a detail asset in a misconfigured deployment — the loop bailed
out and the labels Map stayed populated only with whatever the loop had
already set. That left every observation zone whose boneId belonged to
a failed source falling back to the raw, opaque "point-mpbyo7zq" string
in the rendered PDF.

The refactor:
- Loads every source independently in parallel.
- Wraps each load+parse in its own try/catch.
- Logs a console.warn on failure so the issue is observable in dev.
- Skips empty bone.fr values so the lookup never returns "" (which the
  `??` fallback would treat as a value).

Exports buildZoneLabels so it can be unit-tested directly. The new
suite (4 cases) loads the real Horse + Horse_head SVG fixtures with a
mocked fetch and asserts:
  - detail-popup boneIds resolve to their FR labels,
  - main-SVG boneIds resolve to their FR labels,
  - main labels survive a 404 on the detail asset,
  - unknown species returns an empty map.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 04:55:36 +02:00
Bastien ChanotandClaude 34acb0cc94 feat(editor): badge selected-count on findings tree intermediate nodes
When drilling through the findings catalog, intermediate categories
and sub-categories now carry a rounded accent-coloured badge that
counts every selected leaf in their subtree. Sibling nodes with no
descendant selections stay badge-free, so the practitioner can scan
a level and see at a glance which branches already hold findings
without re-opening each one.

Implementation is a small `pathStartsWith` helper plus a `countSelectedUnder`
lookup against the current observation's findings — restricted to the
picker's `zoneId` so two parallel pickers on the same card never
cross-contaminate counts.

5 new tests cover: count of 2 visible at root, the same 2 visible one
level deeper on the right sub-branch, no badge on un-selected siblings,
singular aria label for 1 selection, and zone isolation.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-20 04:45:45 +02:00
Bastien ChanotandClaude Opus 4.7 95d746b555 feat(editor): fuzzy zone matcher (EN-first, FR fallback, typo-tolerant)
ObservationCard previously bridged SVG zones to the JSON findings
catalog with a strict FR-name equality check. That broke as soon as the
JSON used "(ATM)" while the SVG carried "Articulation Temporo-
Mandibulaire (ATM)" or whenever either side picked up a minor casse /
accent / typo drift.

The new matcher (src/lib/zoneMatch.ts) normalizes both sides
aggressively (lowercase + NFD-strip accents + drop non-alphanumerics)
and scores each pairing across all four (bone-lang, zone-lang)
combinations:

  0     exact normalized match
  1     one normalized string is contained in the other
  2+d   Levenshtein distance d, capped at max(2, ceil(maxLen * 0.25))
  ∞     beyond tolerance — discarded

Preference order: English exact/substring first (no accents → fewer
normalization edge cases), then French exact/substring, then fuzzy
across both languages.

Real-world payoff for the current equine catalog:

  bone EN "Sphenoid"                                    → sphenoid (score 0)
  bone EN "Spheno-Basilar Synchondrosis (SBS)"          → ssb      (score 0)
  bone EN "Temporomandibular Joint (TMJ)"               → atm      (score 0)
  bone FR "(ATM)" alone                                 → atm      (score 1)
  bone EN "sphenoi" / "shenoide" (typo)                 → sphenoid (fuzzy)
  bone EN "Hyoid", "Hip joint", "Stifle", ...           → undefined (correct)

23 new unit tests cover normalization, Levenshtein, scorePair branches,
the full matchZoneFindings strategy ladder, and the absence of false
positives (Sphenoid ↛ SSB, Hyoid/Hanche/etc ↛ anything).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 04:25:05 +02:00
Bastien ChanotandClaude Opus 4.7 1731adf620 fix(editor): match findings tree to SVG zone via FR label
SVG data-anno-id values are opaque generator strings (point-mpbyk...,
zone-mpbx...) that never match the human keys used in the findings
catalog (sphenoid, ssb, atm, ...). The picker therefore stayed hidden
whenever a zone was clicked.

ObservationCard now bridges the two via the FR label parsed from
data-anno-name-fr: it builds a name_fr → ZoneFindings index from the
loaded findings, looks up each observation zone by its Bone.fr, and
renders one picker per matched JSON tree (deduped on tree.id). Emitted
findings carry zoneId = tree.id (the JSON key), keeping the snapshot
contract intact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 04:12:27 +02:00
Bastien ChanotandClaude Opus 4.7 b7b094535e chore(memory): TODO + journal + BDR-009..011 + LRN-011..012
Mark B0/B1/B2/B5 done on TODO. Journal 2026-05-20 entry with the three
commit SHAs and a per-phase recap. Three new design decisions captured:
JSON snake_case kept in TS (BDR-009), snapshot labels at selection time
(BDR-010), hard-fail v1 PDF with FR-language message (BDR-011). Two new
learnings: Zod recursive schemas via z.lazy + explicit ZodType<T>
(LRN-011), once-per-session UX modal via sessionStorage flag (LRN-012).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 03:51:36 +02:00
Bastien ChanotandClaude Opus 4.7 b67f4cd82b feat(editor): findings tree picker + scope disclaimer + PDF render
Replaces the flat PathologyPicker with FindingsTreePicker — breadcrumb
navigation, drill into intermediate categories, toggle leaves, optional
vet-referral badge, optional description rendering. One picker per zone
that has a catalog entry; zones without a tree fall back to the free-text
input (renamed FreeTextFindingInput to match the new vocabulary).

EditorRoute now loads SpeciesFindings instead of a Pathology[] and shows
the scope_disclaimer once per session via a sessionStorage flag so the
practitioner is reminded of the legal perimeter the first time.

PDF observationPage renders findings via the snapshotted FR label and
prefixes ⚠ on vet-referral items, keeping the existing layout pipeline
intact (LRN-007/008/009 still apply).

Also drops the unused Toast and ZoneTooltip stubs, refreshes the
CLAUDE.md folder map, and adds a FindingsTreePicker test covering
navigation, leaf toggle, vet-referral flag, and back-out.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 03:49:11 +02:00
Bastien ChanotandClaude Opus 4.7 d08d773d74 feat(schema): bump report to v2 + observation findings + drop pathology
ObservationSchema now carries a hierarchical Finding (zoneId + path +
labelFrSnapshot + labelEnSnapshot + requiresVetReferral?) plus a renamed
freeTextFindings list, replacing the flat pathologyIds /
freeTextPathologies pair. Snapshot labels keep already-exported reports
readable if the catalog is later edited.

ReportSchema.version bumped from 1 → 2. PDF import surfaces a distinct,
French-language error message on legacy v1 attachments instead of the
generic "not an osteo PDF" line, via a new IncompatibleReportVersionError
detected before the strict Zod parse runs.

Store seed and tests updated for the new shape. The standalone Pathology
Zod schema and its test are removed — the new findings tree is the single
source of truth for what an observation can carry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 03:48:57 +02:00
Bastien ChanotandClaude Opus 4.7 f80e161d61 feat(schema): add findings tree + parse species JSON via Zod
Replaces the flat Pathology[] model with a hierarchical SpeciesFindings
tree (zones → categories → nested children → leaves) authored as JSON and
validated at boot. Equine catalog JSON is now wired through
SpeciesFindingsSchema.parse() so malformed data fails loudly instead of
corrupting an observation later.

Species manifest swaps `pathologies` loader for `findings`. JSON species
id renamed equin → equine to match the registry. Old equine pathology
test deleted; new findings test covers parse + FR/EN label coverage +
zone/category/leaf structure.

Foundational step of the v2 domain pivot; callers in observation/store/
UI/PDF migrated in follow-up commits.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 03:48:43 +02:00
Bastien ChanotandClaude 31be3155ef chore(memory): journal — domain pivot + B0+B1+B2 reminder for next session
Records the schema-v1.1 findings pivot decision, the inert JSON
drop, and the species.id reconciliation ("equin" vs "equine") to
resolve before the next loader migration runs.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 07:53:03 +02:00
Bastien ChanotandClaude a3afdcb763 chore(domain): drop equine findings JSON v1.1 + refactor plan
Adds the schema-v1.1 hierarchical findings JSON authored by the
domain expert at src/domain/species/equine/pathologies.json
(3-zone sample: sphenoid/ssb/atm — placeholder before full-body
authoring).

JSON is inert: not yet imported by the loader (still exports the
empty Pathology[]), so build and tests stay green.

TODO rewritten to sequence the V1 refactor:
- B0 findings schema + JSON loader with Zod parse at boot
- B1 ReportSchema v2 (observation.findings = path + snapshot)
- B2 FindingsTreePicker replacing flat PathologyPicker
- B3 i18n FR/EN site + PDF (locale store, dict, switcher)
- B4 PDF observationPage rendering findings
- B5 stub cleanup
- C  full horse.json authoring + QA + docs + deploy

Known fixup: JSON species.id is "horse" but registry uses
"equine"; align JSON to "equine" at integration time.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 07:44:10 +02:00
Bastien ChanotandClaude 50ad18f4ed chore(tasks): refresh TODO to reflect actual V1 state
Scaffold-era checklist was stale: most Phase 2-5 items already
shipped (full editor flow, PDF roundtrip, Docker, identity edit
dialog, etc.). Rewrite to capture what's actually done vs what
remains for V1/MVP ship.

Remaining for V1: equine pathology DB (40-60 source-cited entries,
currently empty array), stub cleanup (Toast/ZoneTooltip unused,
ObservationEditor never created), PDF QA pass, Docker deploy
validation, doc finalization, Scaleway production deploy.

Post-V1 ideas (Capacitor mobile, accounts/cloud, RDV) captured
in Phase C so they don't get pulled into MVP by mistake.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 07:02:27 +02:00
Bastien ChanotandClaude 8a2f9cc7ff chore(memory): LRN-010 — gate DOM-mutate effect on async-mount loaded state
Co-Authored-By: Claude <noreply@anthropic.com>
2026-05-19 06:56:28 +02:00