diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 179033e4..cd8737ac 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -744,7 +744,7 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - [ ] Follow-up: seed owner row in `private.catalog_write_budgets` is R4's own (none before R4; its first run created it, later runs update that same row, 4 archives per run; 8 of 300 per hour after the final wave, outside the data guard); `catalogue.spec.ts` still leaves its published sheets listed, warm-up its sheet and `sheet_editor` grant per invocation (BLK-015, RR-13) - [ ] owner arbitrations A1-A15 (`V1-2-6_U1_CORRECTIONS.md` §6, `TRIAL_STACK.md` §6) - [x] V1-2.6 UX U2 design: boards 02-06, 13 redrawn + extras from 31 (owner brief 2026-11-17 « R4 est terminé … préparer U2 », orientation 2026-11-14 BDR-117; contract `.claude/tasks/contracts/2026-11-17-u2-design-boards.md`; docs only, no code, no DEV, no merge). [x] audit as built · [x] boards + REVUE + ARBITRAGES in `docs/design/v1-2-6-u2/` (bc19481, fixes 8bdb23a and pass 3) · [x] fresh design review (5 must-fix, 19 should, 19 observations; fixed) · [x] fresh conformity check (ECARTS(4), then re-check ECARTS(1) on 8bdb23a: two labels, fixed) · [x] owner validation 2026-11-17: nine boards + A1-A15 as recommended, adjustments A13 hint, A14 no shift, board 33 messages (ARBITRAGES « Validation du propriétaire ») - - [ ] V1-2.6 UX U2 technical plan (owner brief 2026-11-17 « conception graphique U2 validée … plan technique »): plan `.claude/tasks/plans/2026-11-17-v1-2-6-u2.md` · [x] audit · [x] plan rev 1 · [ ] three fresh plan-challengers · [ ] STOP owner approval of the plan and decisions before any U2 code + - [ ] V1-2.6 UX U2 technical plan (owner brief 2026-11-17 « conception graphique U2 validée … plan technique »): plan `.claude/tasks/plans/2026-11-17-v1-2-6-u2.md` · [x] audit · [x] plan rev 1 · [x] three fresh plan-challengers (rev 1: correctness FATAL(9), robustness FATAL(9), simplicity CONCERNS(5); rev 2 integrates them) · [ ] STOP owner approval of the plan and decisions before any U2 code - [ ] Test anomaly A (owner 2026-11-09, separate from U1/U2): fictitious fingerprints `'a'.repeat(64)` from worker stand-ins (`packages/supabase/tests/sandbox/sheet-fixtures.ts:115` openRound, `sheets-concurrency.sandbox.ts:168`, `sheets-perf.sandbox.ts:169`); 7 published/deprecated sandbox versions fail `check_published`. Fix: real fingerprint through the core (as e2e `fingerprintOf`, `apps/app/e2e/support/catalogue.ts:88`); never weaken the publish gate or the reader check. Needs its own go. Census 2026-11-17 (R4 Task 3, read-only): 4 of 164 catalogue entries fail, the four current « Cheval sandbox » versions (2 at v1, 2 at v2), all `fingerprint_mismatch`; R4 cards show them with the integrity line. - [ ] Test anomaly B (owner 2026-11-09, separate from U1/U2): `packages/supabase/tests/sandbox/sheets-admin.sandbox.ts:181-195` creates the historical working copy and never archives it; slot taken → `admin.spec.ts:717` fails x4. Fix test independence and cleanup; the existing copy `8c315a12-20d4-4432-9db3-7cb88b27a5b4` stays untouched until the owner authorises. Linked: RR-13, the admin.spec confirmation line above. - [x] Test anomaly C (owner 2026-11-09, separate from U1/U2): CLOSED 2026-11-17 with R4's owner validation. Integrity failure invisible in catalogue cards; implemented as lot R4; failure shown, never hidden or bypassed. Built 2026-11-17 (R4 Task 1-3 and final fix wave, `V1-2-6_U1_CORRECTIONS.md` §5 row C: built by R4, closes on the owner's validation); checked off with R4's owner validation. diff --git a/.claude/tasks/plans/2026-11-17-v1-2-6-u2.md b/.claude/tasks/plans/2026-11-17-v1-2-6-u2.md index 789ba0f2..9751dbaa 100644 --- a/.claude/tasks/plans/2026-11-17-v1-2-6-u2.md +++ b/.claude/tasks/plans/2026-11-17-v1-2-6-u2.md @@ -1,431 +1,507 @@ -# U2 Direct Manipulation of Annotations Implementation Plan (V1-2.6), rev 1 +# U2 Direct Manipulation of Annotations Implementation Plan (V1-2.6), rev 2 > **For agentic workers:** REQUIRED SUB-SKILL: Use subagent-driven-development to implement this plan task-by-task. > Steps use checkbox (`- [ ]`) syntax for tracking. -**Status:** rev 1, NOT validated. Waits for three fresh `plan-challenger` reviews, then the owner's approval. No U2 -code before that approval. DEV unchanged, no merge. +**Status:** rev 2, NOT validated. Waits for the owner's approval and the answer to D1. No U2 code before both. DEV +unchanged, no merge. + +Rev 2 is rev 1 plus three fresh challenges of 2026-11-17: correctness FATAL(9), robustness FATAL(9), simplicity +CONCERNS(5). What became of each finding is recorded in « Challenge round », at the end. **Goal:** in the sheet editor's Annotations tab, points and polygon zones are created, moved, resized, reshaped and redrawn directly on the drawing, by mouse, by touch and by keyboard. Properties are read and edited in a modal dialog placed over the right-hand column. Each accepted change is one undo step. No data is lost, and the drawing never moves when the interface around it changes. -**Architecture:** mostly page work. Gestures are decided by small pure modules: pointer slop, press priority, -polygon edits, point sizes, Escape order, move steps, missing fields and the two-finger hint. They are table-tested, -and the React hooks only wire them to DOM events. The core still judges every end state on commit, through -`geometryAccept`. One additive core value tells the page the smallest radius a point may have in each view. -`Dialog` gains a "column" placement and a light backdrop. The navigation gains an `annotation` history layer plus a -`drawing` guard for creations, redraws and move modes in progress. A fixed-height strip above the drawing and a -fixed-height message line under it replace `ToolNotes`, `SelectionTag` and `TracingBar`. The per-field properties -panel and the coordinate fields leave the edit path. +**Architecture:** page work around four pieces. + +1. **The press machine.** One pure press machine (`press.ts`) decides every press on the drawing: click or drag, + which handle, which annotation, and what a second pointer cancels. It replaces the three deciders the editor runs + today (`clickHandler`, `useEmptyTap`, `swallowClick`, and `useMoveGesture`'s threshold). +2. **The work store.** A small work store holds what is uncommitted: the creation in progress with its form, the + move-mode or slider preview, and the chosen vertex. Each preview is stamped with the document text it was computed + on, so the leave guards, the undo paths and the tabs can see it, and a stale preview never commits. +3. **The dialogs.** `Dialog` gains an `anchor` prop that places it over the right column with a light veil. An + `annotation` history layer carries the properties dialog and the creation dialog. Both are mounted outside the + editable subtree with a `readOnly` prop, as the finding dialog is. +4. **The strip and the message line.** A fixed-height strip above the drawing and a fixed-height message line under + it replace `ToolNotes`, `SelectionTag` and `TracingBar`. + +The core judges every end state on commit, through `geometryAccept`. One additive core value gives the smallest +radius a point may have in each view. **Tech Stack:** React 19, TypeScript strict, Zustand 5, Tailwind 4, motion 11; Rust core (`crates/core`) through the wasm facade and `packages/core-wasm`; vitest + happy-dom; Playwright Chromium + axe on `pnpm db:sandbox`. -**Spec:** boards `docs/design/v1-2-6-u2/` 02 to 06, 13, 31, 32 and 33, with `REVUE.md` and `ARBITRAGES.md`. Those are -A1 to A15 and the three adjustments of 2026-11-17, all validated: BDR-122. Also `docs/development/V1-2-6_UX_PLAN.md` -§U2 with its « Orientation 2026-11-14 » and its owner validation note, §1.3, §1.9, §1.10 and §2 G. Then -`V1-2-6_UX_TESTS.md` §U2 (realigned in Task 10), `V1-2-6_UX_DECISIONS.md` (T15, T16, T18) and the design contract -`.claude/tasks/contracts/2026-11-17-u2-design-boards.md`. Boards 14 and 16 (phone, read-only) are unchanged. +**Spec:** + +- The boards `docs/design/v1-2-6-u2/` 02 to 06, 13, 31, 32 and 33, with `REVUE.md` and `ARBITRAGES.md`: A1 to A15, + and the « Validation du propriétaire » section with its three adjustments (BDR-122). +- `docs/development/V1-2-6_UX_PLAN.md` §U2, with « Orientation 2026-11-14 » and the validation note, plus §1.3, + §1.9, §1.10 and §2 G. +- `V1-2-6_UX_TESTS.md` §U2, realigned in Task 9. +- `V1-2-6_UX_DECISIONS.md`: T15, T16, T18. +- Boards 14 and 16 (phone, read-only) are unchanged. Plan form, as for R2 to R4: pure functions in full; React tasks give the files, the behaviour, the test cases and how to verify. The executor writes the JSX under TDD against the boards. -## Audit findings (2026-11-17, read-only, at 29073a9) +## Audit findings (2026-11-17, read-only, at 29073a9; checked by the three challenges) -- **Gestures today.** The selection is a click (`useCanvasGestures.ts`, `clickHandler`). A selected circle or - polygon moves as a block after 4 px (`useMoveGesture.ts`, `gesture.ts:5`). An empty tap deselects - (`catalogue/useEmptyTap.ts:5`, slop 4 px, shared with the catalogue). Zoom and pan come from - `catalogue/useFraming.ts`, which is also shared with `components/catalogue/CatalogueCanvas.tsx:69`. - - With one pointer, a press pans when `canPan` allows it, using a cumulative path above 4 px. - - With two pointers it only zooms around the midpoint (`useFraming.ts:126-136`). There is NO two-finger pan - today, so A13's "two fingers move the drawing" is new work. - - The arrows pan the focused box (`useFraming.ts:150-168`). - - `touch-action` is `none` while a tool, a drag, a zoom or a movable selection is active (`useCanvasGestures.ts`, - `touchStyle`). -- **Overlay.** `AnnotationOverlay.tsx` is `aria-hidden` and `pointer-events-none`. Its vertices are decorative, with a - radius of span/200 drawing units, so they scale with the zoom. No handle can be focused or hit. -- **Layout.** These elements sit above the drawing and change height: the tool line, the hint, `UnmeasuredHint` and - `SelectionTag` (`EditableAnnotations.tsx`, `ToolNotes`). `TracingBar` sits under it (LRN-131). The canvas box is - `aspect-[4/3] w-full` (`AnnotationCanvas.tsx`). `styles/index.css:6` sets `html:has(dialog:modal) { overflow: - hidden; }`: with classic scrollbars the page loses its scrollbar while a dialog is open, so the drawing shifts - sideways. -- **Properties.** `PropertiesPanel.tsx` is shared with the narrow read-only twin (`tabs/AnnotationsTab.tsx:201-228`). - - `AnnotationFields.tsx` commits each field on its own: one `update` and one undo entry per field, through - `useSend`. - - `GeometryGroup.tsx` applies the numeric group under `accept`. This is the only way to repair an inherited point - that sits out of its frame (`e2e/shell/editor-geometry.spec.ts`), because `geometryAccept` refuses a changed - annotation that is still invalid (`issues.ts` 158-170). - - The review status is an immediate `set_status`. Deletion goes through `DeleteDialog`. A path offers « Remplacer - par un polygone » (`TraceReplacement`). -- **Creation.** `CreationPanel.tsx` and `CreationFields.tsx`; `creation.ts`: `emptyForm` preselects the first - category and leaves the laterality blank. `formProblem` returns `'fields'` or `'names'`. `fr.ts:1665` - `editor.annotations.required.fields` is the general line that board 33 B shows: « Choisissez la catégorie et la - latéralité (et la vue ouverte pour un accès). » - - The correction flow C26 (`correction.ts`, `CorrectionNotice`) prints x and y in its text (`fr.ts:1638`). - - The keyboard path (`KeyboardAdd.tsx`) places a pending element at the centre, then expects typed coordinates. - - The link tool creates a `detail_trigger` with the field `opens`. - - `insertAnnotation` and `updateGeometry` (`annotationCommit.ts`) are the geometry commits under `accept`. -- **Dialogs (R2).** - - `ModalDialog.tsx` is a full-viewport transparent native ``, with focus in and out and the Escape and - close requests. - - `Dialog.tsx` hardcodes centred placement (79) and a `bg-black/40` backdrop that closes on click (82-89). Sizes run - from sm to xl, and the panel is capped at `max-h-[85vh]`. No anchoring support exists. - - `useFormDraft(initial, guards, same, layer)` already takes a layer name (`findings/useDirtyGuard.ts:60-76`). - `FormActions` and `DiscardConfirm` live in `findings/DiscardConfirm.tsx`. `useEditCommand` provides `run`, - `runNew` and `runBatch` (one batch, one undo). -- **History layers.** `LAYERS = ['finding','citations','reference']` (`useEditorNavigation.ts:61-62`). Adding a layer - touches these files: - - `navigation.ts`: `EditorView`, `DEFAULT_VIEW`, `viewOf`, `sameView`, `restoreView`, the reducer, and the resets - in `selectTab`, `goTo` and `showAllReferences`. - - `useEditorNavigation.ts`: `useAskLeaving` and the return object. - - `history/entry.ts`: `sanitizeView`, `layerCount` and `isRemoval`. - - `history/useEditorHistory.ts`: `sameLayers`, `leavingLayers`, `upTo` and `useViewOf`. - - `history/useLeaveConfirm.ts`: `clearerOf`. - - `leftDraft.ts`: `elementOf` and `LAYERS_TOP_DOWN`. - - `tabs.ts`: `EditorPlaceProps`. - - `EditorWorkspace.tsx`: `Places`. +### Gestures - Guards are keyed by `LayerName`. A POP asks only the layers it removes (`refusal`). A non-layer modal makes every - layer be asked. -- **Undo.** `state/undo.ts` keeps full document texts, capped at 8 MiB (`HISTORY_LIMIT_BYTES`). The equine draft is - 174 974 bytes as compact JSON, so the cap holds about 47 snapshots; the "about 20" of UX plan §2 G assumed pretty - JSON. Each U2 gesture is one snapshot. `useUndoShortcuts` ignores Ctrl+Z while any `dialog[open]` exists. There is - NO toast component in the app. -- **Core.** `MIN_VISIBLE_PX = 4` (`crates/core/src/anatomy/frame.rs:67`). - - The scale is `Frame::preview_scale(main)`, the xMidYMid meet scale into the phone preview boxes: main 286 × 310, - detail 254 × 191. - - A point's visible size is `2 × max(2, r − 12)` (`layer.rs:260`). It is refused when `size × scale < 4`, so the - smallest radius is `12 + 2/scale` when `scale < 1`, and there is no minimum when `scale ≥ 1`. It depends on the - view, never on the position. - - `PreviewState` (`domain/sheet/preview.rs:359-370`) is mirrored by ts-rs (`packages/core-wasm/types/PreviewState.ts`). - It is not in the N-1 reader list (runtime state, never persisted). - - Wasm gate: 600 000 B gzip-9 by Node (`packages/core-wasm/tests/size.test.ts`). The last recorded figure is - 580 522 B (`RUST.md:4523`). LRN notes that a GNU gzip measure once overstated the margin, so Task 0 re-measures. -- **Equine data.** 28 annotations: 22 circles and 6 polygons, with at most 17 vertices. Point radii are 30 and 34 on - the main view and 27 on the head view (REVUE « Données vraies »). +- The click is `clickHandler` (`useCanvasGestures.ts:57-97`) behind `framing.swallowClick`, which uses a 4 px + cumulative path (`useFraming.ts:20,126-127,171-175`). +- An empty tap is `useEmptyTap`: 4 px cumulative (`catalogue/useEmptyTap.ts:5,90-97`), shared with + `CatalogueCanvas.tsx:73`. +- The block drag is `useMoveGesture`: 4 px displacement (`gesture.ts:5`). Its preview stays inside the canvas + (`useMoveGesture.ts:43-58`). +- `useFraming` is shared with `CatalogueCanvas.tsx:69` (no options). It decides the one-pointer pan at pointerdown + (`:113`). With two pointers it only zooms around the midpoint (`:128-137`), so there is NO two-finger pan. It pans + on arrows for every bubbled keydown (`:150-168`; the box receives the keys of its descendants, + `useCanvasGestures.ts:130-133`). +- The selection comes from the top element only: `annotationIdOf(event.target)` (`useCanvasGestures.ts:90`). +- Point hitboxes are painted under zones, and the visible element wins (`docs/ANNOTATION-RENDERING.md:30-38`). +- The trace closes within `CLOSE_SHARE 0.015 × span` (`usePlacement.ts:14,33-37`), about 8 px at 1 280 px. -## Migration inventory (where each capability lands) +### Overlay and layout + +- `AnnotationOverlay.tsx` is `aria-hidden` and `pointer-events-none` (`:121`). Its vertices are decorative, span/200 + units. +- These change height above the drawing: the tool line, the hint, `UnmeasuredHint` and `SelectionTag` + (`EditableAnnotations.tsx` `ToolNotes`). `TracingBar` sits under it (LRN-131). The header save line wraps + (`DraftHeader.tsx:68`) and changes text on the first commit. +- `styles/index.css:6` sets `html:has(dialog:modal) { overflow: hidden; }`: with classic scrollbars, an open dialog + removes the page scrollbar. +- Playwright headless Chromium hides scrollbars (`--hide-scrollbars`), so a box-only test cannot see that shift. + +### Read-only and mounting + +- `EditableAnnotations` lives under `EditOnly` → `KeptPlace` `hidden` (`tabs/AnnotationsTab.tsx:73-80`, + `KeptPlace.tsx:20`). A native modal must not live there (`editor/editingContext.ts:19-23`). +- The finding dialog is mounted outside `EditOnly` with `readOnly` (`FindingsTab.tsx:352-359`). +- Read-only comes from a crossing below 1 024 px, a refusal (frozen, rights) or a refresh (`editor/mode.ts:74-91`). + +### Properties and creation + +- `PropertiesPanel.tsx` is shared with the read-only twin (`AnnotationsTab.tsx:201-228`). `SelectionTag` is also + used by the twin (`:186-191`). +- `AnnotationFields.tsx` commits per field. `GeometryGroup.tsx` is imported by `PropertiesPanel.tsx:31`, + `CreationPanel.tsx:22` and `views/RepairDialog.tsx:5,203` (the « temporary form » of an attach refused for + annotations out of the new frame, owner decision 7; UX plan U5 lists it). It is the only repair path for an + out-of-frame point (`e2e/shell/editor-geometry.spec.ts:273-281`), because `geometryAccept` refuses a changed + annotation that is still invalid (`issues.ts` 158-170). +- `CreationFields.tsx:60-115` is a set of controlled inputs over a `CreationForm`. +- `creation.ts` `formProblem` and `creationAttempt.ts:49` produce the general line `fr.ts:1665`. +- `defaultRadius` (about 74 units on the main view) feeds `proposePoint`, `correctedCircle`, `centreCircle` + (`frame.ts:86-146`), `pendingForClick` and the keyboard path (`creation.ts:90,178`), and the test in + `correction.ts:34`. + +### Navigation, leave, undo + +- `LAYERS` is at `useEditorNavigation.ts:61-62`. +- `useTabSelect` (`:554-567`) and `openSection` (`:298-334`) ask no guard. `useAskLeaving` and `topDirtyLayer` walk + `LAYERS` only. +- `leaveGuardArmed` = unsaved or recovery (`editorBase.ts:62-64`). It is read by the route (`AdminSheetDraftRoute.tsx:93`) + and by `SignOutButton.tsx:20`. +- `ConfirmDialog.tsx` exists (title, body, two answers). +- Ctrl+Z is route-level (`useUndoShortcuts.ts:15-24`) and ignored only while a `dialog[open]` exists. +- `recordCommit` clears redo (`undo.ts:52-54`). Reload and recovery replace the text (`editorLoad.ts:136-153`, + `recoveryFlow.ts:167-186`). +- History cap: 8 MiB. The equine draft is 174 974 bytes as compact JSON, so the cap holds about 47 snapshots (UX + plan §2 G said about 20). + +### Core + +- `MIN_VISIBLE_PX = 4` (`frame.rs:67`). The scale is `preview_scale(main)` (`:104-112`); the twin is + `max(2, r − 12)` (`layer.rs:260`). +- The smallest radius is `12 + 2/scale` when `scale < 1`, else there is none. It depends on the view only, about + 26.50 on the main view and 15.98 on the head (challenge, computed). +- `PreviewState` is ts-rs mirrored and not in the N-1 list. +- Wasm gate: 600 000 B gzip-9 by Node. The last figure is 580 522 B (`RUST.md:4523`). + +### Equine data + +- 28 annotations: 22 circles and 6 polygons, at most 17 vertices. +- Radii: 30 and 34 on the main view, 27 on the head view. +- Main view: 0.25 px per unit at 1 280 px, so the « Thoraciques » segments are 11 to 15 px. +- Hitboxes overlap (elbow and carpus 59 units apart with r 34 + 34). Junction points sit on the vertebral zones + (c7-t1 on « Thoraciques »). + +## Migration inventory | Today | U2 | Task | |---|---|---| -| `ToolNotes` (tool line, unmeasured hint, no-category, no-child-view, refusal hint) | Fixed strip: left = status lines, middle = refusal or notice (2 lines max), right = commands | 3 | -| `SelectionTag` | Strip, line 1 (name, status) and line 2 (type, detail) | 3 | -| `TracingBar` (« Fermer le tracé », « Annuler le tracé », count) | Strip, plus « Retirer le dernier sommet » | 3 | -| Drag of the selected shape (`useMoveGesture`) | Kept for the mouse on the interior; the point handle drags at any pointer | 4, 5 | -| `GeometryGroup` numeric fields (A8) | Removed. Repair of an out-of-frame shape = move mode (preview free, one commit on « Valider la position ») or redraw | 4, 5 | -| `TraceReplacement` (path → polygon) | Strip command « Remplacer par un polygone » on a selected path (same label, T16, BDR-101) | 5 | -| `GeometryIssues` | Strip middle (first issue, `+n` when more) and an alert block in the dialog's read mode | 3, 7 | -| `AnnotationFields` per-field commits | Dialog edit mode, one transactional save | 7 | -| `StatusActions` | Dialog read mode, direct action, one undo (A10) | 7 | -| `Deletion` + `DeleteDialog` | Dialog read mode « Supprimer », same `DeleteDialog` | 7 | -| « Désélectionner », « Tout afficher » | Strip « Désélectionner »; the overview list is always shown (A3) | 3, 7 | -| `UnmeasuredHint` | Strip middle, with its link to the views section | 3 | -| `PropertiesPanel` in the narrow read-only twin (boards 14, 16) | Kept, reduced to the shared read body (`AnnotationReadBody`) | 7 | -| `CreationPanel` (form, C26 correction, « Créer », « Annuler ») | Creation dialog: first line (« Replacer le point » / « Reprendre le tracé »), the C26 notice, then the fields; « Créer », « Abandonner » | 8 | -| `KeyboardAdd` (centre + typed coordinates) | Same buttons: the shape at the centre, the creation dialog opens; after « Créer » the keyboard handles and the move mode correct it | 8 | -| Link tool (`detail_trigger`, field `opens`) | Same creation dialog with « Vue ouverte »; same properties dialog | 7, 8 | -| « Aller à » an annotation (focus on `data-properties-heading`) | Selects it on its view and focuses its row (A1: no dialog). The strip shows its first issue | 7 | -| Focus targets `data-creation-heading` and `tracing-bar` (busy « Aller à ») | The creation dialog's heading, the strip's tracing commands | 8 | +| `clickHandler`, `useEmptyTap`, `swallowClick`, `useMoveGesture` threshold | `press.ts` machine, the editor's only decider; the catalogue keeps `useEmptyTap` and `useFraming` defaults | 2 | +| `ToolNotes`, `SelectionTag` (edit body), `TracingBar` | Fixed strip; `SelectionTag` stays for the read-only twin | 3 | +| Block drag of the selection | The press machine: point handle at any pointer, zone interior by mouse or pen | 2, 4, 5 | +| `GeometryGroup` in the properties panel and the creation panel | Removed from both (A8). The repair of an out-of-frame shape = move mode or redraw | 4, 5, 7 | +| `GeometryGroup` in `RepairDialog` (owner decision 7) | **D1** | — | +| `TraceReplacement` (path → polygon) | Strip command « Remplacer par un polygone » (T16, BDR-101) | 5 | +| `GeometryIssues` | Strip middle (first issue, `+n`) and an alert block in the dialog's read mode | 3, 6 | +| `AnnotationFields` per-field commits | Deleted. The edit form renders `CreationFields` (+ « Couleur ») on a `CreationForm` draft, one save | 6 | +| `StatusActions`, `Deletion` | Dialog read mode: direct review action (A10), « Supprimer » via `DeleteDialog` | 6 | +| `PropertiesPanel` (read-only twin) | Deleted. The twin renders `AnnotationReadBody` directly | 6 | +| `CreationPanel` (form, C26, « Créer », « Annuler ») | Creation dialog: first line, the C26 notice, `CreationFields`; « Créer », « Abandonner » | 7 | +| `KeyboardAdd` (centre + typed coordinates) | Same buttons: the shape at the centre at the A5 size, the dialog opens; then handles and move mode | 7 | +| Link tool (`detail_trigger`, `opens`) | Same dialogs with « Vue ouverte » | 6, 7 | +| « Aller à » an annotation (`data-properties-heading`) | Selects it on its view and focuses its row (R-5) | 6 | +| Busy « Aller à » targets (`data-creation-heading`, `tracing-bar`) | The creation dialog's heading, the strip's tracing commands | 3, 7 | ## Owner decisions -None blocks the plan. Every visible choice the boards leave open is listed below with the answer applied unless the -owner objects. One condition can bring a question back, at Task 0: if neither loupe technique holds a smooth drag on a -tablet, the owner chooses between a loupe without the drawing (outline and handles only) and no loupe. +| # | Question | Recommendation | Alternative | Cost if wrong | +|---|---|---|---|---| +| D1 | `RepairDialog` (after attaching a drawing that leaves annotations out of the new frame, owner decision 7) still shows coordinate fields. A8 says « retirés partout ». | Keep them in that dialog only, until U5 rewrites it with `remap_view` (UX plan U5 already lists `RepairDialog.tsx`). It is a rare repair outside the annotation journey; its values are proposals in a frame not attached yet, so no drawing exists to drag on. `GeometryGroup.tsx` stays as the repair's own component. | Replace it in U2: list the out-of-frame annotations, attach the drawing first, then correct each one on the drawing with the move mode. That changes owner decision 7 (nothing is attached until it is valid), needs a new board, and adds a task. | Recommendation: coordinates remain in one rare dialog until U5. Alternative: a redesign of decision 7 inside U2. | + +Conditional, Task 8: if neither loupe technique keeps a smooth drag on the editor itself, the owner chooses between a +loupe without the drawing (outline and handles only) and no loupe. No question before then. ## Recorded unless the owner objects -- **R-1 Two-finger hint (adjustment A13).** Text FR « Deux doigts pour déplacer ou zoomer le dessin », EN « Use two - fingers to move or zoom the drawing ». - - It appears in the message line under the drawing, neutral tone, no action, for 4 s. - - It is triggered only by a one-finger drag on the drawing, past the touch slop, that moved nothing: off every - handle, outside a move mode, while touch-action is `none` because a selection, a tool or a zoom is active. - - At most once a minute. Never again in this editor visit after a two-finger pan or zoom has worked. - - It never replaces a « Défaire » message still shown; it waits for it to go. -- **R-2 Message line (adjustment A14).** The line under the drawing has a fixed height, a single line that truncates - with an ellipsis, and fixed slots: the add buttons on the left, the message on the right. - - Showing or hiding a message changes no box: the canvas, the strip and the column keep the same position and size. - The page keeps the same scroll height. Chromium's Layout Instability API records no shift. - - The page gets `scrollbar-gutter: stable` on `html`, so an open dialog does not remove the scrollbar width either. - This applies to the whole application: a page with no scrolling keeps a 15 px gutter on classic-scrollbar systems. - - The message lasts 6 s (A14) and stays while it is hovered or focused. - - Any commit, undo or redo closes it. Its « Défaire » calls the same `undo()` as the header (T15 name « Défaire la - dernière modification »). - - It is a polite live region; a refusal is `role="alert"`, red, with no « Défaire ». -- **R-3 Validation messages (adjustment board 33).** Each missing field is named under that field, and only missing - fields are named. - - FR « Saisissez le nom en français. », « Saisissez le nom en anglais. », « Choisissez une catégorie. », « Choisissez - une latéralité. » (board 33 B), « Choisissez la vue ouverte. » - - EN « Enter the French name. », « Enter the English name. », « Choose a category. », « Choose a laterality. », - « Choose the view it opens. » - - One summary line names only the missing fields: FR « À compléter : Latéralité. », EN « To complete: Laterality. » - It uses the field labels in form order and is `role="alert"`. The focus goes to the first missing field. - - The general line `editor.annotations.required.fields` is removed. The edit form of the dialog follows the same - rule. -- **R-4 C26 correction in the creation dialog.** The notice keeps its two buttons. Its text loses the numbers (A8): - FR « Le point ne tient pas à l'endroit choisi : la position corrigée est proposée sur le dessin. », EN « The point - does not fit where you clicked: the corrected position is shown on the drawing. » -- **R-5 « Aller à » an annotation.** It selects the annotation on its view and focuses its row in the overview. If a - filter hides the row, it focuses the drawing. It opens no dialog (A1). A creation or a tracing in progress keeps - the request, as today. -- **R-6 Undo depth.** `HISTORY_LIMIT_BYTES` goes from 8 MiB to 16 MiB: about 95 equine steps instead of about 47, - measured in Task 0 on the stored text. U2 turns every vertex gesture into a snapshot. 16 MiB of strings in one tab - is negligible on the target tablets. -- **R-7 Handle cap (T18).** `HANDLE_CAP = 40` vertices: the equine maximum is 17, so 40 leaves a margin of more than - two. Above it the shape shows its outline and the board 33 D message, with no handles; the move mode and redraw - remain. -- **R-8 Slop.** A press becomes a drag beyond 4 CSS px for a mouse, 6 px for a pen and 10 px for a finger, measured - as displacement from the press. One module serves the editor. The catalogue keeps its own 4 px. -- **R-9 Move step.** One arrow (strip or key) moves by 0.5 % of the frame's longer side, rounded to 0.01 with a - floor of 0.01. Shift multiplies it by 10 (keys only). -- **R-10 Point sizes.** - - Stops are the distinct radii of the view's points; links are excluded. - - A new point takes the radius used most often in the view; a tie goes to the smaller one. A view with no point - falls back to `defaultRadius(frame)` (A5). - - The slider runs from half the smaller of (smallest stop, minimum) to twice the larger of (largest stop, default - radius). It snaps to a stop within 8 CSS px. Arrows step by 1 % of the range; Page Up and Page Down go to the - next stop. - - It commits on release, Enter or blur: one undo step (BDR-050). - - The red mark is the core's minimum (Task 1). It is absent when the core gives none. -- **R-11 Pen.** A pen counts as a mouse for dragging the interior of a selected zone, but uses the pen slop and the - touch-sized handles. -- **R-12 Confirmation during a creation (A12).** A tab, a view chip, a tool, Back or Escape during a creation that - holds a shape or typed text opens a confirmation: - - FR « Abandonner la création ? », « Continuer », « Abandonner »; EN « Discard the creation? », « Continue », - « Discard ». - - Leaving the editor (a link or a tab close) asks the same through the existing leave guard and `beforeunload`. - - Inside the creation dialog, the R2 `DiscardConfirm` takes this place (A2 dialog, T15 wording). - - A click on the creation dialog's veil asks; it never discards. -- **R-13 Touch-sized handles.** Used when the last press was a finger or a pen, or when `(pointer: coarse)` matches at - load. Board 13 sizes: vertex 18 px, « + » 24 px, « − » bubble 44 × 36 px, each with a 44 px hit circle. Mouse sizes - follow board 05: vertex 12 px, « + » 16 px. Sizes stay constant in CSS px under zoom. +### R-1 Two-finger hint (adjustment A13) + +- Text: FR « Deux doigts pour déplacer ou zoomer le dessin », EN « Use two fingers to move or zoom the drawing ». +- Where: in the message line, neutral tone, no action, 4 s. +- Trigger: a one-finger drag on the drawing, past the touch slop, that moved nothing (`dragAction` `none` with + `futile`), shown only when the line is free. +- Once a two-finger pan or zoom has worked in this editor visit, it never shows again. No timer, no queue. + +### R-2 Message line (adjustment A14) + +- Layout: one fixed-height line under the drawing, single line, truncated with an ellipsis. The add buttons sit on + the left, the message on the right. +- No movement: showing or hiding a message changes no box. The canvas, the strip, the column and the header keep + their position and size, and the page keeps its scroll height. +- Scrollbar: `html:has([data-editor-workspace]) { scrollbar-gutter: stable; }`, scoped to the editor, so an open + dialog removes no scrollbar width there. +- Timing: 6 s (A14). It pauses while hovered with a mouse only; a touch never pauses it. Any commit, undo or redo + closes it. +- Undo: its « Défaire » calls the same `undo()` as the header (T15). It is hidden while a creation runs (A12). +- Announcements: a polite live region. A refusal is `role="alert"`, red, with no « Défaire ». + +### R-3 Validation messages (adjustment board 33) + +- Each missing field is named under that field, and only missing fields are named. +- FR: « Saisissez le nom en français. », « Saisissez le nom en anglais. », « Choisissez une catégorie. », « Choisissez + une latéralité. » (board 33 B), « Choisissez la vue ouverte. » +- EN: « Enter the French name. », « Enter the English name. », « Choose a category. », « Choose a laterality. », + « Choose the view it opens. » +- One summary line, `role="alert"`, names only the missing fields with their labels in form order: FR « À compléter : + Latéralité. », EN « To complete: Laterality. » The focus goes to the first missing field. +- The general line `editor.annotations.required.fields` is removed. The creation dialog and the edit form share + `missingFields` and these keys. + +### R-4 C26 correction in the creation dialog + +The notice keeps its two buttons. Its text loses the numbers (A8): FR « Le point ne tient pas à l'endroit choisi : la +position corrigée est proposée sur le dessin. », EN « The point does not fit where you clicked: the corrected position +is shown on the drawing. » + +### R-5 « Aller à » an annotation + +- It selects the annotation on its view and focuses its row, or the drawing when a filter hides the row. +- No dialog opens (A1). +- A creation in progress keeps the request, as today. + +### R-6 Veil + +A click on the veil of an annotation dialog (properties or creation) does nothing. The dialog closes by ✕, Échap, +« Annuler » or « Abandonner », or Back (board 31 D). A tap that opens the dialog cannot close it with its own click, +and a stray tap never discards a creation. + +### R-7 Handle cap (T18) + +- `HANDLE_CAP = 40` vertices; the equine maximum is 17. +- Above it the shape shows its outline and the board 33 D message, with no handles. +- The move mode and redraw remain. + +### R-8 Slop and double click + +- A press becomes a drag beyond 4 CSS px for a mouse, 6 px for a pen and 10 px for a finger, measured as + displacement from the press. +- A second pointer during a press cancels it: no click, no commit. +- Two clicks within 400 ms and 8 px open the properties dialog of the annotation they hit. They never run a handle + action and never insert. + +### R-9 Handles + +- Device size, read once from `(any-pointer: coarse)`: + - Coarse: board 13 sizes. Vertex 18 px, « + » 24 px, « − » bubble 44 × 36 px, hit radius 22 px. + - Otherwise: board 05 sizes. Vertex 12 px, « + » 16 px, hit radius 10 px. +- Sizes are constant in CSS px under zoom. +- The handle nearest the press wins; at equal distance a vertex beats « − », which beats « + ». +- A « + » is hidden while its segment is shorter than two hit radii at the current zoom. Insert on the keyboard and + zooming still reach it. + +### R-10 Point sizes + +- Stops are the distinct radii of the view's points; links are excluded. +- A new point takes the radius used most often in the view; a tie goes to the smaller one. A view with no point + falls back to `defaultRadius(frame)` (A5). +- This size feeds every new point: a click, the C26 candidate and its test, and the keyboard. +- The slider runs from half the smaller of (smallest stop, minimum) to twice the largest stop, or around the fallback + when there is no stop. +- It snaps to a stop within 8 CSS px. Arrows step by 1 % of the range; Page Up and Page Down go to the next stop. +- It commits on release, Enter or blur: one undo step (BDR-050). +- The red mark is the core's minimum (Task 1). It is absent when there is none. + +### R-11 Move step and trace closing + +- One arrow moves by 0.5 % of the frame's longer side, at least 0.01. Shift multiplies it by 10 (keys only). +- A trace closes on its first vertex within 12 CSS px for a mouse and 22 px for a finger or a pen. + +### R-12 Confirmation during a creation (A12) + +- During a creation that holds a shape or typed text, a confirmation (`ConfirmDialog`) is asked before: a tab, a + section, a view chip, a tool, Back, Escape, sign-out and leaving the editor. +- FR « Abandonner la création ? », « Continuer », « Abandonner »; EN « Discard the creation? », « Continue », + « Discard ». Inside the creation dialog, the R2 `DiscardConfirm` takes this place. +- A move mode, a redraw or a pending keyboard series is NOT a creation: Back, a tab or a view change cancels it + silently, the stored shape staying. These are not history entries (orientation). + +### R-13 Undo with something pending + +- An undo (header, shortcut, message) while a move mode, a slider or a keyboard series is pending only cancels that + preview. The next undo undoes. +- During a creation, undo is inactive (A12). +- A document change made elsewhere (redo, reload, recovery, a save refresh) drops every stale preview and the chosen + vertex. + +### R-14 Read-only flip + +The editor turns read-only on a crossing below 1 024 px, a refusal or a refresh. Then: + +- An open properties or creation dialog stays open in read-only form: a notice, inputs disabled, the draft kept, the + save disabled. +- Move modes and previews are dropped. +- Nothing commits while read-only, and the draft comes back editable on the way back. +- The anchor falls back to the visible column, or to the centre. + +### R-15 Undo depth + +The cap stays at 8 MiB: about 47 equine steps, written in UX_TESTS in place of « about 20 ». ## Global Constraints +### Where and how + - Work in `/home/bchanot/Documents/faunosteo-v1-2`, every shell command with that absolute path checked first (LRN-110). Commit in place on `feature/v1-2-anatomical-sheets`, one commit per coherent change, pushed by the hooks. No sub-branch, no merge, no `gitflow.sh finish`. -- Never DEV: the `supabase_*_faunosteo` containers are DEV. Database work happens only through `pnpm db:sandbox`, in - the order `test-db → e2e:shell → test` (LRN-113). Forbidden: `pnpm db:start`, `db:reset`, `db:test`, `db:types`, - `pnpm supabase …`. Never run `editor-equine.spec.ts` outside the sandbox alias. +- Never DEV: the `supabase_*_faunosteo` containers are DEV. + - Database work happens only through `pnpm db:sandbox`, in the order `test-db → e2e:shell → test` (LRN-113). + - Forbidden: `pnpm db:start`, `db:reset`, `db:test`, `db:types`, `pnpm supabase …`. + - `editor-equine.spec.ts` runs only through its sandbox alias. + +### Core and Rust + - The core judges every geometry. The page proposes and commits through `geometryAccept` (`insertAnnotation`, - `updateGeometry`). A refusal restores the previous shape exactly. No TypeScript copy of a core rule: the minimum - radius comes from Task 1, frame tests stay in the core. -- Rust by default (BDR-043): the geometry arithmetic in Task 2 (midpoint, translation, vertex move, snapping) is - interaction-rate preview math. UX plan §1.3 and §2 G, ratified at U0, place it in the page. It writes nothing on its - own; each result goes through `sheet.edit` and the core's verdict. One row is added to the review's Part II - exception table, class C, as R3 did. + `updateGeometry`). +- A refusal restores the previous shape exactly. +- The minimum radius comes from Task 1; no TypeScript copy of a core rule. +- Rust by default (BDR-043): the geometry arithmetic of `polygonEdit.ts` and `pointSize.ts` is interaction-rate + preview math. UX plan §1.3 and §2 G, ratified at U0, place it in the page, and each result goes through + `sheet.edit` and the core's verdict. One row is added to the review's Part II exception table, class C. + +### Undo and previews + - One undo step per accepted change: per gesture, per slider release, per move-mode validation, per dialog save, per review toggle, per creation. Previews never enter history. -- Pending previews are cancelled and restored before any undo, redo, document replacement, save reload, tab change, - view change, mode change or second pointer (§2 G). Index-based edits never apply to a document they were not - computed on. -- No layout shift: every state change of the tab keeps the canvas box's position and size. This covers selection, - strip content, message, dialog open and close, mode entry and exit. It is asserted in Task 3's helper and used by - every later task. +- Every preview, keyboard series and chosen vertex carries the `documentText` it was computed on (R-13). A commit + with a stale stamp is refused, and one store subscription drops stale work. + +### Mounting and layout + +- The dialogs are mounted outside `EditOnly` with `readOnly` (R-14). +- No layout shift: every state change of the tab keeps the canvas box, the strip, the aside and the header box + unchanged. This covers selection, strip content, message, dialog open and close, mode entry and exit, and the + first commit's save line. Task 3's helper asserts it, and every later task uses it. + +### Code rules + - Every string goes through `useT()`, with the same keys in `fr.ts` and `en.ts`. Labels come from REVUE.md's table - and from R-1 to R-12. « Défaire » and « Refaire » are as built (R0). « Abandonner » is reserved for leaving a form - (T15). -- Rendering changes update `docs/ANNOTATION-RENDERING.md` « Editor overlay » FIRST: handles, ghost, dimmed - annotations, old outline, loupe. + and from R-1 to R-12. « Abandonner » is reserved for leaving a form (T15). +- Rendering changes update `docs/ANNOTATION-RENDERING.md` « Editor overlay » FIRST. - Limits: 25 logic lines per function, 100 columns for TypeScript, 5 parameters, 5 locals. `shortcut:` comments are harvested into TODO.md. -- Phone (< 1 024 px): the editor stays read-only (O14 A). Boards 14 and 16 do not change. +- Phone (< 1 024 px): read-only (O14 A), boards 14 and 16 unchanged. ## Review Focus -1. **A finger lands on a vertex, then a second finger lands.** The drag is cancelled, the shape restored, nothing is - committed, and the pinch zooms. Test: Task 9, CDP two-point touch. -2. **An undo arrives while a drag, a move mode or a slider is pending** (header button, Ctrl+Z from a field, Back). - The preview is dropped first and the undo applies to the committed document. Test: Task 2 table - (`cancelPreview` reasons), Task 4 unit (undo during the move mode). -3. **An editor opens the properties dialog, types, then crosses 1 024 px or presses Back.** It asks, and nothing is - lost or silently committed. Test: Task 6 and Task 7 (`editor-no-loss`, `editor-leave-confirm` cases). -4. **A message appears or expires while the user is about to tap a handle.** Nothing moves. Test: Task 3 helper - with the Layout Instability observer, used at 1 024, 1 180 and 1 280 px. -5. **An inherited out-of-frame point is repaired without coordinate fields.** The move mode previews freely and - « Valider la position » commits once, accepted. A partial move is refused and restored. Test: Task 4 (replaces - the `editor-geometry.spec.ts` numeric repair). +1. **A finger on a vertex, then a second finger.** The drag is cancelled, the shape restored, nothing committed, and + the pinch zooms. A pinch whose anchor finger barely moves never ends as a click. Tests: Task 2 table, Task 8 CDP + two-point touch. +2. **Ctrl+Z with focus on a handle after arrow moves, or on a move-mode arrow.** The undo only cancels the preview, + and a later Enter commits nothing stale. After undoing « + », « − » never removes the wrong vertex. Tests: Task 4 + and Task 5 units. +3. **A typed properties or creation form when the width crosses 1 024 px, the device rotates, or a save is refused + as frozen.** The dialog stays, read-only, the draft is kept, nothing is committed; editable again on the way + back. Tests: Task 6 and Task 7 (width flip and mode flip). +4. **A message appears or expires while the user is about to tap a handle.** Nothing moves (boxes, header, scroll + height). Test: Task 3 helper at 1 024, 1 180 and 1 280 px. +5. **A tap or a double click that opens the dialog on the selected shape.** The dialog stays open; no vertex is + inserted; the veil ignores the synthesised click. Tests: Task 2 table, Task 6 e2e mouse and touch. ## File Structure -Pure modules, new, under `apps/app/src/editor/annotations/`: +New: -- `pointer.ts`: slop per pointer kind. -- `press.ts`: hit list → target → click or drag action (board 32 priority). -- `polygonEdit.ts`: midpoint insert, vertex removal, vertex move, degenerate move, handle cap. -- `pointSize.ts`: stops, most used, snap, range. -- `escape.ts`: Escape situation (board 32 rows 3 to 6). -- `moveStep.ts`: arrow step. -- `missingFields.ts`: replaces `formProblem`. -- `twoFingerHint.ts`: when the hint may show. -- `preview.ts`: the pending preview and its cancel reasons. - -React, new: - -- `components/editor/annotations/EditStrip.tsx`: the fixed strip and its command sets. -- `GestureMessage.tsx` and `editor/annotations/useGestureMessage.ts`: the message line. -- `SizeSlider.tsx`. -- `MoveModeBar.tsx`: the four arrows, « Valider la position », « Annuler ». -- `HandleLayer.tsx`: the interactive handles inside the overlay. -- `Loupe.tsx`. -- `AnnotationDialog.tsx`: read and edit. -- `AnnotationReadBody.tsx`: shared with the narrow twin. -- `AnnotationEditForm.tsx`. -- `CreationDialog.tsx`: replaces `CreationPanel.tsx`. -- `CreationConfirm.tsx`: R-12. +- `apps/app/src/editor/annotations/press.ts`: slop per kind, hit choice, click and drag actions, double click, the + press machine. +- `apps/app/src/editor/annotations/polygonEdit.ts`: midpoint, removal, vertex move, no-op move, cap, + insert-visibility. +- `apps/app/src/editor/annotations/pointSize.ts`: stops, most used, snap, range. +- `apps/app/src/editor/annotations/escape.ts`: Escape action. +- `apps/app/src/editor/annotations/missingFields.ts`: replaces `formProblem`. +- `apps/app/src/editor/annotations/workStore.ts`: zustand: `creation`, `preview`, `chosen`, `stale()`. +- `apps/app/src/components/editor/annotations/EditStrip.tsx`, `GestureMessage.tsx`, `SizeSlider.tsx`, + `MoveModeBar.tsx`, `HandleLayer.tsx` (its own SVG, not aria-hidden), `Loupe.tsx`, `AnnotationDialog.tsx`, + `AnnotationReadBody.tsx`, `AnnotationEditForm.tsx`, `CreationDialog.tsx`. +- `apps/app/e2e/support/layout.ts` (`expectNoShift`). Modified: -- Canvas and overlay: `AnnotationCanvas.tsx`, `AnnotationOverlay.tsx`, `EditableAnnotations.tsx`. -- Annotation state and gestures: `uiState.ts`, `usePlacement.ts`, `useMoveGesture.ts` (folded into the press - handler), `useCanvasGestures.ts`, `gesture.ts`, `frame.ts` (`proposePoint` takes a radius), `creation.ts`. -- Shared with the catalogue: `catalogue/useFraming.ts` (opt-in options, catalogue defaults unchanged). -- Dialogs: `components/ui/Dialog.tsx` (placement, backdrop). -- Navigation and history: `navigation.ts`, `useEditorNavigation.ts`, `history/{entry,useEditorHistory,useLeaveConfirm}.ts`, - `leftDraft.ts`, `tabs.ts`, `EditorWorkspace.tsx`. -- Undo: `HistoryButtons.tsx` and `useUndoShortcuts.ts` (inactive during a creation), `state/undo.ts` (R-6). -- Page-wide: `styles/index.css` (R-2), `i18n/{fr,en}.ts`. -- Read-only twin: `tabs/AnnotationsTab.tsx`. +- Canvas and gestures: `AnnotationCanvas.tsx`, `AnnotationOverlay.tsx`, `EditableAnnotations.tsx`, `uiState.ts`, + `usePlacement.ts`, `useCanvasGestures.ts`, `gesture.ts`. +- Geometry and creation: `frame.ts` (radius passed in; `moveStep`), `creation.ts`, `creationAttempt.ts`, + `correction.ts`, `focusTarget.ts`, `CreationFields.tsx` (« Couleur » behind a prop, field order region then zone). +- Shared with the catalogue, opt-in only: `catalogue/useFraming.ts` (`twoPointerPan`; keys only on the box itself; + defaults unchanged). +- Dialogs: `components/ui/Dialog.tsx` (`anchor`), `ConfirmDialog.tsx` (`body` optional). +- Navigation and history: `navigation.ts`, `useEditorNavigation.ts` (layer, `useTabSelect`, `openSection`, + `useAskLeaving`), `history/{entry,useEditorHistory,useLeaveConfirm}.ts`, `leftDraft.ts`, `tabs.ts`, + `EditorWorkspace.tsx`, `tabs/AnnotationsTab.tsx` (dialog mounts, twin). +- Leave and undo: `AdminSheetDraftRoute.tsx` and `SignOutButton.tsx` (`leaveGuardArmed` or creation work), + `HistoryButtons.tsx` and `useUndoShortcuts.ts` (R-13). +- Page-wide: `styles/index.css` (R-2), `DraftHeader.tsx` (the save line holds its height, if Task 3 finds it + shifts), `i18n/{fr,en}.ts`. -Removed: +Removed: `TracingBar.tsx`, `CreationPanel.tsx`, `PropertiesPanel.tsx`, `AnnotationFields.tsx`, `useMoveGesture.ts`, +the `ToolNotes` and `TagOf` parts of `EditableAnnotations`, and the field helpers of `geometryEdit.ts` used by +annotations only. `GeometryGroup.tsx` stays for `RepairDialog` (D1). -- `GeometryGroup.tsx`, `ToolNotes` (inside `EditableAnnotations`), `TracingBar.tsx`, `SelectionTag.tsx`, - `CreationPanel.tsx`. -- The edit paths of `PropertiesPanel.tsx`, and `AnnotationFields.tsx`'s per-field commits. -- `geometryEdit.ts`'s field helpers (`fieldsOf`, `parseFields`, `sameAsStored`, `changedFieldNames`, - `withVertexAfter`, `withoutVertex`); `isEditable` stays. - -Core: - -- `crates/core/src/anatomy/frame.rs` (`min_point_radius`). -- `crates/core/src/domain/sheet/preview.rs` (`PreviewState.min_point_radius`). -- `crates/core/tests/sheet_preview.rs`. -- `packages/core-wasm/types/PreviewState.ts` (generated). -- `packages/core-wasm/tests/contracts.types.test.ts`. - -### Task 0: Baselines and the loupe spike (nothing shipped) - -**Files:** a scratch harness page `apps/app/e2e/harness/loupe-spike.{html,tsx}` (dev server only, deleted at the end -of the task). Results go into this plan's « Task 0 results ». - -- [ ] **Step 1: wasm baseline.** Run `pnpm wasm:build` then `pnpm --filter @faunosteo/core-wasm exec vitest run - tests/size.test.ts`, and record the gate's printed gzip figure and the margin to 600 000 B. -- [ ] **Step 2: undo depth.** In a unit test against the bundled draft (`tests/helpers/sheet.ts`), print - `encoder.encode(state.documentText).length` after load. Compute 8 MiB and 16 MiB divided by it, and record both - depths. Confirm or correct R-6. -- [ ] **Step 3: loupe, technique A.** In the harness, use the composed equine main view. - - At touch-drag start, clone the drawing's `` once (`cloneNode(true)`, `aria-hidden`, `inert`) into a - 120 px circular box placed 90 px above the finger and clamped inside the canvas box. - - Scale it ×2 around the finger point, with the overlay's preview outline copied on top. - - Measure, in Chromium with touch emulation at 1 180 px and CPU throttling ×4 (CDP - `Emulation.setCPUThrottlingRate`), the median and 95th percentile of `pointermove` handling to next frame over - a 2 s drag. Pass: p95 under 16 ms. -- [ ] **Step 4: technique B, if A fails.** The loupe shows the overlay only (outline, handles, finger point) on a - white disc, without the drawing. If B is the only one to pass, STOP and ask the owner (Owner decisions). -- [ ] **Step 5:** delete the harness files, write the figures here and in `docs/development/RUST.md` (size). Commit - the plan and RUST.md: `docs(docs): U2 baselines, wasm size, undo depth, loupe spike`. +Core: `crates/core/src/anatomy/frame.rs`, `crates/core/src/domain/sheet/preview.rs`, +`crates/core/tests/sheet_preview.rs`, `packages/core-wasm/types/PreviewState.ts` (generated), +`packages/core-wasm/tests/contracts.types.test.ts`. ### Task 1: Core: the smallest radius a point may have in each view -**Files:** - -- Modify `crates/core/src/anatomy/frame.rs` (beside `annotation_placement`, l.208-227). -- Modify `crates/core/src/domain/sheet/preview.rs` (`PreviewState`, l.359-370; `state()`, l.272-292). -- Test `crates/core/tests/sheet_preview.rs`. -- Generated `packages/core-wasm/types/PreviewState.ts`. -- Test `packages/core-wasm/tests/contracts.types.test.ts`. -- App reader `apps/app/src/editor/annotations/minRadius.ts`. +**Files:** `frame.rs` (beside `annotation_placement`, l.208-227), `preview.rs` (`PreviewState` l.359-370, `state()` +l.272-292), `crates/core/tests/sheet_preview.rs`, the generated `PreviewState.ts`, `contracts.types.test.ts`, +`docs/development/RUST.md`. **Interfaces:** -- Produces (Rust): - ```rust /// The smallest hitbox radius of a point (a circle that is not a trigger) that passes -/// `TooSmall` in a view with this frame; None when every positive radius passes -/// (preview scale ≥ 1, the twin's 2-unit floor already shows 4 px). +/// `TooSmall` in a view with this frame, rounded up to 0.01; None when every positive +/// radius passes (preview scale ≥ 1: the twin's 2-unit floor already shows 4 px). pub fn min_point_radius(frame: &Frame, main_view: bool) -> Option ``` - It is computed from the same constants as `annotation_placement`. With `scale = frame.preview_scale(main_view)`, - the twin must reach `MIN_VISIBLE_PX / 2 / scale`. Because `twin_radius(r) = max(2, r - 12)`, the result is - `Some(12 + MIN_VISIBLE_PX / 2 / scale)` when that twin exceeds 2, else `None`. The value is rounded UP to 0.01, so - the page never offers a refused value at the mark. -- Produces (state): `PreviewState.min_point_radius: BTreeMap`, view id → radius, with only views that - have a usable frame and a minimum. ts-rs gives `{ [key in string]?: number }`. -- Produces (app): `minPointRadius(state: PreviewState | null, viewId: string): number | null` in `minRadius.ts`. +`twin_radius(r) = max(2, r − 12)` must reach `MIN_VISIBLE_PX / 2 / scale`, with `scale = frame.preview_scale(main)`. +So the result is `Some(ceil_0.01(12 + MIN_VISIBLE_PX / 2 / scale))` when `MIN_VISIBLE_PX / 2 / scale > 2`, else +`None`. `PreviewState.min_point_radius: BTreeMap` maps a view id to its radius, for views with a usable +frame and a minimum. The app reads `previewState.min_point_radius[viewId] ?? null` inline. -- [ ] **Step 1: failing Rust tests** in `sheet_preview.rs`: - - The equine main and head views give the values computed from their frames. Assert against the formula on the - frame read from the fixture, not a pasted number. - - A frame of width 100 (scale > 1) gives no entry. - - A frame exactly at scale 1 gives no entry. - - A view without a usable frame gives no entry. - - For each entry, a circle with `r = value` passes `annotation_placement` and `r = value − 0.01` gives `TooSmall`. - This consistency check is the property that matters. -- [ ] **Step 2:** `cargo test -p faunosteo-core --test sheet_preview`: FAIL (the field is missing). -- [ ] **Step 3:** implement `min_point_radius`, fill the map in `state()`, and run `cargo test` with features `ts` to - regenerate `PreviewState.ts`. -- [ ] **Step 4:** `pnpm rust:check` green. `pnpm wasm:build`, then the size test, then record the figure and its delta - against Task 0 in `RUST.md`. Then `contracts.types.test.ts` asserts the field's shape, and an app unit test checks - `minPointRadius` on the bundled draft equals the core's value. -- [ ] **Step 5:** commit Rust, the generated types and RUST.md: `feat(domain): per-view minimum point radius in - preview state`. +- [ ] **Step 1: baseline.** `pnpm wasm:build`, then the gate's size test (`packages/core-wasm/tests/size.test.ts`); + record the printed figure. +- [ ] **Step 2: failing Rust tests** in `sheet_preview.rs`: + - The equine main and head views give the formula's value on their frames: about 26.50 and 15.98, asserted from + the frame read from the fixture. + - Width 100, an exact scale of 1 and an unusable frame give no entry. + - Property: for each entry, a circle with `r = value` passes `annotation_placement`, and `r = value − 0.01` gives + `TooSmall`. +- [ ] **Step 3:** `cargo test -p faunosteo-core --test sheet_preview` gives FAIL. Implement, then regenerate the types + (`cargo test` with features `ts`). +- [ ] **Step 4:** `pnpm rust:check`, `pnpm wasm:build`, and the size test. Record the figure and its delta in + `RUST.md`. `contracts.types.test.ts` asserts the field, and an app unit test checks the bundled draft's main-view + value. +- [ ] **Step 5:** commit `feat(domain): per-view minimum point radius in preview state`. -### Task 2: Pure interaction modules +### Task 2: The press machine (one decider for the editor) and the stale stamp -**Files:** create the nine modules of the File Structure, each with `tests/unit/annotations..test.ts` table -tests. `gesture.ts` keeps `translatedGeometry` and `clientToDrawing`, and loses `DRAG_START_PX` and -`pastDragThreshold` for `pointer.ts`. +**Files:** + +- Create `press.ts` and `workStore.ts`. +- Modify `useCanvasGestures.ts`: the editor stops using `clickHandler`, `useEmptyTap`, `swallowClick` and + `useMoveGesture`; `canPan` becomes `dragAction(...).type === 'pan'`; the framing keys are passed only when + `event.target === event.currentTarget`. +- Modify `gesture.ts`: `DRAG_START_PX` and `pastDragThreshold` go. +- Delete `useMoveGesture.ts`. +- Tests: `tests/unit/annotations.press.test.ts` and `annotations.workStore.test.ts`. The existing suites stay green: + select, deselect on an empty tap, block drag of the selection, catalogue unchanged. **Interfaces (produced, exact):** ```ts -// pointer.ts +// press.ts import type { XY } from './frame' + export type PointerKind = 'mouse' | 'pen' | 'touch' /** CSS px a press travels before it is a drag (R-8): a finger jitters more than a mouse. */ export const SLOP_PX: Readonly> = { mouse: 4, pen: 6, touch: 10 } +export const DOUBLE_MS = 400 +export const DOUBLE_PX = 8 + export function pointerKindOf(pointerType: string): PointerKind { return pointerType === 'touch' || pointerType === 'pen' ? pointerType : 'mouse' } -export function pastSlop(kind: PointerKind, from: XY, to: XY): boolean { - return Math.hypot(to.x - from.x, to.y - from.y) > SLOP_PX[kind] -} -``` -```ts -// press.ts -import type { PointerKind } from './pointer' +const distance = (a: XY, b: XY) => Math.hypot(a.x - b.x, a.y - b.y) + +export function pastSlop(kind: PointerKind, from: XY, to: XY): boolean { + return distance(from, to) > SLOP_PX[kind] +} + export type HandleRef = | { kind: 'point' } | { kind: 'vertex'; index: number } - | { kind: 'insert'; after: number } | { kind: 'remove'; index: number } -/** One element under the pointer, top first (document.elementsFromPoint order). */ -export type Hit = { kind: 'handle'; handle: HandleRef } | { kind: 'annotation'; id: string } + | { kind: 'insert'; after: number } + +/** One element under the press, top first (`elementsFromPoint`); handle centres in CSS px. */ +export type Hit = + | { kind: 'handle'; handle: HandleRef; centre: XY } + | { kind: 'annotation'; id: string } + +const RANK: Record = { point: 0, vertex: 0, remove: 1, insert: 2 } + +/** R-9: the nearest handle; at equal distance a vertex, then « − », then « + ». */ +export function nearestHandle(hits: readonly Hit[], at: XY): HandleRef | null { + let best: { handle: HandleRef; d: number } | null = null + for (const hit of hits) { + if (hit.kind !== 'handle') continue + const d = distance(hit.centre, at) + const better = + !best || d < best.d || (d === best.d && RANK[hit.handle.kind] < RANK[best.handle.kind]) + if (better) best = { handle: hit.handle, d } + } + return best?.handle ?? null +} + +export interface Selection { + selectedId: string | null + chosenVertex: number | null +} + export type PressTarget = | { kind: 'handle'; handle: HandleRef } | { kind: 'other'; id: string } | { kind: 'interior'; id: string } | { kind: 'empty' } -export interface Selection { - selectedId: string | null - chosenVertex: number | null -} -/** Board 32: the selection's handles, then another annotation, then its interior, then nothing. */ -export function pressTarget(hits: readonly Hit[], sel: Selection): PressTarget { - for (const hit of hits) if (hit.kind === 'handle') return hit - const other = hits.find((h) => h.kind === 'annotation' && h.id !== sel.selectedId) - if (other?.kind === 'annotation') return { kind: 'other', id: other.id } - const own = hits.some((h) => h.kind === 'annotation' && h.id === sel.selectedId) - return own && sel.selectedId !== null - ? { kind: 'interior', id: sel.selectedId } - : { kind: 'empty' } + +/** Board 32: the selection's handles, then the TOPMOST annotation (the visible wins), else nothing. */ +export function pressTarget(hits: readonly Hit[], at: XY, sel: Selection): PressTarget { + const handle = nearestHandle(hits, at) + if (handle) return { kind: 'handle', handle } + const top = hits.find((hit) => hit.kind === 'annotation') + if (top?.kind !== 'annotation') return { kind: 'empty' } + return top.id === sel.selectedId ? { kind: 'interior', id: top.id } : { kind: 'other', id: top.id } } + export type ClickAction = | { type: 'choose_vertex'; index: number } | { type: 'insert'; after: number } @@ -434,6 +510,7 @@ export type ClickAction = | { type: 'unchoose' } | { type: 'open'; id: string } | { type: 'deselect' } + /** A press released within the slop (A1): select first, open on the selection itself. */ export function clickAction(target: PressTarget, sel: Selection): ClickAction { if (target.kind === 'other') return { type: 'select', id: target.id } @@ -447,30 +524,362 @@ export function clickAction(target: PressTarget, sel: Selection): ClickAction { if (handle.kind === 'remove') return { type: 'remove', index: handle.index } return sel.selectedId ? { type: 'open', id: sel.selectedId } : { type: 'deselect' } } + +/** R-8: the second of two clicks close in time and place opens; it never acts on a handle. */ +export interface LastClick { at: XY; time: number } +export function isDoubleClick(last: LastClick | null, at: XY, time: number): boolean { + return last !== null && time - last.time <= DOUBLE_MS && distance(last.at, at) <= DOUBLE_PX +} + +export interface DragContext { + kind: PointerKind + /** The selection can move now (editable, measured, circle or polygon, under the cap). */ + movable: boolean + /** « Déplacer … » is on: a drag anywhere moves its target (board 06 B). */ + moveMode: boolean +} + export type DragAction = + | { type: 'drag_mode' } | { type: 'drag_point' } | { type: 'drag_vertex'; index: number } | { type: 'drag_shape'; id: string } | { type: 'pan' } | { type: 'none'; futile: boolean } + /** A press past the slop: a finger moves only what it holds (A13); a mouse or pen drags the interior. */ -export function dragAction(target: PressTarget, kind: PointerKind): DragAction { +export function dragAction(target: PressTarget, ctx: DragContext): DragAction { + if (ctx.moveMode) return { type: 'drag_mode' } if (target.kind === 'handle') { + if (!ctx.movable) return { type: 'none', futile: false } if (target.handle.kind === 'point') return { type: 'drag_point' } if (target.handle.kind === 'vertex') return { type: 'drag_vertex', index: target.handle.index } return { type: 'none', futile: false } } - if (kind === 'touch') return { type: 'none', futile: true } - if (target.kind === 'interior') return { type: 'drag_shape', id: target.id } + if (ctx.kind === 'touch') return { type: 'none', futile: true } + if (target.kind === 'interior' && ctx.movable) return { type: 'drag_shape', id: target.id } return { type: 'pan' } } + +/** The press in flight: one pointer, or a multi-pointer gesture that never clicks nor commits. */ +export type Press = + | { phase: 'idle' } + | { phase: 'down'; pointerId: number; kind: PointerKind; start: XY; target: PressTarget } + | { phase: 'drag'; pointerId: number; action: DragAction } + | { phase: 'multi' } + +/** `pointers`: how many pointers are down after the event. */ +export type PressEvent = + | { type: 'down'; pointerId: number; kind: PointerKind; at: XY; target: PressTarget; pointers: number } + | { type: 'move'; pointerId: number; at: XY } + | { type: 'up'; pointerId: number; pointers: number } + | { type: 'cancel' } + +export type PressEffect = + | { type: 'click'; target: PressTarget } + | { type: 'drag_start'; action: DragAction } + | { type: 'drag_end' } + | { type: 'drag_cancel' } + | null + +const IDLE: Press = { phase: 'idle' } + +export function stepPress( + press: Press, + event: PressEvent, + ctx: Omit, +): { press: Press; effect: PressEffect } { + if (event.type === 'cancel') { + return { press: IDLE, effect: press.phase === 'drag' ? { type: 'drag_cancel' } : null } + } + if (event.type === 'down') { + if (press.phase === 'idle' && event.pointers === 1) { + const { pointerId, kind, at, target } = event + return { press: { phase: 'down', pointerId, kind, start: at, target }, effect: null } + } + return { press: { phase: 'multi' }, effect: press.phase === 'drag' ? { type: 'drag_cancel' } : null } + } + if (event.type === 'move') { + if (press.phase !== 'down' || event.pointerId !== press.pointerId) return { press, effect: null } + if (!pastSlop(press.kind, press.start, event.at)) return { press, effect: null } + const action = dragAction(press.target, { ...ctx, kind: press.kind }) + return { press: { phase: 'drag', pointerId: press.pointerId, action }, effect: { type: 'drag_start', action } } + } + if (press.phase === 'multi') return { press: event.pointers === 0 ? IDLE : press, effect: null } + if (press.phase === 'down') return { press: IDLE, effect: { type: 'click', target: press.target } } + if (press.phase === 'drag') return { press: IDLE, effect: { type: 'drag_end' } } + return { press, effect: null } +} ``` -Notes: +```ts +// workStore.ts +import { create } from 'zustand' +import type { Geometry } from '@faunosteo/core-wasm/types' +import type { CreationForm, PendingElement } from './creation' -- `pan` is the mouse or pen pan, only when zoomed; `useFraming` still decides through `canPan`. -- A mouse drag on another annotation pans. It never selects. -- `futile: true` feeds R-1. +/** A geometry shown but not committed, stamped with the document text it was computed on. */ +export interface Preview { annotationId: string; geometry: Geometry; base: string; source: 'move' | 'size' | 'keys' } +export interface Chosen { annotationId: string; vertex: number; base: string } +export interface Creation { + /** A new zone or link being traced lives here from its first vertex (`closed` false). */ + pending: PendingElement + closed: boolean + form: CreationForm + /** The dialog is shown; false while the shape is replaced or the trace resumed. */ + dialog: boolean +} +interface Work { + creation: Creation | null + preview: Preview | null + chosen: Chosen | null +} +export const useAnnotationWork = create(() => ({ creation: null, preview: null, chosen: null })) + +/** R-12: a creation holds work once a shape exists or a field is typed. */ +export function holdsCreationWork(work: Work): boolean { + return work.creation !== null +} + +/** R-13: drop what was computed on another document text; the caller passes the current text. */ +export function dropStale(text: string): void { + useAnnotationWork.setState((work) => ({ + preview: work.preview && work.preview.base !== text ? null : work.preview, + chosen: work.chosen && work.chosen.base !== text ? null : work.chosen, + })) +} +``` + +Notes on the code above: + +- A creation always holds its shape, so `holdsCreationWork` is the existence of the creation. The tool alone, before + the first click or the first vertex, holds nothing and creates no `creation`. +- The tracing of a NEW zone or link moves from `ui.tracing` to `creation` (Task 7). A redraw stays in `ui.tracing` + (target `replace`): it is not a creation (R-12). +- The drag preview of a pointer drag stays canvas-local, as `useMoveGesture` keeps it today, for speed. It is + dropped by `drag_cancel`, by a second pointer and by a document change. +- `workStore` is reset when the sheet changes and when the editor unmounts. `editorStore` calls `dropStale` from + one subscription on `documentText`. + +- [ ] **Step 1: failing table tests.** + - `nearestHandle`: the nearest of three overlapping hit circles wins (Thoraciques 11 px segment); at a tie, + vertex beats « − », which beats « + ». + - `pressTarget`: a selected zone hit first and a point hitbox under it gives `interior`; a point twin hit first + and the selected zone under it gives `other`; empty gives `empty`. + - `clickAction`: as in rev 1 (interior with a chosen vertex gives `unchoose`, without one `open`; a point handle + gives `open`). + - `isDoubleClick`: the edges at 400 ms and 8 px. + - `dragAction`: a move mode gives `drag_mode` whatever the target or pointer. A finger off a handle gives `none` + with `futile`. A mouse on the interior while not movable (read-only, unmeasured, path) gives `pan`. « + » and + « − » never drag. + - `stepPress`: + - A single press within the slop gives `click`. + - Past the slop gives `drag_start`, then `drag_end`. + - A second down while `down` gives `multi`, with no click on any up, and `idle` only at zero pointers (a pinch + never clicks). + - A second down while `drag` gives `drag_cancel`. + - `cancel` while `drag` gives `drag_cancel`. + - A move from another pointer id is ignored. + - `dropStale`: drops on a different text and keeps on the same one. +- [ ] **Step 2:** `pnpm --filter @faunosteo/app exec vitest run tests/unit/annotations.press tests/unit/annotations.workStore` + gives FAIL. +- [ ] **Step 3:** implement, then wire `useCanvasGestures`. + - `hitsAt(client)` uses `document.elementsFromPoint`. It maps handles by `data-handle` (JSON of `HandleRef`) with + their centre from `getBoundingClientRect`, and annotations by `annotationIdOf`. + - Pointer events feed `stepPress`. A `click` effect dispatches `clickAction` (or `open` when `isDoubleClick`). A + `drag_shape` reuses the block translation (`translatedGeometry`) and commits once on `drag_end` through + `updateGeometry`. `deselect` keeps today's focus rule (`useDeselect.byDrawing`). + - The box no longer handles `onClick`. +- [ ] **Step 4:** `pnpm typecheck && pnpm test:run && pnpm lint`, plus the e2e of today's gestures on the sandbox: + `editor-annotations.spec.ts` « a click with jitter never moves; a drag moves by the pointer delta », + `editor-deselect.spec.ts` mouse and touch, `catalogue.spec.ts`. All green unchanged. +- [ ] **Step 5:** commit `refactor(editor): one press machine for clicks, drags and taps on the drawing`. + +### Task 3: The fixed strip, the message line, no layout shift + +**Files:** + +- Create `EditStrip.tsx`, `GestureMessage.tsx` and `apps/app/e2e/support/layout.ts`. +- Modify `EditableAnnotations.tsx`: remove `ToolNotes`, `TagOf` and `TracingBar`, and mount the strip over both + columns. +- Modify `uiState.ts` (`trace_pop`), `usePlacement.ts` (Backspace removes the last vertex), `focusTarget.ts` (busy + tracing target = the strip's tracing commands), `styles/index.css` (R-2) and i18n. +- Modify `DraftHeader.tsx` only if the helper shows the save line moving. +- Delete `TracingBar.tsx`. + +**Interfaces:** + +- `EditStrip` props: `{ lead: StripLead; notice: StripNotice | null; commands: ReactNode }`. + - `StripLead = { title: string; status?: ReviewStatus; detail: string; icon: IconName }`. + - `StripNotice = { tone: 'error' | 'info'; text: string; more?: number; link?: { label: string; onClick(): void } }`. +- `useGestureMessage()` returns `{ message, show(text, { undo, tone }), hint(text) }`. + - It clears on any change of `documentText` or of the history stacks. + - The 6 s timer is paused only by `pointerenter` with `pointerType === 'mouse'` and by focus inside. + - `hint` shows only when no message is shown. +- `expectNoShift(page, act)`: + 1. Records the boxes of the canvas, the strip, the aside and the header, `scrollHeight`, the computed + `scrollbar-gutter` and `document.documentElement.clientWidth`. + 2. Installs a `PerformanceObserver({ type: 'layout-shift' })`. + 3. Runs `act`, then waits two animation frames. + 4. Asserts equal boxes and widths, and a zero sum of every entry, `hadRecentInput` included. + +- [ ] **Step 1: failing unit tests** (`editor-annotations-tab.test.tsx`, `describe('the strip')`). + - The labels per state come from REVUE's table: tool Point, a selected point, a selected zone (« Zone · 9 sommets »), + tracing (« Fermer le tracé », « Retirer le dernier sommet », « Annuler le tracé »), read-only, an unmeasured view + with its link, and geometry issues with `+n`. + - The strip has a fixed height and `overflow-hidden`; a long name truncates before the status. + - « Retirer le dernier sommet » and Backspace remove the last vertex. + - The message: + - A commit shows « Point déplacé · Défaire »; « Défaire » calls `undo`. + - A new commit replaces the message, and an undo from the header clears it. + - A refusal shows `role="alert"` with no « Défaire ». + - Mouse hover pauses the timer, a touch does not (fake timers). +- [ ] **Step 2:** FAIL. **Step 3:** implement and move the existing texts into the strip notice. +- [ ] **Step 4: e2e** `editor-annotations.spec.ts`, « the drawing never moves ». + - At 1 024, 1 180 and 1 280 px, `expectNoShift` around select, deselect, tool change, tracing start, add, pop and + close, the first commit (save line), a message showing, and its expiry (`page.clock`). + - At 1 280 px, the scoped `scrollbar-gutter` is `stable` on the editor page and absent on the dashboard. + - Existing selectors move to the strip; `editor-focus-request` busy cases are re-pointed. +- [ ] **Step 5:** gates, then commit `feat(editor): fixed edit strip and message line without layout shift`. + +### Task 4: Point editing: handle, size slider, move mode, the repair without fields + +**Files:** + +- Create `HandleLayer.tsx`: its own ``, same `viewBox`, not `aria-hidden`, beside the overlay. +- Create `SizeSlider.tsx`, `MoveModeBar.tsx`, `pointSize.ts` and `escape.ts`. +- Modify `frame.ts`: + - `proposePoint(frame, click, radius)`, `correctedCircle(frame, at, radius)`, `centreCircle(frame, radius)`. + - `moveStep(frame, big)`. +- Modify the callers `creation.ts` (`pendingForClick`, `keyboardPending`) and `correction.ts` (the test against + the given radius, R-10). +- Modify `uiState.ts` (`mode: { kind: 'move'; target: 'shape' | { vertex: number } } | null`), + `useCanvasGestures.ts` (`drag_point`, `drag_mode`) and `deselect.ts` (the Escape listener calls `escapeAction`). +- Modify the properties panel: its numeric group goes, and the panel keeps its fields until Task 6. +- Doc `docs/ANNOTATION-RENDERING.md` « Editor overlay » FIRST. + +**Interfaces:** + +```ts +// pointSize.ts +import type { Annotation } from '@faunosteo/core-wasm/types' +import { round2 } from './frame' +const pointRadii = (annotations: readonly Annotation[], viewId: string): number[] => + annotations.flatMap((a) => + a.kind === 'point' && a.view_id === viewId && a.geometry?.type === 'circle' ? [a.geometry.r] : [], + ) +/** The slider's stops: the distinct radii of the view's points, ascending (links excluded). */ +export function sizeStops(annotations: readonly Annotation[], viewId: string): number[] { + return [...new Set(pointRadii(annotations, viewId))].sort((a, b) => a - b) +} +/** A5: the radius used most in the view, the smaller on a tie; null without any point. */ +export function mostUsedSize(annotations: readonly Annotation[], viewId: string): number | null { + const counts = new Map() + for (const r of pointRadii(annotations, viewId)) counts.set(r, (counts.get(r) ?? 0) + 1) + let best: [number, number] | null = null + for (const [r, n] of counts) { + if (!best || n > best[1] || (n === best[1] && r < best[0])) best = [r, n] + } + return best?.[0] ?? null +} +/** The nearest stop within `reach` drawing units, else the value on the 0.01 grid. */ +export function snapSize(value: number, stops: readonly number[], reach: number): number { + let nearest: number | null = null + for (const stop of stops) { + const closer = nearest === null || Math.abs(stop - value) < Math.abs(nearest - value) + if (Math.abs(stop - value) <= reach && closer) nearest = stop + } + return nearest ?? round2(value) +} +export interface SizeRange { low: number; high: number } +/** R-10: around the stops when there are some, around the fallback radius otherwise. */ +export function sizeRange(stops: readonly number[], minimum: number | null, fallback: number): SizeRange { + const smallest = stops.length > 0 ? stops[0] : fallback + const largest = stops.length > 0 ? stops[stops.length - 1] : fallback + const base = minimum === null ? smallest : Math.min(smallest, minimum) + return { low: round2(Math.max(0.01, base / 2)), high: round2(2 * largest) } +} +``` + +```ts +// escape.ts +export interface EscapeInput { + /** A keyboard series or a slider not yet committed (outside a move mode). */ + previewPending: boolean + creating: boolean + /** A redraw or a move mode. */ + inMode: boolean + chosenVertex: number | null + selectedId: string | null +} +export type EscapeAction = + | 'drop_preview' | 'ask_creation' | 'drop_mode' | 'unchoose' | 'deselect' | null +/** Board 32 rows 3 to 6, one situation per press (rows 1 and 2, a dialog and a side panel, consume it first). */ +export function escapeAction(s: EscapeInput): EscapeAction { + if (s.previewPending) return 'drop_preview' + if (s.creating) return 'ask_creation' + if (s.inMode) return 'drop_mode' + if (s.chosenVertex !== null) return 'unchoose' + return s.selectedId !== null ? 'deselect' : null +} +``` + +```ts +// frame.ts (added) +/** R-11: one arrow = 0.5 % of the frame's longer side (0.01 at least); Shift ×10 on keys. */ +export function moveStep(frame: Frame, big: boolean): number { + const step = Math.max(0.01, round2(Math.max(frame.w, frame.h) * 0.005)) + return big ? round2(step * 10) : step +} +``` + +How the pieces work: + +- The strip shows `SizeSlider` for a selected point and for the Point tool before the click (A5). +- `MoveModeBar` replaces the commands during the mode. Its arrows write `useAnnotationWork.preview` with + `source: 'move'`. « Valider la position » commits once through `updateGeometry`, with the stamp checked. +- The overlay reads the preview through a zustand selector, so the tab does not re-render on each step. +- The point handle carries the accessible name « Point {nom} », with arrow keys as a series (`source: 'keys'`) + committed on Enter or blur. + +- [ ] **Step 1: doc.** In « Editor overlay »: handles and their sizes (R-9), the chosen vertex (bigger, filled, + ringed), the old place (grey dashes), the refused place (red dashes), the move-mode target, and the handle layer + as its own SVG. +- [ ] **Step 2: failing tests.** + - Unit `pointSize`: on the bundled draft, the main view gives 30 and 34, the head 27; a tie goes to the smaller; a + view without a point gives null; the range on the main view runs from about 13.25 to 68; `snapSize` reach edges. + - Unit `escapeAction`: one situation per press, in the board's order. + - Unit `moveStep`: tiny and large frames. + - The slider: + - It shows the stops and the red mark at the core value. + - Arrows, Page Up and release commit once (history depth +1). + - A value under the mark is refused by the core and restored with a red message. + - The move mode: + - Its arrows commit nothing until « Valider la position », which commits once. « Annuler » and Escape restore. + - Ctrl+Z during the mode only cancels it (R-13), and a later Enter commits nothing (Review Focus 2). + - A document change during the mode drops it. + - The keyboard on the point handle: arrows pan nothing (the box keys only), Enter commits once. + - A5: a click, the C26 candidate and the keyboard point all use the most used size. + - E2E mouse: + - Drag the point, change its size by a track click (WCAG 2.5.7). + - Repair the inherited out-of-frame point with the move mode, replacing the numeric repair of + `editor-geometry.spec.ts:273-281` (a partial move is refused and restored). + - Re-point the C26 test (`:118`) to the dialog in Task 7 (until then, to the panel's state). + - All under `expectNoShift`. +- [ ] **Step 3:** implement. **Step 4:** gates and the touched e2e on the sandbox. +- [ ] **Step 5:** commit `feat(editor): point handle, size slider with core minimum, move mode`. + +### Task 5: Zone editing: vertices, « + », « − », interior drag, redraw, paths, cap + +**Files:** + +- `polygonEdit.ts` (below). +- `HandleLayer.tsx`: vertices, « + » with its visibility rule, the « − » bubble. +- `useCanvasGestures.ts` and `usePlacement.ts`: redraw = tracing target `replace` on any polygon; the close radius + in CSS px (R-11). +- `EditStrip.tsx` commands, and i18n. + +**Interfaces:** ```ts // polygonEdit.ts @@ -506,82 +915,153 @@ export function isNoOpMove(points: readonly Point[], index: number, moved: reado (j) => points[j][0] === x && points[j][1] === y, ) } -``` - -```ts -// pointSize.ts -import type { Annotation } from '@faunosteo/core-wasm/types' -import { round2 } from './frame' -const pointRadii = (annotations: readonly Annotation[], viewId: string): number[] => - annotations.flatMap((a) => - a.kind === 'point' && a.view_id === viewId && a.geometry?.type === 'circle' ? [a.geometry.r] : [], - ) -/** The slider's stops: the distinct radii of the view's points, ascending (links excluded). */ -export function sizeStops(annotations: readonly Annotation[], viewId: string): number[] { - return [...new Set(pointRadii(annotations, viewId))].sort((a, b) => a - b) -} -/** A5: the radius used most in the view, the smaller on a tie; null without any point. */ -export function mostUsedSize(annotations: readonly Annotation[], viewId: string): number | null { - const counts = new Map() - for (const r of pointRadii(annotations, viewId)) counts.set(r, (counts.get(r) ?? 0) + 1) - let best: [number, number] | null = null - for (const [r, n] of counts) { - if (!best || n > best[1] || (n === best[1] && r < best[0])) best = [r, n] - } - return best?.[0] ?? null -} -/** The nearest stop within `reach` drawing units, else the value on the 0.01 grid. */ -export function snapSize(value: number, stops: readonly number[], reach: number): number { - let nearest: number | null = null - for (const stop of stops) { - if (Math.abs(stop - value) <= reach && (nearest === null || Math.abs(stop - value) < Math.abs(nearest - value))) - nearest = stop - } - return nearest ?? round2(value) -} -export interface SizeRange { low: number; high: number } -/** R-10: half the smaller of (smallest stop, minimum) to twice the larger of (largest stop, fallback). */ -export function sizeRange(stops: readonly number[], minimum: number | null, fallback: number): SizeRange { - const lows = [stops[0], minimum].filter((v): v is number => v !== null && v !== undefined) - const base = lows.length > 0 ? Math.min(...lows) : fallback - const low = round2(Math.max(0.01, base / 2)) - const high = round2(2 * Math.max(stops[stops.length - 1] ?? fallback, fallback)) - return { low, high } +/** R-9: a « + » shows only when its segment is at least two hit radii long on screen. */ +export function showsInsert(segmentPx: number, hitRadiusPx: number): boolean { + return segmentPx >= 2 * hitRadiusPx } ``` -```ts -// escape.ts -export interface EscapeInput { - creating: boolean - /** A shape placed or traced, or a typed field, in the creation. */ - holdsWork: boolean - redrawingOrMoving: boolean - chosenVertex: number | null - selectedId: string | null -} -export type EscapeAction = 'ask_creation' | 'drop_creation' | 'drop_mode' | 'unchoose' | 'deselect' | null -/** Board 32 rows 3 to 6 (rows 1 and 2, a dialog and the side panel, consume Escape first). */ -export function escapeAction(s: EscapeInput): EscapeAction { - if (s.creating) return s.holdsWork ? 'ask_creation' : 'drop_creation' - if (s.redrawingOrMoving) return 'drop_mode' - if (s.chosenVertex !== null) return 'unchoose' - return s.selectedId !== null ? 'deselect' : null -} -``` +- [ ] **Step 1: failing tests.** + - Unit tables: + - `insertMidpoint`: the wrap, and an out-of-range index gives null. + - `removeVertex`: null at 3. + - `moveVertex`: non-finite gives null. + - `isNoOpMove`: the neighbours. + - `showsInsert`: the edges. + - Unit tab: + - A click on a vertex chooses it (« sommet 7 choisi »), stamped. A click on the interior unchooses it. + - A vertex drag commits once; a release on a neighbour commits nothing. + - « + » inserts and chooses the new vertex. Undo, then « − », removes nothing stale: the chosen vertex was + dropped (Review Focus 2). + - « − » is disabled at 3 with « Une zone garde au moins 3 sommets ». Insert and Delete keys. + - The interior drag by mouse moves the zone; « Déplacer la zone » and « Déplacer le sommet » use the Task 4 mode. + - 41 vertices show the outline and the cap message. + - A path shows no handle, offers « Remplacer par un polygone », and its `d` is byte-identical after neighbour + gestures (UX_TESTS « Paths »). + - Redraw: the old outline stays during the trace. An accepted close commits once and keeps every property. A + refusal (`interior_too_small`) keeps the trace open with its message. Escape keeps the old shape. + - E2E mouse on « Thoraciques »: vertex drag, « + », « − », zone drag, redraw accepted and refused, undo for each, + all under `expectNoShift`. Also a click inside « Thoraciques » on c7-t1 selects the point that is drawn on top + (topmost rule). +- [ ] **Step 2:** FAIL. **Step 3:** implement. Map each removed numeric-group assertion to its replacement in the + commit body. +- [ ] **Step 4:** gates. **Step 5:** commit `feat(editor): vertex handles, insert and remove, zone move, redraw`. + +### Task 6: The properties dialog over the column (A1, A2, A3, A9, A10) + +**Files:** + +- `Dialog.tsx`: `anchor?: RefObject`. With an anchor box, the panel sits at the anchor's left + and width, at `top = max(12, rect.top)`, with `max-height = innerHeight − top − 12`, and the light veil (22 % ink). + - When the space left is under 320 px (tablet keyboard, through `visualViewport`), it sits at + `visualViewport.offsetTop + 12` with `height = visualViewport.height − 24`. + - Without an anchor box, the placement is centred. + - It is measured at open and on `resize` and `visualViewport` `resize`. + - The veil ignores clicks when anchored (R-6). +- `ConfirmDialog.tsx`: `body` optional. +- Navigation and history: + - `navigation.ts`: `EditorView.annotation: { id: string } | { create: NewKind } | null`, on tab `annotations` + only. + - `useEditorNavigation.ts`: `LAYERS = ['annotation', 'finding', 'citations', 'reference']`, the + `useAnnotationLayer` moves `open`, `close` and `replace`, `useAskLeaving`. + - `history/{entry,useEditorHistory,useLeaveConfirm}.ts` and `leftDraft.ts` at each site of the audit + (exhaustiveness on `Record` finds them). + - `tabs.ts` and `EditorWorkspace.tsx`. +- Create `AnnotationDialog.tsx`, `AnnotationReadBody.tsx` and `AnnotationEditForm.tsx` (it renders `CreationFields` + with « Couleur » on a `CreationForm` draft, with `missingFields`; R-3). +- `tabs/AnnotationsTab.tsx`: + - The dialog is mounted beside `EditOnly`, with `readOnly`. + - The twin renders `AnnotationReadBody` and keeps `SelectionTag`. + - Delete `PropertiesPanel.tsx` and `AnnotationFields.tsx`. +- `EditableAnnotations.tsx`: the aside always shows `OverviewPanel`, with the selected row `aria-current="true"`. +- `AnnotationList.tsx`: Enter on the selected row opens the dialog. +- `focusTarget.ts` (R-5), i18n. + +**Interfaces:** + +- Opening (A1): a press-machine `open`, from the selection's interior or point, or a double click (R-8); Enter on + the selected row; the strip's « Propriétés ». A drag never opens. +- Save: + 1. Read the CURRENT annotation by id from `useEditorStore.getState().previewState.document`. + 2. Merge the changed fields. + 3. Run one `update` through `useEditCommand.run`. + 4. If the id is gone, close with the vanished-element replace and an announcement. +- Read mode: + - The fields as text; « Couleur » only when set, « Région vertébrale » only when set, and « Vue ». + - The geometry issues as an alert. + - « Modifier » and « Modifier la forme »; « Marquer comme relu » or « Remettre à confirmer » (one `set_status`, + one undo); « Supprimer » (`DeleteDialog`). +- Focus return (board 32): + - Opened by « Propriétés »: the button. + - Opened from the drawing or the list: the row, or the drawing when the row is filtered out. + - « Modifier la forme »: the dialog closes, keeps the selection and focuses the first handle. +- Read-only (R-14): the dialog stays with a notice, disabled inputs and its draft, and Save is disabled. It becomes + editable again on the way back. +- History: Back closes the dialog and Forward reopens it. + - A layer whose id no longer exists is sanitised away, and the view lands on nothing selected, with an + announcement. + - A layer for an annotation of another view switches the view and selects it. + - `{ create }` is a form: dropped on reload, and treated as vanished on any restore without a pending creation in + the work store. + +- [ ] **Step 1: failing tests.** + - `ui.Dialog.test.tsx`: + - The anchored geometry from a stubbed rect. + - The keyboard fallback from a stubbed `visualViewport` (height 350, `offsetTop` 0). + - The centred fallback. + - The veil ignores clicks when anchored; centred dialogs are unchanged. + - Layer suites (`editor-navigation`, `editor-history-entry`, `editor-history-guards`): open, close, Back, Forward, + vanished, other view, `{ create }` without a creation. + - Unit tab: + - A first click and Enter on a row only select (A1). A second click on the interior opens; with a chosen vertex + it unchooses. + - Read mode per type. + - « Marquer comme relu » gives one undo. + - Edit category and both names, then save: ONE history entry. + - A blank name shows « Saisissez le nom en anglais. » and the summary. + - « Annuler » when dirty asks; « Abandonner » writes nothing. + - The issues block on the inherited out-of-frame point. + - The twin renders the read body. + - « Aller à » focuses the row (R-5). + - Unit read-only flip: open, type, `mode` flips to read-only. The dialog is still open, Save is disabled, the draft + is kept, nothing is committed; on the way back it is editable with the draft. + - E2E: + - The dialog box lies inside the aside's x-range, starts at its top, and never overlaps the canvas box at 1 024, + 1 180 and 1 280 px. + - axe in read and edit modes. + - A typed form, then Back, asks; then « Abandonner ». + - A double click on the selected zone leaves the dialog open with no vertex added. + - A touch tap on the selected shape opens the dialog, and it stays open. + - Width crossing below 1 024 px with a typed form, and back: the draft is intact (Review Focus 3). + - `expectNoShift` around open and close. +- [ ] **Step 2:** FAIL. **Step 3:** implement. Map every removed `PropertiesPanel` and `AnnotationFields` assertion + (`editor-annotations-tab`, `editor-deselect.spec`, `editor-annotations.spec`, `editor-focus-request`, + `editor-escape`, `editor-no-loss`) in the commit body. +- [ ] **Step 4:** gates; the finding, history and leave suites green on the sandbox. +- [ ] **Step 5:** commit `feat(editor): annotation properties dialog over the column, transactional save`. + +### Task 7: Creation by placing and tracing, then the creation dialog (A4, A5, A7, A12, A15) + +**Files:** + +- Create `CreationDialog.tsx`, mounted beside `EditOnly` with `readOnly`. Delete `CreationPanel.tsx`. +- `creation.ts` (`missingFields` replaces `formProblem`), `creationAttempt.ts`, `missingFields.ts` (below), + `CreationFields.tsx` (field order: region, then zone), `usePlacement.ts`, and `KeyboardAdd.tsx`. +- `workStore.ts`: `creation` holds the pending shape and the form across « Replacer le point » and « Reprendre le + tracé ». +- The drawing guard: + - `useEditorNavigation.ts`: `useTabSelect`, the arrow-key tab move, `openSection` and the view chips ask, with + R-12 through `ConfirmDialog`. + - `history/useEditorHistory.ts`: `refusal` asks it on every POP. + - `history/useLeaveConfirm.ts`. + - `AdminSheetDraftRoute.tsx` and `SignOutButton.tsx`: `leaveGuardArmed(state) || holdsCreationWork(work)`. + - `HistoryButtons.tsx` and `useUndoShortcuts.ts`: inactive during a creation. + - `GestureMessage`: « Défaire » hidden during a creation. +- The dimming: a host attribute `data-creating` and the CSS of the other annotations. Doc first. +- i18n. ```ts -// moveStep.ts -import { round2, type Frame } from './frame' -/** R-9: one arrow = 0.5 % of the frame's longer side (0.01 at least); Shift ×10 on keys. */ -export function moveStep(frame: Frame, big: boolean): number { - const step = Math.max(0.01, round2(Math.max(frame.w, frame.h) * 0.005)) - return big ? round2(step * 10) : step -} -``` - -```ts -// missingFields.ts (replaces creation.ts formProblem) +// missingFields.ts (creation dialog and edit form) import type { CreationForm, NewKind } from './creation' export type MissingField = 'name_fr' | 'name_en' | 'category' | 'laterality' | 'opens' const blank = (v: string) => v.trim() === '' @@ -598,409 +1078,189 @@ export function missingFields(kind: NewKind, form: CreationForm): MissingField[] } ``` -```ts -// twoFingerHint.ts -export const HINT_GAP_MS = 60_000 -export interface HintMemory { lastShown: number | null; twoFingerUsed: boolean } -/** R-1: after a futile one-finger drag, at most once a minute, never after two fingers worked. */ -export function mayHintTwoFingers(memory: HintMemory, now: number): boolean { - if (memory.twoFingerUsed) return false - return memory.lastShown === null || now - memory.lastShown >= HINT_GAP_MS -} -``` +Behaviour: -```ts -// preview.ts -import type { Geometry } from '@faunosteo/core-wasm/types' -/** A geometry shown but not committed: a drag, a move mode, a slider, a redraw. */ -export interface PendingPreview { annotationId: string; geometry: Geometry; source: 'drag' | 'move' | 'size' | 'redraw' } -export type CancelReason = - | 'undo' | 'redo' | 'replace_document' | 'save_reload' | 'tab' | 'view' | 'mode' | 'second_pointer' | 'escape' -/** §2 G: every reason drops the preview and restores the stored shape; none commits. */ -export function cancelPreview(_reason: CancelReason): null { - return null -} -``` - -`cancelPreview` exists so that every call site names its reason and the table test lists them all. Its only -behaviour is that no reason commits. - -- [ ] **Step 1: failing table tests**, one file per module. These are the cases that pin the boards. - - `pressTarget`: a handle beats everything. A point drawn inside the selected zone beats the zone (board 32 row 2). - Only the selected annotation hit gives `interior`. No hit gives `empty`. Another zone overlapping the interior - gives `other`. - - `clickAction`: interior with a chosen vertex gives `unchoose`, without one `open`. A point handle gives `open`. A - vertex gives `choose_vertex`. - - `dragAction`: a touch on the interior, on empty or on another annotation gives `none` with `futile: true`. A - mouse on the interior gives `drag_shape`. The `insert` and `remove` handles never drag. - - `insertMidpoint`: the wrap from the last vertex to the first, and an out-of-range index returns null. - - `removeVertex`: returns null at 3 vertices. - - `moveVertex`: returns null for a non-finite target. - - `isNoOpMove`: true on the neighbours. - - `sizeStops` and `mostUsedSize`: on the bundled draft's views, 30 and 34 on the main view and 27 on the head - (REVUE data). A tie goes to the smaller radius. A view with no point gives null. - - `snapSize`: the reach edges. - - `sizeRange`: with and without a minimum. - - `escapeAction`: the board 32 order. - - `moveStep`: tiny and large frames, Shift. - - `missingFields`: a category already chosen is never listed (adjustment 3). A link with both names blank is - fine, with one blank names it. The fields come in form order. - - `mayHintTwoFingers`: the gap edge, and `twoFingerUsed`. -- [ ] **Step 2:** `pnpm --filter @faunosteo/app exec vitest run tests/unit/annotations.` gives FAIL. -- [ ] **Step 3:** write the modules as above. Move `useCanvasGestures` and `useMoveGesture` to `pastSlop`; keep the - 4 px mouse behaviour (the existing tests stay green). -- [ ] **Step 4:** the same run gives PASS. Then `pnpm typecheck && pnpm lint`. -- [ ] **Step 5:** commit `feat(editor): pure U2 interaction rules (slop, priority, polygon, sizes, escape)`. - -### Task 3: The fixed strip, the message line, the stable gutter - -**Files:** - -- Create `EditStrip.tsx`, `GestureMessage.tsx` and `editor/annotations/useGestureMessage.ts`. -- Modify `EditableAnnotations.tsx`: remove `ToolNotes`, `TagOf` and `TracingBar`, and mount the strip over both - columns. -- Modify `styles/index.css` (`html { scrollbar-gutter: stable; }`) and i18n. -- E2E helper `apps/app/e2e/support/layout.ts`. - -**Interfaces:** - -- Produces `EditStrip` props: - - `{ lead: StripLead; notice: StripNotice | null; commands: ReactNode }` - - `StripLead = { title: string; status?: ReviewStatus; detail: string; icon: IconName }` - - `StripNotice = { tone: 'error' | 'info'; text: string; link?: { label: string; onClick(): void } }` -- Produces `useGestureMessage()`: - - Returns `{ message, show(text, { undo: boolean, tone }), hint(text) }`. - - It subscribes to the editor store and clears on any change of the history stacks or of `documentText`. - - The 6 s timer pauses while hovered or focused. -- Produces the e2e helper `expectNoShift(page, act: () => Promise, locators)`. It records the bounding boxes - of the canvas, the strip and the aside, plus `document.scrollingElement.scrollHeight`, and sums the - `layout-shift` entries of a `PerformanceObserver({ type: 'layout-shift', buffered: false })` installed before - `act`. It asserts equal boxes and a zero sum. - -- [ ] **Step 1: failing unit tests** (`editor-annotations-tab.test.tsx`, new `describe('the strip')`). - - The strip renders the board labels per state: tool Point (« Ajouter un point », « Cliquez dans le dessin pour - placer le point »), a selected point, a selected zone (« Zone · 9 sommets »), tracing (« Fermer le tracé », - « Retirer le dernier sommet », « Annuler le tracé »), read-only (« Point · fiche en lecture seule »), and an - unmeasured view with its link. - - The strip has a fixed height class and `overflow-hidden`. - - Long names truncate before the status. - - The message: a commit through `updateGeometry` shows « Point déplacé · Défaire ». « Défaire » calls the store's - `undo` and disappears. A second commit replaces the message. An undo from the header clears it. A refusal shows - in `role="alert"` with no « Défaire ». Hover keeps it past 6 s (fake timers). - - « Retirer le dernier sommet » and Backspace remove the last tracing vertex. -- [ ] **Step 2:** FAIL. **Step 3:** implement and move the existing hint, unmeasured, no-category and no-child-view - texts into the strip notice. -- [ ] **Step 4:** e2e `editor-annotations.spec.ts`, new test « the drawing never moves ». At 1 024, 1 180 and - 1 280 px, `expectNoShift` holds around select, deselect, tool change, tracing start and close, a commit message - showing, and its 6 s expiry (clock `page.clock`). Existing tests stay green after their selectors move from the - tool line to the strip. -- [ ] **Step 5:** `pnpm typecheck && pnpm test:run && pnpm lint`, then commit `feat(editor): fixed edit strip and - message line without layout shift`. - -### Task 4: Point editing: handle, size slider, move mode, repair - -**Files:** - -- Create `HandleLayer.tsx`, `SizeSlider.tsx` and `MoveModeBar.tsx`. -- Modify `AnnotationOverlay.tsx`: it hosts `HandleLayer`, and `pointer-events` is enabled on handles only. -- Modify `useCanvasGestures.ts`: one press handler built on `press.ts` replaces `useMoveGesture`. -- Modify `uiState.ts` (`chosenVertex`, `mode: { kind: 'move'; target; preview } | null`, `size: number | null`) and - `frame.ts` (`proposePoint(frame, click, radius)`). -- Doc `docs/ANNOTATION-RENDERING.md` « Editor overlay » FIRST. - -**Interfaces:** - -- Consumes Task 2 (`pressTarget`, `clickAction`, `dragAction`, `pastSlop`, `pointSize`, `moveStep`, `preview`) and - Task 3 (`EditStrip`, `useGestureMessage`). -- Produces the ui actions `{ type: 'mode_move'; target: 'shape' | { vertex: number } }`, `{ type: 'mode_preview'; - geometry }`, `{ type: 'mode_end' }`, `{ type: 'choose_vertex'; index: number | null }` and `{ type: 'size'; - radius: number }`. -- Produces the hit reading `hitsAt(client: XY): Hit[]`. It uses `document.elementsFromPoint`, maps handles by - `data-handle` (JSON of `HandleRef`) and annotations by `annotationIdOf`, and lives in `useCanvasGestures.ts`. -- Handles carry `role="button"`, `tabindex="0"` and `aria-label` « Point {nom} », « Sommet {i} de {nom} », « Ajouter un - sommet après le sommet {i} » or « Retirer le sommet {i} ». - -- [ ] **Step 1: doc.** Update « Editor overlay »: handles and their sizes (R-13), the chosen vertex (bigger, filled, - ringed), the old place (grey dashes), the refused place (red dashes) and the move-mode target. -- [ ] **Step 2: failing tests.** - - Unit: on a selected point the strip shows the slider with stops (main view 30 and 34) and the red mark at the - core value. Arrow, Page Up and release commit once (history depth +1). A value under the mark is refused by the - core, with the message in red and the size restored. - - « Déplacer le point » enters the mode. The strip arrows move by `moveStep`, nothing is committed until - « Valider la position », which commits once. « Annuler » and Escape restore it. Undo during the mode cancels - the preview first (Review Focus 2). - - Keyboard on the focused point handle: arrows move as a series, committed once on Enter or blur. - - E2E mouse: - - Drag a point. A click on the selected point opens nothing yet (the dialog comes in Task 7; the test asserts - the selection is kept). - - Change the size by a track click (WCAG 2.5.7). - - Repair the inherited out-of-frame point of `editor-geometry.spec.ts` with the move mode, replacing the - numeric repair (Review Focus 5). A partial move is refused and restored. - - Each with `expectNoShift`. -- [ ] **Step 3:** implement. - - The new point's size is the slider's value: A5 default, and the strip slider is shown with the Point tool - before the click. - - `proposePoint` uses that radius. -- [ ] **Step 4:** `pnpm typecheck && pnpm test:run && pnpm lint`, and the e2e files touched, on the sandbox. -- [ ] **Step 5:** commit `feat(editor): point handle, size slider with core minimum, move mode`. - -### Task 5: Zone editing: vertices, « + », « − », interior drag, redraw, paths, cap - -**Files:** `HandleLayer.tsx` (vertices, insert, remove bubble), `useCanvasGestures.ts`, `usePlacement.ts` (redraw = -tracing target `replace` on any polygon; « Retirer le dernier sommet »), `EditStrip.tsx` commands, removal of -`GeometryGroup.tsx` and the field helpers of `geometryEdit.ts`, i18n. - -**Interfaces:** Consumes `polygonEdit.ts`, `HANDLE_CAP`, and the Task 4 mode and handle layer. Produces -`{ type: 'trace_pop' }`. Redraw keeps the old outline as `overlay.old` until closing is accepted. +- **Placing.** The Point tool shows a preview under the mouse pointer at the strip size; touch has no hover. + - A click creates `creation` and opens « Nouveau point » (A2) with the ghost under the light veil. + - Changing the category recolours the ghost (A4). The laterality has no default. + - « Replacer le point » hides the dialog (`dialog: false`); the next click moves the ghost and shows it again. +- **Tracing.** The zone tool: closing on the first vertex (R-11), Enter or « Fermer le tracé » opens « Nouvelle + zone ». « Reprendre le tracé » keeps the vertices and shows « Revenir aux propriétés ». +- **Créer.** `insertAnnotation` under `accept`, one undo. Then the tool returns to « Sélectionner », the new annotation + is selected (A7), the message « Point créé · Défaire » or « Zone créée · Défaire » shows, and the focus goes to + its row (board 32). +- **Abandonner.** It asks with typed text (`DiscardConfirm`), then clears the creation. The focus goes to the tool + button. +- **During a creation.** Other annotations are dimmed and unselectable. The guard sites ask (R-12), and undo is + inactive. +- **Keyboard.** The add buttons place the shape at the centre at the A5 size and open the dialog. +- **Links.** A link shows « Vue ouverte ». +- **C26.** The notice shows in the dialog (R-4). +- **Read-only flip (R-14).** The dialog stays with its form and Créer is disabled. - [ ] **Step 1: failing tests.** - - Unit: - - A click on a vertex chooses it (strip « sommet 7 choisi »). A click on the interior unchooses it. A drag of a - vertex commits one update. A release on a neighbour commits nothing. - - « + » inserts and chooses the new vertex. « − » removes it, and at 3 vertices it is disabled with « Une zone - garde au moins 3 sommets ». - - Insert and Delete on the keyboard. - - The interior drag by mouse moves the zone. « Déplacer la zone » and « Déplacer le sommet » use the Task 4 mode. - - A shape with 41 vertices shows the outline and the cap message, with no handles, and still allows the mode and - redraw. - - A path shows no handle, offers « Remplacer par un polygone », and its `d` is byte-identical after neighbour - gestures (UX_TESTS « Paths »). - - Redraw: the old outline stays during the trace. An accepted closing commits once, keeping name, category, - laterality, region, zone and status. A refusal (`interior_too_small`) keeps the trace open with its message. - Escape keeps the old shape. - - E2E mouse on the « Thoraciques » zone: drag a vertex, « + », « − », zone drag, redraw accepted and refused, and - undo for each (owner demo script), each with `expectNoShift`. -- [ ] **Step 2:** FAIL. **Step 3:** implement, then delete `GeometryGroup.tsx` and the unit cases of « a numeric - edit ». Map each removed assertion to its replacement in the commit body. -- [ ] **Step 4:** gates as in Task 4. **Step 5:** commit `feat(editor): vertex handles, insert and remove, zone move, - redraw; numeric group removed`. - -### Task 6: Dialog column placement and the annotation history layer - -**Files:** - -- `components/ui/Dialog.tsx`: - - `placement?: 'center' | { anchor: RefObject }`, default `'center'`. - - `backdrop?: 'default' | 'light'`: `bg-black/40` or `bg-[color-mix(in_srgb,var(--color-ink)_22%,transparent)]`. -- `styles/index.css`. -- Navigation and history: `navigation.ts`, `useEditorNavigation.ts`, `history/{entry,useEditorHistory,useLeaveConfirm}.ts`, - `leftDraft.ts`, `tabs.ts` and `EditorWorkspace.tsx`. - -**Interfaces:** - -- Produces `EditorView.annotation: AnnotationLayer | null`, with `type AnnotationLayer = { id: string } | { create: - NewKind }`. It is read only on tab `annotations`; `{ create }` is a form and is dropped when `forms` is false. -- Produces `LAYERS = ['annotation', 'finding', 'citations', 'reference']`. The annotation layer and the finding layer - never coexist: they belong to different tabs. -- Produces `GuardName = LayerName | 'drawing'`. - - `Guards.register` and `Guards.ask` accept `'drawing'`. - - `refusal` asks `'drawing'` on every POP while it is registered. - - `useLeaveConfirm` and `beforeunload` treat a registered `drawing` that holds work as dirty. -- Produces `EditorPlaceProps.annotationLayer`: - - `{ open(id: string): void; startCreation(kind: NewKind): void; close(forced?: boolean): boolean; replace(layer: - AnnotationLayer | null, text?: string): void }` - - These mirror `openFinding`, `startFinding`, `closeFinding` and `replaceFinding`. -- Column placement: - - The panel sits at `left = rect.left`, `width = rect.width` and `top = max(12, rect.top)` of the anchor (the aside). - - Its height is clamped to `visualViewport.height − top − 12`. It is recomputed on `resize` and on - `visualViewport` `resize` and `scroll` (the tablet keyboard). - - With no anchor box (below `lg`), the placement is centred. - - The motion origin is top. Reduced motion is kept. - -- [ ] **Step 1: failing tests.** - - `ui.Dialog.test.tsx`: the anchored geometry from a stubbed rect, the light backdrop class, the centred fallback, - and a backdrop click calling `onClose` (unchanged). - - `editor-navigation.test.ts`, `editor-history-entry.test.ts` and `editor-history-guards.test.tsx`: - - The annotation layer opens and closes with one entry. Back closes it, Forward reopens it. - - A layer for an id that no longer exists is sanitised away, and the view lands on the selection with an - announcement. - - A layer for an annotation of another view switches the view and selects it. - - `sanitizeView` keeps it only on the annotations tab. - - A `drawing` guard that refuses keeps the POP, re-pushes and shows R-12. - - E2E `expectNoShift` around a dialog open and close at 1 280 px on a classic-scrollbar page (`scrollbar-gutter`). -- [ ] **Step 2:** FAIL. **Step 3:** implement the layer at each site listed in the audit (TypeScript exhaustiveness - on `Record` finds them). **Step 4:** gates. The unit layer suites are green, and so are - `editor-history.spec.ts`, `editor-leave-confirm.spec.ts` and `editor-finding-dialog.spec.ts` on the sandbox - (findings unchanged). -- [ ] **Step 5:** commit `feat(editor): annotation history layer, drawing guard, dialog over the column`. - -### Task 7: The properties dialog (A1, A2, A3, A9, A10) - -**Files:** - -- Create `AnnotationDialog.tsx`, `AnnotationReadBody.tsx` and `AnnotationEditForm.tsx`. -- Modify `EditableAnnotations.tsx`: - - The aside always shows `OverviewPanel` with the selected row marked (`aria-current="true"`). - - The dialog is anchored to the aside. -- Modify `AnnotationList.tsx`: Enter on the selected row opens. -- Modify `tabs/AnnotationsTab.tsx`: the narrow twin uses `AnnotationReadBody`. -- Remove the edit paths of `PropertiesPanel.tsx` and the per-field commits of `AnnotationFields.tsx`; the fields - become plain controlled inputs. -- Modify `focusTarget.ts` (R-5) and i18n. - -**Interfaces:** - -- Consumes Task 6's layer and placement, `useFormDraft(initial, guards, same, 'annotation')`, `FormActions`, - `DiscardConfirm`, `useItemMode`, `useEditCommand` and `missingFields`'s edit-form twin (names only: - `editor.field.required`). -- Save: - 1. Read the CURRENT annotation from `useEditorStore.getState().previewState.document` by id. - 2. Merge the changed fields. - 3. Run one `update`. - 4. If the stored annotation changed underneath (an id gone), stop with the vanished-element replace. -- Opening (A1): `clickAction` gives `open`, from a click on the selected shape's interior or point. Also on a - double click on an annotation (`dblclick`, which selects it then opens), Enter on the selected row, and the strip's - « Propriétés ». A drag never opens. -- Focus return (board 32): - - Opened by « Propriétés »: the button. - - Opened from the drawing or the list: the row, or the drawing when the row is filtered out. - - « Modifier la forme »: the dialog closes, keeps the selection and focuses the first handle. - -- [ ] **Step 1: failing tests.** - - Unit: - - Reading mode on a point and a zone shows the fields as text. « Couleur » appears only when set, « Région - vertébrale » only when set, and « Vue » is shown. - - « Marquer comme relu » gives one undo and a message. « Remettre à confirmer » reverts it. - - « Supprimer » goes through `DeleteDialog`. - - « Modifier »: change the category and both names, save, and get ONE history entry. - - « Annuler » when dirty asks; « Abandonner » writes nothing. - - A blank name is refused on its field. - - The geometry issues block is shown in read mode for an inherited out-of-frame point. - - The narrow twin renders the same read body (ids prefixed, `editor-no-loss` case kept). - - Selection without a dialog: a first click or Enter on a row only selects (A1). - - « Aller à » focuses the row (R-5). + - Unit `missingFields`: a chosen category is never listed (adjustment 3). A link with both names blank is fine, + with one blank names it. The fields come in form order. + - Unit tab: each behaviour above. « Créer » without a laterality shows only « Choisissez une latéralité. » and + « À compléter : Latéralité. » + - Unit guards: a tab click, an arrow-key tab move, a section, a view chip, a tool, Back, Escape, sign-out and the + route leave each ask during a creation. « Continuer » keeps everything; « Abandonner » proceeds. Move mode and + redraw are cancelled silently by a tab change and by Back (R-12). + - Unit: a creation open, then the width flips to read-only and back: the form and the ghost are intact. - E2E: - - The dialog sits over the aside: its box is inside the aside's x-range and starts at its top, and it never - overlaps the canvas box at 1 024, 1 180 and 1 280 px. - - axe in read and edit modes. - - A typed form, then Back, asks; then « Abandonner ». A typed form, then a 1 024 px crossing, keeps the left - draft as the finding dialog does (Review Focus 3). - - `expectNoShift` holds. -- [ ] **Step 2:** FAIL. **Step 3:** implement. Map every removed `PropertiesPanel` and `AnnotationFields` assertion - (`editor-annotations-tab`, `editor-deselect.spec`, `editor-annotations.spec`, `editor-focus-request`, - `editor-escape`) to its replacement in the commit body. -- [ ] **Step 4:** gates and the touched e2e suites on the sandbox. **Step 5:** commit `feat(editor): annotation - properties dialog over the column, transactional save`. - -### Task 8: Creation by placing and tracing, then the creation dialog (A4, A5, A7, A12, A15) - -**Files:** - -- Create `CreationDialog.tsx`, replacing `CreationPanel.tsx`, and `CreationConfirm.tsx`. -- Modify `CreationFields.tsx` (field order: vertebral region before findings zone, as the edit form), `creation.ts` - (`missingFields`), `usePlacement.ts`, `uiState.ts` (`creation: { phase: 'placing' | 'tracing' | 'dialog' | - 'resumed' }`), `KeyboardAdd.tsx`, `HistoryButtons.tsx` and `useUndoShortcuts.ts` (inactive during a creation), - `useCanvasBuild.ts` or the host class for dimming (doc first), and i18n. - -**Interfaces:** Consumes Task 6 (`startCreation`, `drawing` guard) and Task 2 (`missingFields`, `escapeAction`). -« Créer » = `insertAnnotation` under `accept`, one undo step. Then the tool returns to « Sélectionner », the new -annotation is selected (A7), and the message « Point créé · Défaire » or « Zone créée · Défaire » shows. - -- [ ] **Step 1: failing tests.** - - Unit: - - The Point tool: a click places the point at the strip size and the dialog opens by itself with the ghost under - the light veil. - - Changing the category recolours the ghost (A4). The laterality has no default (A4). - - « Créer » with a missing laterality shows only « Choisissez une latéralité. » and the summary « À compléter : - Latéralité. », never the category (adjustment 3). A missing English name names only it. - - « Replacer le point » closes the dialog with the form kept; the next click moves the ghost and reopens the - dialog. - - The zone tool: a trace, then a close on the first vertex, Enter or « Fermer le tracé », opens « Nouvelle zone ». - « Reprendre le tracé » keeps the vertices and shows « Revenir aux propriétés ». - - « Abandonner » with typed text asks (`DiscardConfirm`). A veil click asks (R-12). - - During a creation, other annotations are dimmed and unselectable. Tab, view chip, tool, Back and Escape ask - (R-12). « Défaire » is inactive. - - The keyboard add buttons place the shape at the centre and open the dialog. - - A link uses « Vue ouverte ». - - C26: a click at the edge shows the correction notice in the dialog (R-4). - - E2E: point, zone and link created by clicks, undone and redone, then saved (`editor-annotations.spec.ts` - rewritten). Keyboard only: create a zone, add and remove a vertex, move the zone, validate (UX_TESTS - « Keyboard »). axe on the creation states. `expectNoShift` when the dialog opens. -- [ ] **Step 2:** FAIL. **Step 3:** implement and delete `CreationPanel.tsx`. **Step 4:** gates. + - Point, zone and link created by clicks, undone and redone, then saved (`editor-annotations.spec.ts` + rewritten). + - Keyboard only: create a zone, add and remove a vertex, move the zone, validate (UX_TESTS « Keyboard »). + - The C26 test of `editor-geometry.spec.ts:118` re-pointed. + - axe on the creation states. + - `expectNoShift` when the dialog opens. +- [ ] **Step 2:** FAIL. **Step 3:** implement. **Step 4:** gates. - [ ] **Step 5:** commit `feat(editor): creation on the drawing then the creation dialog`. -### Task 9: Touch: slop, one finger, two fingers, the hint, the loupe, 44 px +### Task 8: Touch: two fingers, the hint, the loupe, the sizes **Files:** -- `catalogue/useFraming.ts`: opt-in options, catalogue unchanged. - - `slopOf?: (event) => number` - - `onePointerPan?: (event) => boolean`, which replaces `canPan`; the old name stays as an alias until the last - caller moves. - - `twoPointerPan?: boolean`: the pinch also translates by the midpoint's movement. -- `useCanvasGestures.ts`, `Loupe.tsx` (technique from Task 0), `HandleLayer.tsx` (R-13 sizes), - `useGestureMessage.ts` (R-1). - -**Interfaces:** Consumes `dragAction(...).futile` and `mayHintTwoFingers`. The editor passes `onePointerPan: (e) => -pointerKindOf(e.pointerType) !== 'touch'` and `twoPointerPan: true`. +- `catalogue/useFraming.ts`: `twoPointerPan?: boolean`. The pinch branch also translates by the midpoint's + movement. The catalogue passes nothing and keeps today's behaviour. +- `useCanvasGestures.ts`: `twoPointerPan: true`; the hint on a `futile` drag. +- `Loupe.tsx`: + - Technique A: at a touch-drag start, clone the drawing's `` once (`aria-hidden`, `inert`) into a 120 px + disc 90 px above the finger, clamped inside the box, ×2 around the finger, with the preview outline on top. + - Technique B: the outline and handles only. +- `HandleLayer.tsx`: R-9 sizes from `(any-pointer: coarse)`. - [ ] **Step 1: failing tests.** - - Unit `useFraming`: the defaults are unchanged (catalogue tests green). With `twoPointerPan`, two pointers moving + - Unit `useFraming`: the defaults are unchanged (catalogue suites). With `twoPointerPan`, two pointers moving together translate without scaling. - - Unit hint: a futile drag shows R-1 once. A second within 60 s shows nothing. After a two-finger pan, it never - shows again. - - E2E touch (`hasTouch`, 1 024, 1 180 and 1 280 px, CDP `Input.dispatchTouchEvent`): - - One finger drags a vertex and a point, with the loupe visible during the drag. + - Unit hint: a futile drag shows R-1 when the line is free, never while a message shows, and never again after a + two-finger gesture worked. + - E2E touch (`hasTouch`; 1 024, 1 180 and 1 280 px; CDP `Input.dispatchTouchEvent`): + - One finger drags a vertex and a point, with the loupe shown. - One finger off the handles moves nothing and shows the hint once. - Two fingers zoom and pan. - - Finger 1 on a vertex then finger 2 elsewhere: the drag is cancelled, the shape restored, nothing committed, and - the pinch zooms (Review Focus 1). - - The explicit move mode by a finger. - - A tap on the selected zone opens the dialog; a tap with a chosen vertex unchooses it. - - Page scroll over the canvas without a selection keeps working (UX_TESTS). - - Every handle hit circle is ≥ 44 px (measured on boxes). - - `expectNoShift` at the hint's show and hide. -- [ ] **Step 2:** FAIL. **Step 3:** implement. **Step 4:** gates. **Step 5:** commit `feat(editor): touch gestures, - two-finger pan, hint and loupe`. + - Finger 1 on a vertex then finger 2: the drag is cancelled, the shape restored, nothing committed, and the + pinch zooms (Review Focus 1). + - The move mode by a finger. + - A tap on the selected zone opens the dialog; with a chosen vertex it unchooses. + - The trace closes from a finger within 22 px. + - Page scroll over the canvas without a selection keeps working. + - Every handle hit circle is at least 44 px. + - `expectNoShift` at the hint. + - E2E smoothness on the editor itself: Chromium touch at 1 180 px, CPU ×4 (CDP + `Emulation.setCPUThrottlingRate`), a 2 s vertex drag on the equine main view. The p95 of pointermove to next + frame is under 16 ms, loupe included. If technique A fails and B passes, STOP for the conditional owner + decision. +- [ ] **Step 2:** FAIL. **Step 3:** implement. **Step 4:** gates. +- [ ] **Step 5:** commit `feat(editor): two-finger pan, touch hint, loupe, touch-sized handles`. -### Task 10: Documents realigned +### Task 9: Documents realigned **Files:** - `docs/development/V1-2-6_UX_TESTS.md` §U2, rewritten to this plan: the dialog, A11, A12, the three adjustments, - « Défaire » in place of the toast's « Annuler », 6 s. -- `docs/development/V1-2-6_UX_PLAN.md` §U2: the file list, a 6 s message in place of « stays until closed », and - the status. -- `docs/ANNOTATION-RENDERING.md`: already updated in Tasks 4, 5 and 8; read again whole. -- `docs/development/RUST.md`: the size figures and the Part II exception row. -- `docs/development/RUST_ARCHITECTURE_REVIEW.md` Part II: the row. -- `docs/design/README.md`: the U2 status. -- `CLAUDE.md`: folder lines for the new components. + « Défaire » in place of the toast's « Annuler », 6 s, about 47 undo steps. +- `docs/development/V1-2-6_UX_PLAN.md` §U2: the file list, the message, the status. +- `docs/ANNOTATION-RENDERING.md`: read again whole. +- `docs/development/RUST.md`: the size figures and the exception row. +- `RUST_ARCHITECTURE_REVIEW.md` Part II: the row. +- `docs/design/README.md`. +- `CLAUDE.md`: folder lines. -- [ ] **Step 1:** write. **Step 2:** grep for the removed names (`GeometryGroup`, `TracingBar`, `CreationPanel`, - `required.fields`, `toast`) in `docs/`, `CLAUDE.md` and `.claude/rules/`, and fix every citer. **Step 3:** commit - `docs(docs): U2 tests, plan, rendering and Rust review aligned`. +- [ ] **Step 1:** write. **Step 2:** grep the removed names (`TracingBar`, `CreationPanel`, `PropertiesPanel`, + `AnnotationFields`, `useMoveGesture`, `required.fields`, `toast`) in `docs/`, `CLAUDE.md` and `.claude/rules/`, + and fix every citer. +- [ ] **Step 3:** commit `docs(docs): U2 tests, plan, rendering and Rust review aligned`. -### Task 11: Gates and the owner checkpoint +### Task 10: Gates and the owner checkpoint -- [ ] **Step 1:** `pnpm check:all` (rust:check, types drift, wasm:build, check, app image, worker:test, - worker:image). Record the exact output lines. -- [ ] **Step 2:** sandbox `pnpm db:sandbox up fresh`, `test-db`, `e2e-shell` (the whole shell suite), then `test`. +- [ ] **Step 1:** `pnpm check:all`. Record the exact output lines. +- [ ] **Step 2:** sandbox `pnpm db:sandbox up fresh`, `test-db`, `e2e-shell` (whole shell suite), then `test`. Record the counts. -- [ ] **Step 3:** performance: commit latency under 500 ms for a vertex drag, an insert and a removal - (`editor-equine.spec.ts` budget, through its sandbox alias). -- [ ] **Step 4:** fresh `verifier` against the U2 implementation contract (written at the start of execution from - this plan, with the owner's approval brief verbatim), and fresh `security-auditor` on the U2 diff. Both run once. +- [ ] **Step 3:** commit latency under 500 ms for a vertex drag, an insert and a removal (`editor-equine.spec.ts` + through its sandbox alias). +- [ ] **Step 4:** fresh `verifier` against the U2 implementation contract (written at the start of execution with + the owner's approval brief verbatim), and fresh `security-auditor` on the U2 diff, once each. - [ ] **Step 5:** owner demo script in `docs/development/V1-2-6_OWNER_TRIAL.md` U2, on the sandbox demo sheet. - Mouse: move a point, change its size, drag a vertex of « Thoraciques », add and remove a vertex, move the zone, - redraw it and cancel, open and edit the properties, undo each step. - - The same on a tablet in landscape, with the two-finger hint and the loupe. + redraw it and cancel, open and edit the properties, create a point and a zone, undo each step. + - Tablet in landscape: the same, plus the two-finger hint, the loupe, and a rotation with a dialog open. - Watch for no jump when a message appears. -- [ ] **Step 6:** STOP for the owner's checkpoint (mouse and tablet). Capitalize per the project's closing flow. +- [ ] **Step 6:** STOP for the owner's checkpoint (mouse and tablet). Capitalize per the closing flow. ## Out of scope, tracked -- Curves (curve handles, path editing): the curves lot (T16). A path only gets « Remplacer par un polygone ». -- The « Constats » part of the annotation dialog: U2b (F1 to F22), where the dialog receives it. -- The category colour picker: U3 and U6 (A9 keeps the hex field). -- Phone editing: O14 A, read-only below 1 024 px. -- Firefox and WebKit runs: a follow-up as in R2; Chromium only until V1-5. -- BLK-015, RR-13 and anomalies A and B: separate tracks. +- Curves: the curves lot (T16). A path only gets « Remplacer par un polygone ». +- The « Constats » part of the annotation dialog: U2b. +- The colour picker: U3 and U6 (A9 keeps the hex field). +- `RepairDialog`'s coordinate fields: U5 (D1 recommendation). +- Phone editing: O14 A. +- Firefox and WebKit: a follow-up, Chromium only until V1-5. +- BLK-015, RR-13, anomalies A and B: separate tracks. -## Task 0 results +## Challenge round (2026-11-17, three fresh `plan-challenger` agents, read-only, on rev 1) -Empty until Task 0 runs. +### Correctness: FATAL(9) -## Challenge round +| # | Finding | Rev 2 | +|---|---|---| +| 1 | `GeometryGroup` deleted while `RepairDialog`, `CreationPanel` and `PropertiesPanel` import it | Accepted: kept for `RepairDialog` (D1); removed from the panels in Tasks 4, 6 and 7 | +| 2 | A5 radius reaches only `proposePoint` | Accepted: radius passed through `correctedCircle`, `centreCircle`, `pendingForClick`, `keyboardPending`, `correction.ts` (R-10, Task 4) | +| 3 | Any other annotation in the stack beats the interior | Accepted: topmost annotation decides (`pressTarget`) | +| 4 | First handle in DOM order | Accepted: `nearestHandle`, ranked ties | +| 5 | Mouse pan during a handle or interior drag | Accepted: `canPan` = `dragAction(...).type === 'pan'` (Task 2) | +| 6 | A double click opens then closes, or inserts | Accepted: R-8 double click, R-6 veil ignores clicks | +| 7 | No site asks for a tab change | Accepted: `useTabSelect`, the arrow-key tab move, `openSection` and the view chips (Task 7) | +| 8 | Arrows on a handle also pan | Accepted: framing keys only on the box itself (Task 2) | +| 9 | Three slop measures | Accepted: the press machine is the editor's only decider (Task 2) | +| 10 | `trace_pop` and the file lists out of order | Accepted: `trace_pop` and `focusTarget.ts` in Task 3, `creationAttempt.ts` and `creation.ts` listed | +| 11 | Undo with a pending preview acts twice | Accepted: R-13, undo cancels only | +| 12 | Escape lacks a pending row; `dragAction` lacks inputs | Accepted: `drop_preview` row; `movable` and `moveMode` | +| 13 | Message « Défaire » live during a creation | Accepted (R-2, Task 7) | +| 14 | Focusable handles in an `aria-hidden` svg | Accepted: `HandleLayer` has its own svg | +| 15 | Range bound from `defaultRadius` | Accepted: `sizeRange` | +| 16 | Generic required key in the edit form | Accepted: shared `missingFields` (R-3) | +| 17 | Pointer preview and two focus returns missing | Accepted (Task 7) | +| 18 | `{ create }` reached by Forward without a shape | Accepted: treated as vanished (Task 6) | +| 19 | Classic-scrollbar test vacuous in headless | Accepted: computed style and `clientWidth` asserted | -Empty until the three fresh challenges have run on rev 1. +### Robustness: FATAL(9) + +| # | Finding | Rev 2 | +|---|---|---| +| 1 | Dialogs inside the hidden editable subtree on a read-only flip | Accepted: mounted beside `EditOnly` with `readOnly` (R-14); Review Focus 3 rewritten | +| 2 | Drawing work invisible to leave, sign-out, tabs and undo | Accepted: `workStore`, read by every site (Task 7) | +| 3 | Stale previews and chosen vertex | Accepted: stamps, `dropStale`, R-13 | +| 4 | Press at pointer-up vs click; three deciders; pinch ends as a click | Accepted: press machine with `multi`; veil ignores clicks (R-6) | +| 5 | Paint order | Accepted (as correctness 3) | +| 6 | Overlapping handles, « + » on a plain click | Accepted: nearest handle, « + » hidden on short segments, double click guarded | +| 7 | Forward onto `{ create }` | Accepted (as correctness 18) | +| 8 | Tablet keyboard breaks the anchored height | Accepted: `visualViewport` fallback under 320 px, tested | +| 9 | Smoothness never measured on the page; per-move state at the tab root | Accepted: canvas-local drag, store selector for previews, p95 e2e on the editor (Task 8) | +| 10 | Hybrid devices | Accepted: `(any-pointer: coarse)` read once, no element re-creation | +| 11 | Scrollbar test vacuous | Accepted (as correctness 19) | +| 12 | `expectNoShift` false passes | Accepted: two frames, every entry, header box | +| 13 | Message sticks on touch | Accepted: mouse-only hover pause | +| 14 | Trace close under the finger slop | Accepted: R-11 in CSS px per kind | +| 15 | R-6 heap; Back in a mode | R-6 dropped (8 MiB kept, R-15); Back in a mode cancels it (R-12) | + +### Simplicity: CONCERNS(5) + +| # | Finding | Rev 2 | +|---|---|---| +| 1 | Three click deciders | Accepted (Task 2) | +| 2 | `preview.ts` no-op | Accepted: deleted; stamps in `workStore` | +| 3 | Two field components | Accepted: `AnnotationEditForm` renders `CreationFields`, one `missingFields`, `AnnotationFields` deleted | +| 4 | `drawing` guard too wide | Accepted: creations only (R-12) | +| 5 | Task split | Accepted: pure modules land with their first consumer; `trace_pop` in Task 3; loupe built and measured in Task 8; no Task 0 | +| 6 | `creation.phase` restates state | Accepted: `creation.dialog` boolean only, form lifted to the store | +| 7 | `canPan` rename churn | Accepted: name kept | +| 8 | `CreationConfirm` duplicates `ConfirmDialog` | Accepted | +| 9 | Dialog change too wide | Partly: one `anchor` prop implying the light veil. The `visualViewport` fallback is kept, because robustness 8 shows the plain `max-h` fails with the tablet keyboard | +| 10 | Page-wide gutter, page-wide shift sum | Gutter scoped to the editor. The page-wide sum is kept with the header box (robustness 12) | +| 11 | R-6 and Task 0 step 2 unasked | Accepted: dropped | +| 12 | Last-press switch | Accepted: `(any-pointer: coarse)` | +| 13 | Hint clock and queue | Accepted: no clock | +| 14 | One-liner modules; Escape wiring unnamed | Accepted: `moveStep` in `frame.ts`, the radius read inline, `escapeAction` wired into `useEscapeDeselect` | +| 15 | `SelectionTag` and `PropertiesPanel` for the twin | Accepted: `SelectionTag` kept, `PropertiesPanel` deleted | +| 16 | `sizeRange` | Accepted |