feat(editor): cross-region vertebra picks spawn their spine zone

Picking vertebrae in a region tab other than the clicked zone now creates
(or additively merges) the matching spine zone, so the SVG highlights it,
it appears in the observation's selected zones, and its findings picker shows.

Extract distributeVertebraeToZones + findSpineZoneId + regionFromLabel into
src/lib/spineZones.ts (regionFromLabel re-exported from VertebraPicker for
back-compat). Target region replaces (deselection sticks); other regions union
(side-tab picks never wipe a pre-existing zone). Unmapped regions fall back to
the target zone.

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 18:14:01 +02:00
1 parent 8e94196e5a
commit 9544924165
4 files changed
+220 -20

No files matched your search

+9 -2
View File
@@ -19,6 +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 type { Bone, BoneState } from '@/anatomy/types'
import type { Observation, ObservationZone } from '@/domain/schema/observation'
import type { SpeciesFindings } from '@/domain/schema/findings'
@@ -438,8 +439,14 @@ export default function EditorRoute() {
setVertebraTarget(null)
return
}
const next = [...fresh.zones]
next[vertebraTarget] = { ...next[vertebraTarget], vertebrae }
// 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,
)
updateObservation(activeIndex, { ...fresh, zones: next })
setVertebraTarget(null)
}}