feat(therapy-compass): promote to a first-class app mode#679
Conversation
Therapy Compass was a dev-only mockup at /mockups/therapy-compass (404 in
production, absent from the mode system). This wires it up as a real,
production-visible mode reachable from the app navigation.
- Register the "therapy-compass" mode in the app-mode registry (id, label,
"/therapy-compass" href, and the benign "tools" search kind reused since the
tool owns its in-library search), plus the required exhaustive maps: mode
icon (Compass), universal-search domains (none — it searches the imported
library, not an indexed domain), and the sitemap example.
- Add the production route src/app/therapy-compass/{layout,page}.tsx: the layout
mounts GlobalSearchShell with searchComposerVisible=false (the tool provides
its own search surface), the page renders TherapyCompassPage.
- Add it to the sidebar tool list with the Compass icon; the active-state
highlight resolves on the route.
- Regenerate docs/site-map.md.
The dev-only mockup route stays for design reference. Bundled content is
unchanged; the tool keeps its source-status / needs-review framing (source-
grounded decision support surfaced with review status, not presented as
validated).
Verified in Chromium: the mode appears in the sidebar (with active highlight)
and the MODE dropdown; selecting it renders the tool in the production shell
with no double search bar; and every button works -- all 8 internal screens,
Open record, Compare, Generate patient sheet, and Copy intervention -- with no
console errors. typecheck, lint, prettier, and verify:cheap (2411 tests) pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesTherapy Compass integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ClinicalSidebar
participant TherapyCompassRoute
participant GlobalSearchShell
participant TherapyCompassPage
participant TcProvider
User->>ClinicalSidebar: Select Therapy Compass
ClinicalSidebar->>TherapyCompassRoute: Navigate to /therapy-compass
TherapyCompassRoute->>GlobalSearchShell: Render therapy-compass mode
TherapyCompassRoute->>TherapyCompassPage: Pass query and run state
TherapyCompassPage->>TcProvider: Mount with seeded query
TcProvider->>TcProvider: Set search screen and query
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc217c4695
ℹ️ 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. 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. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc217c4695
ℹ️ 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".
…e tool route
Two production-route breakages caught in Codex review of the mode promotion:
- Data path: the loader fetched /mockups/therapy-compass/*.json, but proxy.ts
404s every /mockups path in production, so the live /therapy-compass route
would load the shell with no dataset. Moved the JSON to
public/therapy-compass-data/ and pointed the loader there (the dev-only mockup
route uses the same loader, so it keeps working).
- Shell routing: adding the mode to namespaceIsolatedModes makes
appModeHomeHref(..., { run: true }) generate /therapy-compass?q=...&run=1, but
GlobalSearchShell rendered ClinicalDashboard for any submitted-search mode not
in its standalone exclusions. Excluded therapy-compass in both
shouldRenderDashboardSearch blocks so run-enabled links keep rendering the tool.
Adds tests/therapy-compass-mode-wiring.test.ts guarding both invariants.
Verified in Chromium: /therapy-compass loads all 211 records, and
/therapy-compass?q=...&run=1 renders the tool (not the dashboard), with no
console errors. typecheck, lint, prettier, and verify:cheap (2414 tests) pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 320fff3f51
ℹ️ 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".
Third of the run-enabled-link findings: /therapy-compass?q=...&run=1 now renders the tool (prior shell fix), but TcProvider ignored q/run and always started on Home, so a query submitted from the universal composer or a recent-search pick landed on the home page with no results. - The route reads q/run from searchParams and threads initialQuery/autoRunSearch through TherapyCompassPage into TcProvider (mirroring the formulation route). - TcProvider seeds screen="search" and search.query when run-enabled, so the submitted query runs in-tool; plain /therapy-compass still opens on Home. Extends tests/therapy-compass-mode-wiring.test.ts to guard the seeding. Verified in Chromium: /therapy-compass?q=behavioural%20activation&run=1 opens on Search with the query seeded and 18 results; /therapy-compass opens on Home; no console errors. typecheck, lint, prettier, and verify:cheap (2415 tests) pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b2034cce1
ℹ️ 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".
… arrives Follow-up to the run-enabled seeding: the App Router preserves TcProvider across /therapy-compass navigations, so its useState seed only ran on first mount — navigating to a different /therapy-compass?q=...&run=1 while already on the tool kept the previous search instead of running the new one. Rather than sync state in an effect (the repo bans synchronous setState in effects), remount the provider via a key derived from the run-query in TherapyCompassPage, so React re-runs the seed for each fresh deep link. In-tool navigation (which does not change the URL) leaves the key — and the tool state — untouched. Adds tests/therapy-compass-provider-seed.dom.test.tsx (rerender re-seeds on key change). typecheck, lint, prettier, and verify:cheap (2416 tests) pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@public/therapy-compass-data/pathways.json`:
- Line 1: Re-curate the therapy steps in the pathway records, especially the
clearly mismatched crisis-risk, grief-loss, and pain-somatic mappings, so every
recommendation addresses its pathway’s clinicalProblem. Add validation for the
pathway data that rejects any step whose therapy domain does not match the
pathway, using the existing pathway and therapy identifiers (slug,
clinicalProblem, and therapySlug) and preventing invalid mappings from reaching
production.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a701ea21-d56b-4c5a-b9ce-d64abaff5d15
📒 Files selected for processing (12)
.prettierignoredocs/branch-review-ledger.mdpublic/therapy-compass-data/pathways.jsonpublic/therapy-compass-data/reference.jsonpublic/therapy-compass-data/therapies.jsonsrc/app/therapy-compass/page.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/therapy-compass/bindings.tsxsrc/components/therapy-compass/data/use-therapy-data.tssrc/components/therapy-compass/therapy-compass-page.tsxtests/therapy-compass-mode-wiring.test.tstests/therapy-compass-provider-seed.dom.test.tsx
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@public/therapy-compass-data/pathways.json`:
- Line 1: Re-curate the therapy steps in the pathway records, especially the
clearly mismatched crisis-risk, grief-loss, and pain-somatic mappings, so every
recommendation addresses its pathway’s clinicalProblem. Add validation for the
pathway data that rejects any step whose therapy domain does not match the
pathway, using the existing pathway and therapy identifiers (slug,
clinicalProblem, and therapySlug) and preventing invalid mappings from reaching
production.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a701ea21-d56b-4c5a-b9ce-d64abaff5d15
📒 Files selected for processing (12)
.prettierignoredocs/branch-review-ledger.mdpublic/therapy-compass-data/pathways.jsonpublic/therapy-compass-data/reference.jsonpublic/therapy-compass-data/therapies.jsonsrc/app/therapy-compass/page.tsxsrc/components/clinical-dashboard/global-search-shell.tsxsrc/components/therapy-compass/bindings.tsxsrc/components/therapy-compass/data/use-therapy-data.tssrc/components/therapy-compass/therapy-compass-page.tsxtests/therapy-compass-mode-wiring.test.tstests/therapy-compass-provider-seed.dom.test.tsx
🛑 Comments failed to post (1)
public/therapy-compass-data/pathways.json (1)
1-1: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
Correct the pathway-to-therapy mappings before production release.
Several pathways contain clearly unrelated recommendations—for example, the
crisis-riskpathway starts with ERP for tics,grief-losscontains anorexia/binge-eating therapies, andpain-somaticcontains tic-focused ERP. This can present clinically misleading options to users. Re-curate the mappings and add a validation check that each step’s therapy domain matches the pathway.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@public/therapy-compass-data/pathways.json` at line 1, Re-curate the therapy steps in the pathway records, especially the clearly mismatched crisis-risk, grief-loss, and pain-somatic mappings, so every recommendation addresses its pathway’s clinicalProblem. Add validation for the pathway data that rejects any step whose therapy domain does not match the pathway, using the existing pathway and therapy identifiers (slug, clinicalProblem, and therapySlug) and preventing invalid mappings from reaching production.
Summary
Therapy Compass shipped as a dev-only mockup (
/mockups/therapy-compass, 404 in production, absent from the mode system), so it wasn't reachable from the live app. This wires it up as a first-class, production-visible mode — explicitly requested, with the production-visibility governance call made by the maintainer.src/lib/app-modes.ts(id: "therapy-compass",label: "Therapy Compass",href: "/therapy-compass"). It reuses the benign"tools"search kind because the tool owns its in-library search (over the imported therapy dataset), not the universal RAG corpus — so it contributes no universal-search domains.Compass), universal-search domains ([]), and the sitemap example.src/app/therapy-compass/{layout,page}.tsx: the layout mountsGlobalSearchShellwithsearchComposerVisible={false}(the tool provides its own search), the page rendersTherapyCompassPage.MODEdropdown automatically.docs/site-map.md.The dev-only mockup route stays for design reference. No change to the tool's code or bundled content — this is purely the mode/route/nav wiring.
8 files, +63.
Verification
npm run verify:cheap— green, 2411 tests pass (runtime, GH-actions pin, sitemap, brand, type-scale, icon-scale, lint, typecheck, full unit suite). Adding the mode broke no existing mode-list/nav assertions.npm run verify:pr-local— not run to completion in this sandbox (optional deps); the individual gates above were run directly. CIBuild/Static PR checks/Unit coveragecover the full install.npm run verify:ui— CICritical UI smoke/UI regressionrun the Chromium suite (manual Chromium walkthrough done above).npm run eval:retrieval:quality— N/A. No retrieval/ranking/selection/chunking/scoring change; the tool's search is a self-contained static-JSON scorer, not the RAG pipeline.npm run check:production-readiness— not run here (provider-confirmation boundary). This is the relevant governance gate for promoting a clinical surface to production — recommend running it before the PR merges.Clinical Governance Preflight
This change does touch a production clinical surface (a decision-support tool goes live), so — not N/A:
Clinical KB Database) — the tool serves static JSON, not Supabase; no schema/RLS/service-role change.check:production-readinessand your governance sign-off before merging.Notes
Requested explicitly ("wire it to the mode… ensure all buttons work"), and production-visibility was chosen deliberately. If you'd prefer to hold production exposure pending governance sign-off, the one-line change is to mark the mode
devOnly: true(keeps it in the dev switcher, hides it in production) — say the word and I'll flip it.🤖 Generated with Claude Code
https://claude.ai/code/session_01TJaXJntdH7Q98ejoSZF46K
Generated by Claude Code
Summary by CodeRabbit
/therapy-compass, including a dedicated layout, page metadata, and a sidebar entry with a compass icon.?q=...&run=1can automatically start a search in the tool.