diff --git a/.claude/tasks/contracts/2026-11-12-r2-references-tab-1730.md b/.claude/tasks/contracts/2026-11-12-r2-references-tab-1730.md new file mode 100644 index 00000000..f6b7966d --- /dev/null +++ b/.claude/tasks/contracts/2026-11-12-r2-references-tab-1730.md @@ -0,0 +1,152 @@ +# CONTRACT — r2-references-tab +- date: 2026-11-12 | flow: ship-feature | branch: feature/v1-2-anatomical-sheets (commit in place, no finish) +- status: active +- plan: .claude/tasks/plans/2026-11-12-r2-references-tab-1730.md + +## REQUEST (verbatim — IMMUTABLE) +# FAUNOSTEO V1-2.6 — Validation du correctif E2E et GO R2 + +Le propriétaire valide le checkpoint du correctif E2E. + +## 1. Correctif E2E accepté + +Le commit 2cdee42 est accepté. + +Résultats retenus : +- Les quatre échecs historiques ont disparu. +- Deux passages successifs réussis. +- Le véritable composant WorkingCopyAction est couvert dans e2e:ui. +- Les contrôles de la fiche historique restent présents dans e2e:shell. +- Les refus serveur restent couverts. +- Les 637 fiches préexistantes sont restées inchangées pendant cette intervention. + +Conserver la limite documentaire : le dialogue n'est plus testé dans son contexte serveur réel par ce contrôle d'accessibilité. + +## 2. Mémoire — VALIDÉE + +Enregistrer : + +BLK-014 — admin.spec dialog check depended on shared singleton working-copy state — resolved 2cdee42. + +Préciser que la résolution concerne les quatre échecs de ce contrôle, pas tous les risques de concurrence des suites E2E. + +LRN-132 — E2E tests and database-wide singleton state. + +Documenter : +- Ne pas exiger qu'une ressource unique soit disponible dans une base persistante partagée. +- Tester le véritable composant UI indépendamment lorsque nécessaire. +- Vérifier dans les tests serveur la cohérence de l'état réellement présent. +- Nettoyer ou archiver exclusivement les ressources créées et identifiées par la suite concernée. +- Vérifier les identifiants effectivement modifiés par les opérations de nettoyage. +- Éviter les interactions concurrentes entre suites manipulant une ressource singleton. + +Effectuer les contrôles documentaires et commit/push. + +## 3. Risque editor-equine — À encadrer + +La suite editor-equine archive temporairement les copies actives de la fiche historique puis les restaure. + +Ce comportement a déjà modifié la date de modification de 8c315a12. + +Il ne doit plus être exécuté sur une base persistante contenant des données préexistantes à préserver. + +Avant de relancer une suite qui inclut editor-equine : +- Identifier précisément ses écritures. +- Proposer une isolation reproductible et non destructive pour les ressources préexistantes. +- Vérifier les interactions possibles avec admin.spec et les autres suites parallèles. +- Préserver la copie 8c315a12 et ses métadonnées actuelles. +- Ne pas chercher à rétablir artificiellement une ancienne date. +- Ne pas supprimer ou réinitialiser la sandbox. + +Présenter une correction séparée si nécessaire. Ne pas élargir silencieusement le périmètre R2. + +Suivre également les fiches créées par les tests pour éviter l'accumulation de fixtures persistantes. + +## 4. GO — Implémentation de R2 + +J'autorise R2.0 à R2.6 conformément au plan technique approuvé et aux maquettes R0. + +R2.0 — Renommage interne du volet de références. + +R2.1 — Cinquième onglet Références et navigation. + +R2.2 — Tuiles de références dépliables. + +R2.3 — Recherche, tri et actions. + +R2.4 — Volet contextuel des références citées par un constat. + +R2.5 — Tests et non-régressions. + +R2.6 — Documentation, traductions et clôture. + +Respecter les décisions A1 à A4 et D1 à D4, ainsi que les exigences enregistrées dans la TODO par a1d4084. + +Chaque sous-lot doit être vérifié, commité et poussé avant le suivant. + +Ne pas déclencher une suite dangereuse pour les données préexistantes au prétexte qu'elle fait partie des contrôles habituels. Si cela bloque une validation obligatoire, s'arrêter au checkpoint correspondant et proposer une solution. + +## 5. Exigences R2 + +- Une référence citée ne peut pas être supprimée. +- « Retirer de ce constat » retire seulement l'association concernée et reste annulable. +- Aucune modification en lecture seule. +- Recherche et tri en TypeScript, exclusivement pour l'affichage. +- Aucune mutation de l'ordre enregistré ou du document. +- Volet contextuel sans déplacement du schéma. +- Navigation clavier et gestion du focus conformes aux maquettes. +- Accessibilité, mobile et prefers-reduced-motion respectés. +- Tableau exhaustif des nouveaux libellés FR/EN à présenter avant leur validation définitive. +- Documenter l'exception TypeScript dans la revue d'architecture Rust. + +## 6. Restrictions + +Aucune intervention sur db:trial ou DEV. + +Les tests automatisés utilisent uniquement les environnements autorisés et ne doivent jamais modifier des données préexistantes à préserver. + +Ne pas toucher à la fiche équine historique ni à la copie d'essai manuelle. + +Aucune migration SQL, modification Rust ou worker hors périmètre. + +Aucune suppression de données, aucune fusion et aucun déploiement. + +Préserver le fichier de revue ChatGPT non suivi. + +Ne pas commencer R3, R4, U2 ou U2b. + +## 7. Checkpoint final + +Fournir : +- La liste des sous-lots R2 réalisés. +- Les commits et leur état de push. +- Les résultats exacts des tests exécutés et ceux volontairement non exécutés. +- Les revues indépendantes et les éventuelles réserves. +- Le statut du risque editor-equine. +- Le tableau FR/EN des nouveaux libellés. +- Le protocole de test manuel sur db:trial. + +S'arrêter après R2 et attendre la validation utilisateur. + +## CLARIFICATIONS +Q: family detail « n références » button? / A: same panel with family words (« Retirer de cette famille », badge « cette famille », « N références citées par cette famille »); new FR/EN labels in the checkpoint table. [gated 2026-11-12] +Q: 640-1 023 px tab row? / A: all five tabs shown; the row may wrap (fixed per width, never moves on interaction, no horizontal scroll). [gated 2026-11-12] +Q: « Retirer » marks the finding / family « À confirmer » (core rule, edit.rs)? / A: accepted; documented in docs and db:trial protocol; one « Défaire » restores both. [gated 2026-11-12] +Q: shell gate with editor-equine? / A: excluded from every run (owner §3, §4 « ne pas déclencher une suite dangereuse »); its helper calls are updated for typecheck only, never run; per-id snapshot of pre-existing anatomical_sheets before/after each shell run. +Q: where does the FR/EN table live? / A: `docs/development/V1-2-6_R2_LABELS.md` (decided in plan, shown at the gate). + +## ACCEPTANCE CRITERIA +Seed (from the request); design criteria appended at STEP 3 with [gated]. +1. Five editor tabs in the order Général, Annotations, Constats, Références, Vérification; below 640 px « Plus » holds Général, Constats, Références; no header « Références » button. +2. A cited reference never shows « Supprimer » (hint instead); an uncited one keeps « Supprimer » + existing dialog; the core refusal stays the authority. +3. « Retirer de ce constat / cette famille » removes only that association, one « Défaire » restores it; the reference stays in the document. +4. Read-only and no-right modes show no edit control in the tab or the panel. +5. Search and the four sorts are TypeScript display functions over ids; the document text, stored order, ids and history are identical before and after any search or sort (tested). +6. The panel opens only from a finding or family, width ≤ 34 rem and ≤ available width, slide 180 / 140 ms, none under reduced motion, page inert and panel unreachable while closed or exiting, focus back to the trigger if it still exists; no layout shift of the tab content on open / close. +7. A1 to A4 hold; « Aller à » from Vérification opens the right tile, open and focused; references reachable when a search returns nothing (clear button). +8. Exhaustive FR/EN table of new and changed labels with ambiguities: `docs/development/V1-2-6_R2_LABELS.md`; Rust exception rows in `RUST_ARCHITECTURE_REVIEW.md` Part II. +9. Gates per sub-lot: typecheck, lint, test:run, build; e2e:ui; e2e:shell on db:sandbox without editor-equine; pre-existing rows unchanged per id; one commit + push per sub-lot. +10. No change under supabase/, crates/, scripts/db-trial*, docker/; no db:trial / DEV access; untracked review file kept; no merge. + +## FILE SCOPE +apps/app/src/editor/{tabs,navigation,focusRequest,useEditorNavigation,verification,editingContext}.ts, apps/app/src/editor/annotations/deselect.ts, apps/app/src/editor/references/** (new sort.ts), apps/app/src/components/editor/{EditorWorkspace,EditorTabBody,EditorTabs,DraftHeader,HeaderActions,KeptPlace}.tsx, apps/app/src/components/editor/references/**, apps/app/src/components/editor/findings/{FindingsTab,FindingContent,FindingDetail}.tsx, apps/app/src/components/editor/tabs/** (new ReferencesTab), apps/app/src/i18n/{fr,en}.ts, apps/app/tests/unit/**, apps/app/e2e/{support,shell,ui}/**, docs/development/{V1-2-6_U1_CORRECTIONS,BROWSER_TESTS,V1-2-6_OWNER_TRIAL,RUST_ARCHITECTURE_REVIEW,V1-2-6_R2_LABELS}.md, docs/design/README.md, CLAUDE.md (tree), this contract, the plan, .claude/tasks/TODO.md, memory. diff --git a/.claude/tasks/plans/2026-11-12-r2-references-tab-1730.md b/.claude/tasks/plans/2026-11-12-r2-references-tab-1730.md new file mode 100644 index 00000000..f15893d9 --- /dev/null +++ b/.claude/tasks/plans/2026-11-12-r2-references-tab-1730.md @@ -0,0 +1,245 @@ +# PLAN — R2 « Références » tab (V1-2.6) — rev 2 + +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. + +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]: 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 [owner] family trigger → same panel, family words. +- 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. » / « Cette + famille ne cite plus aucune référence. » (new provisional labels) + « Tout afficher »; 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): `open_citations`, `data-citations-trigger`, `aria-expanded`, `aria-controls` (P13). +- 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 `