feat(editor): a clear final state once the engine spent its three recoveries (canvas and action alerts)

This commit is contained in:
bchanot committed 2026-10-15 17:58:11 +02:00
1 parent f0580922b5
commit 0279953e9e
19 files changed
+101 -16

No files matched your search

@@ -17,6 +17,13 @@ export interface AnatomyCanvasProps {
const ANNOTATED = '[data-anno-id]'
/** Only an engine that can still recover offers a retry. */
const FAILURE_MESSAGE: Record<ViewFailure, string> = {
engine: 'sheet.core_unavailable',
engine_stopped: 'core.stopped',
view: 'canvas.view_unavailable',
}
function annotatedTarget(event: Event): Element | null {
const target = event.target
return target instanceof Element ? target.closest(ANNOTATED) : null
@@ -133,9 +140,7 @@ export default function AnatomyCanvas({
{failure && (
<div className="absolute inset-0 grid place-items-center p-4">
<div className="space-y-3 max-w-sm">
<Notice tone="error">
{t(failure === 'engine' ? 'sheet.core_unavailable' : 'canvas.view_unavailable')}
</Notice>
<Notice tone="error">{t(FAILURE_MESSAGE[failure])}</Notice>
{failure === 'engine' && (
<Button onClick={() => setAttempt((n) => n + 1)}>
{t('sheet.core_retry')}
@@ -20,6 +20,7 @@ import { pickLabel } from '@/i18n/pickLocaleLabel'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import type { Locale } from '@/i18n/types'
import { coreFailureMessage } from '@/core/failure'
export interface ObservationCardProps {
observation: Observation
@@ -168,7 +169,7 @@ export default function ObservationCard({
...(side ? { side } : {}),
})
if (outcome.ok) onChange(outcome.value)
else window.alert(t('core.action_failed'))
else window.alert(coreFailureMessage(t))
}
const removeFinding = (target: Finding) =>
onChange({
@@ -10,6 +10,7 @@ import { useLocaleStore } from '@/state/localeStore'
import { isObservable, type SheetIndex } from '@/services/sheetIndex'
import { pickLabel } from '@/i18n/pickLocaleLabel'
import { useT } from '@/i18n/useT'
import { coreFailureMessage } from '@/core/failure'
/** The zone the vertebra picker edits, with its initial selection (computed on open). */
export interface VertebraTarget {
@@ -63,7 +64,7 @@ export default function ObservationPickers({
if (!fresh) return
const outcome = run(fresh)
if (outcome.ok) updateObservation(activeIndex, outcome.value)
else window.alert(t('core.action_failed'))
else window.alert(coreFailureMessage(t))
}
return (
@@ -11,6 +11,7 @@ import { pickLabel } from '@/i18n/pickLocaleLabel'
import { reportOps } from '@/core/reportOps'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import { coreFailureMessage } from '@/core/failure'
export interface VertebraPickerProps {
open: boolean
@@ -68,7 +69,7 @@ export default function VertebraPicker({
const apply = (action: VertebraAction) => {
const outcome = reportOps.selectVertebrae(selected, action)
if (outcome.ok) setSelected(outcome.value)
else window.alert(t('core.action_failed'))
else window.alert(coreFailureMessage(t))
}
const toggle = (region: string, index: number) =>
apply({ kind: 'toggle', region, index })