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

+6
View File
@@ -418,3 +418,9 @@ Status: closed (merged aab61c2).
Plan rev 2 after 3 challengers (32 findings). Reader = prescan (markup state machine, caps before parse: 2 MiB, BOM, DOCTYPE, depth 64, 20k elements, attrs 256/100k, 16 xmlns, raw `<` 100k `=` 200k) → roxmltree 0.21.1 → own tree (qualified names as written, TS allowlist parity) → allowlist + declared extras (SVG ns only, comments dropped, text only title/desc ≤ 4 KiB, root without class/style/transform/filter/mask/clip-path, id grammar, href/url( local only after ASCII/CSS whitespace) → reference graph (cycles refused, expansion ≤ 50k) → serialiser (control whitespace as char refs, output ≤ 4 MiB). Product drawing with any removal refused at load (LRN-055). Facade: only `view.canvas {viewId}` (stateless, memoised per view; data-state still restyled in place). Highlight composition = core fn proven vs TS (O3), no facade op until R4 (snapshot-based call). Behaviour = code where ANNOTATION-RENDERING.md differed (doc rewritten first). Canvas failure → existing degraded notice + retry. Plan rev 2 after 3 challengers (32 findings). Reader = prescan (markup state machine, caps before parse: 2 MiB, BOM, DOCTYPE, depth 64, 20k elements, attrs 256/100k, 16 xmlns, raw `<` 100k `=` 200k) → roxmltree 0.21.1 → own tree (qualified names as written, TS allowlist parity) → allowlist + declared extras (SVG ns only, comments dropped, text only title/desc ≤ 4 KiB, root without class/style/transform/filter/mask/clip-path, id grammar, href/url( local only after ASCII/CSS whitespace) → reference graph (cycles refused, expansion ≤ 50k) → serialiser (control whitespace as char refs, output ≤ 4 MiB). Product drawing with any removal refused at load (LRN-055). Facade: only `view.canvas {viewId}` (stateless, memoised per view; data-state still restyled in place). Highlight composition = core fn proven vs TS (O3), no facade op until R4 (snapshot-based call). Behaviour = code where ANNOTATION-RENDERING.md differed (doc rewritten first). Canvas failure → existing degraded notice + retry.
Alt rejected: roxmltree alone with nodes_limit (recursion overflows wasm stack, measured); `svg.sanitize` / `view.highlighted` ops now (no consumer, wrong source for R4); states in the canvas op (dead: restyle runs after every build); dangling-ref removal (rendering change); duplicate-id refusal; property tests (no generator crate). Alt rejected: roxmltree alone with nodes_limit (recursion overflows wasm stack, measured); `svg.sanitize` / `view.highlighted` ops now (no consumer, wrong source for R4); states in the canvas op (dead: restyle runs after every build); dangling-ref removal (rendering change); duplicate-id refusal; property tests (no generator crate).
Status: active; R3 awaiting owner validation, not merged. Status: active; R3 awaiting owner validation, not merged.
## BDR-054 | 2026-10-15 | R3 owner UX decisions: trigger names per language, three canvas failure states, retry policy
Owner validated after R3 review: (1) unnamed trigger → `data-anno-name-fr`/`-en` + title take opened view name per language, empty language falls back to other; display only (not identifier, not persisted); frozen oracles untouched, tests apply declared change (`with_trigger_names_per_language` / `withTriggerNamesPerLanguage`, MAKE refused). (2) canvas failures distinct: engine (core_unavailable, internal) → `sheet.core_unavailable` + Réessayer (fresh instance may succeed); view (svg_rejected, no_asset, unknown_view, invalid_character, parse) → `canvas.view_unavailable`, no retry; detail in core outcome + DEV console only. (3) recovery cap 3 kept; after it `CoreRuntime.stopped` → `core.stopped` ("reload the page, report kept in tab") in canvas and in the 8 action alerts (`coreFailureMessage`), no retry. Wording of the three messages accepted.
Alt rejected: correcting the TS renderer too (engine/pipeline frozen until R4/R5; invisible in PDF: data-* dropped, title not rasterised); retry for deterministic view failures; editing goldens.
Status: closed (decisions); R3 still awaiting owner LAN confirmation, not merged.
+1
View File
@@ -266,3 +266,4 @@ Owner brief: maintenance before R3. bugfix/r2-maintenance: rustls 0.23.46 (4 adv
feature/rust-r3-anatomy-core: plan rev 2 after 3 challengers (32 findings; blocker = roxmltree recursion, measured overflow < 3,000 levels on 1 MiB → markup prescan before any parse). Freeze first: O1 canvas trees, O2 layer order, O3 36 highlights, O4/O5 36 hostile + 10 floods + 4 product SVGs, Chromium refs. Rust reader (prescan, tree, allowlist, reference graph, serialiser), layer, canvas/highlight compose, `view.canvas`; app canvas switched, denylist + anatomy dep deleted. All oracles green, mutation-checked; Chromium DOM = O1, 30/30 pixel-identical; module 396 KB gz (+56). check:all green. Gates dispatched; stop for owner validation, no merge, no R4. feature/rust-r3-anatomy-core: plan rev 2 after 3 challengers (32 findings; blocker = roxmltree recursion, measured overflow < 3,000 levels on 1 MiB → markup prescan before any parse). Freeze first: O1 canvas trees, O2 layer order, O3 36 highlights, O4/O5 36 hostile + 10 floods + 4 product SVGs, Chromium refs. Rust reader (prescan, tree, allowlist, reference graph, serialiser), layer, canvas/highlight compose, `view.canvas`; app canvas switched, denylist + anatomy dep deleted. All oracles green, mutation-checked; Chromium DOM = O1, 30/30 pixel-identical; module 396 KB gz (+56). check:all green. Gates dispatched; stop for owner validation, no merge, no R4.
- Same day: gates. Verifier CONFORME 11/11. Security PASS + MEDIUM (prescan closer searched inside its opener, `<!-->` hid 5,000 levels → stack overflow) fixed; pass 2 PASS (4M differential docs) + LOW url( whitespace fixed; verifier re-run CONFORME. Final check:all green, Chromium 30/30 identical. BDR-052/053, LRN-056, EVAL-022. Stop: owner LAN validation. - Same day: gates. Verifier CONFORME 11/11. Security PASS + MEDIUM (prescan closer searched inside its opener, `<!-->` hid 5,000 levels → stack overflow) fixed; pass 2 PASS (4M differential docs) + LOW url( whitespace fixed; verifier re-run CONFORME. Final check:all green, Chromium 30/30 identical. BDR-052/053, LRN-056, EVAL-022. Stop: owner LAN validation.
- 2026-10-15 owner UX decisions on R3: unnamed trigger names per language (contract doc first, Rust layer, declared change applied to frozen oracles, goldens untouched); canvas engine failure (retry) vs view failure (own message, no retry). check:all green, Chromium 30/30 identical + DOM = O1 (declared), verifier CONFORME 8/8, security PASS 0 findings. Owner LAN tests in progress; no merge, no R4. - 2026-10-15 owner UX decisions on R3: unnamed trigger names per language (contract doc first, Rust layer, declared change applied to frozen oracles, goldens untouched); canvas engine failure (retry) vs view failure (own message, no retry). check:all green, Chromium 30/30 identical + DOM = O1 (declared), verifier CONFORME 8/8, security PASS 0 findings. Owner LAN tests in progress; no merge, no R4.
- 2026-10-15 owner validated both UX fixes + retry on internal; asked 3-attempt cap then clear failure state: found canvas + 8 alerts would still offer retry after cap → `CoreRuntime.stopped` + `core.stopped` message, no retry. BDR-054. R3 not merged (LAN tests pending).
+1
View File
@@ -199,6 +199,7 @@ feat/findings-tree-v2 merged (FindingsTreePicker tracked in HEAD); all work belo
- [x] R3.6 gates: verifier CONFORME 11/11 ×2; security PASS ×3 (MEDIUM prescan closer desync + 3 LOW fixed: href/url( Unicode spaces, root painting attrs); check:all green 1 min 56 s; Chromium final 30/30 identical, DOM = O1 - [x] R3.6 gates: verifier CONFORME 11/11 ×2; security PASS ×3 (MEDIUM prescan closer desync + 3 LOW fixed: href/url( Unicode spaces, root painting attrs); check:all green 1 min 56 s; Chromium final 30/30 identical, DOM = O1
- [ ] R3 owner validation (LAN: TEST FONCTIONNEL + TEST GRAPHIQUE), then merge on the owner's go; R4 not started - [ ] R3 owner validation (LAN: TEST FONCTIONNEL + TEST GRAPHIQUE), then merge on the owner's go; R4 not started
- [x] R3 owner decisions 2026-10-15: unnamed trigger names per language (6882c6d, contract d8e9bd3); canvas engine failure (retry) vs view failure (no retry) (c0a5c8c) - [x] R3 owner decisions 2026-10-15: unnamed trigger names per language (6882c6d, contract d8e9bd3); canvas engine failure (retry) vs view failure (no retry) (c0a5c8c)
- [x] R3 owner follow-up 2026-10-15: retry kept for `internal`; after the 3 recoveries a clear final state (`core.stopped`) in the canvas and the action alerts, no retry (BDR-054)
- [ ] R3 follow-ups kept by the owner (2026-10-15): worker TLS exercised against a real HTTPS endpoint before the deployment that needs it; roxmltree limits + SVG prescan (pin the iterative release when published); Firefox/WebKit check; SVG references across drawings scoped per view before community uploads (Step 13); WASM size margin (396 of 600 KB) before R4; TypeScript PDF sanitiser still present until R4 - [ ] R3 follow-ups kept by the owner (2026-10-15): worker TLS exercised against a real HTTPS endpoint before the deployment that needs it; roxmltree limits + SVG prescan (pin the iterative release when published); Firefox/WebKit check; SVG references across drawings scoped per view before community uploads (Step 13); WASM size margin (396 of 600 KB) before R4; TypeScript PDF sanitiser still present until R4
- [ ] R4 pdf core: reader (Web Worker, BLK-009 browser measurements) + writer (`pdf-writer`, Std14 AFM, draw log; lines/rects/colours golden frozen with the TS engine first, D-R2) + `report-compare` tool; `packages/pdf` deleted; N-1 scanner reads R4 PDFs - [ ] R4 pdf core: reader (Web Worker, BLK-009 browser measurements) + writer (`pdf-writer`, Std14 AFM, draw log; lines/rects/colours golden frozen with the TS engine first, D-R2) + `report-compare` tool; `packages/pdf` deleted; N-1 scanner reads R4 PDFs
- [ ] R5 curation pipeline + importer + upload tool: seed golden regenerated once (new `documentSha256`, D-R5), `packages/anatomy` + `packages/domain` deleted, docs map; all before Step 13 - [ ] R5 curation pipeline + importer + upload tool: seed golden regenerated once (new `documentSha256`, D-R5), `packages/anatomy` + `packages/domain` deleted, docs map; all before Step 13
+1 -1
View File
@@ -12,7 +12,7 @@ Versions follow [Semantic Versioning](https://semver.org/).
- **No visible change**, proven first with the TypeScript: canvas trees of both views and 28 selection states, layer trees with attribute order, 36 PDF highlight compositions, 36 hostile SVGs and 10 generated floods, the 4 product SVGs untouched; in Chromium 156 the live canvas trees equal the frozen ones and 30 screenshots (desktop and phone) are pixel-identical before and after. The Step 6 goldens are untouched. - **No visible change**, proven first with the TypeScript: canvas trees of both views and 28 selection states, layer trees with attribute order, 36 PDF highlight compositions, 36 hostile SVGs and 10 generated floods, the 4 product SVGs untouched; in Chromium 156 the live canvas trees equal the frozen ones and 30 screenshots (desktop and phone) are pixel-identical before and after. The Step 6 goldens are untouched.
- Declared differences, none on a product drawing: elements outside the SVG namespace removed, comments dropped, no `class`/`style` on the inline root, stricter ids, text only in `title`/`desc` (4 KiB each), floods and reference cycles refused, a product drawing the allowlist would alter refused at load instead of silently cut, a canvas that cannot be composed shows the existing degraded notice with a retry (`docs/development/RUST.md` §9.4). - Declared differences, none on a product drawing: elements outside the SVG namespace removed, comments dropped, no `class`/`style` on the inline root, stricter ids, text only in `title`/`desc` (4 KiB each), floods and reference cycles refused, a product drawing the allowlist would alter refused at load instead of silently cut, a canvas that cannot be composed shows the existing degraded notice with a retry (`docs/development/RUST.md` §9.4).
- `docs/ANNOTATION-RENDERING.md` rewritten to describe the code exactly (no rendering change). Module 396 KB gzip (+56 KB, budget 600 KB). - `docs/ANNOTATION-RENDERING.md` rewritten to describe the code exactly (no rendering change). Module 396 KB gzip (+56 KB, budget 600 KB).
- Owner decisions after the R3 review: a detail-view trigger without its own name now carries the opened view's name in each language (the English attribute and the tooltip title used to repeat the French name); the canvas tells an engine that did not load ("Réessayer") from a view whose drawing is refused or cannot be composed (its own message, no retry). - Owner decisions after the R3 review: a detail-view trigger without its own name now carries the opened view's name in each language (the English attribute and the tooltip title used to repeat the French name); the canvas tells an engine that did not load ("Réessayer") from a view whose drawing is refused or cannot be composed (its own message, no retry); after its three recoveries the engine shows a clear final state (reload the page, the report is kept in the tab) in the canvas and in the action alerts, never a retry that cannot work.
### Security (maintenance after R2, 2026-10-14) ### Security (maintenance after R2, 2026-10-14)
+6 -3
View File
@@ -1,3 +1,4 @@
import { coreStopped } from '@/core/runtime'
import type { SheetIndex } from '@/services/sheetIndex' import type { SheetIndex } from '@/services/sheetIndex'
/** /**
@@ -10,11 +11,12 @@ import type { SheetIndex } from '@/services/sheetIndex'
export type ViewStates = ReadonlyMap<string, 'current'> export type ViewStates = ReadonlyMap<string, 'current'>
/** /**
* Why a view cannot be drawn: the engine did not run (a retry may succeed), or the view * Why a view cannot be drawn: the engine did not run (a retry may succeed), the engine
* stopped after its three recoveries (only a reload starts it again), or the view
* itself cannot be drawn (a refused drawing, a view the core cannot compose: retrying * itself cannot be drawn (a refused drawing, a view the core cannot compose: retrying
* changes nothing). The technical kind stays in the core's outcome and the DEV console. * changes nothing). The technical kind stays in the core's outcome and the DEV console.
*/ */
export type ViewFailure = 'engine' | 'view' export type ViewFailure = 'engine' | 'engine_stopped' | 'view'
export type ViewBuild = { ok: true; svg: SVGSVGElement } | { ok: false; failure: ViewFailure } export type ViewBuild = { ok: true; svg: SVGSVGElement } | { ok: false; failure: ViewFailure }
@@ -28,7 +30,8 @@ function failed(failure: ViewFailure, kind: string, detail?: string): ViewBuild
export function buildViewSvg(index: SheetIndex, viewId: string): ViewBuild { export function buildViewSvg(index: SheetIndex, viewId: string): ViewBuild {
const text = index.canvasSvg(viewId) const text = index.canvasSvg(viewId)
if (!text.ok) { if (!text.ok) {
return failed(ENGINE_KINDS.has(text.kind) ? 'engine' : 'view', text.kind, text.detail) const engine = coreStopped() ? 'engine_stopped' : 'engine'
return failed(ENGINE_KINDS.has(text.kind) ? engine : 'view', text.kind, text.detail)
} }
const parsed = new DOMParser().parseFromString(text.value, 'image/svg+xml') const parsed = new DOMParser().parseFromString(text.value, 'image/svg+xml')
const root = parsed.documentElement const root = parsed.documentElement
+5 -4
View File
@@ -36,6 +36,7 @@ import type { ExportWarning } from '@faunosteo/pdf'
import type { RebaseOutcome } from '@faunosteo/core-wasm/types' import type { RebaseOutcome } from '@faunosteo/core-wasm/types'
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
import { DEFAULT_SPECIES_ID } from './NewReportRoute' import { DEFAULT_SPECIES_ID } from './NewReportRoute'
import { coreFailureMessage } from '@/core/failure'
const DISCLAIMER_FLAG = 'osteo:disclaimer-shown' const DISCLAIMER_FLAG = 'osteo:disclaimer-shown'
@@ -161,7 +162,7 @@ export default function EditorRoute() {
const activeObs = const activeObs =
activeIndex >= 0 ? report.observations[activeIndex] : undefined activeIndex >= 0 ? report.observations[activeIndex] : undefined
const outcome = sheet.index.ops.zoneClick(activeObs ?? null, annotationId) const outcome = sheet.index.ops.zoneClick(activeObs ?? null, annotationId)
if (!outcome.ok) return window.alert(t('core.action_failed')) if (!outcome.ok) return window.alert(coreFailureMessage(t))
const click = outcome.value const click = outcome.value
if (click.observation) store.updateObservation(activeIndex, click.observation) if (click.observation) store.updateObservation(activeIndex, click.observation)
switch (click.kind) { switch (click.kind) {
@@ -189,7 +190,7 @@ export default function EditorRoute() {
/** A store action the core ran: the practitioner hears about a failure. */ /** A store action the core ran: the practitioner hears about a failure. */
const guarded = useCallback( const guarded = useCallback(
(result: ActionResult) => { (result: ActionResult) => {
if (!result.ok) window.alert(t('core.action_failed')) if (!result.ok) window.alert(coreFailureMessage(t))
}, },
[t], [t],
) )
@@ -198,7 +199,7 @@ export default function EditorRoute() {
function openVertebraPicker(index: SheetIndex, zoneIndex: number) { function openVertebraPicker(index: SheetIndex, zoneIndex: number) {
if (!activeObs) return if (!activeObs) return
const outcome = index.ops.vertebraInitial(activeObs, zoneIndex) const outcome = index.ops.vertebraInitial(activeObs, zoneIndex)
if (!outcome.ok) return window.alert(t('core.action_failed')) if (!outcome.ok) return window.alert(coreFailureMessage(t))
setVertebraTarget({ zoneIndex, initial: outcome.value }) setVertebraTarget({ zoneIndex, initial: outcome.value })
} }
@@ -207,7 +208,7 @@ export default function EditorRoute() {
if (!obs) return if (!obs) return
const outcome = index.ops.removeZoneAt(obs, zoneIndex) const outcome = index.ops.removeZoneAt(obs, zoneIndex)
if (outcome.ok) store.updateObservation(i, outcome.value) if (outcome.ok) store.updateObservation(i, outcome.value)
else window.alert(t('core.action_failed')) else window.alert(coreFailureMessage(t))
} }
function acknowledgeDisclaimer() { function acknowledgeDisclaimer() {
+2 -1
View File
@@ -15,6 +15,7 @@ import {
import { useReportStore } from '@/state/reportStore' import { useReportStore } from '@/state/reportStore'
import { loadSheetIndex, useSheetAvailability } from '@/sheets/useSheet' import { loadSheetIndex, useSheetAvailability } from '@/sheets/useSheet'
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
import { coreFailureMessage } from '@/core/failure'
/** The one species this build ships a sheet for. */ /** The one species this build ships a sheet for. */
export const DEFAULT_SPECIES_ID = 'equine' export const DEFAULT_SPECIES_ID = 'equine'
@@ -71,7 +72,7 @@ export default function NewReportRoute() {
else if (created.reason === 'held') { else if (created.reason === 'held') {
window.alert(t('session.held_blocked')) window.alert(t('session.held_blocked'))
navigate('/editor') navigate('/editor')
} else window.alert(t('core.action_failed')) } else window.alert(coreFailureMessage(t))
} }
return ( return (
@@ -17,6 +17,13 @@ export interface AnatomyCanvasProps {
const ANNOTATED = '[data-anno-id]' 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 { function annotatedTarget(event: Event): Element | null {
const target = event.target const target = event.target
return target instanceof Element ? target.closest(ANNOTATED) : null return target instanceof Element ? target.closest(ANNOTATED) : null
@@ -133,9 +140,7 @@ export default function AnatomyCanvas({
{failure && ( {failure && (
<div className="absolute inset-0 grid place-items-center p-4"> <div className="absolute inset-0 grid place-items-center p-4">
<div className="space-y-3 max-w-sm"> <div className="space-y-3 max-w-sm">
<Notice tone="error"> <Notice tone="error">{t(FAILURE_MESSAGE[failure])}</Notice>
{t(failure === 'engine' ? 'sheet.core_unavailable' : 'canvas.view_unavailable')}
</Notice>
{failure === 'engine' && ( {failure === 'engine' && (
<Button onClick={() => setAttempt((n) => n + 1)}> <Button onClick={() => setAttempt((n) => n + 1)}>
{t('sheet.core_retry')} {t('sheet.core_retry')}
@@ -20,6 +20,7 @@ import { pickLabel } from '@/i18n/pickLocaleLabel'
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore' import { useLocaleStore } from '@/state/localeStore'
import type { Locale } from '@/i18n/types' import type { Locale } from '@/i18n/types'
import { coreFailureMessage } from '@/core/failure'
export interface ObservationCardProps { export interface ObservationCardProps {
observation: Observation observation: Observation
@@ -168,7 +169,7 @@ export default function ObservationCard({
...(side ? { side } : {}), ...(side ? { side } : {}),
}) })
if (outcome.ok) onChange(outcome.value) if (outcome.ok) onChange(outcome.value)
else window.alert(t('core.action_failed')) else window.alert(coreFailureMessage(t))
} }
const removeFinding = (target: Finding) => const removeFinding = (target: Finding) =>
onChange({ onChange({
@@ -10,6 +10,7 @@ import { useLocaleStore } from '@/state/localeStore'
import { isObservable, type SheetIndex } from '@/services/sheetIndex' import { isObservable, type SheetIndex } from '@/services/sheetIndex'
import { pickLabel } from '@/i18n/pickLocaleLabel' import { pickLabel } from '@/i18n/pickLocaleLabel'
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
import { coreFailureMessage } from '@/core/failure'
/** The zone the vertebra picker edits, with its initial selection (computed on open). */ /** The zone the vertebra picker edits, with its initial selection (computed on open). */
export interface VertebraTarget { export interface VertebraTarget {
@@ -63,7 +64,7 @@ export default function ObservationPickers({
if (!fresh) return if (!fresh) return
const outcome = run(fresh) const outcome = run(fresh)
if (outcome.ok) updateObservation(activeIndex, outcome.value) if (outcome.ok) updateObservation(activeIndex, outcome.value)
else window.alert(t('core.action_failed')) else window.alert(coreFailureMessage(t))
} }
return ( return (
@@ -11,6 +11,7 @@ import { pickLabel } from '@/i18n/pickLocaleLabel'
import { reportOps } from '@/core/reportOps' import { reportOps } from '@/core/reportOps'
import { useT } from '@/i18n/useT' import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore' import { useLocaleStore } from '@/state/localeStore'
import { coreFailureMessage } from '@/core/failure'
export interface VertebraPickerProps { export interface VertebraPickerProps {
open: boolean open: boolean
@@ -68,7 +69,7 @@ export default function VertebraPicker({
const apply = (action: VertebraAction) => { const apply = (action: VertebraAction) => {
const outcome = reportOps.selectVertebrae(selected, action) const outcome = reportOps.selectVertebrae(selected, action)
if (outcome.ok) setSelected(outcome.value) if (outcome.ok) setSelected(outcome.value)
else window.alert(t('core.action_failed')) else window.alert(coreFailureMessage(t))
} }
const toggle = (region: string, index: number) => const toggle = (region: string, index: number) =>
apply({ kind: 'toggle', region, index }) apply({ kind: 'toggle', region, index })
+11
View File
@@ -0,0 +1,11 @@
import type { useT } from '@/i18n/useT'
import { coreStopped } from './runtime'
/**
* The alert after a core action failed: "try again" while a retry can work; once the engine
* stopped after its three recoveries, the clear final state (reload the page, the report is
* kept in the tab) instead of a retry that cannot succeed (owner decision 2026-10-15).
*/
export function coreFailureMessage(t: ReturnType<typeof useT>): string {
return t(coreStopped() ? 'core.stopped' : 'core.action_failed')
}
+5
View File
@@ -34,6 +34,11 @@ const browserSource: CoreSource = {
let runtime: CoreRuntime | null = null let runtime: CoreRuntime | null = null
/** Whether the page's runtime spent its recoveries (never creates the runtime). */
export function coreStopped(): boolean {
return runtime?.stopped ?? false
}
/** The page's runtime, created on first use. */ /** The page's runtime, created on first use. */
export function coreRuntime(): CoreRuntime { export function coreRuntime(): CoreRuntime {
runtime ??= new CoreRuntime(browserSource) runtime ??= new CoreRuntime(browserSource)
+2
View File
@@ -201,6 +201,8 @@ export const en: Dict = {
'sheet.core_unavailable': 'sheet.core_unavailable':
"Faunosteo's computation engine could not be loaded. Your session data is kept.", "Faunosteo's computation engine could not be loaded. Your session data is kept.",
'sheet.core_retry': 'Retry', 'sheet.core_retry': 'Retry',
'core.stopped':
"Faunosteo's computation engine stopped after several successive errors. Reload the page to start it again: your report is kept in this tab.",
'canvas.view_unavailable': 'canvas.view_unavailable':
"This anatomical view cannot be displayed: its drawing was refused by the safety checks or could not be composed. Your report is not changed.", "This anatomical view cannot be displayed: its drawing was refused by the safety checks or could not be composed. Your report is not changed.",
'core.action_failed': 'core.action_failed':
+2
View File
@@ -215,6 +215,8 @@ export const fr: Dict = {
'sheet.core_unavailable': 'sheet.core_unavailable':
"Le moteur de calcul de Faunosteo n'a pas pu être chargé. Vos données de session sont conservées.", "Le moteur de calcul de Faunosteo n'a pas pu être chargé. Vos données de session sont conservées.",
'sheet.core_retry': 'Réessayer', 'sheet.core_retry': 'Réessayer',
'core.stopped':
"Le moteur de calcul de Faunosteo s'est arrêté après plusieurs erreurs successives. Rechargez la page pour le relancer : votre bilan est conservé dans cet onglet.",
'canvas.view_unavailable': 'canvas.view_unavailable':
"Cette vue anatomique ne peut pas être affichée : son dessin a été refusé par les contrôles de sécurité ou n'a pas pu être composé. Votre bilan n'est pas modifié.", "Cette vue anatomique ne peut pas être affichée : son dessin a été refusé par les contrôles de sécurité ou n'a pas pu être composé. Votre bilan n'est pas modifié.",
'core.action_failed': 'core.action_failed':
@@ -2,6 +2,9 @@ import { beforeAll, describe, expect, it, vi, afterEach } from 'vitest'
import { cleanup, render, screen, waitFor } from '@testing-library/react' import { cleanup, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event' import userEvent from '@testing-library/user-event'
import AnatomyCanvas from '@/components/canvas/AnatomyCanvas' import AnatomyCanvas from '@/components/canvas/AnatomyCanvas'
import type { CoreRuntime } from '@faunosteo/core-wasm'
import { coreRuntime, setCoreRuntime } from '@/core/runtime'
import { coreFailureMessage } from '@/core/failure'
import { buildViewSvg } from '@/anatomy/drawing' import { buildViewSvg } from '@/anatomy/drawing'
import type { SheetIndex } from '@/services/sheetIndex' import type { SheetIndex } from '@/services/sheetIndex'
import { useLocaleStore } from '@/state/localeStore' import { useLocaleStore } from '@/state/localeStore'
@@ -143,6 +146,23 @@ describe('AnatomyCanvas', () => {
expect(screen.queryByText(fr['sheet.core_unavailable']!)).toBeNull() expect(screen.queryByText(fr['sheet.core_unavailable']!)).toBeNull()
}) })
it('after the recoveries are spent, shows the final state with no retry; alerts say the same', async () => {
useLocaleStore.setState({ locale: 'fr' })
const live = coreRuntime()
setCoreRuntime({ stopped: true } as unknown as CoreRuntime)
try {
const down = Object.create(sheet) as SheetIndex
down.canvasSvg = () => ({ ok: false, kind: 'internal' })
render(<AnatomyCanvas index={down} viewId="main" states={new Map()} onZoneClick={() => undefined} />)
await screen.findByText(fr['core.stopped']!)
expect(screen.queryByRole('button', { name: fr['sheet.core_retry'] })).toBeNull()
expect(coreFailureMessage((k: string) => fr[k]!)).toBe(fr['core.stopped'])
} finally {
setCoreRuntime(live)
}
expect(coreFailureMessage((k: string) => fr[k]!)).toBe(fr['core.action_failed'])
})
it('words both failures in English too', async () => { it('words both failures in English too', async () => {
useLocaleStore.setState({ locale: 'en' }) useLocaleStore.setState({ locale: 'en' })
const hostile = await sheetDrawing('<svg xmlns="http://www.w3.org/2000/svg"><script/></svg>') const hostile = await sheetDrawing('<svg xmlns="http://www.w3.org/2000/svg"><script/></svg>')
+5 -1
View File
@@ -809,7 +809,11 @@ imports it and restyles `data-state` in place as before.
7. When the canvas cannot be drawn, it says why, inside the canvas (owner 7. When the canvas cannot be drawn, it says why, inside the canvas (owner
decision 2026-10-15): the engine did not run (`core_unavailable`, decision 2026-10-15): the engine did not run (`core_unavailable`,
`internal`: the existing `sheet.core_unavailable` notice with "Réessayer", `internal`: the existing `sheet.core_unavailable` notice with "Réessayer",
the retry builds again) or the view itself cannot be drawn (`svg_rejected`, the retry builds again on a fresh instance), the engine stopped after its
three recoveries (`CoreRuntime.stopped`: the `core.stopped` notice, "reload
the page, your report is kept in this tab", no retry; the editor's action
alerts say the same instead of "try again") or the view itself cannot be
drawn (`svg_rejected`,
`no_asset`, `unknown_view`, `invalid_character`, a parse failure: the `no_asset`, `unknown_view`, `invalid_character`, a parse failure: the
`canvas.view_unavailable` notice, no retry since nothing would change). The `canvas.view_unavailable` notice, no retry since nothing would change). The
technical kind and detail stay in the core's outcome and the DEV console; technical kind and detail stay in the core's outcome and the DEV console;
+8
View File
@@ -74,6 +74,14 @@ export class CoreRuntime {
return this.state return this.state
} }
/**
* The recovery cap is spent: no retry can bring the module back on this page (owner
* decision 2026-10-15: three attempts, then a clear failure state; a reload starts again).
*/
get stopped(): boolean {
return this.state === 'unavailable' && this.recoveries >= this.maxRecoveries
}
/** Loads the module on first use; true when calls can be made. */ /** Loads the module on first use; true when calls can be made. */
ready(): Promise<boolean> { ready(): Promise<boolean> {
if (this.state === 'ready') return Promise.resolve(true) if (this.state === 'ready') return Promise.resolve(true)
+12
View File
@@ -108,14 +108,26 @@ describe('core runtime', () => {
await runtime.ready() await runtime.ready()
trap(runtime) trap(runtime)
expect(await runtime.ready()).toBe(true) expect(await runtime.ready()).toBe(true)
expect(runtime.stopped).toBe(false)
trap(runtime) trap(runtime)
expect(runtime.status).toBe('unavailable') expect(runtime.status).toBe('unavailable')
expect(runtime.stopped).toBe(true)
expect(await runtime.retry()).toBe(false) expect(await runtime.retry()).toBe(false)
expect(runtime.call('core_version', '')).toMatchObject({ expect(runtime.call('core_version', '')).toMatchObject({
kind: 'core_unavailable', kind: 'core_unavailable',
}) })
}) })
it('is not stopped by a load failure, which a retry can still fix', async () => {
const runtime = new CoreRuntime({
compile: () => Promise.reject(new WebAssembly.CompileError('blocked')),
importGlue: () => Promise.reject(new TypeError('offline')),
})
expect(await runtime.ready()).toBe(false)
expect(runtime.status).toBe('unavailable')
expect(runtime.stopped).toBe(false)
})
it('reports a load failure and loads again on retry', async () => { it('reports a load failure and loads again on retry', async () => {
const inner = nodeCoreSource('pkg') const inner = nodeCoreSource('pkg')
let failNext = true let failNext = true