# R1 (history labels, deselection, Escape) + D6b Implementation Plan — rev 3 (3-lens challenge + re-challenge)
> For agentic workers: executed task by task by fresh implementers (subagent-driven-development), each task
> reviewed before the next. Steps use checkbox syntax.
**Goal:** V1-2.6 lot R1 complete: « Défaire » / « Refaire », « Désélectionner », the Escape priority, and D6b
(a click or tap on the drawing outside any annotation deselects), in the editable editor and its read-only twin.
**Architecture:** one deselect hook (commit the focused field, clear the selection, move or keep focus, announce)
used by the button, Escape and the drawing. Escape needs no registry: only the SHOWN annotation body
(`usePlaceVisible()`) listens for Escape on `document` (bubbling, so React-level consumers that stop or mark the key
go first), and only while it has a resolved selection and no tracing; the « Plus » disclosure closes itself first
through a capture listener while open; the workspace root closes the references panel for an Escape from the header
or tab row. D6b decides on the PRESS, not the click target: a tap tracker (pointerdown target, accumulated
movement, primary/non-primary pointers anywhere in the page, contextmenu) gives an empty-tap verdict at `pointerup`.
Mouse and pen apply it at pointerup (survives the pointer capture of the move gesture, whose click targets the box,
and the canvas rebuild a blur commit triggers at mousedown) and swallow the click that follows. Touch applies it in
the tap's own click, and only if that click's target carries no `[data-anno-id]` (Chromium builds the touch click
after touchend, hit-tests the post-deselect layout and adjusts toward nearby markers: applying at pointerup would
let the click land on what moved under the finger). `useFraming` is not touched.
**Tech stack:** React 19, TypeScript strict, Zustand editor store, Vitest + happy-dom + Testing Library,
Playwright Chromium (`pnpm e2e:shell` on `pnpm db:sandbox`).
**Spec:** `docs/development/V1-2-6_U1_CORRECTIONS.md` §1 (D5, D6, D6b), §3 R1, §6 (A5, A5b, A6); board
`docs/design/v1-2-6-r0/26-historique-deselection.png` (normative, BDR-110), `maquettes.html:380-391, :611-667`,
`REVUE.md:57-60, :72, :108-111, :129-135`. Contract: `.claude/tasks/contracts/2026-11-12-r1-history-deselect-1141.md`.
## Global constraints
- Worktree `/home/bchanot/Documents/faunosteo-v1-2`, branch `feature/v1-2-anatomical-sheets`, commit in place
(auto-push); never run anything in `/home/bchanot/Documents/faunosteo`.
- No change under `supabase/`, `crates/`, `scripts/`, `docker/`; `apps/app/src/catalogue/useFraming.ts`,
`apps/app/src/editor/useUndoShortcuts.ts`, `apps/app/src/app/routes/app/anatomy/SheetRoute.tsx` unchanged;
`src/catalogue` and `src/components/catalogue` import nothing from `@/editor`.
- Every UI string through `useT()`; fr and en get the same keys; `t` never in effect or callback deps (LRN-088).
- Our code: ≤ 25 logic lines per function, ≤ 5 params, ≤ 5 locals, 100 chars per TS line; comments say why.
- Kept places: act only on what is shown; no one-shot focus in mount effects (LRN-119); twin ids keep `ro-`.
- Unit pointer events in happy-dom carry `isPrimary: true, button: 0, pointerType: 'mouse'` explicitly (happy-dom's
default `isPrimary` is false).
- Browser suites: `pnpm e2e:shell` against `pnpm db:sandbox` only (up); never db:trial, never DEV; no sandbox
reset or `down`; never edit `src` while a browser suite runs (LRN-120).
- Commits: Conventional Commits, allowed scopes (`app`, `tests`, `docs`); every rewritten or removed assertion
mapped to its replacement in the commit body (R-24). D6b code and its tests only in the D6b commit.
## Fixed wording (board 26, REVUE.md table)
| Key | FR | EN |
|---|---|---|
| `editor.history.undo` | Défaire | Undo (unchanged) |
| `editor.history.undo_title` | Défaire la dernière modification | Undo the last change (unchanged) |
| `editor.history.redo` | Refaire | Redo (unchanged) |
| `editor.history.redo_title` | Refaire la dernière modification défaite | Redo the last undone change (unchanged) |
| `editor.history.undo_shortcut` (new) | Ctrl+Z ou ⌘Z | Ctrl+Z or ⌘Z |
| `editor.history.redo_shortcut` (new) | Ctrl+Maj+Z ou ⇧⌘Z | Ctrl+Shift+Z or ⇧⌘Z |
| `editor.annotations.deselect` (new) | Désélectionner | Deselect |
| `editor.annotations.deselected` (new) | Aucune annotation sélectionnée. | No annotation selected. |
FR prose: `editor.views.drawing.use_parent_body` « … et vous pouvez défaire ce changement (Défaire). … »;
`editor.views.repair.body_one` / `_other` « … et un seul Défaire les restaure ensemble. ». EN prose unchanged.
`fr.ts:1479` « Annulez, … » and every dialog « Annuler » stay.
## Gate outcomes (filled at the validation gate before dispatch)
- G1 Escape focus [gated 2026-11-12, owner]: focus inside the properties panel → A6 (row if visible, else the
drawing box); focus elsewhere (canvas box, view chips, tool column, add buttons, tab row) → stays where it is.
- G2 « Supprimer » [gated 2026-11-12, owner]: unchanged (filled danger button, no icon), per the board caption
« qui garde son style de danger »; only placed to the right of « Désélectionner » in the bordered row.
## Reviewer checklist (each has its test below)
Shown body only (Task 3 test 9); replace tracing (Task 2 test 8, Task 3 test 6, Task 4 test 10); pending valid value
then a drawing click in a real browser (Task 5 step 7); two-finger tap (Task 4 test 8, Task 5 step 5 with the event
count); filtered-out row (Task 2 test 2); selected marker click and jitter (Task 4 test 4, Task 5 step 3).
---
### Task 1: history reads « Défaire » / « Refaire » (D5) — commit `feat(app): history reads Défaire / Refaire (R1, D5)`
**Files:** `apps/app/src/i18n/fr.ts` (:1284-1287, :1444, :1473-1474), `apps/app/src/i18n/en.ts` (new shortcut keys
only), `apps/app/src/components/editor/HistoryButtons.tsx`, `EditorTabs.tsx:147` (comment only); tests
`tests/unit/editor-history-buttons.test.tsx`, `tests/unit/editor-annotations-tab.test.tsx:514`; e2e titles/comments
`e2e/shell/editor-shell-layout.spec.ts:271, :293`, `editor-shell-journeys.spec.ts:152, :160`, `editor-shell.spec.ts:149`,
`e2e/support/editor.ts:440`.
- [ ] Dictionaries per the wording table.
- [ ] `HistoryButtons.tsx`: `SHORTCUT = { undo: 'Control+Z Meta+Z', redo: 'Control+Shift+Z Meta+Shift+Z' }`;
`aria-label={name}`, `title={`${name} (${t(`editor.history.${direction}_shortcut`)})`}`; comments :41, :53, :121
and `EditorTabs.tsx:147` say « Défaire » / « Refaire ».
- [ ] Unit: constants and assertions to the new FR names; title = name + « (Ctrl+Z ou ⌘Z) » / « (Ctrl+Maj+Z ou
⇧⌘Z) »; `aria-keyshortcuts` the two-form lists; visible labels `['Défaire','Refaire']`; the absence checks (:205,
`editor-annotations-tab.test.tsx:514`) become `/Défaire|Refaire/`; one EN test (names unchanged, title with
« (Ctrl+Z or ⌘Z) »); FR prose keys contain « Défaire » while `use_parent_cancel` still reads « Annuler ».
- [ ] Run `pnpm --filter @faunosteo/app exec vitest run tests/unit/editor-history-buttons.test.tsx tests/unit/i18n.dicts.test.ts tests/unit/editor-annotations-tab.test.tsx`, `pnpm typecheck`, `pnpm lint`. Commit with the R-24 map.
### Task 2: « Désélectionner » (D6, A6) — part of commit `feat(app): Désélectionner and the Escape priority (R1, D6, A5, A6)`
**Files:** new `apps/app/src/editor/annotations/deselect.ts`; `src/editor/useEditorNavigation.ts` (export
`CANVAS_BOX` only); `src/editor/focusRequest.ts` (export `isTextField(target)`; `commitFocusedField` uses it);
`EditorGlyph.tsx` (glyph `deselect`: `M4 8V5a1 1 0 0 1 1-1h3M16 4h3a1 1 0 0 1 1 1v3M20 16v3a1 1 0 0 1-1 1h-3M8 20H5a1 1 0 0 1-1-1v-3M9 9l6 6M15 9l-6 6`);
`annotations/PropertiesPanel.tsx`; `annotations/EditableAnnotations.tsx` (pass `busy`); i18n keys.
- [ ] `deselect.ts`:
- `focusDrawing(): boolean` — `visibleElement(CANVAS_BOX)` focused with `{ preventScroll: true }`.
- `focusRowOrDrawing(id)` — `focusRow({ kind: 'annotation', id }) || focusDrawing()`.
- `useDeselect(id: string | null, clear: () => void)` → `{ byButton(), byKey(fromPanel: boolean) }`. `id` is the
RESOLVED selection (`selected?.id ?? null`, never the raw `selectedId`, which can name a removed annotation).
Each: `id === null` → return false; else `commitFocusedField()`, `flushSync(clear)`, focus (byButton →
`focusRowOrDrawing(id)`; byKey → `focusRowOrDrawing(id)` if `fromPanel`, else per G1), `announce(t(…deselected))`
(`AnnounceContext`), return true. `t` via a ref.
- [ ] `PropertiesPanel`: new optional prop `busy?: boolean` (a tracing runs). After the status actions, one row
`