Answer library line reaches the modes no local catalogue can resolve - #2736
Answer library line reaches the modes no local catalogue can resolve#2736BigSimmo wants to merge 12 commits into
Conversation
The "Also in your library" line under an answer resolved links from four catalogues loaded in the browser (medications, services, forms, differentials). A clinician asking a question in Answer mode could never be shown a matching DSM diagnosis, dictionary term, formulation, specifier, therapy or tool, though every other mode's "Also matches" tray can reach them through /api/search/universal. Widen the data behind the existing line rather than replacing it. The line keeps its disclosure, its placement inside the answer thread, its walk back through earlier turns, and the per-record "Search in <mode>" action and cross_mode_link_open telemetry that the mode-level tray does not have. - buildCrossModeLinksFromUniversalSearch maps universal-search groups to the same CrossModeLink shape, gated on a query term naming the record at a word boundary, the same weight and minimum term length the differentials path uses. An errored or empty group contributes nothing. - The consumed domains and their complement come from one array, so a domain cannot later be read by both halves and print one record twice. - The lookup is opt-in per surface (universalMode) and off by default, so no surface that already mounts UniversalSearchAlsoMatches runs a second one. - It is withdrawn while a generation is in flight, matching the rule the sibling tray follows on this mode, and it never fires for an answer thread restored onto an unsubmitted shared home. Documents stays excluded: an answer already cites its documents in the evidence rail and the source drawer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Ten cases for buildCrossModeLinksFromUniversalSearch, covering the parts that would fail silently: an errored or empty group contributing nothing, a domain the catalogue half already resolves being ignored, a substring hit rejected because the query does not name the record at a word boundary, short query filler dropped, a record the catalogue half already listed not repeated, the per-mode and total caps, and a distinct React key when a domain omits its id. One case pins the two domain lists as exact complements, because that is the property which stops a future domain being read by both halves and printing one record twice. The coverage register's Answer exemption now states the current contract rather than only the 2026-08-26 duplication history, and a new case pins the universalMode opt-in on the answer surface. Without it the exemption's claim that Answer answers cross-mode discovery elsewhere quietly stops being true. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Review of the first commit found an unstated consequence: the catalogue half caps itself at four links and the universal half added up to two more, so the line's ceiling moved from four rows to six without anyone deciding it. Fill to a combined five instead. The widened reach keeps its full two rows on the common answer, which names no medication, service, form or differential at all, and a thread that already resolved four clinical records grows by one row rather than three. The new browser test is the proof the unit tests cannot give: an answer for a question naming a DSM diagnosis, with only /api/search/universal mocked, must show a Bipolar I Disorder card inside the answer's own library line, with both its open and its search-in-mode controls. It also asserts the request carries exactly the six domains the line consumes, which is what stops a record arriving down both paths, and re-asserts that this surface still has one panel and not two. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Section 12.8 records the 2026-08-26 decision to keep one cross-mode panel under an answer and says which one won. It does not say that the winner reached four catalogues while the panel it replaced reached twelve domains, so a reader working from that section would conclude the surfaces were equivalent. They were not, and the gap is invisible from the screenshots the section was written around. Add 12.9: the coverage that was lost, why the fix widens the line rather than undoing the decision, the three constraints that keep it inside 12.8, the new five-link ceiling, and the five modes that remain unreachable because they contribute no cross-entity search domain at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_e7dd1b46-4d96-45ce-8eb6-7cac3580988c) |
Owner decision, 2026-09-07, reversing the collapsed one-line disclosure that direction B introduced on 2026-08-26. The answer surface now renders the same open card strip every other consumer of this block renders, so the same component no longer behaves one way under an answer and another way everywhere else, and the matches are readable without spending a tap. What does not change: the block stays below the governed caution and above the follow-up suggestions, keeps its two per-card actions and their telemetry, and keeps the widened data source added earlier on this branch. CrossModeLinksLine is left in place rather than deleted. It has no consumer now, and it is one prop away from being the presentation again if the owner wants it back. Three browser tests carried the disclosure as their contract. Each is updated rather than dropped, and each now asserts the absence of a trigger alongside a visible rail, so a disclosure reappearing under an answer fails the suite. The 1280px case keeps its computed-display assertion on the rail, because width was where the previous design broke and that class of failure is still worth catching. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Section 12.9 explained the widened data source while still describing the collapsed line as the presentation. Record that the line is gone, what reversing it costs and buys, why CrossModeLinksLine stays in the file with no consumer, and how the three browser tests that carried the disclosure were turned into guards against it returning. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e3076dd326
ℹ️ 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".
|
@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. The only repository destination is BigSimmo/Database, and the only branch destination is the pull request head branch claude/answer-mode-coverage-gap-ilcwui at starting commit e3076dd; never publish fixes to a detached or synthetic work branch and never create a stacked pull request. Use the authenticated GitHub connector to commit each approved fix to BigSimmo/Database:claude/answer-mode-coverage-gap-ilcwui, then verify that the pull request head contains the published commit before reporting success. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. For a fixed thread, reply with as the first line and as the second line. For a no-code disposition, use followed by . These result markers authorize the workflow to close that exact thread only after it verifies a fixed commit is the pull request head; a local-only commit is not a fix. If publication or verification fails, do not use either result marker, do not claim success, and leave the thread open with the blocker. If human input or new authorization is required, do the same. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation. |
Codex review finding on PR #2736, and it is real. The mapper replaced the API's within-domain ordering with a term-count score, and that score ties constantly: most matches hit exactly one query term. The comparator then fell through to alphabetical title order, so among equally scoring items from one domain the earliest title won. With maxPerMode at 1 that is not a cosmetic reordering, it silently drops the domain's actual top result and shows its second. Carry the item's position in the group the server returned it in and use it as the tiebreaker ahead of the title. Equal score and equal mode priority means the same domain, so that comparison is always within a domain and never an incomparable cross-domain one. item.score is deliberately still unused: its own type says it is comparable within a group only. The new case is the one the reviewer described: a higher-ranked "Zzz" item ahead of a lower-ranked "Aaa" item in the same domain, both matching the same terms. Alphabetical order would take the Aaa record; the domain's ranking takes the Zzz one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Five was set while this block was still a collapsed disclosure, where an extra row cost nothing until the reader opened it. It is open at every width now, so every row is unconditional height on the answer surface, between the governed caution and the follow-ups. Four is the ceiling the catalogue half alone allowed before the widened lookup existed, so holding it keeps this change about reach rather than about size. The cap only binds when the catalogue half filled the strip on its own, and a question naming four medication, service, form or differential records is already well served. The common answer names none of them, which is where the widened reach earns its place and where this number never applies. Renamed the constant: there is no line any more. Also records in the handover why CrossModeLinksLine is still in the file. The owner asked for it to be deleted; check:dead-code-candidate refused, because the symbol was introduced on 2026-08-26 and sits inside the gate's 30-day window. The heuristic is wrong here — its consumer existed and was removed the same day — but tuning a threshold to pass a diff is what that gate exists to stop, so it stays until the window lapses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Owner decision, 2026-09-07, after seeing both ends of this built. Neither was right. Closed by default, as direction B shipped it, hides the matches behind a tap nobody has a reason to take: a closed tray cannot show what it holds, so the reader spends the tap to find out whether it was worth spending. Removing the toggle entirely, the first correction, put four unconditional rows into the answer's evidence stack with no way to put them away, on the densest surface in the product. The hybrid is one control that starts open. The matches are readable without a tap and the space is one tap away. variant="line" is the answer surface's presentation again, so the card strip stays what the DSM diagnosis page and the mockups use. The three browser tests that carry this contract now pin the resting state as open and exercise the collapse from there. The 1280px case asserts the rail's own computed display in both states rather than the trigger's word for it: a `hidden` beside a `md:flex` in one class list loses to the media query from 768px up, which once left a rail painted open while its trigger reported it closed. Resting open, the same mechanic would hide a broken collapse instead, so the closed state is the one pinned on computed display. The ceiling stays at four. Its height argument is weaker now the line can be put away, but four is the number the catalogue half alone allowed and there is no reason to spend the difference without asking. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Owner decision, 2026-09-07. The header listed the first three record names beside the label from sm up, so the reader saw "Bipolar disorder · East Metropolitan Eating Disorder Specialist Service · Kara Maar Spe…" and then the same records as cards immediately underneath. Those names were doing real work while the line rested closed: a closed tray cannot show what it holds, so the preview was the only way to tell the reader whether opening it was worth a tap. The line rests open now, so the preview repeats what is already on screen and truncates mid-word to do it. The header is label, rule and count at every width, which is the same editorial device the sibling "Also matches" tray uses. The rule no longer stops at sm, because the names are no longer taking its place from there up. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_cb631f76-8097-4ccf-bbe3-6c10d873f6fe) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b699fd59-5081-423b-bd35-480616e71325) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_9ff49530-be56-4267-98a6-00790d5594a6) |
Summary
/api/search/universaland reaches twelve domains. So since 2026-08-26 a clinician asking a question in Answer mode could never be shown a matching DSM diagnosis, dictionary term, formulation, specifier, therapy or tool, though all sixteen other modes could. The gap is invisible from a screenshot, which is why it survived the chrome convergence in fix(answer): collapse the library tray on desktop, and split its card action in two #2661.UniversalSearchAlsoMatches(owner chose option A). It keeps its placement inside the answer thread between the governed caution and the follow-ups, its walk back through earlier turns when a follow-up drops the entity name, and the per-record "Search in mode" control andcross_mode_link_opentelemetry the mode-level tray does not have.buildCrossModeLinksFromUniversalSearchmaps universal-search groups into the sameCrossModeLinkshape, gated on a query term naming the record at a word boundary. Same weight and minimum term length the differentials path already used, because a content-only score cannot be trusted on a question full of filler.universalMode) and off by default, so no surface that already mountsUniversalSearchAlsoMatchesruns a second one. The consumed domains and their complement come from one array, so a domain cannot later be read by both halves and print one record twice. It is withdrawn while a generation is in flight, matchinganswer && !loadingon the tray, so the lookup never races the answer stream.documentsstays excluded: an answer already cites its documents in the evidence rail and the source drawer. Calculators, Factsheets, Sources, On Call and Favourites remain unreachable because they contribute no cross-entity search domain at all, so nothing can resolve a link to them from any surface.Presentation (settled after three passes, owner-directed)
The block keeps
variant="line"— one toggle in a recessed tray — and now rests open, with no preview of record names in its header.Both extremes were built and looked at first. Closed by default, as direction B shipped it, hides the matches behind a tap nobody has a reason to take: a closed tray cannot show what it holds, so the reader spends the tap to find out whether it was worth spending. Removing the toggle entirely put four unconditional rows into the answer's evidence stack with no way to put them away, on the densest surface in the product. One control that starts open gives the reader the matches for free and the space back on request.
The header's preview of the first three record names went with the same change. Those names earned their room while the line rested closed and had no other way to say what it held; open, they were naming the cards immediately beneath them and truncating mid-word to do it. The header is label, rule and count at every width — the device the sibling tray already uses.
One near-miss worth recording:
CrossModeLinksLinewas almost deleted while it briefly had no consumer.check:dead-code-candidaterefused (introduced 2026-08-26 (12d ago, threshold 30d)), the deletion was dropped rather than forced past the threshold, and within the hour the component was the presentation again.Verification
npm run verify:pr-localVerification not run: the gates below were run directly instead, and their real output is quoted.npm run typecheck— exit 0 on the final head. It caught three real errors during this work (a narrowas consttuple in a new test, a stale locator after a presentation change, and an unused import), each fixed before pushing.npm run lint— clean:[gate-receipts] recorded a pass for "lint:internal" (7433 input files).npm run verify:cheap—Test Files 1269 passed | 1 skipped (1270),Tests 18077 passed | 2 expected fail | 3 skipped, exit 0. Run on the data-layer head, before the presentation settled.npm run check:design-system-contract—design-sync contract checked: 55 components and 7 guidelines,Token-layer divergence pin matches (light 29; dark 22; forcedColors 3).npm run check:diff-integrity—PASS — 3 changed test file(s), 38 -> 50 test case(s), against base 0177bed18.No assertion was weakened or deleted.Focused vitest —
Test Files 3 passed (3), Tests 49 passed (49)on the final head.npx prettier --check— clean on every changed file, result committed.npm run verify:uiwhen UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changedUI verification not run: npm run plan:browser escalated to the full Chromium suite because src/components/ClinicalDashboard.tsx counts as a shared foundation, though the change there is one prop. CI runs that suite on this PR, so it was not paid for twice locally.CI's full browser suite (Production UI critical,Production UI (1),(2),(3)) passed on an earlier head of this branch. What was run locally against the final presentation is a focused proof of the five specs this diff can break:Through
scripts/run-playwright.mjsagainst its isolated production build andnext startserver, on the repo's pinned browser (Chromium revision 1234 is installed and launchable, version 151.0.7922.34; noPLAYWRIGHT_CHROMIUM_EXECUTABLE_PATHoverride was needed or set). This proves those five journeys only; regressions elsewhere are CI's job.A new browser test carries the contract this change exists for: with only
/api/search/universalmocked with NDJSON, an answer to a question naming a DSM diagnosis must show a Bipolar I Disorder card in the answer's own library line, with both its open and its search-in-mode controls. It also asserts the request carries exactly the six consumed domains, and that this surface has one panel and not two.The three tests that pin the disclosure now assert it rests open and exercise the collapse from there. The 1280px case asserts the rail's own computed display in both states rather than the trigger's word for it: a
hiddenbeside amd:flexin one class list loses to the media query from 768px up, which once left a rail painted open while its trigger reported it closed. Resting open, the same mechanic would hide a broken collapse instead.Screenshots were taken at 390, 834 and 1440 in light and dark for each presentation considered, from a dev server rather than a production build — a real difference, and not offered as production visual proof.
npm run eval:retrieval:quality— not applicable, no retrieval, ranking, selection, chunking or scoring behaviour changed.npm run eval:rag/npm run eval:quality— not applicable, answer generation, the synthesis prompt and answer post-processing are untouched.npm run check:production-readiness— not run. No clinical workflow, privacy, environment, Supabase, source governance or deployment behaviour changed; this is a navigation affordance below a completed answer.No provider-backed command was run. This session has no Supabase or OpenAI credentials and the app runs in demo mode, so no live retrieval was validated and none is claimed.
Risk and rollout
/api/search/universalrequest per completed answer on the Answer surface, to an endpoint the other sixteen modes already call on every submitted search, debounced and cached by the existing hook.src/lib/rag/**, clinical-search, retrieval-selection, ranking-config, the retrieval RPCs, the eval harness or the golden fixtures is touched. The change consumes/api/search/universalas a client and alters no ranking, scoring or ordering inside it.Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Evidence for those, in the same order: this adds navigation to library records and never a clinical statement, and the governed caution above it is untouched; no patient-identifiable workflow exists in the diff; no Supabase surface is touched;
src/lib/cross-mode-links.tsimportsUniversalSearchGroupfrom@/lib/universal-searchas a type only, erased at build, so the server module's snapshot, rag and supabase chain cannot enter the client bundle; the endpoint's existing demo and live split is unchanged; failure degrades to rendering nothing rather than a guess; and no clinical decision-support behaviour changed.Notes
Reviewer's attention is best spent on two things. Whether four is the right ceiling now that the line can be collapsed again — the height argument for it is weaker than when the line had no toggle at all. And the render-time read of
window.location.searchinCrossModeLinksSection, which reuses the pattern already shipped inuniversal-search-also-matches.tsxand is safe only because it feeds the hook'senabledand changes no markup.One thing worth recording because it is not enforced anywhere: the type-only import of
@/lib/universal-searchis what keeps the server module out of the client bundle, and no lint rule or bundle gate would catch a future accidental value import. The same is already true ofuse-universal-search.ts, so this is a pre-existing convention rather than a new exposure, but it is a real gap.docs/answer-page-redesign-handover.mdgains a §12.9 recording what the 2026-08-26 direction-B decision cost, why the presentation ended where it did after both ends of it were built, and the dead-code gate's part in that.🤖 Generated with Claude Code
https://claude.ai/code/session_015Xwq7U1Gu9Ncs2Aj3yFfMF
Note
Low Risk
Changes are limited to post-answer navigation suggestions and an extra debounced universal-search client call; answer text, citations, and retrieval are untouched.
Overview
Answer’s “Also in your library” line now reaches DSM, dictionary, formulation, and other modes that only exist on
/api/search/universal, without bringing back the duplicate mode-level “Also matches” tray.CrossModeLinksSectionaccepts an opt-inuniversalMode(Answer passes"answer"when not generating). It merges catalogue links withbuildCrossModeLinksFromUniversalSearch, which maps six universal domains intoCrossModeLink, filters by word-boundary title matches, dedupes against the catalogue half, and respects a four-link strip ceiling. The lookup is disabled whilegeneratingso it does not race streaming answers.Presentation: the line variant starts expanded (still collapsible) and the header drops the three-name preview—label, rule, and count only—matching the sibling tray.
Tests and handover §12.9 document coverage, domain exclusions, and disclosure behavior.
Reviewed by Cursor Bugbot for commit f2b26e3. Configure here.