feat(editor): unified spine picker — show all regions, click opens own tab

The vertebra picker now edits the whole spine at once instead of a single
zone. Seed it with the union of vertebrae across every spine zone of the
observation (collectSpineVertebrae) so switching tabs reveals selections made
on other zones. Clicking a zone always opens its own region tab (initialRegion
now takes priority over the first existing selection).

On confirm, syncSpineZones reconciles authoritatively per region: replace each
region's vertebrae (deselection sticks), prune a spine zone whose region drops
to zero, spawn a zone for a newly picked region. Non-spine zones and their
order are preserved untouched. Supersedes the additive distribute model.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-27 19:22:42 +02:00
1 parent fc7069c2cb
commit 38888cb3d1
5 files changed
+137 -96

No files matched your search

+9 -10
View File
@@ -19,7 +19,7 @@ import { writeCachedPractitioner } from '@/state/practitionerCache'
import { getSpecies } from '@/domain/species/registry'
import { loadSvg } from '@/anatomy/svgLoader'
import { parseSvgBones } from '@/anatomy/svgConvention'
import { distributeVertebraeToZones } from '@/lib/spineZones'
import { collectSpineVertebrae, syncSpineZones } from '@/lib/spineZones'
import type { Bone, BoneState } from '@/anatomy/types'
import type { Observation, ObservationZone } from '@/domain/schema/observation'
import type { SpeciesFindings } from '@/domain/schema/findings'
@@ -439,18 +439,17 @@ export default function EditorRoute() {
setVertebraTarget(null)
return
}
// Vertebrae picked in another region tab spawn/merge the matching
// spine zone, so the SVG highlights it and its findings picker shows.
const next = distributeVertebraeToZones(
fresh.zones,
vertebraTarget,
vertebrae,
bones,
)
// Picker edits every region at once: reconcile all spine zones —
// spawn newly picked regions, prune emptied ones, keep the rest.
const next = syncSpineZones(fresh.zones, vertebrae, bones)
updateObservation(activeIndex, { ...fresh, zones: next })
setVertebraTarget(null)
}}
initial={activeObs.zones[vertebraTarget].vertebrae ?? []}
initial={collectSpineVertebrae(
activeObs.zones,
bones,
activeObs.zones[vertebraTarget].boneId,
)}
formula={species.vertebralFormula}
title={`${t('vertebra.title_prefix')}${boneLabel(
bones.get(activeObs.zones[vertebraTarget].boneId),