Skip to content

Registry follow-ups: multi-user auto-seed, index reconciliation (prepared), favourites hydration - #238

Merged
BigSimmo merged 7 commits into
mainfrom
claude/registry-followups
Jul 3, 2026
Merged

Registry follow-ups: multi-user auto-seed, index reconciliation (prepared), favourites hydration#238
BigSimmo merged 7 commits into
mainfrom
claude/registry-followups

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Three independent registry follow-ups on one branch, each its own commit:

  • Multi-user auto-seed (cb0657f) — registry records are owner-scoped and were only seeded via the CLI for one owner, so any other authenticated account saw the empty "run the seed" state. ensureRegistrySeeded (src/lib/registry-seed.ts) is now called lazily from the registry API: the list route seeds when the owner has no records, the detail route seeds on a miss when the owner has zero rows of that kind (covers deep-linking a saved favourite before loading home). Idempotent upsert (owner_id,kind,slug) is race-safe; a seed failure falls back to the empty set rather than 500-ing. Demo / local-no-auth behaviour is unchanged.
  • storage_cleanup_jobs index reconciliation (f4fa3bc) — migration 20260703030000 (idempotent) drops the legacy live index names and (re)creates the intended named/partial indexes to match supabase/schema.sql. Prepared for review only — NOT applied to live. Functional-not-broken (the document_id FK is covered). Docs debt note added.
  • Favourites hub surfaces saved services/forms (85d4f4f) — new useSavedRegistryFavourites hydrates localStorage-saved slugs via useRegistryRecords into the hub, with additive services/forms favourite types + tabs. Prototype items remain for the not-yet-backed categories.

Verification

  • npm run verify:cheap (981 tests green)
  • npm run verify:ui (87 Chromium tests green, incl. the new favourites hydration test)
  • npm run verify:release
  • npm run format:check
  • npm run check:production-readiness (:ci variant — READY; warnings are env-only in the worktree)
  • npm run check:deployment-readiness (no deployment/hosting change)

Clinical Governance Preflight

Registry auto-seed touches owner-scoped document/registry access:

  • Source-backed claims still require linked source verification before clinical use (unchanged)
  • No patient-identifiable document workflow was introduced or expanded
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only (seed uses the admin client server-side; a type-only import keeps registry-seed runtime-decoupled)
  • Demo/synthetic content remains clearly separated (auto-seed only runs on the authenticated non-demo path; demo mode still returns fixtures)
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative (deriveGovernanceColumns unchanged; seeding never emits approved)
  • Deployment classification/TGA SaMD impact checked — no clinical decision-support behaviour change (reference-data seeding + UI + index reconciliation only)

Notes

  • Migration 20260703030000 is prepared, NOT applied. It reconciles live's legacy auto-named storage_cleanup_jobs indexes with schema.sql; apply to live only with explicit approval. Idempotent and a no-op on a fresh db reset.
  • Multi-user auto-seed's full behaviour needs a second real account to prove end-to-end (local runs use demo/no-auth and bypass the DB path); the route logic is covered by unit tests and the favourites hydration by a Chromium test.

🤖 Generated with Claude Code

BigSimmo and others added 3 commits July 3, 2026 17:29
Registry records are owner-scoped and were only seeded via the CLI for one
owner, so any other authenticated account saw the empty "run the seed"
state. Add ensureRegistrySeeded (src/lib/registry-seed.ts) and call it
lazily from the registry API: the list route seeds when the owner has no
records, and the detail route seeds on a miss when the owner has zero rows
of that kind (covers deep-linking a saved favourite before loading home).

The upsert conflict target (owner_id,kind,slug) makes it idempotent and
race-safe for concurrent first requests; a seed failure falls back to the
empty set rather than 500-ing the read. The seed CLI now shares the row
builder (keeping its reseed governance-preservation). Demo / local-no-auth
behaviour is unchanged, so env-less e2e stays green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…apply)

Live carries legacy auto-named indexes (storage_cleanup_jobs_document_id_idx,
_owner_id_idx, a non-partial _status_created_idx) that diverge from the names /
definitions in supabase/schema.sql, even though the hardening migration that
supersedes them is recorded as applied. Add an idempotent migration that drops
the legacy names and (re)creates the intended named/partial indexes, plus a
docs/process-hardening.md debt note.

Functional-not-broken (the document_id FK is covered), so this is prepared for
review only -- APPLY TO LIVE with explicit approval. Safe/no-op on a fresh
db reset. schema.sql already matches the intended shape, so there is no schema
change and the duplicate-stem schema test is unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Favourites hub rendered only prototype data, so a user's saved
services/forms (localStorage clinical-kb-saved-*) never appeared. Add
"services"/"forms" favourite types + tabs (additive; the mockup uses its own
local fixtures, so no blast radius) and a useSavedRegistryFavourites hook that
hydrates the saved slugs via useRegistryRecords -- fetch-gated on there being
saved items, so the empty case makes no request. Prototype items remain for the
not-yet-backed categories. Adds a Chromium test that seeds a saved slug and
asserts the hydrated title appears.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo enabled auto-merge (squash) July 3, 2026 10:04

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85d4f4f1e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/app/api/registry/records/route.ts Outdated
BigSimmo and others added 3 commits July 3, 2026 18:09
format:check is not part of verify:cheap, so the Item 4 files were not
prettier-checked locally before the first push. No logic change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codex review (PR #238): the auto-seed try wrapped both the seed write and the
follow-up read, so a read failure after a successful seed was logged as a seed
failure and returned an empty registry (list route) / 404 (detail route). Move
the re-read outside the try in both routes -- only the seed write is
best-effort; a genuine read failure now surfaces as an error rather than a
misleading empty/missing result.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo merged commit d762280 into main Jul 3, 2026
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d0032a6a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +33
id: `${type}:${record.slug}`,
title: record.title,
type,
set: "",
meta: record.subtitle ?? (type === "services" ? "Saved service" : "Saved form"),
sourceMeta: type === "services" ? "Service" : "Form",
primaryAction: "Open",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wire saved favourites to detail routes

For saved services/forms this new item only carries id: ${type}:${record.slug} and labels the action as Open; FavouriteItemRow renders that as a plain button with no handler, and the mobile chevron is also inert. When a user opens /favourites after saving a service or form, the hydrated item appears but cannot navigate back to /services/{slug} or /forms/{slug}, so the new saved-registry favourite is display-only. Carry an href/slug through this shape and route the primary/mobile action based on type.

Useful? React with 👍 / 👎.

Comment on lines +52 to +53
setSavedServices(readSavedSlugs(savedServicesKey));
setSavedForms(readSavedSlugs(savedFormsKey));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope saved registry favourites by user

These fixed localStorage keys are read without considering the authenticated user, so if two accounts use the same browser profile the second account's /favourites page hydrates slugs saved by the first account (and the registry API will even seed/hydrate those defaults for the second owner). This makes saved services/forms leak across account switches on a shared workstation; include the current user id in the storage key or clear/reload these values on auth changes, and update the detail-page writers consistently.

Useful? React with 👍 / 👎.

@BigSimmo
BigSimmo deleted the claude/registry-followups branch July 5, 2026 11:43
BigSimmo pushed a commit that referenced this pull request Aug 5, 2026
#1606

#1606 is closed, but it carried the one fix nothing else in the queue provides:
MobileResultFilterControl's native <select> paints a harsh system-blue highlight
on phones, and #1615 keeps that native select (its change is the iOS 16px
anti-zoom rule). So the fix does not survive #1615 landing.

Records it as #238 with the two defects the redo must not repeat: the unresolved
keyboard trap on disabled options, and the set-state-in-effect lint error that
PR #1620's new pre-push guard would now catch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T97Kqdj9Xh1Cubv5ms3KVy
BigSimmo pushed a commit that referenced this pull request Aug 5, 2026
…sign

Four conflicts, resolved as the trial merge recorded in the PR body predicted.

`search-screen.tsx` reduced to the handler alone, exactly as forecast: both
sides had independently arrived at `--text-muted`, so the only disagreement
left was `clearSearchFilters` (here) versus `clearSearch` (main). Kept this
branch's — #1616 branched before defect #1611's sibling was fixed, and
`clearSearch` on a control labelled `Clear` inside a filter row deletes the
query the reader is looking at.

`search-results-header-band.tsx` (2 hunks) took this branch: main's side is
the pre-restructure shelf carrying only the token migration this branch had
already applied.

`document-search-results.tsx` (3 hunks): the two empty-state hunks took this
branch's shared `SearchResultsEmptyState`. The import hunk is a genuine merge —
v2 renamed `metadataPill` to `metadataPillDensity`, and the auto-merged body now
calls `metadataPillDensity.roomyCompact`, so the import must follow. `EmptyState`
is dropped from it because both of v2's call sites are the ones this branch
replaced.

`docs/outstanding-issues.md`: #1616 minted its own #237 and #238 from the same
`next-id`, so both sides landed rows under both numbers. Renumbered *this*
branch's to #246 and #247 and bumped the marker to 248, rather than taking one
side wholesale — main's rows are already landed and referenced. This is the
collision `#156` and `#168` predict; the guard caught it.

Two v2 gates then failed on the merged tree and are now satisfied:

- `check:design-system-contract` ratchets `textSoftConsumers` per file, and v2
  had driven both of these to zero. The four remaining usages here are icons and
  glyphs, which this branch had deliberately left on `--text-soft` because v1
  defined no decoration token. v2 defines `--decoration-soft`, so that
  constraint is gone and they move there — the tier v2 itself uses for the same
  nodes.
- The generated adoption manifest and COMPONENTS.md maturity section went stale
  as a result; regenerated with `design-system:adoption:update`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a
BigSimmo pushed a commit that referenced this pull request Aug 5, 2026
…tap floor

Two sessions resolved the #1616 merge independently. The pushed one (`5c0fe4d`)
failed `Static PR checks` on the outstanding-issues guard: #1616 minted its own
#237 and #238 from the same `next-id`, and that resolution kept both sides under
both numbers. This merge keeps the resolution that renumbers *this* branch's
rows to #246/#247 and bumps the marker to 248 — main's are already landed and
referenced, so they keep their numbers. The guard now passes: 245 rows, unique
ids, next-id above the highest, no ids dropped from base 08595cc.

The only other conflict was a duplicated comment block on the therapy quick-filter
`Clear`; both sides already agreed on `--text-muted` and `clearSearchFilters`.

Also fixes a review finding, which is a real inconsistency this branch
introduced: the find-a-filter field shipped at `min-h-10` — 40px — in the very
commit that raised the facets, the disclosure headings, the shelf `Clear` and the
sheet footer to `min-h-tap` (48px). On the surface that exists for phones, the
one control added to make a long filter list usable was the smallest target in
the sheet. It now matches the facets exactly (`min-h-tap sm:min-h-9`).

`decoration-on-text.contract.test.ts` had pinned that field by slicing 600
characters after its testid, so documenting the line broke the guard. It now
walks forward to the element's own `className`, and additionally pins the tap
floor so the 40px version cannot come back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a
BigSimmo added a commit that referenced this pull request Aug 5, 2026
* fix(ui): make the applied-filter shelf reachable and its dead ends readable

Four review findings land on one row and interact.

F4 — the shelf was a single `overflow-x-auto` row: label, chips, a `flex-1`
spacer, then `Clear`. With four or five chips on a phone the spacer collapses
and `Clear` sits past the right edge, reachable only by swiping a row whose
scrollbar is hidden. That is the same defect the shelf was built to avoid for
the chips themselves. The chips now scroll in an inner track and `Clear` is
pinned outside it.

F5 — the rail fades its edge on overflow and the shelf did not, so a sixth chip
simply stopped existing visually. The chip track now carries the same mask on
the same overflow condition, via a second instance of the existing
`useRailOverflow` hook.

F3 — `Clear` was `px-2 py-1`, about 26px beside 48px chips: the row's only
global action was also its hardest target. Matched to the chips instead, staying
quiet through weight and an underline. 48px rather than the 44px generic tap
guidance suggests, because `min-h-11` reintroduces a fixed `ui-smoke` sub-pixel
flake and `--spacing-tap` is this repo's floor.

F10 — zero-count facets in the documents sheet were dimmed with `opacity-50`,
which multiplies against an already-muted foreground and lands at 2.34:1. The
disabled state was least readable exactly when it most needed explaining.
Replaced with a real muted pair plus a dashed border: 4.72:1, and it survives
forced colors, where border-style is preserved and opacity is not. The three
facet states are now mutually exclusive branches rather than a base plus an
override — `cn` is a plain join, so competing `border-[color:…]` utilities would
both reach the DOM and stylesheet order, not intent, would pick the winner.

Also rewires the therapy-compass quick-filter row's `Clear` to
`clearSearchFilters`. It sits among the filter chips and is labelled `Clear`,
but it called `clearSearch`, which wipes the query with them — the sibling of
the defect #1611 fixed on the shelf, missed when that was reviewed. The sheet's
`Clear all` is deliberately a full reset and is untouched.

Shelf label becomes a funnel glyph below `sm` and the wordmark from `sm`: a
prefixed chip costs ~215px of a 350px bar, so every character the label spends
is a chip the reader cannot see. The group keeps `aria-label="Applied filters"`
either way, so both forms are decorative.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* feat(ui): give the filtered-to-zero empty state its relax-the-filter route back

F11. The release that made filters real (#1555) is also the one that removed the
only copy pointing at relaxing them. The old empty state read "Relax the scope,
try an example, or jump to another mode" with a `Clear scope filters (N)`
button; both were dead — they keyed off the inert scope system and never
rendered — so the change deleted them and left "Try an example, or jump to
another mode." A reader who has filtered to zero is offered an unrelated example
query and a different mode, never the chips sitting directly above that caused
it.

`SearchResultsEmptyState` now takes the same `appliedFilters` the shelf renders,
plus `onClearFilters` and `onBrowseAll`. When the set is non-empty it leads with
`Remove "X"` and `Clear all filters`, and demotes the example and cross-mode
routes below a rule — an example query is a different search, and the reader has
not finished this one. With nothing applied the current copy is already correct
and is untouched.

Two things it deliberately does not claim. The heading counts the filters rather
than quoting the query, because the query is not what emptied the set and saying
so sends the reader to rewrite the one thing that was working. And `Remove "X"`
names the last chip without calling it the most recent: `appliedFilters` arrives
in group order, not application order, so that would be a claim the data cannot
support.

Documents and therapy-compass rendered their own bare `EmptyState` for this
case — naming the problem while offering no route out of it — so both now use
the shared surface. Documents also passes Browse, because when narrowing this
result set is not the answer, reaching the whole corpus is.

This retires the last `clearSearch` mislabel on therapy-compass. Its empty state
had one button labelled `Clear filters` wired to `clearSearch`, which wiped the
query too; `Remove "X"` and `Clear all filters` are now separate controls, so
each label matches its own action. The guard added in the previous commit
tightens to assert exactly one full reset survives that screen — the sheet's
`Clear all`, the only control whose label says it clears everything.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* feat(ui): rebuild the documents filter sheet around eleven groups

F7 — facet buttons were `min-h-7`: 28px targets, packed at `gap-1.5`, on the
surface that exists for phones and whose only interactive elements they are.
Raised to the tap token, relaxing to 36px from `sm` and 32px from `lg` where a
pointer is likely. 48px rather than the 44px the design called for, because
`min-h-11` reintroduces a fixed `ui-smoke` sub-pixel flake and `--spacing-tap`
is this repo's floor; the sheet has the vertical room.

F8 — source type is a `radiogroup` and the facets below are `aria-pressed`
toggles, but both rendered as chips of near-identical size, colour and radius,
directly adjacent. Nothing said one row replaces and the next accumulates, so
the OR-within-group, AND-across-groups model had to be found by experiment.
Source type is now a joined segmented control, which reads as one-of on sight,
with a `one only` hint for the first time it is seen. The ARIA is unchanged —
this is presentation.

F9 — eleven groups stacked in one phone column with no collapsing and no search,
so reaching Document type meant scrolling past ten sections. Adds a
find-a-filter field and collapses groups by default, each carrying its selected
count. Both are gated on the same density threshold: a sheet showing two groups
that are both shut is a scroll saved that never existed and two taps added that
did, so below four groups everything stays open and the heading is not a
disclosure control at all. A group holding a selection cannot be collapsed —
a closed section silently narrowing the list is worse than the scroll it saves.

F12 — Library leaves the utility rail. It sat adjacent to Filter while answering
a different question, and it occupied the rail space the pinned Filter needs; it
is also the reason the phone rail could overflow at all. It is moved, not
removed: the requirement the old comment protected still holds, since the
documents action menu routes through `onSearchModeChange`, which clears the
query. Both new homes preserve it — the sheet footer under a rule, phrased as
reach with the corpus count beside it, and the zero-result state.

Also drops the footer's duplicate count. It printed "12 documents" beside "Show
12 documents", spending the sheet's most prominent slot on a number two
centimetres to its left; the button carries it, the new meter and readout carry
the proportion, and the live announcement moves to `sr-only` so it still speaks
as the number changes underneath. The header's `Clear all` becomes `Clear
filters`, matching a handler that was already filter-only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* feat(ui): collapse the results bar to one line and pin what must not scroll away

The band was 123px on a phone to say "12 documents". The utility rail dropped to
its own row and that row was ~85% empty, so the height was spent on the layout
rather than on anything the reader needed. It is now 58px, 60px from `sm`.

F1 — the rationale for moving Filter last was that the right edge is where a
thumb already rests, but the spacer that pushed the rail right was
`hidden lg:block lg:flex-1`, so it did nothing below 1024px. On every phone the
rail was left-packed and Filter sat mid-rail: the change delivered its stated
benefit only at the width where thumbs are least relevant. The query now takes
the flexible space and the control group is edge-aligned at every width, with no
conditional spacer. `mr-auto` does it rather than moving `lg:flex-1` down —
auto margins only absorb what is left after flexible lengths resolve, so the
wide layout is byte-identical and no breakpoint had to move.

F2 — the rail was one `overflow-x-auto` region with Filter as its last child, so
the only control carrying filter state was the first to fall off the right edge
once a Retry button or a longer sort label appeared. The code's own comment
explained that applied-filter chips had been moved out of that rail for exactly
this reason. Only the optional controls scroll now; Filter and Retry are pinned
siblings outside the track. Retry too, because it is the recovery action in a
degraded state — the one control that must never need a horizontal swipe.

The state tile is deleted and the full-width accent border becomes a 2 x 18px
lead rule inside the padding: at bar height a line across the whole width read as
a divider between the composer and the results rather than as the band's accent.

That deletion is where the design as drawn had to be extended. The tile carried
state as SHAPE — alert when faulted, spinner while running, funnel once filtered
— and the mockup replaced it with colour alone, which makes a failed search
identical to a successful one for a reader who cannot separate the hues, and
contradicts a recorded decision. The tile turned out to carry three jobs and only
one needed a tile. Narrowed is now carried by the shelf, which grows the band by
a whole labelled row. Running was already inline. Faulted keeps three
independent non-chromatic channels: the lead rule doubles from one stroke to
two, a CircleAlert renders before the count for non-ready states only, and a
faulted band still renders no digit at all. The mark is a `border-left` on a
zero-width box rather than a background precisely so that forced colors, which
drops backgrounds but maps border colour to CanvasText and preserves
border-style, keeps all of it.

F12 — Library leaves the rail (moved in the previous commit), which is what makes
the arithmetic work: at 390px count + query + Library + Filter does not fit, and
without Library it fits comfortably.

One line is not safe for every mode, and the mockup was drawn for documents. Six
modes pass `MobileResultFilterControl` into `mobileControls` — a `w-full` native
select, and formulation and specifiers pass two in a two-column grid — which is
unreadable pinned into a 58px line at 320px. `mobileControlsPlacement` therefore
defaults to `row` whenever a page passes a phone control and to `inline` when it
passes none; documents and therapy-compass opt in explicitly. The default is the
safe one so a new mode that forgets the prop degrades to today's layout rather
than to an unusable one. Verified at 320/390/430/768/1024/1440 in light, dark and
forced-colors with no page horizontal overflow at any of them.

`tests/ui-accessibility.spec.ts` is rewritten, not deleted: it caught the accent
degrading to a neutral border when Tailwind's utilities layer outranked the
component layer, which has actually happened here, and the same failure now shows
up as a zero-width box. It gains the fault assertion the border-top version could
not make — a border has no style to change — and a guard that its own probe
returned real values, because a silently-null measurement reads as a pass. The
style-effect contract in `tests/helpers/style-contracts.ts` is retargeted from
`search-band` to `search-band-lead` for the same reason.

`docs/search-results-bar-decisions.md` is amended in this commit, since two of
its records go stale here: the state tile, and Library staying in the bar.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* docs(ui): correct two comments the redesign left describing the old band

`search-band` no longer paints the accent, and the placement note referenced a
variable name that never shipped. Also drops the claim that `refetching` is
dimmed "via CSS `data-status`": no such rule exists in globals.css and there is
no evidence one ever did, so the sentence described an intention rather than the
code. Adding the rule is a visual change across twelve modes and belongs to
whoever decides a background refresh should look different — asserting it here
while it does not exist is what let it go unnoticed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* docs(issues): capture the two follow-ups the results-bar redesign surfaced

#237 — the band claimed a `refetching` dimming rule that globals.css has never
defined, so a background refresh is signalled by a pulsing dot alone against
text that is deliberately identical to `ready`. Corrected the comment in the
redesign rather than adding the rule, because adding it is a visual change
across twelve modes.

#238 — the one-line bar currently reaches two modes plus every mode that passes
no phone control. Six pass a `w-full` native select (two of them pass a pair),
which is unreadable pinned into a 58px line at 320px, so they keep their own
row by default. Widening them is per-mode work, not a shared-band change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): reach the corpus from the sheet, and re-point the test that pinned it

Fallout from moving Library off the utility rail, caught by `verify:ui`
(`348 passed, 1 failed`) rather than by anything offline.

`ui-smoke.spec.ts` asserted the ribbon still carried an "Open source library"
button, then used that same button further down to open the Sources drawer and
check focus returned to it on Escape. Both are re-pointed at Library's new home
in the filter sheet's footer rather than deleted — the ribbon assertion is
inverted into an absence, so putting Library back on the rail re-creates the
overflow F12 removed and fails loudly instead of passing quietly.

The behaviour fix the test exposed: the footer control called `onOpenLibrary`
without dismissing the sheet, so the Sources drawer opened underneath a filter
panel still covering the results both of them describe. Browsing the corpus is
leaving the filter surface, not another thing to do on it, so it now closes the
sheet on the way out.

That in turn moves where focus lands when the drawer closes: the opener has
unmounted with the sheet, so the app falls back to the documents options button.
Asserted explicitly, with the reasoning, rather than loosened to "not body" —
it is a visible related control in the same workspace and the app's existing
restore target, but it is a fallback and the comment says so.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* docs(ledger): record the results-bar redesign review at 7eb723b

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): keep document filter sheet chrome scoped to the active query

Reset the find-a-filter needle and expand set when the search query changes,
and keep selected facets visible while the find field narrows the list so an
active constraint cannot become unreachable inside the sheet.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix: restore empty-state recovery and rail observation

* fix: restore therapy zero-result recovery

* fix: keep document filter recovery paths reachable

* test: cover announced empty-state recovery

* test: cover document filter recovery paths

* test: intercept the differential search endpoint

* fix: close filter disclosure click handler

* fix: use a valid exact search route regex

* style: format empty-state regression test

* style: format document-search-results.tsx

* fix(ui): observe overflow without effect state writes

* chore(ui): remove obsolete empty-state import

* fix(ui): stop the empty state claiming a second status region

The auto-fix for Devin's announcement finding gave `SearchResultsEmptyState` a
`role="status"` root. The band already renders one unconditionally on every
search route, so `getByRole("status")` became ambiguous everywhere the empty
state can appear — which is every mode. Devin's own prompt flagged the risk
("checking it does not collide with the band's own single-status-region
assertions"); the collision landed anyway and broke three suites.

A bare `aria-live="polite"` announces identically — `role="status"` is just
implicit polite + atomic — without adding a node to the role query. `aria-atomic`
is deliberately left off: heading and body change together, and re-reading the
whole panel on every keystroke is worse than reading what changed.

Also repairs three tests that were asserting the wrong things:

- The therapy guard counted `b.clearSearch` call sites and required exactly one.
  An agent then added a correctly-labelled `Clear search` recovery, and the count
  read it as a regression. The rule was never about head-count — it is that a
  control wired to `clearSearch` must be *labelled* for clearing the search.
  Rewritten to assert that, so `onClear`/`onClearSearch` pass and an
  `onClearFilters` or bare `onClick` still fails. A duplicate copy of the same
  test carrying the old assertion is removed.

- `states the proportion once…` expected `Show 0 documents` from selecting
  Clozapine + Suicide. The panel deliberately prevents that: once Clozapine
  narrows the set, Suicide re-counts to 0, becomes a dead end, and dead ends are
  click-guarded. The test read the feature as a bug. It now asserts the guard —
  `aria-disabled`, the description, and that the guarded click leaves the count
  alone.

- Two `getByRole("status")` queries in the empty-state tests are now by text,
  matching the role change above.

Two failures in `document-search-record-fault.dom.test.tsx` are untouched here
and are not from this commit — verified failing with these changes stashed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* test: follow the zero-match state onto the shared empty state

`document-search-record-fault.dom.test.tsx` still expected "No matching
documents". That branch adopted `SearchResultsEmptyState` so Library stays
reachable from a search that returned nothing — the gap Codex and Devin both
raised — which changed the heading to the shared "No matches for <query>".

Re-pointed rather than loosened: the assertions still name the exact copy and
still distinguish the loading state from the settled one, so a state that stops
rendering its heading fails here the way it did before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): keep the documents zero-result title a heading

Adopting the shared empty state demoted the main document-search
zero-result title from `h3` back to a paragraph, silently undoing #1612 —
the release that gave `EmptyState` an optional heading level precisely so
the two states owning their region could keep one. Nothing offline
noticed; the only signal was `ui-smoke`'s `@critical` journey going red on
`getByRole("heading", { name: "No matching documents" })`.

`SearchResultsEmptyState` now takes the same opt-in, un-defaulted
`headingLevel` as `EmptyState`, for the same reason: most of the twelve
modes rendering it sit inside a region whose heading the band already
owns, so promoting every title would insert an outline level the page
never declared. Documents passes `3` at the call site that owns its
region; the inline filtered-to-zero state inside the results grid stays a
paragraph.

The Playwright assertion follows the new copy but keeps asserting the
role and level, and `document-search-record-fault` now pins the same
level so the fast gate catches this next time instead of a Chromium
journey.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(test): restore the differentials fault interception, and match empty-state copy to its controls

Three review findings, one of which was a live CI failure caused by acting on
a fourth without running it.

`ui-accessibility`'s two fault tests were switched from intercepting
`/api/differentials` to `/api/search` on review advice. That page's catalog
hook fetches `/api/differentials?kind=diagnosis|presentation` and never
touches `/api/search`, so the interception faulted nothing, the band stayed
healthy, and both tests hung waiting for a fault panel that could not render
— two red `Production UI` shards. Restored, with the endpoint named in a
comment so the swap is not made again.

The empty state's body told every reader to "try an example, or jump to
another mode". `searchCommandSurfaceByMode` is a `Partial<Record<…>>` with no
therapy-compass entry, so on that mode the panel renders neither control and
the copy named two affordances that were not there. The body is now derived
from what the panel actually offers.

Also drops a hardcoded neutral colour literal from the lead-rule assertion —
the line above it already compares against the probed neutral — and scopes the
style-effect contract's selector to `[data-tone="accent"]`, so a degraded
live result cannot fail a contract that exists to catch cascade regressions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): move the new search-surface text nodes off the deprecated decoration tier

Readying this change for the v2 design system (#1616), which activates the
canonical token layer across 224 files and touches four of the same files.

`--text-soft` is a deprecated alias of `--decoration-soft`, and
`ckb-v2-token-contract` pins it *below* 4.5:1 deliberately, "so the tier cannot
be fixed away". TOKENS.md §7 forbids it on any text node. This branch added
eight new text-node usages, which under the v1 palette measure a comfortable
4.72:1 and look correct — and under the v2 palette measure 2.99:1.

The dead-end facet is the one that matters. Its entire reason to exist is that
the previous `opacity-50` treatment measured 2.34:1; putting the replacement on
the decoration tier meant the fix held only until the v2 layer activated, at
which point the same markup would have been worse than the AA floor again with
nothing reporting it.

  dead-end facet copy on --surface-subtle
    opacity-50, before this branch      2.34:1
    --text-soft   v1 / v2         4.72:1 / 2.99:1
    --text-muted  v1 / v2         7.29:1 / 5.99:1   (7.54:1 v2 dark)

Counts, the shelf label, the shelf Clear and the disabled-facet copy move to
`--text-muted`; the find-a-filter placeholder moves to `--text-placeholder`,
which is the role the existing recipe contract already requires. Icons and
glyphs keep `--text-soft` — that is what the tier is for, and v1 defines no
`--decoration-soft` to move them to.

Two of these lines are the exact lines #1616 migrates, so both sides now make
the same change and those hunks merge instead of conflicting.

`decoration-on-text.contract.test.ts` gains four cases pinning the tier per
surface, verified to fail on the regression and pass when restored. A DOM
assertion cannot do this job: jsdom sees the class, not the resolved colour, so
it would pass on either token.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): move the therapy quick-filter Clear label off the decoration tier

The last text node on this branch still using `--text-soft`. It is a button
label, so under the v2 palette it measures 2.99:1; `--text-muted` gives 5.99:1
light and 7.54:1 dark. Found by trial-merging the v2 branch rather than by
reading the diff — the conflict hunk showed v2 migrating this exact line while
this branch kept the old tier.

Matching v2's token choice also shrinks that conflict to the handler alone,
which is the part the two branches genuinely disagree about
(`clearSearchFilters` here versus `clearSearch` on v2's base).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): restore Library on the record-match path, and stop the phantom collapse

Two defects raised in review, both verified against the code and both introduced
by this branch. Neither was covered — the existing suites passed before these
fixes as well as after, which is why each gets a guard proven by inversion.

**Library was unreachable from a services or forms search that matched records
but no documents.** Moving Library off the utility rail left it three homes: the
sheet footer, the zero-result empty state, and the inline fallback. The footer
needs `matches.length > 0`; the empty state needs `recordMatchCount === 0`. The
record-match render satisfies neither and returned `null` outright, so on that
path the only route to the corpus was the documents action menu — which calls
`setQuery("")` and destroys the search being read. That is the precise thing
`docs/search-results-bar-decisions.md` requires an in-context route for. The
control is now a shared const rendered from both paths, so a fourth branch
cannot be added without one.

**A group heading reported a collapse it did not perform.** `isOpen` is forced
true while the find-a-filter field has text, but the disclosure button stayed
mounted and its handler still branched on that forced-true value: tapping it
left `aria-expanded="true"`, rotated no chevron, hid nothing — and wrote the
group into `collapsed`, so the collapse ambushed the reader later, once the
field was cleared and the tap forgotten. While searching, the needle owns what
is open, so the heading now renders in its static form. This is the rule the
comment three lines above it already stated; the needle case was simply missed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

* fix(ui): stabilize results-band review findings on #1615

Keep phone-control row geometry across loading, stop wide selects sharing a
shrinkable flex line with Sort, announce empty states without double-speaking
filtered zeros, and clear the stale docs/comments the redesign left behind.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix(ui): keep the deferred empty-state announce out of the effect body

`788b664` added a deferred screen-reader announcement for the query-only empty
state — a live region that mounts already populated is silent in most screen
readers, so the message has to arrive on a later frame. The mechanism is right;
the implementation called `setLiveMessage("")` synchronously in the effect body
twice, which `react-hooks/set-state-in-effect` blocks. `Static PR checks` went
red on that lint error, and nothing offline caught it: lint is in neither the
unit suite nor `tsc`.

Both cleared calls were dead anyway. The region renders only when `!filtered`,
so the filtered branch had nothing mounted to clear, and that same gate unmounts
and remounts the region across the transition, so it starts empty on its own.
Only the `requestAnimationFrame` callback now sets state, which is the form the
rule allows and the one the deferral needs.

CodeRabbit reached the same fix independently on the same head.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qm3i3eLCDcwytzge1sKM4a

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Aug 5, 2026
* fix(gates): catch lint and type errors before push, not in CI

Two open PRs burned full CI cycles this week on defects a single local
command would have caught: #1606 on a react-hooks/set-state-in-effect lint
error, #1618 on a TS2339 for `mode.devOnly` (a union member that lacks the
property, where app-modes.ts already exports the correct `"devOnly" in mode`
guard). Neither lint nor typecheck was in the pre-push path.

Typecheck could not simply be added, because it was already unusable
(outstanding-issues #210). tsconfig.json's `include` carries
`.next/types/**/*.ts` and `.next/dev/types/**/*.ts` — gitignored build
artifacts — so deleting a page leaves the stale generated validator importing
a removed module. Reproduced rather than inferred: a planted
`.next/dev/types/validator.ts` referencing a removed mockup page yields
`error TS2307: Cannot find module .../mockups/deleted-mockup-route/page.js`,
base config exit 2, source-only config exit 0. Full source typecheck is clean
(71s cold, 8.8s warm). Red locally and green in CI is how the gate got
abandoned, which is how the real type error then reached CI.

- tsconfig.typecheck.json + `typecheck:source`: identical compiler options,
  minus the `.next` globs, with a separate tsbuildinfo so the two incremental
  caches cannot invalidate each other. Route-signature validation is not lost;
  `next build` still covers it in CI.
- guard-push.mjs gains a fourth guard running eslint over the pushed files and
  this typecheck. Verified to reproduce both defects above with CI-identical
  messages. Scoped to the lint roots and to pushes that touch TS, skips loudly
  when node_modules is absent rather than pushing people to
  GUARD_PUSH_DISABLE=1, and overridable with SKIP_STATIC_GUARD=1.

Also corrects a doc claim that made #1580 surprising: "mockups are exempt"
was being read as blanket. Mockups are exempt from the wiring and reachability
gates and nothing else — they are still typechecked, and their client chunks
still count toward check:bundle-budget, which totals every built chunk rather
than the initial production bundle. That the budget's scope contradicts
ledger #13's "not an initial production bundle" position is a real unmade
decision, now recorded as #237 rather than papered over.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T97Kqdj9Xh1Cubv5ms3KVy

* docs(issues): capture the phone Category soft-menu fix salvaged from PR #1606

#1606 is closed, but it carried the one fix nothing else in the queue provides:
MobileResultFilterControl's native <select> paints a harsh system-blue highlight
on phones, and #1615 keeps that native select (its change is the iOS 16px
anti-zoom rule). So the fix does not survive #1615 landing.

Records it as #238 with the two defects the redo must not repeat: the unresolved
keyboard trap on disabled options, and the set-state-in-effect lint error that
PR #1620's new pre-push guard would now catch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T97Kqdj9Xh1Cubv5ms3KVy

* issues: capture #239 stale Cloud acceptance pin on PR #1617, #240 remote-container browser gate drift

* Tighten guard coordinator test

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix(gates): shared source-typecheck lease and safer static pre-push

Treat typecheck:source:internal as a shared read-only coordinator lease with
a distinct per-worktree buildinfo file, drop the pinned in-repo cache path,
and harden staticGuard: acquire a short exclusive lease (fail-open when busy),
use a private eslint cache, escalate lint on eslint policy changes, fail closed
when the push tip is not HEAD, cover eslint-rules, and add Vitest coverage.
Align hook/docs wording with the fourth guard and point CLAUDE.md at #252.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix(gates): keep tsBuildInfoFile when run-heavy has no npm_execpath

Pre-push invokes run-heavy via plain node, so the npm_execpath spawn path
was skipped and the fallback dropped effectiveForwarded — undoing the
per-worktree buildinfo injection. Also warn when staticGuard passes on a
dirty working tree.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* docs: refresh scripts-index for lint:changed:internal

Keep docs:check-inventory green after adding the pre-push eslint wrapper
script to package.json.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix(gates): address Devin findings on static pre-push guard

- Treat "Database focused-test capacity is full" as coordinator busy so
  shared typecheck slot exhaustion fails open instead of faking a type error.
- Skip source typecheck when every changed .ts path is excluded by
  tsconfig.typecheck.json (edge functions, archive, scratch, worktrees).
- Restore check-github-shell-access.mjs (and its Role notes) in the scripts index.

* chore(ledger): record PR #1620 babysit

* fix(gates): emit structured heavy-run admission-busy signal

Prefer exit 75 + DATABASE_HEAVY_RUN_ADMISSION_BUSY over prose matching so
tsc/eslint output that quotes busy strings cannot false-pass the static guard.

* fix(gates): tip-check only when static work runs; isolate typecheck cache

Addresses follow-up Devin on PR #1620:
- Reorder staticGuard so tip-vs-HEAD fails closed only when lint/typecheck
  will actually read the working tree; ignore tag refs in the tip check.
- Pin a distinct tsBuildInfoFile on tsconfig.typecheck.json so direct tsc
  does not collide with the base config cache (run-heavy still overrides).

* fix(gates): keep lint failures when typecheck admission is busy

Addresses Devin on PR #1620 — a prior eslint failure must still block the
push if the follow-up source typecheck cannot get a coordinator slot.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
BigSimmo pushed a commit that referenced this pull request Aug 14, 2026
Second serial transaction. 25 active mutations (13 done, 6 add, 6 update)
plus 5 cancellation decisions. Ledger 106 open / 222 archived to
99 open / 235 archived; inbox 0 pending / 129 applied.

Three of the closures queued in #1940 were cancelled by review, and the
cancellations are right: #235, #237 and #238 each asked for visual or
browser proof, and they were closed on executable evidence instead —
proof shots, a real 320px browser pass, and product-overlay journeys are
not satisfied by a docs table, a jsdom assertion, or generic Sheet unit
coverage. Those three rows stay open. The other six closures applied.

Verified zero live same-target collisions before applying.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017paT42ZVMf8jaLtkjFxdy5
BigSimmo pushed a commit that referenced this pull request Aug 14, 2026
…s instrument now exists

Four corrections, queued as immutable inbox requests.

#235, #237 and #238 each had a `done` queued in PR #1940 and cancelled on
review. The cancellations were right: all three ask for visual or browser
proof and were closed on executable evidence. Each row now records the
attempt, the reason it was refused, and a Stop rule naming the evidence
class that must not be used again — so the next reader does not repeat it:

- #235: section 7.1 opens with "records executable evidence RATHER THAN
  committing image baselines", so the section that looks like the evidence
  says in its first line that it is not
- #237: jsdom does not lay out text, so a 320px assertion proves the string
  is present, not that it fits
- #238: the risk is ancestor-scoped CSS/contain/transform on five specific
  host surfaces, which no Sheet component test can see

All three also drop their IN FLIGHT do-not-start prefix; PRs #1841 and
#1842 have merged, so the warning was blocking rather than protecting.

#231's "Next: instrument and reproduce" is stale — commit a3bc4da added
scripts/probe-generation-quality.ts and adjudicated PR #1861 as superseded
for phase 1. The row now says so, so nobody reviews #1861 as the live fix
or rebuilds the probe. Next is running it where credentials exist.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017paT42ZVMf8jaLtkjFxdy5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant