-
Notifications
You must be signed in to change notification settings - Fork 0
feat(therapy-compass): promote to a first-class app mode #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+213
−10
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dc217c4
feat(therapy-compass): promote to a first-class app mode
claude 320fff3
fix(therapy-compass): serve data off /mockups and keep run URLs on th…
claude 7b2034c
fix(therapy-compass): honor run-enabled deep links in the tool
claude f5ca25f
fix(therapy-compass): re-seed the tool when a new run-query deep link…
claude 1fd4467
docs: record Therapy Compass PR review
BigSimmo 5c6672b
Merge remote-tracking branch 'origin/main' into HEAD
BigSimmo 53151a5
docs: preserve Therapy Compass review record
BigSimmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { ReactNode } from "react"; | ||
|
|
||
| import { GlobalSearchShell } from "@/components/clinical-dashboard/global-search-shell"; | ||
|
|
||
| // Therapy Compass keeps the universal header + rail but provides its own primary | ||
| // search surface (the in-tool therapy search), so the shared search composer is | ||
| // suppressed here — mirroring how the mockup mounted it. | ||
| export default function TherapyCompassLayout({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <GlobalSearchShell initialMode="therapy-compass" searchComposerVisible={false}> | ||
| {children} | ||
| </GlobalSearchShell> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { Metadata } from "next"; | ||
|
|
||
| import { TherapyCompassPage } from "@/components/therapy-compass"; | ||
|
|
||
| export const metadata: Metadata = { | ||
| title: "Therapy Compass - Clinical KB", | ||
| description: | ||
| "Source-grounded therapy decision support: search, compare, recommend, pathways, brief interventions and patient sheets.", | ||
| }; | ||
|
|
||
| type TherapyCompassRouteProps = { | ||
| searchParams?: Promise<{ q?: string | string[]; run?: string | string[] }>; | ||
| }; | ||
|
|
||
| function firstParam(value: string | string[] | undefined) { | ||
| return Array.isArray(value) ? value[0] : value; | ||
| } | ||
|
|
||
| export default async function TherapyCompassRoute({ searchParams }: TherapyCompassRouteProps) { | ||
| const params = searchParams ? await searchParams : {}; | ||
| const query = firstParam(params.q)?.trim() ?? ""; | ||
| const autoRunSearch = firstParam(params.run) === "1" && query.length > 0; | ||
| return <TherapyCompassPage initialQuery={query} autoRunSearch={autoRunSearch} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { existsSync, readFileSync } from "node:fs"; | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| // Guards the two production-mode wiring invariants for Therapy Compass. Both were | ||
| // real breakages caught in review when the mockup was promoted to a live mode. | ||
|
|
||
| const loaderSrc = readFileSync( | ||
| new URL("../src/components/therapy-compass/data/use-therapy-data.ts", import.meta.url), | ||
| "utf8", | ||
| ); | ||
| const shellSrc = readFileSync( | ||
| new URL("../src/components/clinical-dashboard/global-search-shell.tsx", import.meta.url), | ||
| "utf8", | ||
| ); | ||
| const dataDir = new URL("../public/therapy-compass-data/", import.meta.url); | ||
|
|
||
| describe("Therapy Compass production-mode wiring", () => { | ||
| it("loads its dataset from a non-/mockups path (proxy.ts 404s every /mockups path in production)", () => { | ||
| const base = loaderSrc.match(/const BASE = "([^"]+)"/)?.[1]; | ||
| expect(base).toBeTruthy(); | ||
| expect(base).not.toMatch(/^\/mockups/); | ||
| }); | ||
|
|
||
| it("ships the dataset at the non-mockups public path the loader points to", () => { | ||
| for (const file of ["therapies.json", "pathways.json", "reference.json"]) { | ||
| expect(existsSync(new URL(file, dataDir))).toBe(true); | ||
| } | ||
| }); | ||
|
|
||
| it("excludes therapy-compass from the shell dashboard-search so run-enabled links keep the tool", () => { | ||
| // Both shouldRenderDashboardSearch blocks (standalone + non-standalone client) must exclude the mode, | ||
| // otherwise /therapy-compass?q=…&run=1 renders ClinicalDashboard over TherapyCompassPage. | ||
| const occurrences = shellSrc.match(/resolvedSearchMode !== "therapy-compass"/g) ?? []; | ||
| expect(occurrences.length).toBeGreaterThanOrEqual(2); | ||
| }); | ||
|
|
||
| it("honors run-enabled deep links by seeding the in-tool search instead of landing on Home", () => { | ||
| const routeSrc = readFileSync(new URL("../src/app/therapy-compass/page.tsx", import.meta.url), "utf8"); | ||
| const bindingsSrc = readFileSync( | ||
| new URL("../src/components/therapy-compass/bindings.tsx", import.meta.url), | ||
| "utf8", | ||
| ); | ||
| // The route reads q/run and threads autoRunSearch into the provider... | ||
| expect(routeSrc).toMatch(/searchParams/); | ||
| expect(routeSrc).toMatch(/autoRunSearch/); | ||
| // ...and the provider opens on Search (not Home) with the query seeded. | ||
| expect(bindingsSrc).toMatch(/seededQuery \? "search" : "home"/); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import { render } from "@testing-library/react"; | ||
| import { afterEach, describe, expect, it, vi } from "vitest"; | ||
|
|
||
| import { TcProvider, useTcBindings } from "@/components/therapy-compass/bindings"; | ||
|
|
||
| // TcProvider fetches its dataset on mount; stub fetch so it mounts without | ||
| // network. The screen/search seed is independent of data loading, which is what | ||
| // this test exercises. | ||
| afterEach(() => vi.unstubAllGlobals()); | ||
|
|
||
| function Probe() { | ||
| const b = useTcBindings(); | ||
| return <div data-testid="probe" data-screen={b.screen} data-query={b.search.query} />; | ||
| } | ||
|
|
||
| describe("TcProvider run-enabled seeding", () => { | ||
| it("seeds Search + query on mount and re-seeds when the deep-link query changes", () => { | ||
| // Never-resolving fetch → the provider stays in its loading state without needing data. | ||
| vi.stubGlobal( | ||
| "fetch", | ||
| vi.fn(() => new Promise(() => {})), | ||
| ); | ||
|
|
||
| const { getByTestId, rerender } = render( | ||
| <TcProvider key="q:alpha" initialQuery="alpha" autoRunSearch> | ||
| <Probe /> | ||
| </TcProvider>, | ||
| ); | ||
| expect(getByTestId("probe").getAttribute("data-screen")).toBe("search"); | ||
| expect(getByTestId("probe").getAttribute("data-query")).toBe("alpha"); | ||
|
|
||
| // A fresh /therapy-compass?q=beta&run=1 navigation changes the provider key | ||
| // (as TherapyCompassPage computes it), remounting the provider so its seed | ||
| // re-runs for the new query. | ||
| rerender( | ||
| <TcProvider key="q:beta" initialQuery="beta" autoRunSearch> | ||
| <Probe /> | ||
| </TcProvider>, | ||
| ); | ||
| expect(getByTestId("probe").getAttribute("data-screen")).toBe("search"); | ||
| expect(getByTestId("probe").getAttribute("data-query")).toBe("beta"); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.