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>
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.
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
Enables in-place edit of report identity blocks from the editor.
Mirrors existing setConclusion/setRecommendations pattern; no-op
when no report is loaded.
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>