Skip to content

Improve Therapy best-match visibility - #2342

Merged
BigSimmo merged 7 commits into
mainfrom
codex/therapy-best-match-20260824
Aug 24, 2026
Merged

Improve Therapy best-match visibility#2342
BigSimmo merged 7 commits into
mainfrom
codex/therapy-best-match-20260824

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • highlight the first genuinely query-ranked Therapy search result with a clear Best match badge, accent edge, and stronger Open action
  • avoid implying a recommendation for an unqueried alphabetical catalogue, while preserving ranking logic and the clinician-review warning
  • cover the ranked and unranked states with focused DOM and responsive browser contracts

Verification

  • npm run verify:pr-local
    • Verification not run: explicit bare PR publication request; CI is the requested verification surface.
  • npm run verify:ui when UI, routing, styling, browser behavior, reduced-motion, or forced-colors behavior changed
    • UI verification not run in full: the shared repository browser lane remained occupied by unrelated work.
  • npm run verify:release before release or handoff confidence claims
    • Not run: no release or handoff confidence claim.
  • Focused component and responsive contracts: npm test -- tests/therapy-compass-search-filters.dom.test.tsx tests/recommend-screen.dom.test.tsx tests/therapy-compass-responsive-contract.test.ts — 24/24 passed.
  • Targeted production browser build compiled and TypeScript passed; the new treatment rendered at 320px without horizontal overflow. The corrected six-width Playwright assertion remains unrun because of shared-lane contention.

Risk and rollout

  • Risk: a prominent result marker could be mistaken for a clinical endorsement. The UI says Best match, only appears when query scoring is active, and retains the existing awaiting-clinician-review warning.
  • Rollback: revert commit 8c62edd6b.
  • Provider or production effects: None.
  • RAG impact: none — no RAG retrieval, ranking, source, or answer behavior changed.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

None of these are affected by this diff: it is a presentation-only badge on an existing, unchanged ranking — no Supabase config, service-role/access-control code, source-metadata rendering, or decision-support logic is touched.

Notes

  • Commit: 8c62edd6b8f3fb9f31d8875edb33df2db2166129
  • Push guard skipped local static checks because the repository heavy-run coordinator was occupied; CI still enforces them.

Note

Medium Risk
Presentation-only change to clinical ranking UI; a prominent Best match marker could be read as endorsement, though scoring logic is unchanged.

Overview
Therapy search now marks the first result as Best match only when a real query is ranking the list, not when the catalogue is just alphabetical.

ResultCard shows a Best match badge on featured cards (search and recommend). Empty-query browse no longer implies a top recommendation. Tests cover ranked vs unranked states and the phone layout offset from the accent edge.

Reviewed by Cursor Bugbot for commit 8c62edd. Configure here.

Summary by CodeRabbit

  • New Features
    • Added a “Best match” badge and visual highlight to the top relevant therapy result.
    • Search results now feature a match only when the query produces meaningful ranking.
  • Bug Fixes
    • Prevented empty, punctuation-only, or unsearched results from incorrectly highlighting the alphabetically first therapy.
  • Tests
    • Expanded coverage for featured-result behavior across ranked, unqueried, and mobile views.

@coderabbitai

coderabbitaiBot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 631c9022-7f24-4871-a119-2fe6fcd302ef

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc4416 and c5701bd.

📒 Files selected for processing (6)
  • src/components/therapy-compass/screens/search-screen.tsx
  • src/components/therapy-compass/therapy-card.tsx
  • src/lib/therapy-ranking.ts
  • tests/recommend-screen.dom.test.tsx
  • tests/therapy-compass-search-filters.dom.test.tsx
  • tests/ui-route-coverage.spec.ts

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

Search results now feature the first card only for searchable queries. Featured cards display a “Best match” badge with a Sparkles icon. Tests cover ranked, unqueried, and punctuation-only searches.

Changes

Therapy best match flow

Layer / File(s)Summary
Search query feature selection
src/lib/therapy-ranking.ts, src/components/therapy-compass/screens/search-screen.tsx, tests/therapy-compass-search-filters.dom.test.tsx
The search screen detects searchable queries and features only the first ranked result. Tests cover ranked, unqueried, and punctuation-only queries.
Featured card presentation
src/components/therapy-compass/therapy-card.tsx, tests/recommend-screen.dom.test.tsx, tests/ui-route-coverage.spec.ts
Featured cards show the “Best match” badge and Sparkles icon. UI tests verify the single highlighted card and border-aware alignment.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk:🔵 Low · up to c5701

The PR changes how ranked Therapy results are highlighted and adjusts responsive layout. Core checks pass, but the six-width responsive behavior still needs confirmation because its required browser was unavailable; the change is otherwise mergeable with explicit owner awareness.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Docstring Coverage✅ PassedDocstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Description check✅ PassedThe description covers the change, verification status, risks, rollback, RAG impact, and all Clinical Governance Preflight items.
Title check✅ PassedThe title clearly and concisely summarizes the main Therapy best-match visibility change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/therapy-best-match-20260824

Comment @coderabbitai help to get the list of available commands.

@supabase

supabaseBot commented Aug 24, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@cursorcursorBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.

Reviewed by Cursor Bugbot for commit 8c62edd. Configure here.

Comment threadsrc/components/therapy-compass/screens/search-screen.tsx Outdated

@cursorcursorBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale comment

Cursor Bugbot completed with an unresolved finding on false best-match treatment for punctuation-only or otherwise unranked queries, and the Bugbot check itself skipped, so I am not approving. Human review is needed.

Open in WebView Automation

Sent by Cursor Approval Agent: Pull Request Router and Approver

@chatgpt-codex-connectorchatgpt-codex-connectorBot 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:8c62edd6b8

ℹ️ 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 threadsrc/components/therapy-compass/screens/search-screen.tsx Outdated
@BigSimmo

Copy link
Copy Markdown
OwnerAuthor

@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 codex/therapy-best-match-20260824 at starting commit 8c62edd; 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:codex/therapy-best-match-20260824, 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit:8c62edd6b8

ℹ️ 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".

@cursorcursorBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale comment

I am not approving this update. Cursor Bugbot’s unresolved finding on false best-match treatment for punctuation-only queries still applies on the current head, and no Bugbot check ran for this commit. Human review is needed; no additional reviewers were assigned because the only code owner is the PR author.

Open in WebView Automation

Sent by Cursor Approval Agent: Pull Request Router and Approver

@github-actions

Copy link
Copy Markdown
Contributor

CI triage

CI failed on this PR. Automated classification of the 2 failed job(s):

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #13648 (failure).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

cursor[bot]
cursorBot approved these changes Aug 24, 2026

@cursorcursorBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved. Cursor Bugbot did not re-run on this head; the earlier outdated finding on punctuation-only best-match is addressed by the shared searchable-query helper, and no approval policy requires human review. No reviewers were assigned.

Open in WebView Automation

Sent by Cursor Approval Agent: Pull Request Router and Approver

cursor[bot]
cursorBot approved these changes Aug 24, 2026

@cursorcursorBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I approved this update. Cursor Bugbot did not run on the current head, and its earlier punctuation-only best-match finding is outdated and addressed by hasSearchableTherapyQuery plus the covering test. No reviewers were assigned.

Open in WebView Automation

Sent by Cursor Approval Agent: Pull Request Router and Approver

BigSimmo added a commit that referenced this pull request Aug 24, 2026
Records the Run-PR-style sweep check on PR #2342 (Improve Therapy
best-match visibility): review comments already fixed, branch synced
from main, CI green on completed checks.
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
Co-authored-by: Claude <noreply@anthropic.com>
BigSimmo added a commit that referenced this pull request Aug 24, 2026
* Add branch review record for PR #2342 sweep
Records the Run-PR-style sweep check on PR #2342 (Improve Therapy
best-match visibility): review comments already fixed, branch synced
from main, CI green on completed checks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* docs(ledger): record Run PR sweep of Dependabot PRs #2296, #2297, #2325, #2326
Immutable review records for the four-PR dependency sweep: CI fix on
#2325, clean main-syncs on #2296/#2297, and diagnosis-only on #2326
(Node 26 Docker bump incompatible with the engine-strict Node 24 pin).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* Add branch review record for PR #2339 sweep
Records the Run-PR-style sweep check on PR #2339 (therapy comparison
mobile design mockups): already fully green, only needed a main sync.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* Add branch review records for PR #2341, #2347 sweep
Records the Run-PR-style sweep checks on #2341 (dictionary filter
band, fixed via main sync, unrelated flake confirmed) and #2347
(browser test gate handoff, fixed stale generated file + doc-link
allowlist entries; owner closed the PR mid-sweep for unrelated reasons).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
---------
Co-authored-by: Claude <noreply@anthropic.com>
BigSimmo added a commit that referenced this pull request Aug 24, 2026
* Add branch review record for PR #2342 sweep
Records the Run-PR-style sweep check on PR #2342 (Improve Therapy
best-match visibility): review comments already fixed, branch synced
from main, CI green on completed checks.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* docs(ledger): record Run PR sweep of Dependabot PRs #2296, #2297, #2325, #2326
Immutable review records for the four-PR dependency sweep: CI fix on
#2325, clean main-syncs on #2296/#2297, and diagnosis-only on #2326
(Node 26 Docker bump incompatible with the engine-strict Node 24 pin).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* Add branch review record for PR #2339 sweep
Records the Run-PR-style sweep check on PR #2339 (therapy comparison
mobile design mockups): already fully green, only needed a main sync.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* Add branch review records for PR #2341, #2347 sweep
Records the Run-PR-style sweep checks on #2341 (dictionary filter
band, fixed via main sync, unrelated flake confirmed) and #2347
(browser test gate handoff, fixed stale generated file + doc-link
allowlist entries; owner closed the PR mid-sweep for unrelated reasons).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
* Add branch review records for PR #2338, #2337, #2333 sweep
Records the Run-PR-style sweep checks: #2337 fixed a design-token
ratchet failure, #2333 fixed a tap-target size regression and
resolved a concurrent-push merge, #2338 was only a main sync. #2333
and #2338 still have an open PR-policy failure (missing Clinical
Governance Preflight section) left for the PR author to fill in.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C4RHy24AtgPobEQQwrj7u1
---------
Co-authored-by: Claude <noreply@anthropic.com>
@BigSimmo
BigSimmo merged commit 69564d5 into mainAug 24, 2026
30 of 31 checks passed
@BigSimmo
BigSimmo deleted the codex/therapy-best-match-20260824 branch August 24, 2026 19:27
Sign up for freeto 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

@BigSimmo