feat(sharing): the shared-access panel and the record-activity view

Settings gains one section for one concept: who else can open this health
record, whose this account may open, and when they were opened. Split across
two pages it would be two half-answers.

An invitation confers nothing until the other person accepts it, and the card
says so above the field rather than after the submit — that is the part
somebody needs to know before they type a name. Refusals are named from the
stable errorCode, because "no account with that name" and "that person already
has access" are different situations with different next steps.

Ended grants stay in the list. The row is the consent record, and "who had
access, from when to when, and who ended it" is the question the panel exists
to answer; a list that dropped them could not. Revoking asks once and then does
it: reducing access must never be harder than granting it was.

`GET /api/account/activity` answers the owner's other question. One row per
person per day with a count, not one per request — a hundred identical lines
is a way of answering nothing. The window is published with the rows rather
than assumed: audit history is purged on a schedule the operator sets, so the
view prints the number the server resolved from the same setting the purge job
reads. An instance running ninety days says ninety.

Six locales ship with it.
This commit is contained in:
Marc-André Bombeck committed 2026-08-02 14:26:39 +02:00
1 parent dd3d5646de
commit 5199de78af
20 files changed
+1620

No files matched your search

@@ -498,6 +498,40 @@ const REGISTRY: DestructiveEntry[] = [
],
},
// ── Account sharing ─────────────────────────────────────────────────────
{
file: "components/settings/access/grants-given-card.tsx",
destroys:
"another account's standing access to this health record, and every browser session of theirs that was inside it",
recovery: "permanent",
confirm: ["ConfirmButton"],
undetected:
"No detector sees it. The DELETE goes out from `useRevokeGrant` in `lib/queries/use-account-grants.ts`, and `lib/` is an excluded root; the card itself only calls `.mutate(grant.id)` with a bare string, which no payload pattern matches, and the route path lives in the hook rather than here. Registered by hand.",
},
{
file: "components/settings/access/grants-received-card.tsx",
destroys:
"this account's own access to somebody else's record, handed back rather than withdrawn",
recovery: "permanent",
confirm: ["ConfirmButton"],
undetected:
"Same shape as the card above, and one step further out of reach: renouncing is a POST, so not even a DELETE goes out. The path (`/api/account/grants/{id}/renounce`) names an act the D2 vocabulary does not carry, and it lives in the hook regardless. Registered by hand.",
},
{
file: "components/settings/access/grant-invite-card.tsx",
destroys:
"nothing — it offers access, and the offer confers nothing until the other person accepts it",
recovery: "permanent",
confirm: [],
unconfirmed: [
{
control: "the invitation form",
reason:
"D3 flags this file for `expiresAt: null` in the invite payload, reading it as a field being blanked. It is not: null means the grant runs until somebody ends it, which is the common household case and the absence of an expiry rather than the removal of one. The form creates a pending row and destroys nothing, and gating a creation behind a confirmation dialog would teach people to click through the dialogs that do guard a loss.",
},
],
},
// ── Admin ───────────────────────────────────────────────────────────────
{
file: "components/admin/danger-zone-section.tsx",