diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index b611afd9..97ae549d 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -477,7 +477,22 @@ Order (BDR-071): P0 docs + decisions → V1-1 clients and animals → V1-2 sheet - Acceptance: gates + Playwright green; owner check on phone and computer over the LAN - Security: only `packages/supabase` reaches the API; explicit column lists; no text filter in GET URLs; failures phrased by closed kinds - Stop if: the mockup lacks a pattern the screens need (propose, ask, never invent a direction); a visible choice not covered by §11 - - [ ] V1-1.6 Animals and relations UI, navigation and closure + - [ ] V1-1.6 Animals and relations UI, navigation and closure (owner brief 2026-10-26 « Validation V1-1.5 et autorisation V1-1.6 Interface Animaux et clôture »; isolated stack only; DEV untouched; stop at checkpoint before merge, V1-2 and DEV) + - [x] V1-1.5 closure: owner validated (CONFORME 11/11, security PASS, check:all green); reserves accepted for V1-1 (search not kept on back, E.164 display, back/forward not guarded), kept in product follow-up + - [x] owner decisions 2026-10-26: D11 drawer only for V1-1 (no tab bar, mockup kept as later UX subject); first animal from the client page (« Ajouter un animal » → /app/animals/new, client passed in navigation state, never the URL; one atomic create_animal); no relation role preselected; relation add as an in-page panel (no modal form), end / dates / void as ModalDialog confirmations; U3 date fills and locks the year; D12 tiles not in the brief's scope → not built, reported + - [x] access layer: records.ts + `duplicate_relation`, `already_ended`; `animals.ts` (search POST with probe row and species_filter, read by id with explicit columns and uuid gate, create with optional initial relation, update, archive); `relations.ts` (an animal's relations by one select with the client embedded, voided left out, explicit columns; create, end, dates, void); unit tests + real-PostgREST sandbox suite + - [x] app foundations: one RequireWorkspace above clients and animals; species labels loaded once per workspace mount (context, dropped on account change); local-date helper; « Animaux » nav entry after Clients; i18n FR/EN + - [x] animal form: schema on field-limits (D-R7: name, species from the active rows, detail iff other, sex required with no default, breed, birth year/date U3, start date), optional initial client (picker on search_clients, role required once a client is chosen, start date), request id per intent, conflict with stored values, leave guard; create and edit routes + - [x] animal list: debounced POST search, species filter, archived toggle, « Afficher plus », current owners or « Propriétaire non renseigné », states + - [x] animal page: identity, species, sex, breed, birth with its precision, status; relations current / former (voided never shown), client links and `tel:`; add panel, end (optional date), dates, void (erroneous entry, final) dialogs pending until settled; archive / restore; archived read-only; same « introuvable » for unknown / foreign / malformed ids + - [x] client page: animals as links grouped per animal with their roles, « Ajouter un animal » (pre-associated), « Associer un animal existant » panel (search_animals), none on an archived client + - [x] unit tests (schema, birth, other, sex, relation fields, access mapping, screens: states, idempotent retry, conflict, archive, relations, counts, session) + Playwright `e2e/shell/animals.spec.ts` (brief §17 items 1-24, FR/EN, desktop + 375, axe, URLs free of fixture values) + - [ ] gates (typecheck, test:run, lint, build, e2e:ui, e2e:shell, db:sandbox test-db/test/types --check, import:equine --check, rust:check, check:all), counter-checks, impeccable detect, fresh verifier + security audit + - [x] local gates: typecheck, lint, test:run (60 + 127 + 566), e2e:shell 82, db:sandbox test-db 919 / types match / test 61, import:equine --check 0 diff, check:all green 17:19:26 (rust:check, build, e2e:ui PASSED), impeccable detect 0; counter-checks 12 unit + 2 browser all caught + - [ ] fresh verifier + security audit (contract `.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md`) + - Found: `Card` dropped `aria-labelledby` since Step 7 (V1-1.5 section cards unnamed), fixed; Button takes `ref` + - Follow-up at merge: CHANGELOG Unreleased entry for V1-1 (the section describes develop only) + - [ ] docs: contract §11.8 as built + D11 + closure inventory, SUPABASE.md §3.3 DEV procedure reviewed, FRONTEND_ARCHITECTURE, BROWSER_TESTS, TEST_STRATEGY, design README (tab bar not reproduced), CLAUDE.md; BDR, EVAL, journal; commits pushed; checkpoint (brief §23, 23 points) - Objective: animal screens, relation panels on both pages, journeys 1 to 7, D11 navigation, D12 tiles, Definition of Done (contract §12.6) - Depends: V1-1.5; U3, D11, D12 - Files: `apps/app/src/app/routes/app/animals/*`; `apps/app/src/animals/*`; `apps/app/src/components/{animals,relations}/*`; `AppLayout.tsx`, `DashboardRoute.tsx`; i18n; tests; `apps/app/e2e/{animals,relations}.spec.ts`; `docs/design/README.md`, `CLAUDE.md`, contract "as built", `SUPABASE.md`, CHANGELOG Unreleased diff --git a/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md b/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md new file mode 100644 index 00000000..7578f637 --- /dev/null +++ b/.claude/tasks/contracts/2026-10-26-v1-1-6-animals-ui.md @@ -0,0 +1,78 @@ +# CONTRACT: V1-1.6 Animals and relations UI, owner brief 2026-10-26 « Validation V1-1.5 et autorisation V1-1.6 Interface Animaux et clôture » + +- branch `feature/v1-1-clients-animals`, base 3c2b503 (V1-1.5 validated); commits e223576 (access layer), 930499c + (screens), 3c2b503..HEAD also holds 3e968ee (Playwright journeys, sandbox e2e argument passthrough) and e215e9b (docs) +- diff under review: `git diff 3c2b503..HEAD -- packages apps docs scripts CLAUDE.md` +- functional contract `docs/development/V1-1_OWNERS_ANIMALS.md` §5.2, §5.3, §5.4, §7.1, §9.3, §9.4, §11.1 to §11.5, + §11.8 (as built), §13.3, §15 (closure inventory); owner decisions recorded in §11.8 and TODO: D11 drawer only, first + animal from the client page in one `create_animal` call, no role preselected, relation add as an in-page panel, end / + dates / void as confirmations, U3 date fills and locks the year; D12 not in the brief +- isolated stack `pnpm db:sandbox` is UP. Allowed: `pnpm db:sandbox test`, `pnpm db:sandbox test-db`, + `pnpm db:sandbox types --check`, `pnpm db:sandbox e2e-shell [spec] [--project ...] [--grep ...]`, + `pnpm --filter @faunosteo/supabase test:run`, `pnpm --filter @faunosteo/app exec vitest run`, typecheck and lint, + read-only SQL through `pnpm db:sandbox sql`. Not allowed: `pnpm check:all` and builds, `db:sandbox up/down`, any + file change, anything on the DEV stack except `pnpm supabase migration list --local`. + +## Clauses + +C1. **Scope.** Animal screens, relation panels and dialogs, the client page's animal section, their data access, tests +and docs only: no migration, nothing under `supabase/` or `crates/`, no bilan link (V1-3), no sheet shown, no cabinet, +no tab bar, no dashboard tiles, no weight / photo / coat / identification / neutering / death date / notes field, no +redesign of the client screens (the client page's animal section and the shared `Card` / `Button` fixes aside). + +C2. **Access layer.** `packages/supabase/src/{animals,relations}.ts` and the `records.ts` additions: writes only +through the M3 RPCs (no direct insert, update or delete on a record table); reads by id with explicit column lists, +never `select=*`; searches through POST RPCs (no term in a URL); the relations read by animal id with `voided_at is +null` and a bound; generated argument names; Zod-checked answers; closed failure kinds including `duplicate_relation` +and `already_ended`; a non-uuid id makes no request; a foreign id reads as unknown; no service key. + +C3. **Routes and isolation.** `/app/animals`, `/new`, `/:animalId`, `/:animalId/edit` behind the workspace gate +(remount per workspace, no data of a previous account shown); the same « Animal introuvable » for unknown, foreign and +malformed ids; no private value or business identifier in a URL query (the origin client travels in the navigation +state and is read again and checked active before being pre-associated); the workspace id is a context, never an +authorisation. + +C4. **Form (D-R7).** Name, species, sex required; sex with no preselected value; species from the active rows only; +the detail required for « Autre » and never sent for another species; breed optional; birth year or full date (D6b), +a full date fills and locks the year (U3), no year turned into a date, not in the future (device date), not before +1900; bounds and patterns from `field-limits.ts`; errors under their field, first error focused; one +`create_request_id` per creation intent reused on a retry; `conflict` keeps the typed values and shows the stored +ones; leave guard. + +C5. **Creation with a first client.** Optional; one atomic `create_animal` call carrying `client_id`, +`relation_role` and `started_on` (never two calls); the role explicit with none preselected; the pre-associated client +removable before saving; a lost answer retried with the same request id gives one animal and one relation. + +C6. **Animal page.** Identity, species, sex, breed, birth with its known precision, status; current relations then the +history, roles, client links, phones as `tel:`, dates only when known (`ended_at` never shown as a date); « Propriétaire +non renseigné » without a current owner, never a placeholder client; voided relations shown nowhere; actions only on an +active animal; archive and restore through the shared dialog, archived page read-only, no client archived. + +C7. **Relation writes.** Add (both active, explicit role, optional start), end with an optional real date not before +the start, correct dates, void explained as an erroneous entry and final, never a physical deletion; every write sends +the revision it read; `duplicate_relation`, `conflict`, `already_ended`, `archived`, `limit_reached`, `rate_limited`, +`session_expired`, `network` phrased distinctly; a stale relation (`conflict`, `not_found`) reloads the relations; +confirmations refuse to close while pending and return focus after the change is shown, also when the opener left. + +C8. **Client page.** Animals from `list_client_animals` once per animal and group with every role and dates, linked to +the animal page; « Ajouter un (premier) animal » with the client pre-associated; « Associer un animal existant » panel; +none on an archived client; the contractual `current_animal_count` of the list unchanged; ended relations shown as +former, voided ones nowhere. + +C9. **Navigation, design, accessibility.** « Animaux » after « Clients » in the sidebar and the drawer, drawer only (no +tab bar); existing components and tokens; labels, visible focus, errors announced, heading focused on page open; 375 px +without horizontal overflow; FR/EN key parity; the new pages pass axe without any KNOWN exception applying to their own +elements; the two phone states scanned from the top of the page are justified in BROWSER_TESTS.md §6. + +C10. **Tests.** Unit (access mapping and call shapes, schema and display rules, screens: states, request id reuse, +conflict, archive, relations, client page, session gate); the access layer against real PostgREST +(`animals-access.sandbox.ts`); Chromium journeys `e2e/shell/animals.spec.ts` (brief §17 items 1 to 24, FR/EN, desktop +and 375, axe, request URLs free of fixture values); existing suites green; counter-checks recorded in §11.8. + +C11. **Reports, docs, git.** No private data in reports, traces or logs beyond fictitious fixtures (shell suite: no +trace, no HTML report); contract §11.8, §13.3, §14, §15, SUPABASE.md §3.3 (restore check, DEV browser acceptance), +BROWSER_TESTS, TEST_STRATEGY, FRONTEND_ARCHITECTURE, design README, CLAUDE.md updated; commits pushed; no merge; `main`, +`develop` and `release/0.2.0` untouched; DEV untouched (M1 to M3 still pending there). + +C12. **Technology boundary.** No business rule re-implemented in TypeScript that PostgreSQL already enforces beyond the +D-R7 form checks; no artificial Rust/wasm call; the boundary choice written in §11.8.