diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index f6c503ed..61632265 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -1003,3 +1003,10 @@ Alternatives: write-now + delete on abandon (two undo steps, rejected); fold exi **Rationale:** selection without dialog keeps successive shape corrections cheap; skeleton stays visible; list stays keyboard path. **Alternatives:** orientation rules 1 and 6 literal (dialog per click), dialog over drawing, column removed (rejected by owner choice). **Next:** U2 technical plan + challengers, owner gate before code. No merge, DEV unchanged. + +## BDR-123 — U2 plan validated: D1 repair coords until U5, D2 zoom hint, mode guard when started (2026-11-17) (2026-11-17) +- **Status**: accepted +**Decision:** U2 plan rev 2 validated by owner 2026-11-17, implementation authorised (plan rev 3, contract `2026-11-17-v1-2-6-u2-implementation.md`). D1: RepairDialog keeps coordinate fields until U5; A8 = normal annotation journey only. D2: « + » hidden on segments too short at current zoom, zoom reveals; while selected zone has hidden « + », strip shows discreet « Zoomez pour ajouter un sommet sur les segments courts. » (R-18). R-12 corrected: move mode / redraw end at once on navigation when nothing started; ask (« Abandonner le déplacement ? » / « … nouveau tracé ? ») once position changed or vertex placed; « Annuler », Escape = explicit, immediate. No silent loss: read-only flip suspends started mode; document change elsewhere dropping it is announced. Confirmed: veil ignores clicks, double-click opens, strip/messages no shift, read-only keeps properties readable, touch/loupe/gestures; A13, A14, board 33 as integrated. +**Rationale:** precision without accidental insert; no silent loss of started work. +**Alternatives:** RepairDialog redone in U2 (rejected: rare, redesign of decision 7); all « + » always shown (rejected: mis-tap inserts); silent cancel of modes (corrected by owner). +**Next:** execute plan Tasks 1-10; owner trial on `pnpm db:trial` before U2 closure. No merge, DEV unchanged. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index cd8737ac..2c5d18aa 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -744,7 +744,8 @@ 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 · [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 + - [x] 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) · [x] owner approval 2026-11-17 (rev 2 + D1, D2 with zoom hint R-18, R-12 corrected) → rev 3, BDR-123 + - [ ] V1-2.6 UX U2 implementation (contract `.claude/tasks/contracts/2026-11-17-v1-2-6-u2-implementation.md`, plan rev 3, subagent-driven): [ ] T1 core min radius · [ ] T2 press machine · [ ] T3 strip + message, no shift · [ ] T4 points, move mode, guard · [ ] T5 zones, redraw, R-18 · [ ] T6 properties dialog · [ ] T7 creation · [ ] T8 touch, loupe · [ ] T9 docs · [ ] T10 gates, verifier, security · [ ] STOP owner trial on `pnpm db:trial` before closure - [ ] 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/contracts/2026-11-17-v1-2-6-u2-implementation.md b/.claude/tasks/contracts/2026-11-17-v1-2-6-u2-implementation.md new file mode 100644 index 00000000..7b33e71e --- /dev/null +++ b/.claude/tasks/contracts/2026-11-17-v1-2-6-u2-implementation.md @@ -0,0 +1,268 @@ +# CONTRACT — v1-2-6-u2-implementation +- date: 2026-11-17 | flow: implementation of U2 (direct manipulation of annotations, properties dialog) | + branch: feature/v1-2-anatomical-sheets +- status: open +- plan: `.claude/tasks/plans/2026-11-17-v1-2-6-u2.md` (rev 3, validated 2026-11-17) +- base: 838ae42. Commit in place, pushed by the hooks; no merge, no `gitflow.sh finish`. +- worktree: /home/bchanot/Documents/faunosteo-v1-2. Every command runs from this absolute path, checked first + (LRN-110). Never DEV: the `supabase_*_faunosteo` containers are DEV. Database work goes through `pnpm db:sandbox` + only. Claude writes nothing on the trial stack (`pnpm db:trial`), which is the owner's. +- untracked file kept: `faunosteo-v1-2-6-revue-ux-chatgpt.md`. + +## REQUEST (verbatim — IMMUTABLE) + +### Owner brief 2026-11-17 (U2 design validated, technical plan requested) + +J'ai fait examiner l'archive graphique U2 par ChatGPT. + +La revue graphique est favorable. Je valide les neuf maquettes ainsi que les arbitrages A1 à A15, y compris les trois écarts A1, A2 et A3 par rapport à l'orientation initiale. + +En particulier : + +- A1 : le premier clic sélectionne l'annotation sans ouvrir de modale. Un deuxième clic, un double-clic ou le bouton « Propriétés » ouvre la modale. La création ouvre automatiquement la modale après le placement du point ou la fermeture du tracé. +- A2 : la modale des propriétés s'affiche sur la colonne de droite pour préserver la visibilité du squelette. +- A3 : la colonne de droite reste présente avec les vues, catégories et annotations. +- A4 à A15 : les propositions des maquettes sont acceptées. + +Trois ajustements mineurs sont demandés : + +1. A13 : rendre compréhensible le déplacement du dessin à deux doigts sur tablette, avec une indication discrète et contextuelle. Ne pas surcharger l'interface. + +2. A14 : s'assurer que l'apparition et la disparition des messages comme « Point déplacé · Défaire » ne provoquent aucun déplacement ni redimensionnement du schéma. + +3. Planche 33 : rendre les messages de validation cohérents avec les champs réellement manquants. Si la catégorie est déjà sélectionnée, le message ne doit pas demander de la choisir à nouveau. + +Ces ajustements ne nécessitent pas de refaire l'ensemble des maquettes. + +Tu peux considérer la conception graphique U2 comme validée et poursuivre avec la préparation du plan technique U2, selon ton processus habituel. + +Je te laisse autonome sur l'architecture, les choix techniques, les tests, les relectures et l'organisation des travaux. + +L'objectif reste une édition anatomique fluide, précise et intuitive, aussi bien à la souris qu'au toucher, sans perte de données et sans déplacement intempestif de l'interface. + +Présente-moi le plan technique et les éventuels arbitrages réellement nécessaires avant l'implémentation. + +### Owner brief 2026-11-17 (U2 plan rev 2 validated, implementation authorised) + +Je valide le plan technique U2 en révision 2, avec les décisions suivantes. + +D1 : VALIDÉ. +Conserver les coordonnées dans le dialogue exceptionnel de réparation des dessins jusqu'à U5. + +La suppression des champs de coordonnées prévue en A8 concerne le parcours normal d'édition des annotations. Il n'est pas nécessaire de refaire le dialogue de réparation dans U2. + +D2 : VALIDÉ, avec une précision UX. +Masquer les boutons « + » lorsque les segments sont trop courts pour être manipulés correctement. + +Le zoom doit permettre de les faire apparaître et de les utiliser. + +En revanche, lorsqu'une zone est sélectionnée et que ses segments sont trop courts, prévoir une indication discrète permettant de comprendre qu'il faut zoomer pour ajouter un sommet. + +L'objectif est d'éviter les insertions accidentelles sans rendre la fonction incompréhensible. + +J'ai également une correction à apporter à l'une des règles R-1 à R-17. + +Le plan indique que Retour ou un changement d'onglet annule automatiquement les modes Déplacer et Redessiner, sans confirmation. + +Je souhaite distinguer deux situations : + +- Aucune manipulation commencée : annulation immédiate, sans confirmation. +- Position déjà modifiée ou nouveau tracé commencé, mais pas encore validé : demander confirmation avant d'abandonner. + +Cette règle doit rester cohérente avec nos décisions précédentes sur la protection des modifications en cours et l'absence de perte silencieuse. + +Les autres choix visibles du plan me conviennent : +- clic sur le voile sans fermeture ; +- double-clic pour ouvrir les propriétés ; +- bandeau et messages sans déplacement du schéma ; +- lecture seule avec propriétés consultables ; +- gestion du toucher, de la loupe et des gestes. + +Je valide également les trois ajustements A13, A14 et planche 33 tels que tu les as intégrés. + +Tu peux finaliser le contrat d'implémentation, intégrer ces décisions et commencer U2 selon ton orchestration habituelle. + +Je te laisse autonome sur les détails techniques, les relectures, les tests et l'organisation des tâches. + +L'objectif est de livrer une manipulation directe des annotations fluide, précise, accessible et sans perte silencieuse de travail. + +Je souhaite pouvoir essayer le résultat sur db:trial avant la clôture définitive de U2. + +## CLARIFICATIONS +- Graphic reference: boards `docs/design/v1-2-6-u2/` 02 to 06, 13, 31, 32 and 33 with `REVUE.md` and + `ARBITRAGES.md` (A1 to A15 validated, three adjustments, BDR-122). Boards 14 and 16 (phone, read-only) unchanged. +- The plan's recorded choices R-1 to R-18 bind, as validated, with the owner's correction of R-12 (move mode and + redraw: immediate end when nothing was started, a question once work has started) and the D2 precision (R-18). +- Reading of the R-12 correction: the owner names Back and a tab change. The rule applies to every navigation that + would drop the mode: Back, a tab, a section, a view chip, a tool, sign-out and leaving the editor. « Annuler », + « Annuler le tracé » and Escape are explicit cancels drawn on board 32 (row 4) and act at once. +- No silent loss, applied beyond the navigation sites: + - A read-only flip suspends a started mode instead of dropping it (R-14). + - A document change made elsewhere (reload, recovery, save refresh) that drops a started mode says so (R-13). +- D1: `RepairDialog` keeps its coordinate fields until U5. A8 governs the normal annotation editing journey. +- Rust by default: the new TypeScript modules are listed in R-17 and in the review's Part II exception table. +- Owner trial: on `pnpm db:trial` before U2 closes. U2 adds no migration. The owner runs `db:trial start` and + `db:trial app`; Claude writes nothing there. + +## ACCEPTANCE CRITERIA + +### Core + +1. **Minimum point radius.** `PreviewState.min_point_radius` gives, for each view with a usable frame and a minimum, + the smallest radius that passes `TooSmall`, rounded up to 0.01. It is absent when the preview scale is at least + 1. + - Rust tests cover the equine values (about 26.50 on the main view, 15.98 on the head) and the edge frames. + - Property: `r = value` passes and `r = value − 0.01` gives `TooSmall`. + - The ts-rs types are committed, and the wasm gzip figure and its delta are recorded in `RUST.md`, within + 600 000 B. + +### Press and handles + +2. **Press machine.** One press machine is the editor's only click, drag and tap decider. + - Slop: 4, 6 and 10 CSS px for mouse, pen and finger, measured as displacement. + - A second pointer cancels the press: no click, no commit, and the pinch zooms. + - The topmost annotation decides; the nearest handle wins, with ranked ties. + - A double click (400 ms, 8 px) opens the properties and never acts on a handle. + - The catalogue's behaviour is unchanged. + - Table-tested (`stepPress`, `pressTarget`, `nearestHandle`, `clickAction`, `dragAction`, `isDoubleClick`), plus + e2e mouse and touch. +3. **Arrow keys.** They pan only when the canvas box itself has the focus. On a focused handle they move the handle + as a series: one commit on Enter or blur, none on Escape. + +### Strip, messages, layout + +4. **Strip.** One fixed-height strip above the drawing and the column replaces the tool line, the selection tag (in + the edit body) and the tracing bar. Its labels per state come from REVUE's table and R-1 to R-18. +5. **No layout shift (A14).** The boxes of the canvas, the strip, the aside and the header, the scroll height and + the client width are unchanged, with a zero layout-shift sum, around: + - select, deselect, tool change, tracing steps, the first commit, + - a message showing and expiring, the hint, + - dialog open and close, mode entry and exit. + + This is checked at 1 024, 1 180 and 1 280 px. The editor carries `scrollbar-gutter: stable`, asserted as a + computed style. +6. **Message line.** It reads « Point déplacé · Défaire » and the like, lasts 6 s, pauses on mouse hover only, and + is closed by any commit, undo or redo. Its « Défaire » is the header's undo and is hidden during a creation. It + is a polite live region; a refusal is an alert with no « Défaire ». +7. **Two-finger hint (A13, R-1).** « Deux doigts pour déplacer ou zoomer le dessin » / « Use two fingers to move or + zoom the drawing » shows after a futile one-finger drag, only when the line is free, and never again in the visit + once a two-finger gesture has worked. + +### Points and zones + +8. **Points.** + - The handle drags at any pointer. + - The size slider has the view's stops, the red mark at the core minimum and the R-10 range. It commits once on + release, Enter or blur. + - A new point takes the most used size (A5) on every path: click, C26 and keyboard. + - « Déplacer le point » opens the move mode: four arrows, « Valider la position » commits once, « Annuler » and + Escape restore. + - The inherited out-of-frame point is repaired through the move mode, with no coordinate field. +9. **Zones.** + - Vertex choose and drag, « + » (midpoint, new vertex chosen), « − » (disabled at 3 with its reason), Insert and + Delete. + - The interior drag works by mouse and pen; « Déplacer la zone » and « Déplacer le sommet » use the mode, with a + finger or the arrows. + - « Redessiner » keeps the old outline until it is accepted, makes one commit, and keeps the trace open on a + refusal. + - Above 40 vertices, the outline and the message. + - A path keeps its `d` byte-identical and gets « Remplacer par un polygone » only. +10. **« + » and zoom (D2, R-18).** A « + » shows only when its segment is at least two hit radii long on screen, + and zooming reveals it. While a selected zone has a hidden « + », the strip shows « Zoomez pour ajouter un + sommet sur les segments courts. » / « Zoom in to add a vertex on short segments. » This line is not timed and + yields to a refusal or an issue. Insert stays available on the keyboard. + +### Dialogs + +11. **Properties dialog (A1, A2, A3, A9, A10).** + - Opening: a first click or Enter on a row only selects. A second click on the selection (with no vertex + chosen), a double click, Enter on the selected row or « Propriétés » opens it. A drag never opens it. + - Placement: over the right column at its width and top, never over the canvas box at 1 024, 1 180 and + 1 280 px, under a 22 % veil that ignores clicks; with the tablet keyboard, the `visualViewport` fallback. + - Read mode first. « Couleur » appears only when set. « Marquer comme relu » is one undo. + - Edit mode is transactional: one save is one undo step, built from the current stored annotation. « Supprimer » + goes through `DeleteDialog`. + - The focus returns as board 32 says. The aside always shows the overview, with the selected row marked. + - It is an `annotation` history layer: Back closes it, Forward reopens it, a vanished id is sanitised away, and + another view's id switches the view. +12. **Creation (A4, A5, A7, A12, A15).** + - The point preview follows the pointer. A click or a closed trace opens « Nouveau point » or « Nouvelle zone » + by itself, with the ghost visible. + - The category is prefilled and recolours the ghost; the laterality has no default. + - « Replacer le point » and « Reprendre le tracé » keep the form. + - « Créer » is one insert. Then: « Sélectionner », the new annotation selected, its message, and the focus on + its row. + - « Abandonner », ✕, Escape and Back always ask (the shape exists). + - During a creation, the others are dimmed and unselectable, and undo is inactive. + - The keyboard add buttons place the shape and open the dialog. A link uses « Vue ouverte ». The C26 notice + shows in the dialog, without numbers. +13. **Validation messages (board 33).** Only the missing fields are named, under each field, with the summary + « À compléter : … » in form order. A chosen category is never asked for again. The general line + `editor.annotations.required.fields` is gone. The creation and the edit form share `missingFields`. + +### No silent loss + +14. **Guards (R-12, owner correction).** + - A creation asks before a tab, a section, a view chip, a tool, Back, Escape, sign-out and leaving the editor. + - A move mode or a redraw ends at once on those navigations while nothing is started. Once the position + differs or a vertex is placed, it asks « Abandonner le déplacement ? » or « Abandonner le nouveau tracé ? ». + - « Annuler », « Annuler le tracé » and Escape cancel a mode at once. + - « Continuer » always keeps the work intact. +15. **Pending work.** + - An undo while a move mode, a slider or a keyboard series is pending only cancels that preview (R-13). + - Previews and the chosen vertex are stamped with the document text. A stale one never commits; it is dropped, + and announced when it was a started mode. + - After undoing « + », « − » removes nothing stale. +16. **Read-only flip (R-14).** A crossing below 1 024 px, a refusal or a refresh keeps an open dialog in read-only + form with its draft, and nothing commits. It suspends a started mode. Both resume on the way back. +17. **Read-only sheet (R-16).** At 1 024 px and wider: the strip in read-only form, « Propriétés » opening the + read-only dialog, the overview kept, no handle, no slider. Below 1 024 px, boards 14 and 16 are unchanged. + +### Accessibility and touch + +18. **Accessibility.** + - Handles are focusable outside any `aria-hidden` subtree, with names such as « Sommet 3 de Thoraciques ». + - Every drag has a non-drag path (WCAG 2.5.7): move mode arrows, a track click, « + » and « − » clicks, + « Redessiner ». + - axe passes on the selection, tracing, move, creation and dialog states. + - The touch hit circles are at least 44 px on a coarse pointer. +19. **Touch.** + - One finger on a handle drags it, with the loupe. + - One finger elsewhere moves nothing. + - Two fingers zoom and pan. + - A finger closes a trace within 22 px. + - Page scroll over the canvas without a selection still works. + - The smoothness measure (p95, CPU ×4, 1 180 px) is recorded in the plan. If only the loupe without the drawing + is acceptable, STOP for the owner. + +### Scope, gates, process + +20. **Scope.** + - `RepairDialog` keeps `GeometryGroup` (D1). No other coordinate field remains in the annotation journey. + - `PropertiesPanel.tsx`, `AnnotationFields.tsx`, `CreationPanel.tsx`, `TracingBar.tsx` and `useMoveGesture.ts` + are deleted; every removed assertion is mapped in its commit body. + + CHECK: cd /home/bchanot/Documents/faunosteo-v1-2/apps/app/src && test ! -e components/editor/annotations/PropertiesPanel.tsx && test ! -e components/editor/annotations/AnnotationFields.tsx && test ! -e components/editor/annotations/CreationPanel.tsx && test ! -e components/editor/annotations/TracingBar.tsx && test ! -e editor/annotations/useMoveGesture.ts && [ "$(grep -rl "GeometryGroup" --include=*.tsx . | grep -v "annotations/GeometryGroup.tsx" | sort | tr '\n' ' ')" = "./components/editor/views/RepairDialog.tsx " ] && echo SCOPE_OK + + EXPECT: SCOPE_OK +21. **Documents.** All aligned as built: + - `docs/ANNOTATION-RENDERING.md` « Editor overlay », updated before the rendering changes. + - `V1-2-6_UX_TESTS.md` §U2 and `V1-2-6_UX_PLAN.md` §U2. + - `RUST.md` (size, exception row) and `RUST_ARCHITECTURE_REVIEW.md` Part II. + - `docs/design/README.md` and `CLAUDE.md` folder lines. + - `V1-2-6_OWNER_TRIAL.md` §4.17 « Démonstration U2 », in French, on `pnpm db:trial`. +22. **Gates.** Typecheck, lint, the app unit suite, build, `pnpm rust:check`, `pnpm wasm:build` and the size test. + `pnpm check:all` exits 0 at the final head. The sandbox runs `up fresh → test-db → e2e-shell → test` with exact + counts recorded. The commit latency stays under 500 ms for a vertex drag, an insert and a removal. No failed + suite is called green. +23. **Reviews.** A fresh verifier against this contract, and a fresh security auditor on the U2 diff, once each + before the checkpoint. Their exact results are recorded. +24. **Process.** No merge, no deploy, DEV unchanged, no write on the trial stack. U2 closes only after the owner's + trial on `pnpm db:trial`. + +## FILE SCOPE +crates/core/src/anatomy/frame.rs, crates/core/src/domain/sheet/preview.rs, crates/core/tests/**, +packages/core-wasm/types/**, packages/core-wasm/tests/**, apps/app/src/{editor/**,components/editor/**, +components/ui/Dialog.tsx,catalogue/useFraming.ts,app/routes/app/admin/AdminSheetDraftRoute.tsx, +components/shell/SignOutButton.tsx,styles/index.css,i18n/fr.ts,i18n/en.ts}, apps/app/tests/**, apps/app/e2e/**, +docs/**, CLAUDE.md, CHANGELOG.md, .claude/tasks/**, .claude/memory/* 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 9246bd54..c3d3afb3 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,10 +1,14 @@ -# U2 Direct Manipulation of Annotations Implementation Plan (V1-2.6), rev 2 +# U2 Direct Manipulation of Annotations Implementation Plan (V1-2.6), rev 3 > **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 2, NOT validated. Waits for the owner's approval and the answers to D1 and D2. No U2 code before both. DEV -unchanged, no merge. +**Status:** VALIDATED by the owner, 2026-11-17 (brief « Je valide le plan technique U2 en révision 2 »). D1 validated. +D2 validated with a precision: a discreet hint tells the user to zoom to add a vertex (R-18). R-12 is corrected: a +move mode or a redraw with work started asks before Back or a tab drops it. A13, A14 and the board 33 adjustment +are validated as integrated. Implementation authorised. The owner tries the result on `pnpm db:trial` before U2 +closes. DEV unchanged, no merge. Rev 3 = rev 2 + the owner's answers. Contract: +`.claude/tasks/contracts/2026-11-17-v1-2-6-u2-implementation.md`. 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. @@ -153,9 +157,9 @@ to verify. The executor writes the JSX under TDD against the boards. | # | 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. | +| D1 (VALIDATED) | `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. | -### D2: « + » on segments too short for the finger +### D2: « + » on segments too short for the finger (VALIDATED, with R-18) On the equine main view at fit zoom, the zone segments are 5 to 38 px long at 1 280 px and 6 to 49 px at 1 180 px. Board 13 asks for 44 px touch targets, and board 05 draws a « + » on every segment. @@ -283,8 +287,17 @@ and a stray tap never discards a creation. 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 or a redraw is NOT a creation: Back, a tab or a view change cancels it silently, and the stored shape - stays. These are not history entries (orientation). +- A move mode or a redraw (owner correction, 2026-11-17): + - With no work started, Back, a tab, a section, a view chip, a tool, sign-out or leaving the editor ends it at + once, without a question. The stored shape stays. + - Work is started once the move mode's position differs from the stored one, or the redraw has at least one + vertex. The same actions then ask first through `ConfirmDialog`: FR « Abandonner le déplacement ? » or + « Abandonner le nouveau tracé ? », with « Continuer » and « Abandonner »; EN « Discard the move? » or « Discard + the new tracing? », « Continue », « Discard ». + - « Annuler », « Annuler le tracé » and Escape are explicit cancels and act at once, as board 32 (row 4) draws. + - During a move mode, a click on another annotation or on the empty drawing selects nothing. The mode ends only + through « Valider la position », « Annuler », Escape or an action asked as above. + - Neither is a history entry (orientation): the question is the guard's, not a layer's. - A keyboard series on a handle and the size slider commit on blur (BDR-050), as text fields do today (§1.9). A click on a tab or on « Défaire » therefore commits the series first. @@ -293,8 +306,11 @@ and a stray tap never discards a creation. - 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. +- A document change made elsewhere (reload, recovery, a save refresh) drops every stale preview and the chosen + vertex. When the dropped work was a started move mode or redraw, the live region and the message line say so: + FR « Déplacement abandonné : la fiche a changé. » or « Nouveau tracé abandonné : la fiche a changé. », EN « Move + discarded: the sheet changed. » or « New tracing discarded: the sheet changed. » Nothing is dropped without being + said. ### R-14 Read-only flip @@ -302,7 +318,8 @@ The editor turns read-only on a crossing below 1 024 px, a refusal or a refresh. - 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. +- A move mode or a redraw in progress is suspended, not dropped. It is kept (the body stays mounted, and the + preview stays in the work store) and resumes on the way back, unless the document changed meanwhile (R-13). - 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. @@ -319,6 +336,17 @@ The cap stays at 8 MiB: about 47 equine steps, written in UX_TESTS in place of second click, a double click, « Propriétés », Enter on the selected row. - Below 1 024 px (phone, boards 14 and 16) the twin is unchanged: the read body sits inline in the stacked column. +### R-18 Zoom hint for short segments (D2 precision) + +- When a zone is selected with its handles shown, and at least one of its « + » is hidden because its segment is too + short at the current zoom, the strip's middle shows a discreet line, info tone: FR « Zoomez pour ajouter un sommet + sur les segments courts. », EN « Zoom in to add a vertex on short segments. » +- It is not timed. It stays while the condition holds and goes when zooming reveals every « + ». +- It yields to a refusal or a geometry issue, which take the same place first. It is absent in a move mode, a + redraw and read-only. +- It changes no box: the strip's height is fixed. +- The keyboard path (Insert on the chosen vertex) stays available whatever the zoom. + ### R-17 Rust by default (BDR-043) These new modules stay in TypeScript. Each is listed in the review's Part II exception table: @@ -359,6 +387,8 @@ These new modules stay in TypeScript. Each is listed in the review's Part II exc ### Mounting and layout - The dialogs are mounted outside `EditOnly` with `readOnly` (R-14). +- No silent loss: uncommitted work (a creation, a started move mode, a started redraw, a dialog draft) is asked + before any navigation drops it, or announced when a document change made elsewhere drops it (R-12, R-13). - 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. @@ -673,16 +703,30 @@ export interface Creation { /** The dialog is shown; false while the shape is replaced or the trace resumed. */ dialog: boolean } +/** A move mode or a redraw; `started` once the position differs or a vertex is placed (R-12). */ +export interface ModeWork { kind: 'move' | 'redraw'; annotationId: string; started: boolean } interface Work { creation: Creation | null + mode: ModeWork | null preview: Preview | null chosen: Chosen | null } -export const useAnnotationWork = create(() => ({ creation: null, preview: null, chosen: null })) +export const useAnnotationWork = create(() => ({ + creation: null, + mode: 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 +export type GuardWork = 'creation' | 'move' | 'redraw' | null +/** R-12: what a navigation must ask about; an unstarted mode asks nothing and simply ends. */ +export function guardWork(work: Work): GuardWork { + if (work.creation !== null) return 'creation' + return work.mode?.started ? work.mode.kind : null +} +/** The end of a mode without a question (unstarted, or « Abandonner » answered). */ +export function endMode(): void { + useAnnotationWork.setState({ mode: null, preview: null }) } /** R-13: drop what was computed on another document text; the caller passes the current text. */ @@ -696,10 +740,10 @@ export function dropStale(text: string): void { Notes on the code above: -- A creation always holds its shape, so `holdsCreationWork` is the existence of the creation. The tool alone, before +- A creation always holds its shape, so `guardWork` reports any 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 tracing of a NEW zone or link moves from `ui.tracing` to `creation` (Task 7). A redraw keeps its vertices in `ui.tracing` + (target `replace`) and sets `mode: { kind: 'redraw', started }` beside it (R-12): it is not a creation. - 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 @@ -806,9 +850,14 @@ Notes on the code above: - `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`). +- The move mode lives in `workStore.mode` (target in the preview: the shape, or a vertex), so the guard sites outside + the tab can read and end it. Modify `useCanvasGestures.ts` (`drag_point`, `drag_mode`) and `deselect.ts` (the + Escape listener calls `escapeAction`). - The properties panel keeps its numeric group until Task 5, where polygons get their handles. +- The drawing guard and its sites (R-12): `workStore.ts` (`guardWork()`: what is started), `useEditorNavigation.ts` + (`useTabSelect`, the arrow-key tab move, `openSection`, the view chips and tools through the tab), `history/useEditorHistory.ts` + (`refusal` asks it on every POP), `history/useLeaveConfirm.ts`, `AdminSheetDraftRoute.tsx` and `SignOutButton.tsx` + (`leaveGuardArmed(state) || guardWork(work) !== null`), `ConfirmDialog.tsx` (`body` optional). - Doc `docs/ANNOTATION-RENDERING.md` « Editor overlay » FIRST. **Interfaces:** @@ -909,6 +958,11 @@ How the pieces work: - 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. + - A click on another annotation selects nothing during the mode. + - Guard (R-12): THIS task builds the shared drawing guard and its sites (listed under Task 7, which adds the + creation to them), with the move mode as its first user. With no step taken, a tab + change ends the mode silently. After one step, it asks « Abandonner le déplacement ? »; « Continuer » keeps + the mode and the position. - 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. @@ -997,6 +1051,10 @@ export function showsInsert(segmentPx: number, hitRadiusPx: number): boolean { 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. + - Redraw guard (R-12): before the first vertex, Back ends it at once. After one vertex, Back asks « Abandonner + le nouveau tracé ? ». + - R-18: « Thoraciques » selected at fit zoom shows the zoom line; zooming until every « + » shows removes it; + a refusal message takes its place while shown. - 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). @@ -1015,7 +1073,6 @@ export function showsInsert(segmentPx: number, hitRadiusPx: number): boolean { - 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 } | null`, on tab `annotations` only. The creation dialog is NOT a layer (Task 7). @@ -1105,6 +1162,8 @@ export function missingFields(kind: NewKind, form: CreationForm): MissingField[] - « 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. + - Unit read-only flip during a started move mode: the mode is suspended and resumes with its position on the way + back (R-14). - 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. @@ -1129,14 +1188,14 @@ export function missingFields(kind: NewKind, form: CreationForm): MissingField[] and `KeyboardAdd.tsx`. - `workStore.ts`: `creation` holds the pending shape and the form across « Replacer le point » and « Reprendre le tracé ». -- The drawing guard: +- The drawing guard (built in Task 4 for the move mode, extended in Task 5 to the redraw; this task adds the + creation and the undo rules; R-12): - `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. The creation dialog is a modal without a layer (like `DeleteDialog`), so a Back while it is open is refused as `'modal'`, and `askAll` (which now includes the drawing guard) shows its question inside the dialog. - `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. @@ -1169,8 +1228,10 @@ Behaviour: shape is kept on « Continuer ». « 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). + route leave each ask during a creation. « Continuer » keeps everything; « Abandonner » proceeds. + - The same sites, for a move mode and a redraw: they act at once before any work, and ask once work has started + (R-12). Escape and « Annuler » never ask for a mode. + - A started move mode, then a recovery replaces the document: the mode is dropped and announced (R-13). - Unit: a creation open, then the width flips to read-only and back: the form and the ghost are intact. - E2E: - Point, zone and link created by clicks, undone and redone, then saved (`editor-annotations.spec.ts` @@ -1248,12 +1309,20 @@ Behaviour: 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. +- [ ] **Step 5:** owner trial section `docs/development/V1-2-6_OWNER_TRIAL.md` §4.17 « Démonstration U2 », on the + dedicated trial stack `pnpm db:trial` (owner's request, 2026-11-17). + - U2 adds no migration: `pnpm db:trial start`, then `pnpm db:trial app` serve this branch's code on the existing + data. The owner runs them; Claude writes nothing on the trial stack. + - If `db:trial status` shows a missing migration or drawing, the section says which existing command fixes it + (`migrate`, `assets`) and the owner runs it. - 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, 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 closing flow. + - Leave a started move mode and a started redraw by a tab and by Back: each asks; an unstarted one ends at once. + - Select « Thoraciques » at fit zoom: the zoom line shows; zoom until the « + » appear. +- [ ] **Step 6:** STOP for the owner's trial on `db:trial` (mouse and tablet). U2 closes only on the owner's + validation after that trial. Capitalize per the closing flow. ## Out of scope, tracked @@ -1345,3 +1414,17 @@ Behaviour: - The smoothness check becomes a measure, not a suite assertion. - « + » visibility was measured on the equine zones and became D2. - Rust by default became R-17. + +## Owner answers (2026-11-17, rev 3) + +- D1 validated: coordinates stay in the exceptional drawing-repair dialog until U5; A8 concerns the normal + annotation editing journey. +- D2 validated with a precision: « + » hidden on segments too short, revealed by zooming, and a discreet hint while + a selected zone has hidden « + » (R-18). +- R-12 corrected: a move mode or a redraw ends at once when nothing was started, and asks before being dropped + once work has started. The read-only flip suspends such a mode instead of dropping it (R-14), and a drop caused + by a document change elsewhere is announced (R-13), to keep « no silent loss » whole. +- Visible choices confirmed: the veil ignores clicks, a double click opens the properties, the strip and messages + never move the drawing, the read-only sheet keeps its properties readable, touch, loupe and gestures as planned. + A13, A14 and the board 33 adjustment validated as integrated. +- The owner tries the result on `pnpm db:trial` before U2 closes (Task 10).