# PLAN — R2 « Références » tab (V1-2.6) — rev 5 Contract: `.claude/tasks/contracts/2026-11-12-r2-references-tab-1730.md`. Sources: `docs/development/V1-2-6_U1_CORRECTIONS.md` §R2 (D1-D4), `docs/design/v1-2-6-r0/{ARBITRAGES.md A1-A5, REVUE.md, maquettes.html boards 23-27}`, TODO R2 block (a1d4084), BDR-114, BDR-107..110, BDR-113. Read-before digest: analyzer 2026-11-12. Rev 2 = rev 1 + challenge round 1 (correctness FATAL(5), robustness FATAL(7), simplicity CONCERNS(1)); changes tagged [Cn] / [Rn] / [Sn] with the finding number. Rev 3 = challenge round 2 (section at the end). Rev 4 = owner GO 2026-11-12 (brief « GO R2 — Plan révision 3 »): panel from a finding only, arbitrations 1-5, full-row data guard (section at the end; in-place edits marked [O4]). Plan form (deviation from writing-plans « full code », stated): ~30 files; each task gives files, behaviour, test cases and verification; executors write the code under TDD. Design = owner-validated boards (BDR-110), no brainstorm. ## Global rules - Limits: 25 logic lines / function, 100 chars, 5 params, 5 locals, no global state; i18n through `useT()` with fr / en parity; edits only through `useEditCommand` → store.commit (one history entry per action). - Never touch supabase/, crates/, scripts/db-trial*, docker/, packages/supabase/src, components/catalogue/ (reader unchanged) [C9]. No db:trial, no DEV. - Shell runs: `pnpm db:sandbox e2e-shell `; NEVER `editor-equine.spec.ts` (owner §3). - Data guard [R6] (superseded by rev 4 G3, full rows): before and after each shell session, per-id snapshot of pre-existing rows of `anatomical_sheets` (id, status, archived_at, updated_at) AND `anatomical_sheet_versions` (id, status, the revision / updated_at columns, md5(content::text)); compared per id (changed or missing = stop); new rows counted and their sheet ids listed per run (owner §3 fixture tracking). Select-only through `pnpm db:sandbox sql`. - Key removal [R10]: before removing any i18n key or helper, grep src, tests and e2e INCLUDING editor-equine; equine is reported « updated, not run ». - R-24: every removed or rewritten assertion mapped in the sub-lot commit body. - Design floor: `impeccable detect ` on R2.1-R2.4. ## Decisions (owner answers marked [owner]) - P1 [S1] The panel is no navigation place: no `EditorTarget` variant. It opens only through the action `open_citations(citedBy, opener)` (renamed `open_references`, `citedBy` required). Its DOM place name is `citations` (`data-place`, PlaceName member only for its heading and focus scope). R2.1 removes the panel target from `EditorTarget`, `placeOf`, `placeKey`, `moveText` and the panel's own focus-request handler. - P2 « Type » sort = REFERENCE_TYPES order, ties in sheet order. - P3 « Aller à » a reference hidden by the tab search: clear the search only, open the tile, focus it (P8); other open tiles stay open (A2). - P4 [C6] « Tout afficher dans l'onglet Références » = its own action `show_all_references`: closes the panel, then (after exit, P9) selects the tab with a reset signal (search and sort reset, open tiles and a tile in edit kept), focus on the tab heading. Vérification's unresolved reference path selects the tab WITHOUT reset. - P5 [O4] The panel opens ONLY from a finding (`finding_node`), never from a family (`finding_category`): owner GO 2026-11-12 overrides the pass-B answer « same panel with family words ». The trigger « {n} références » is rendered only in a finding's detail; a family's detail keeps its inline citation list (« Retirer », picker) and loses the trigger it shows today (shared `FindingContent`). `open_citations` refuses a key that is not a finding (no-op). No family words in the panel. Families still count and appear in a tile's « Citée {n} fois, par : » list (A4). - P6 [C2][R2] focus fallbacks, in order: the trigger (re-found by `data-citations-trigger=`) if shown → else the active tab button via `focusActiveTab()` (« Plus » button below 640 px). Never a missing heading. - P7 panel: no search, add, delete, reorder (board 25). - P8 [C8] focus target of a reference = the tile's disclosure button, carrying only `data-focus-key` (natural tab stop, no `tabIndex=-1`); the tile is opened first. - P9 [C1][R1][R8] Panel closing is uniform: every close (✕, Escape, scrim, « Tout afficher », « Aller à » from a panel tile, element vanished, tab switch) records ONE pending move (target + focus) in the workspace; the panel animates out (`motion/react` AnimatePresence, enter 180 ms decelerate, exit 140 ms accelerate, translateX only, scrim opacity same timings; `useReducedMotion` → no transition); `onExitComplete` lifts the page `inert`, keeps `ReferencesOpenContext` true until then, and applies the pending move. The panel is `inert` during exit and unmounted after. Focus helpers report « found » only when `document.activeElement` is the target. Page inert through exit is kept (approved CORRECTIONS §R2 text, owner « y compris pendant son animation de sortie »). - P10 editor-equine: helper calls updated, never run. - P11 [owner] 640-1 023 px: five tabs, row may wrap, no horizontal scroll. - P12 [R11] tab search: explicit Escape handler: non-empty query → clear + `preventDefault`; empty → let it bubble (A5). - P13 trigger gains `aria-expanded` + `aria-controls="editor-citations-panel"`. - P14 tile ids prefixed by host (`tab-` / `panel-`). - P15 [owner] « Retirer … » marks the element « À confirmer » (core rule); documented; one « Défaire » restores both. - P16 [C4][C5][R5] Geometry: the Places container gets `overflow-x: clip` (never `hidden`: sticky must keep working) and NO open-state `min-h` toggle; the panel wrapper is `absolute inset-y-0 right-0 w-[min(34rem,100%)]`, the panel inner `sticky top-14 h-full max-h-[calc(100dvh-3.5rem)]` with its own scrolling list, so it never exceeds the container: document height and width never change on open / close / during motion. Heading focus on open uses `preventScroll` and happens after enter completes. - P17 labels table file: `docs/development/V1-2-6_R2_LABELS.md`. - P18 [S4] count wording: reword `editor.references.cited_*` in place to « Citée {n} fois » (capital) and add `editor.references.uncited` « Non citée »; no parallel keys. - P19 [S3] one memoised `citersOf(doc): Map` (families and nodes at any depth); tile count = list length; `citationCounts` derived from it (or removed with its last consumer). - P20 [C3][R2] After « Retirer … »: focus the next tile's disclosure button, else the previous, else the panel heading; zero citations left → the panel stays open with the line « Ce constat ne cite plus aucune référence. » (new provisional label) + « Tout afficher » [O4]; close then follows P6 (the trigger is gone when its count is 0). - P21 [C2][R2] Selecting a tab while the panel is open closes it (pending move = the tab; focus on the new tab button). Défaire / Refaire stay usable with the panel open; an undo that removes the element triggers P6. - P22 [R3] Leaving edit is guarded: « Terminer », switching `editingId`, « Ajouter » while another tile is in edit, and closing the panel with a tile in edit first commit the pending field; on refusal the tile stays in edit, the refused field shows its message and takes focus, and the leave is cancelled. - P23 [R4] Pinning: while `editingId` (or the add draft) is set, that tile stays in the shown set at its current index whatever the sort or search, until it leaves edit. - P24 [C12] Add: « Ajouter une référence » resets search and sort, appends a draft tile in edit (Type « Choisir… », Citation focused); « Ajouter la référence » creates it in one modification; on success the tile stays open, leaves edit, focus on its disclosure button. - P25 [S2] `ReferenceLibrary` (R2.1 extraction) is folded into `ReferencesTab` at R2.4; only `ReferenceTile` is shared. - P26 [C9] links: `editor/references/safeLink.ts` (http / https only; DOI → `https://doi.org/`); `target="_blank" rel="noopener noreferrer"`; the catalogue's `safeHref` is not touched. ## R2.0 — rename the panel's DOM place (no visible change) — `refactor(editor): …` Scope [S1][C10]: the `data-place` / KeptPlace `name="references"` literal, the PlaceName member, `headingOf`, `ownedBy` uses, DOM ids `editor-references-panel` / `editor-references-title` → `editor-citations-*`; `editor/annotations/deselect.ts` only if it names the place; tests and e2e literals. Not renamed (deleted in R2.1): the EditorTarget variant, MoveKinds. E2E [S7]: library assertions routed through one helper (`libraryRoot(page)`) in `e2e/support/editor.ts`, so R2.1 changes one line; `place(page,'citations')` only at the true panel sites. Proof [R9][C10]: `grep -rnE "['\"]references['\"]" apps/app/src apps/app/tests apps/app/e2e` reviewed hit by hit (each remaining hit justified in the commit body), plus `name="references"` absent. Gate: typecheck, lint, test:run, build; e2e:shell crossing, journeys, shell, structures, deselect, access, shell-layout + data guard. Commit + push. ## R2.1 — five tabs, navigation, library in the tab — `feat(editor): …` - `tabs.ts` five tabs; `SHOWN.small` unchanged (« Plus » = general, findings, references); `REFERENCES_BUTTON_ID` removed. `EditorTabs.tsx` row may wrap (P11). - `components/editor/tabs/ReferencesTab.tsx` in `EditorTabBody` BODIES; h2 « Références » with `data-place-heading`; hosts `ReferenceLibrary` (list of the current cards, form, DeleteDialog, search), ids `tab-` (P14). - `navigation.ts`: reference keys → `{place:'tab', tab:'references', key}`; panel EditorTarget removed (P1); `open_citations(citedBy, opener)`; `show_all_references` (P4); `select_tab` closes the panel (P21); pending move plumbing (P9) introduced here with the current (non-animated) panel so focus rules hold from R2.1. - `verification.ts` reference issues → tab; `useEditorNavigation.ts` landing on the tab heading; fallbacks P6. - Header button, separator and props removed (HeaderActions, DraftHeader, EditorWorkspace). - Trigger (FindingContent, finding nodes only [O4] P5): `open_citations`, `data-citations-trigger`, `aria-expanded`, `aria-controls` (P13); removed from a family's detail (R-24 row in the commit body, e2e / unit using it remapped). - i18n: `editor.tab.references`; removals per [R10]. - E2E [C7][R7]: tier-aware `openTab(page, dict, tab)` (opens « Plus » below 640 px); `TABS` five; each existing `openReferences` call mapped explicitly (R-24 table in the commit body) to `openTab(…,'references')` (library) or `openCitations(page, dict, element)` (panel), keeping today's narrow-width panel axe and overflow checks through `openCitations` at 320 / 375 / 768 / 800 px; `warm-up.ts` uses the tab (same commit). - Unit tests rewritten with R-24 mapping (editor-mode, editor-route, editor-references-panel → finding path only [S2], editor-tabs-lists, editor-navigation, editor-focus-request, editor-keep-alive, editor-escape (A5 panel layer through the trigger), editor-no-loss(-decisions), editor-route-recovery, editor-verification); new: select_tab closes panel, P6 fallbacks, Vérification « Aller à » reference → tab + focused row. Gate: typecheck, lint, test:run, build, e2e:ui, e2e:shell (editor-* except equine, admin, shell, journeys) + data guard; impeccable detect. Commit + push. ## R2.2 — collapsible tiles — `feat(editor): …` - `ReferenceTile.tsx` (board 23 / 24 C / D / 27): header `