Skip to content

feat(therapy-compass): promote to a first-class app mode#679

Merged
BigSimmo merged 7 commits into
mainfrom
claude/therapy-compass-pages-rz0m5l
Jul 14, 2026
Merged

feat(therapy-compass): promote to a first-class app mode#679
BigSimmo merged 7 commits into
mainfrom
claude/therapy-compass-pages-rz0m5l

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 14, 2026

Copy link
Copy Markdown
Owner

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.

  • Register the mode in 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.
  • Fill the required exhaustive maps: mode icon (Compass), universal-search domains ([]), 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), the page renders TherapyCompassPage.
  • Nav: add it to the sidebar tool list (Compass icon); active-state highlight resolves on the route. It also appears in the MODE dropdown automatically.
  • Regenerate 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.
  • Chromium walkthrough (the "all buttons work" check): the mode shows in the sidebar (with active highlight) and the MODE dropdown; selecting it renders the tool inside the production shell with no double search bar; and every control works — all 8 internal screens (Home/Search/Recommend/Compare/Pathways/Brief/Sheets/Review), Open record, Compare, Generate patient sheet, and Copy intervention — with zero console errors.
  • npm run verify:pr-local — not run to completion in this sandbox (optional deps); the individual gates above were run directly. CI Build / Static PR checks / Unit coverage cover the full install.
  • npm run verify:ui — CI Critical UI smoke / UI regression run the Chromium suite (manual Chromium walkthrough done above).
  • npm run eval:retrieval:qualityN/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-readinessnot 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:

  • Source-backed claims still require linked source verification before clinical use — the tool surfaces source provenance + review status and frames itself as decision support, not validated output.
  • No patient-identifiable document workflow introduced or expanded.
  • Supabase target unchanged (Clinical KB Database) — the tool serves static JSON, not Supabase; no schema/RLS/service-role change.
  • Service-role keys and private document access remain server-only (untouched).
  • Demo/synthetic separation — the tool's data is the self-contained imported reference export, not mixed into the live document corpus.
  • Source metadata / review status / outdated behaviour remain conservative — needs-review badges, the "N to review" chip, and source provenance are all preserved.
  • Deployment classification / TGA SaMD impact — flagged for your review. Promoting a therapy-recommendation tool to production is a SaMD-relevant decision. The content is static, de-identified reference data with many records still flagged needs-review; the tool presents review status rather than validated recommendations, but the production-visibility and SaMD-classification call is yours. I've kept the review-status framing intact; consider running check:production-readiness and 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

  • New Features
    • Added Therapy Compass as a new app mode at /therapy-compass, including a dedicated layout, page metadata, and a sidebar entry with a compass icon.
    • Enabled deep links so ?q=...&run=1 can automatically start a search in the tool.
  • Bug Fixes
    • Ensured the universal dashboard search UI doesn’t replace the Therapy Compass view for run-enabled queries.
  • Tests
    • Added regression tests to verify sitemap/tool wiring and run-enabled query seeding behavior.
  • Documentation
    • Updated the sitemap to include the new route and its query example.

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
@supabase

supabase Bot commented Jul 14, 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 ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 14, 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 Plus

Run ID: fdc1cc88-48f9-4ab6-b4d3-362f2d19751c

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd4467 and 53151a5.

📒 Files selected for processing (1)
  • docs/branch-review-ledger.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/branch-review-ledger.md

📝 Walkthrough

Walkthrough

Adds a /therapy-compass route and app mode, configures its layout and search behavior, exposes it in the clinical sidebar, loads static therapy data, supports query-driven deep links, and adds sitemap coverage with wiring tests.

Changes

Therapy Compass integration

Layer / File(s) Summary
Register Therapy Compass mode
src/lib/app-modes.ts, src/lib/universal-search-mode-context.ts, src/components/clinical-dashboard/ClinicalSidebar.tsx, src/lib/app-mode-icons.ts
Registers the mode, search configuration, isolated URL handling, empty preferred-domain configuration, sidebar entry, and Compass icon.
Wire route and search shell
src/app/therapy-compass/*, src/components/clinical-dashboard/global-search-shell.tsx
Adds route metadata and query handling, configures the global shell, hides shared search UI, and preserves the in-route view for run-enabled links.
Load data and seed deep links
public/therapy-compass-data/*, src/components/therapy-compass/data/use-therapy-data.ts, src/components/therapy-compass/bindings.tsx, src/components/therapy-compass/therapy-compass-page.tsx
Adds pathway and reference datasets, updates the static asset path, and initializes or remounts provider state from deep-link queries.
Document and validate coverage
scripts/generate-site-map.ts, docs/site-map.md, tests/therapy-compass-*.test.*, .prettierignore, docs/branch-review-ledger.md
Adds sitemap examples and route entries, validates production wiring and provider seeding, updates formatting exclusions, and records review results.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: promoting Therapy Compass to a first-class app mode.
Description check ✅ Passed The description matches the template well, with Summary, Verification, Clinical Governance Preflight, and Notes sections filled in.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/therapy-compass-pages-rz0m5l

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

@BigSimmo
BigSimmo marked this pull request as ready for review July 14, 2026 19:09

@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: 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".

Comment thread src/lib/app-modes.ts
@BigSimmo

Copy link
Copy Markdown
Owner Author

@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.

@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: 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".

Comment thread src/app/therapy-compass/page.tsx Outdated
Comment thread src/lib/app-modes.ts
…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

@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: 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".

Comment thread src/lib/app-modes.ts
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

@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: 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".

Comment thread src/components/therapy-compass/bindings.tsx
claude and others added 4 commits July 14, 2026 19:49
… 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

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc217c4 and 1fd4467.

📒 Files selected for processing (12)
  • .prettierignore
  • docs/branch-review-ledger.md
  • public/therapy-compass-data/pathways.json
  • public/therapy-compass-data/reference.json
  • public/therapy-compass-data/therapies.json
  • src/app/therapy-compass/page.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/therapy-compass/bindings.tsx
  • src/components/therapy-compass/data/use-therapy-data.ts
  • src/components/therapy-compass/therapy-compass-page.tsx
  • tests/therapy-compass-mode-wiring.test.ts
  • tests/therapy-compass-provider-seed.dom.test.tsx

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc217c4 and 1fd4467.

📒 Files selected for processing (12)
  • .prettierignore
  • docs/branch-review-ledger.md
  • public/therapy-compass-data/pathways.json
  • public/therapy-compass-data/reference.json
  • public/therapy-compass-data/therapies.json
  • src/app/therapy-compass/page.tsx
  • src/components/clinical-dashboard/global-search-shell.tsx
  • src/components/therapy-compass/bindings.tsx
  • src/components/therapy-compass/data/use-therapy-data.ts
  • src/components/therapy-compass/therapy-compass-page.tsx
  • tests/therapy-compass-mode-wiring.test.ts
  • tests/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-risk pathway starts with ERP for tics, grief-loss contains anorexia/binge-eating therapies, and pain-somatic contains 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.

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.

2 participants