From 11ec0122a67bc507eeec308b2ab80c234322772c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 12:58:31 +0000 Subject: [PATCH 1/3] fix(rag): avoid over-expanding broad agitation management queries Keep medication-chart token expansion for dose/route/chart/options/listed signals from the rag-tree4 clinical-search change, but drop bare "table" and "management" triggers so topic lookups and pharmacological management questions stay on the agitation arousal topic query. Co-authored-by: BigSimmo --- src/lib/clinical-search.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/clinical-search.ts b/src/lib/clinical-search.ts index 270739d53..70ef483fe 100644 --- a/src/lib/clinical-search.ts +++ b/src/lib/clinical-search.ts @@ -1272,11 +1272,17 @@ export function buildClinicalTextSearchQuery(query: string) { (hasAgitationArousalTypo && /\bagitation\b/i.test(correctedQueryText) && /\barousal\b/i.test(correctedQueryText)) || /\bagitation\b/i.test(correctedQueryText); const agitationMedicationIntent = medicationDoseEvidenceQueryIntent(query); + // Chart/dose/route/options expand into medication-chart terms. Bare "table" or + // "management" alone must not — those appear in topic lookups like + // "which table covers … pharmacological management" and broad management questions. + const agitationChartSurfaceMatch = + /\b(?:dose|dosing|route|oral|intramuscular|im|po|chart|options?|listed)\b/i.test(correctedQueryText); const wantsAgitationMedicationChart = hasAgitationArousalContext && (agitationMedicationIntent.asksAmount || agitationMedicationIntent.asksRoute || - agitationMedicationIntent.asksFrequency); + agitationMedicationIntent.asksFrequency || + agitationChartSurfaceMatch); const wantsAgitationArousal = hasAgitationArousalContext && (wantsAgitationMedicationChart || @@ -1294,7 +1300,11 @@ export function buildClinicalTextSearchQuery(query: string) { normalizedTokens.splice(0, normalizedTokens.length, "clozapine", "monitoring"); } else if (wantsAgitationMedicationChart) { const requestedDoseRouteTerms = medicationDoseEvidenceSearchTerms(query); - normalizedTokens.splice(0, normalizedTokens.length, "agitation", "arousal", ...requestedDoseRouteTerms); + const medicationChartTokens = + requestedDoseRouteTerms.length > 0 + ? ["agitation", "arousal", ...requestedDoseRouteTerms] + : ["agitation", "arousal", "pharmacological", "management", "medication", "chart", "dose", "route", "im", "po"]; + normalizedTokens.splice(0, normalizedTokens.length, ...medicationChartTokens); } else if (wantsAgitationArousal) { normalizedTokens.splice(0, normalizedTokens.length, "agitation", "arousal", "pharmacological", "management"); } else if (/\badmission\b/i.test(query) && /\bcommunity patients?\b/i.test(query)) { From 00b9f1baa16f956cfa55c9a9c96f39165b3a072c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 13:01:12 +0000 Subject: [PATCH 2/3] docs: record PR queue babysit outcomes for #833-#852 Document which screenshot-queue PRs were closed as superseded or unsafe, and that the unique clinical-search fix continues in #853. Co-authored-by: BigSimmo --- docs/branch-review-ledger.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/branch-review-ledger.md b/docs/branch-review-ledger.md index 238466866..0b4ce3044 100644 --- a/docs/branch-review-ledger.md +++ b/docs/branch-review-ledger.md @@ -20,6 +20,7 @@ Use this ledger to prevent repeated branch and PR reviews when the reviewed HEAD | Date | Branch or ref | Reviewed HEAD | Scope | Outcome | Checks | | ---------- | -------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 2026-07-18 | PR batch screenshot queue → #853 / cursor/pr-queue-land-3084 | 11ec0122f (tip of cursor/pr-queue-land-3084) | open-PR review + merge babysit | Reviewed screenshot PRs #833/#837/#845–#852 + Communication #19. #852/#848 already merged. Closed superseded/unsafe: #833/#837 (empty vs main), #845 (clinical-search over-expand; fixed in #853), #846/#847/#849 (Production UI red design-audit dupes), #850 (CONFLICTING), #851 (schema-test regressions), #726 (CONFLICTING CodeRabbit UTG). Unique safe fix landed in #853: agitation chart expansion without bare table/management over-trigger. Communication #19 inaccessible (repo not resolvable). | Focused Vitest clinical-search 42/42. Local verify:cheap unit suite hit pre-existing pdf-extraction-budget failures also on main (2 tests). Hosted CI babysit on #853; no OpenAI/live Supabase writes. | | 2026-07-18 | PR batch screenshot queue → #808/#812/#814 | 44555ab9e414f615981eb444f46a62333c28ec18 | open-PR review + merge babysit | Screenshot PRs #784–#789 closed as superseded. Unique residual work landed via #808 and #812. Design-audit/Playwright stack landed via #814 after Production UI fixes (Clinical Guide H1, service mocks, reduced-motion dock asserts), presentations empty-query fallback, and CodeRabbit thread resolution (RightRail remount, IS DISTINCT FROM, no-op dropped trigram migration). #783 already merged. Communication #17 inaccessible from this token. | Hosted #808/#812/#814 required checks green including Production UI; migration replay green on #814. No OpenAI/live Supabase writes. | | 2026-07-18 | PR batch screenshot queue → #808 / cursor/pr-queue-land-bfe7 | 3b54a785c7c6073024b6bae0182b6a9321154595 | open-PR review + merge babysit | Consolidated unique remaining work from screenshot PRs onto current main via #808 (Also matches placement, factsheets, audit metadata minimize with numeric storageRemoved, answer-progress UI gate, global-error role=alert). Superseded already-landed #800/#799/#801/#802 (via #798/#804). Closed conflicted/failing design-audit duplicates #789/#790/#803/#806/#807/#788 and older duplicates #748/#749/#751 without replaying Production UI regressions. | Hosted #808: required checks green (Static/Unit/Build/Production UI/Migration replay/PR required). Supabase Preview failed (non-blocking concurrent preview limit). Local focused Vitest audit+factsheets; sitemap:check; ci-change-scope self-test. verify:cheap PDF budget failures pre-existing on main. No OpenAI/live Supabase writes. | | 2026-07-17 | PR #732 / claude/edge-to-edge-content-lv9x7k | 354f9bf31b56d811d8611a9b248f7aebc7cde082 | open-PR review + merge babysit | No high-confidence P0-P2. Phone shell/sheet/settings replace dvh clamps with h-full inside fixed inset-0 parents (iOS Safari toolbar collapse). Merged to main via auto-merge. | Hosted required checks + Production UI green; pairwise merge-tree with sibling UI PRs clean. | From 51af6d1aa010dbbf4672adddfc443901aa29a982 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 18 Jul 2026 13:04:10 +0000 Subject: [PATCH 3/3] style: format clinical-search agitation chart expansion Satisfy Prettier so Static PR checks pass on the consolidation PR. Co-authored-by: BigSimmo --- src/lib/clinical-search.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/clinical-search.ts b/src/lib/clinical-search.ts index 70ef483fe..cd9112d27 100644 --- a/src/lib/clinical-search.ts +++ b/src/lib/clinical-search.ts @@ -1275,8 +1275,9 @@ export function buildClinicalTextSearchQuery(query: string) { // Chart/dose/route/options expand into medication-chart terms. Bare "table" or // "management" alone must not — those appear in topic lookups like // "which table covers … pharmacological management" and broad management questions. - const agitationChartSurfaceMatch = - /\b(?:dose|dosing|route|oral|intramuscular|im|po|chart|options?|listed)\b/i.test(correctedQueryText); + const agitationChartSurfaceMatch = /\b(?:dose|dosing|route|oral|intramuscular|im|po|chart|options?|listed)\b/i.test( + correctedQueryText, + ); const wantsAgitationMedicationChart = hasAgitationArousalContext && (agitationMedicationIntent.asksAmount ||