Detail bones were cleared on popup close, so zone labels reverted to
raw ids (point-mpbynls5✕) once the head modal was dismissed. Now the
detailBones map accumulates across opens, and a merged allBones map
(main ∪ detail) is passed to ObservationList so describeZone resolves
the FR label every time.
Co-Authored-By: Claude <noreply@anthropic.com>
When opened from a spine zone, the picker now lands on the matching
region tab instead of defaulting to Cervicales every time. Inference is
substring-based on the FR label first, EN as fallback (cervic→C,
thorac/dors→T, lombair/lumbar→L, sacral/sacre→S, caudal/coccyg→Cd),
case- and accent-insensitive. An existing selection still wins over
the inferred region so re-opening lands where the user left off.
Co-Authored-By: Claude <noreply@anthropic.com>
Three coupled bugs in zone interaction:
1. Clicks inside the head detail popup were ignored — EditorRoute
looked up the clicked id in the main-SVG bones map only, so
detail-only ids (point-mpbykomv et al.) returned undefined.
2. Spine zones did not open VertebraPicker on click; the picker was
only reachable via the per-zone "Vertèbres…" button.
3. The new SVG hint data-anno-special="vertebral-precision" was
present in Horse.svg but unread by the parser/UI.
Parser now reads data-anno-special into Bone.special. EditorRoute
parses the detail SVG on open and falls back to detailBones for id
lookups. When bone.special === 'vertebral-precision', clicking adds
the zone (if absent) and opens VertebraPicker for that zone index;
toggle-off via main click is disabled for these zones (use ✕). The
"Vertèbres…" button in ObservationCard is now shown only on zones
that support it. Convention doc updated.
Co-Authored-By: Claude <noreply@anthropic.com>
User asked that the app interact with anything carrying data-anno-*
attributes without hardcoding any specific category, id, or name. Future
SVGs may introduce new categories, and the existing SVGs may be updated.
Changes:
- `BoneCategory` is now `type BoneCategory = string`. The closed union
is gone; the parser accepts any non-empty value. New categories don't
require code changes.
- `VALID_CATEGORIES` and `isValidCategory()` removed from
svgConvention.ts. `validateBoneElement()` now only enforces presence
of `data-anno-id` and `data-anno-category`.
- EditorRoute no longer auto-triggers the vertebra picker when the
clicked annotation is `zone-colonne`. Any zone is added the same way
to the active observation regardless of category.
- ObservationCard shows a "Vertèbres…" link on every zone badge (was
conditional on `category === 'zone-colonne'`). The praticien picks
vertebrae only when relevant — the UI no longer knows or cares which
zones are spinal.
- Tests rewritten: removed the `isValidCategory` enum assertions and
the "rejects unknown category" branch. New test demonstrates that
parseSvgBones accepts a completely novel category string.
90/90 tests pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
User dropped new Horse.svg / Horse_head.svg that follow a simpler
convention:
- Categories renamed to longer human strings:
articulation → articulations
charniere → charni-res-vert-brales
spine-zone → zone-colonne
cadran-crane → cadrans-du-cr-ne
head, os-overlay → dropped (head zone is now category="os" + data-anno-opens-detail)
os → unchanged
- No more hitbox / visible class split; multiple elements may still share
the same data-anno-id but they all carry the same role.
- Trigger-only zones (`data-anno-opens-detail="head"`) may omit
`data-anno-name-fr/en`.
Changes:
- `Bone` now exposes a single `els: Element[]` instead of `hitboxEls +
visibleEls`.
- `parseSvgBones` accepts annotations without fr/en labels (defaults to
empty string) but still rejects unknown or missing categories.
- The "interactive vs decorative" filter is gone — every parsed
annotation is interactive, since the new SVGs only annotate the
clickable zones.
- Vertebra-picker trigger: `bone.category === 'zone-colonne'`
(EditorRoute + ObservationCard).
- PDF colorisation in `observationPage.colorizedSvgString` writes the
accent fill to every `els[]` entry (no more hitbox dual-pass).
- Dead `src/components/observation/ObservationEditor.tsx` removed (its
body lives inside ObservationCard since the accordion refactor).
- Tests rewritten for the new vocabulary; synthetic fixture uses the new
categories, real-SVG test asserts 18 + 9 unique zones.
92/92 tests pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three issues from manual QA:
1. UX restructure — observations are now an accordion list. Each card has
a header that's always visible (title + chips + chevron + action
buttons) and a body that expands inline showing zones / pathologies /
severity / comment. Click the header (or the chevron) to toggle.
ObservationEditor has been merged into ObservationCard so each card
owns its own details. Only one observation is expanded at a time; the
chevron on the active card collapses everything. EditorRoute uses
activeObservationIndex === -1 to represent "all collapsed".
2. App used to start with 2 observations instead of 1. Root cause:
EditorRoute had a "seed first observation" useEffect that fired twice
under React 19 StrictMode in dev, both invocations seeing length=0 and
queueing addObservation(). Fixed by moving the seed into the store's
initReport (synchronous, one-shot) and removing the useEffect entirely.
Store tests updated to assert the seed behaviour (90/90 pass).
3. PDF export still failed with "The input is not a PNG file!" — canvg
was returning bytes that pdf-lib rejected at embedPng(). Switched
rasterizeSvg to the browser-native pipeline: serialize the SVG into a
Blob URL, load it with an Image element, drawImage onto a 2D canvas,
then toBlob → PNG bytes (with a toDataURL fallback). Validates the
PNG signature before returning. Tree-shaking dropped canvg from the
bundle (979 kB → 874 kB JS).
Tests updated for the new initReport behaviour and the new svgToPng
pipeline (Image mock + dataURL fallback case). lint + typecheck + build
all clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Five fixes from manual QA:
1. ObservationCard — clicking anywhere on the card now selects it.
The wrapping button only covered the text rows; empty space was dead.
The whole card is now role="button" with keyboard (Enter/Space) support;
inner action buttons (↑ ↓ 🗑) stop propagation so they don't double-fire.
This was also the root cause of "details look stuck" — the active
observation simply wasn't being switched.
2. NextAppointmentPicker — when value === undefined the "Date" radio was
still showing as checked because `kind` defaulted to 'date'. The three
radios now read from the raw `value?.kind` (which can be undefined),
so "Aucun" is the only checked option when no next RDV is set.
3. svgToPng.rasterizeSvg — `canvas.toBlob` can return null in some
browsers when the canvas state is unusual; the call now falls back to
`canvas.toDataURL('image/png')` and decodes the base64 payload. Also
paints a white background before canvg renders (so the PDF embed is
opaque) and clamps width/height to >= 1px to avoid zero-area canvases.
canvg errors are caught + logged instead of propagating, so the export
still produces a (possibly blank) page rather than throwing.
4. svgConvention.parseSvgBones — clickable bones are now distinguished
from decorative ones. Interactive = has a hitbox element OR category
is spine-zone OR head. Decorative bones (teeth, malar, mandible,
nasal-bone, facial-crest, individual vertebrae paths…) get
`pointer-events: none` applied to their elements and are excluded from
the returned map. Result: in Horse_head.svg, frontal/temporal/parietal/
sphenoid/occipital/atm/ssb/c0-c1/hyoid become clickable as intended,
while teeth / malar / mandible no longer intercept the clicks.
5. (covered by #1) — the per-observation details panel always read the
active observation; the bug was the click handler scope. Confirmed by
switching observations: the editor section now updates immediately.
88 tests still pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The app is open to any praticien who wants to use it (not 'single-praticien'),
and the architecture is multi-species — equine ships first, dog/cat/goat/cow/
pig/rabbit/donkey/sheep come as pure data drops following the same convention.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three impactful fixes from the post-impl code review:
1. EditorRoute.onExport now catches PDF generation failures, logs to
console, and alerts the praticien in French — previously errors were
swallowed by try/finally with only `setExporting(false)`.
2. VertebraPicker onConfirm reads the active observation from the store
at confirm time instead of closing over the render-scope `activeObs`.
Prevents mutating a stale observation if the praticien switches active
observation while the picker is open.
3. readPersistedDraft validates the parsed JSON with ReportSchema instead
of a raw `as Report` cast. Corrupted drafts now return null cleanly
rather than poisoning the store.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the placeholder with a full 7-step walkthrough: SVG convention,
file placement under public/, species manifest at src/domain/species/<id>/,
registry wiring, vertebral formula, pathology seed (empty allowed in v1),
and the two mirror tests (registry + real-SVG parse + pathologies schema).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Capture the plan §23.2 walkthrough as an unticked checklist with
deliberate TODO markers. Automated browser QA was out of scope for the
/init-project session; this file is the handoff for a manual pnpm dev
verification before delivery. Includes the matching automated coverage
table so reviewers know what is already enforced by CI.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Escape French apostrophes/quotes in JSX text per react/no-unescaped-entities
and replace the report?.observations.length dependency with a derived
observationsCount value so react-hooks/exhaustive-deps is satisfied without
re-firing on every report change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wire index.html to actually load /env.js before the Vite bundle so the
runtime config injected by docker/entrypoint.sh takes effect. Add a
public/env.js stub so local dev and static builds don't 404 — the Docker
container overwrites it via the entrypoint.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>