From 3ffd201658e9a53a2132b53bc157e5febdfb716b Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Wed, 22 Jul 2026 15:38:31 +0800 Subject: [PATCH 1/2] content(therapy): use Therapy mode in user-facing copy --- docs/codebase-index.md | 2 +- docs/site-map.md | 2 +- scripts/generate-site-map.ts | 14 ++++---- src/app/therapy-compass/[slug]/brief/page.tsx | 4 +-- src/app/therapy-compass/[slug]/page.tsx | 4 +-- src/app/therapy-compass/[slug]/sheet/page.tsx | 4 +-- src/app/therapy-compass/compare/page.tsx | 2 +- src/app/therapy-compass/page.tsx | 2 +- src/app/therapy-compass/pathways/page.tsx | 2 +- src/app/therapy-compass/recommend/page.tsx | 2 +- src/app/therapy-compass/review/page.tsx | 2 +- src/app/therapy-compass/search/page.tsx | 2 +- .../therapy-compass/screens/home-screen.tsx | 2 +- src/components/therapy-compass/workspace.tsx | 2 +- src/lib/app-modes.ts | 10 +++--- ...therapy-compass-data-recovery.dom.test.tsx | 10 +++--- tests/therapy-compass-mode-wiring.test.ts | 34 +++++++++++++++++++ tests/ui-accessibility.spec.ts | 2 +- tests/ui-route-coverage.spec.ts | 2 +- 19 files changed, 70 insertions(+), 34 deletions(-) diff --git a/docs/codebase-index.md b/docs/codebase-index.md index 0ad69d4589..1a3ff9fa07 100644 --- a/docs/codebase-index.md +++ b/docs/codebase-index.md @@ -45,7 +45,7 @@ Structured map for AI agents and onboarding. For live routes, see `docs/site-map - **PWA:** `docs/pwa.md` — install assets, privacy-first service worker/offline shell, lifecycle, security, and verification - **Home:** `src/app/page.tsx` — dashboard rendered by shell - **Dashboard:** `src/components/ClinicalDashboard.tsx` + `src/components/clinical-dashboard/` -- **Modes (12):** `src/lib/app-modes.ts` — answer, documents, services, forms, favourites, differentials, DSM-5 diagnosis, specifiers, formulation, prescribing, tools, Therapy Compass +- **Modes (12):** `src/lib/app-modes.ts` — answer, documents, services, forms, favourites, differentials, DSM-5 diagnosis, specifiers, formulation, prescribing, tools, Therapy mode ### Product pages (`src/app/`) diff --git a/docs/site-map.md b/docs/site-map.md index 92210148a5..4c62c0d9e5 100644 --- a/docs/site-map.md +++ b/docs/site-map.md @@ -30,7 +30,7 @@ This file is generated by `npm run sitemap:update`. Run `npm run sitemap:check` - `/specifiers/builder` - Structured diagnostic wording builder. Source: `src/app/specifiers/builder/page.tsx`. - `/specifiers/compare` - Side-by-side psychiatric specifier comparison. Source: `src/app/specifiers/compare/page.tsx`. - `/specifiers/map` - Psychiatric specifier family map. Source: `src/app/specifiers/map/page.tsx`. -- `/therapy-compass` - Therapy Compass home (source-grounded therapy decision support). Source: `src/app/therapy-compass/page.tsx`. +- `/therapy-compass` - Therapy mode home (source-grounded therapy decision support). Source: `src/app/therapy-compass/page.tsx`. - `/therapy-compass/[slug]/brief` - Therapy brief-intervention view. Source: `src/app/therapy-compass/[slug]/brief/page.tsx`. - `/therapy-compass/[slug]/sheet` - Therapy patient-sheet builder. Source: `src/app/therapy-compass/[slug]/sheet/page.tsx`. - `/therapy-compass/compare` - Side-by-side therapy comparison. Source: `src/app/therapy-compass/compare/page.tsx`. diff --git a/scripts/generate-site-map.ts b/scripts/generate-site-map.ts index e19b995376..8de5c23dfb 100644 --- a/scripts/generate-site-map.ts +++ b/scripts/generate-site-map.ts @@ -85,7 +85,7 @@ const routeDescriptions: Record = { "/specifiers/builder": "Structured diagnostic wording builder.", "/specifiers/compare": "Side-by-side psychiatric specifier comparison.", "/specifiers/map": "Psychiatric specifier family map.", - "/therapy-compass": "Therapy Compass home (source-grounded therapy decision support).", + "/therapy-compass": "Therapy mode home (source-grounded therapy decision support).", "/therapy-compass/search": "Therapy library search surface.", "/therapy-compass/recommend": "Recommend a therapy from a clinical question and constraints.", "/therapy-compass/compare": "Side-by-side therapy comparison.", @@ -273,12 +273,14 @@ function renderModeRoutes() { factsheets: appModeHomeHref("factsheets", { query: "sertraline", focus: true, run: true }), }; - return appModeDefinitions.map((mode) => - bullet( + return appModeDefinitions.map((mode) => { + const modeName = mode.label.toLowerCase().endsWith(" mode") ? mode.label : `${mode.label} mode`; + + return bullet( ("href" in mode ? mode.href : undefined) ?? appModeHomeHref(mode.id), - `${mode.label} mode. Search kind: \`${mode.search.kind}\`. Query example: \`${examples[mode.id]}\`.`, - ), - ); + `${modeName}. Search kind: \`${mode.search.kind}\`. Query example: \`${examples[mode.id]}\`.`, + ); + }); } type ModePageIndexRow = { diff --git a/src/app/therapy-compass/[slug]/brief/page.tsx b/src/app/therapy-compass/[slug]/brief/page.tsx index 94e3ec6aa2..133c57f402 100644 --- a/src/app/therapy-compass/[slug]/brief/page.tsx +++ b/src/app/therapy-compass/[slug]/brief/page.tsx @@ -15,8 +15,8 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str return { title: record && record.briefInterventionAvailable - ? `${record.name} · Brief intervention - Therapy Compass` - : "Therapy not found - Therapy Compass", + ? `${record.name} · Brief intervention - Therapy mode` + : "Therapy not found - Therapy mode", }; } diff --git a/src/app/therapy-compass/[slug]/page.tsx b/src/app/therapy-compass/[slug]/page.tsx index 65a8e12e6a..249bd4e046 100644 --- a/src/app/therapy-compass/[slug]/page.tsx +++ b/src/app/therapy-compass/[slug]/page.tsx @@ -11,10 +11,10 @@ export function generateStaticParams() { export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { const { slug } = await params; const record = findTherapyRecord(slug); - if (!record) return { title: "Therapy not found - Therapy Compass" }; + if (!record) return { title: "Therapy not found - Therapy mode" }; const summary = record.clinicalSummary ?? record.bestUsedFor ?? "Source-grounded therapy record."; return { - title: `${record.name} - Therapy Compass`, + title: `${record.name} - Therapy mode`, description: therapyNeedsReview(record) ? `${summary} (Awaiting source review.)` : summary, }; } diff --git a/src/app/therapy-compass/[slug]/sheet/page.tsx b/src/app/therapy-compass/[slug]/sheet/page.tsx index 8420283725..57770d89e5 100644 --- a/src/app/therapy-compass/[slug]/sheet/page.tsx +++ b/src/app/therapy-compass/[slug]/sheet/page.tsx @@ -15,8 +15,8 @@ export async function generateMetadata({ params }: { params: Promise<{ slug: str return { title: record && record.patientSheetAvailable - ? `${record.name} · Patient sheet - Therapy Compass` - : "Therapy not found - Therapy Compass", + ? `${record.name} · Patient sheet - Therapy mode` + : "Therapy not found - Therapy mode", }; } diff --git a/src/app/therapy-compass/compare/page.tsx b/src/app/therapy-compass/compare/page.tsx index b92c9debfc..4f676db164 100644 --- a/src/app/therapy-compass/compare/page.tsx +++ b/src/app/therapy-compass/compare/page.tsx @@ -3,7 +3,7 @@ import type { Metadata } from "next"; import { CompareScreen } from "@/components/therapy-compass/screens/compare-screen"; export const metadata: Metadata = { - title: "Compare therapies - Therapy Compass", + title: "Compare therapies - Therapy mode", description: "Compare therapies side by side on indications, delivery, evidence, and review status.", }; diff --git a/src/app/therapy-compass/page.tsx b/src/app/therapy-compass/page.tsx index 7eae10099f..578a813fa5 100644 --- a/src/app/therapy-compass/page.tsx +++ b/src/app/therapy-compass/page.tsx @@ -4,7 +4,7 @@ import { redirect } from "next/navigation"; import { HomeScreen } from "@/components/therapy-compass/screens/home-screen"; export const metadata: Metadata = { - title: "Therapy - Clinical KB", + title: "Therapy mode - Clinical KB", description: "Source-grounded therapy decision support: search, compare, recommend, pathways, brief interventions and patient sheets.", }; diff --git a/src/app/therapy-compass/pathways/page.tsx b/src/app/therapy-compass/pathways/page.tsx index 099e394091..650b60cd40 100644 --- a/src/app/therapy-compass/pathways/page.tsx +++ b/src/app/therapy-compass/pathways/page.tsx @@ -3,7 +3,7 @@ import type { Metadata } from "next"; import { PathwaysScreen } from "@/components/therapy-compass/screens/pathways-screen"; export const metadata: Metadata = { - title: "Clinical pathways - Therapy Compass", + title: "Clinical pathways - Therapy mode", description: "Problem-based, step-by-step therapy pathways linking source-grounded therapy records.", }; diff --git a/src/app/therapy-compass/recommend/page.tsx b/src/app/therapy-compass/recommend/page.tsx index 3c09b0860e..dc7ae156a2 100644 --- a/src/app/therapy-compass/recommend/page.tsx +++ b/src/app/therapy-compass/recommend/page.tsx @@ -3,7 +3,7 @@ import type { Metadata } from "next"; import { RecommendScreen } from "@/components/therapy-compass/screens/recommend-screen"; export const metadata: Metadata = { - title: "Recommend a therapy - Therapy Compass", + title: "Recommend a therapy - Therapy mode", description: "Match a clinical question and constraints to ranked, source-grounded therapy options.", }; diff --git a/src/app/therapy-compass/review/page.tsx b/src/app/therapy-compass/review/page.tsx index ce768b6b40..4505e3bbc6 100644 --- a/src/app/therapy-compass/review/page.tsx +++ b/src/app/therapy-compass/review/page.tsx @@ -3,7 +3,7 @@ import type { Metadata } from "next"; import { OtherScreen } from "@/components/therapy-compass/screens/other-screen"; export const metadata: Metadata = { - title: "Review queue - Therapy Compass", + title: "Review queue - Therapy mode", description: "Therapy records still awaiting qualified-clinician source review.", }; diff --git a/src/app/therapy-compass/search/page.tsx b/src/app/therapy-compass/search/page.tsx index b92b6efead..87f1498f7c 100644 --- a/src/app/therapy-compass/search/page.tsx +++ b/src/app/therapy-compass/search/page.tsx @@ -3,7 +3,7 @@ import type { Metadata } from "next"; import { SearchScreen } from "@/components/therapy-compass/screens/search-screen"; export const metadata: Metadata = { - title: "Search therapies - Therapy Compass", + title: "Search therapies - Therapy mode", description: "Search the source-grounded therapy library by problem, symptom, skill, or population.", }; diff --git a/src/components/therapy-compass/screens/home-screen.tsx b/src/components/therapy-compass/screens/home-screen.tsx index bcd28c0e8b..da2bd5e1e5 100644 --- a/src/components/therapy-compass/screens/home-screen.tsx +++ b/src/components/therapy-compass/screens/home-screen.tsx @@ -33,7 +33,7 @@ export function HomeScreen() { -

Therapy Compass could not load

+

Therapy mode could not load

The therapy catalogue is unavailable. No results are being shown as a substitute.

diff --git a/src/lib/app-modes.ts b/src/lib/app-modes.ts index 5bd72ee752..c28b9b68bb 100644 --- a/src/lib/app-modes.ts +++ b/src/lib/app-modes.ts @@ -311,7 +311,7 @@ export const appModeDefinitions = [ }, { id: "therapy-compass", - label: "Therapy", + label: "Therapy mode", description: "Source-grounded therapy decision support", href: "/therapy-compass", // Cleared for production discovery: the re-curated therapy pathways have @@ -324,15 +324,15 @@ export const appModeDefinitions = [ kind: "tools", placeholder: "Search therapies, symptoms, or skills...", inputAriaLabel: "Search therapies by problem, symptom, skill, or population", - submitIdleLabel: "Therapy", - submitBusyLabel: "Therapy", - submitAriaLabel: "Open Therapy", + submitIdleLabel: "Therapy mode", + submitBusyLabel: "Therapy mode", + submitAriaLabel: "Open Therapy mode", emptyTitle: "Browse the therapy library", readyTitle: "Search source-grounded therapies", progressLabel: "Loading the therapy library.", resultKind: "tools", resultHeading: "Therapies", - statusLabel: "Therapy", + statusLabel: "Therapy mode", nextStep: "Open a therapy record", badgeLabel: null, }, diff --git a/tests/therapy-compass-data-recovery.dom.test.tsx b/tests/therapy-compass-data-recovery.dom.test.tsx index 0fd27ae73a..2262b3af95 100644 --- a/tests/therapy-compass-data-recovery.dom.test.tsx +++ b/tests/therapy-compass-data-recovery.dom.test.tsx @@ -61,12 +61,12 @@ describe("Therapy Compass required data recovery", () => { expect(await screen.findByRole("status")).toHaveTextContent("Loading therapy library…"); expect(screen.getAllByRole("main")).toHaveLength(1); expect(screen.queryByText(/Source-grounded therapy records\./)).not.toBeInTheDocument(); - expect(screen.queryByRole("heading", { name: "Therapy" })).not.toBeInTheDocument(); + expect(screen.queryByRole("heading", { name: "Therapy mode" })).not.toBeInTheDocument(); release(undefined); await waitFor(() => expect(screen.getByText(/1 source-grounded therapy record\./)).toBeInTheDocument()); - expect(screen.getByRole("heading", { name: "Therapy" })).toBeInTheDocument(); + expect(screen.getByRole("heading", { name: "Therapy mode" })).toBeInTheDocument(); expect(screen.getAllByRole("main")).toHaveLength(1); expect(screen.queryByText(/Source-grounded therapy records\./)).not.toBeInTheDocument(); }); @@ -92,13 +92,13 @@ describe("Therapy Compass required data recovery", () => { expect(screen.queryByText(/Source-grounded therapy records\./)).not.toBeInTheDocument(); expect(screen.queryByRole("heading", { name: "Frequently used therapies" })).not.toBeInTheDocument(); - expect(await screen.findByRole("alert")).toHaveTextContent("Therapy Compass could not load"); - expect(screen.queryByRole("heading", { name: "Therapy" })).not.toBeInTheDocument(); + expect(await screen.findByRole("alert")).toHaveTextContent("Therapy mode could not load"); + expect(screen.queryByRole("heading", { name: "Therapy mode" })).not.toBeInTheDocument(); failTherapies = false; fireEvent.click(screen.getByRole("button", { name: "Retry" })); - expect(await screen.findByRole("heading", { name: "Therapy" })).toBeInTheDocument(); + expect(await screen.findByRole("heading", { name: "Therapy mode" })).toBeInTheDocument(); expect(screen.getByText(/1 source-grounded therapy record\./)).toBeInTheDocument(); expect(screen.queryByRole("alert")).not.toBeInTheDocument(); await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(2)); diff --git a/tests/therapy-compass-mode-wiring.test.ts b/tests/therapy-compass-mode-wiring.test.ts index 4c07c2c7cc..4fce7c124b 100644 --- a/tests/therapy-compass-mode-wiring.test.ts +++ b/tests/therapy-compass-mode-wiring.test.ts @@ -12,8 +12,42 @@ const loaderSrc = readFileSync( "utf8", ); const dataDir = new URL("../public/therapy-compass-data/", import.meta.url); +const therapyMetadataFiles = [ + "../src/app/therapy-compass/page.tsx", + "../src/app/therapy-compass/search/page.tsx", + "../src/app/therapy-compass/recommend/page.tsx", + "../src/app/therapy-compass/compare/page.tsx", + "../src/app/therapy-compass/pathways/page.tsx", + "../src/app/therapy-compass/review/page.tsx", + "../src/app/therapy-compass/[slug]/page.tsx", + "../src/app/therapy-compass/[slug]/brief/page.tsx", + "../src/app/therapy-compass/[slug]/sheet/page.tsx", +]; describe("Therapy Compass production-mode wiring", () => { + it("uses Therapy mode for user-facing mode copy and page metadata", () => { + const appModesSrc = readFileSync(new URL("../src/lib/app-modes.ts", import.meta.url), "utf8"); + const homeSrc = readFileSync( + new URL("../src/components/therapy-compass/screens/home-screen.tsx", import.meta.url), + "utf8", + ); + const workspaceSrc = readFileSync( + new URL("../src/components/therapy-compass/workspace.tsx", import.meta.url), + "utf8", + ); + + expect(appModesSrc).toContain('label: "Therapy mode"'); + expect(appModesSrc).toContain('submitAriaLabel: "Open Therapy mode"'); + expect(homeSrc).toContain('title="Therapy mode"'); + expect(workspaceSrc).toContain("Therapy mode could not load"); + + for (const filename of therapyMetadataFiles) { + const source = readFileSync(new URL(filename, import.meta.url), "utf8"); + expect(source, filename).toContain("Therapy mode"); + expect(source, filename).not.toContain("Therapy Compass"); + } + }); + 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(); diff --git a/tests/ui-accessibility.spec.ts b/tests/ui-accessibility.spec.ts index f9ba9e32cb..0267ca66c1 100644 --- a/tests/ui-accessibility.spec.ts +++ b/tests/ui-accessibility.spec.ts @@ -445,7 +445,7 @@ test.describe("Clinical KB accessibility coverage", () => { await page.setViewportSize({ width: 390, height: 844 }); await page.goto("/therapy-compass", { waitUntil: "domcontentloaded" }); - await expect(page.getByRole("heading", { name: "Therapy", exact: true })).toBeVisible({ + await expect(page.getByRole("heading", { name: "Therapy mode", exact: true })).toBeVisible({ timeout: 60_000, }); diff --git a/tests/ui-route-coverage.spec.ts b/tests/ui-route-coverage.spec.ts index 3803526fcf..d7b4b23276 100644 --- a/tests/ui-route-coverage.spec.ts +++ b/tests/ui-route-coverage.spec.ts @@ -218,7 +218,7 @@ test.describe("previously uncovered production routes", () => { "/therapy-compass", async (currentPage) => { await expect(currentPage.getByRole("main")).toBeVisible(); - await expect(currentPage.getByRole("heading", { name: "Therapy", level: 1, exact: true })).toBeVisible({ + await expect(currentPage.getByRole("heading", { name: "Therapy mode", level: 1, exact: true })).toBeVisible({ timeout: 30_000, }); }, From 4008c62bea9496a1f597a9fc2c3142c69b937cfb Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Wed, 22 Jul 2026 15:54:13 +0800 Subject: [PATCH 2/2] fix(therapy): keep navigation naming synchronized --- docs/codebase-index.md | 2 +- src/components/clinical-dashboard/ClinicalSidebar.tsx | 9 +++++++-- tests/therapy-compass-mode-wiring.test.ts | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/codebase-index.md b/docs/codebase-index.md index 98abd9a40e..c7d597ed5a 100644 --- a/docs/codebase-index.md +++ b/docs/codebase-index.md @@ -45,7 +45,7 @@ Structured map for AI agents and onboarding. For live routes, see `docs/site-map - **PWA:** `docs/pwa.md` — install assets, privacy-first service worker/offline shell, lifecycle, security, and verification - **Home:** `src/app/page.tsx` — dashboard rendered by shell - **Dashboard:** `src/components/ClinicalDashboard.tsx` + `src/components/clinical-dashboard/` -- **Modes (12):** `src/lib/app-modes.ts` — answer, documents, services, forms, favourites, differentials, DSM-5 diagnosis, specifiers, formulation, prescribing, tools, Therapy mode +- **Modes (13):** `src/lib/app-modes.ts` — answer, documents, services, forms, favourites, differentials, DSM-5 diagnosis, specifiers, formulation, prescribing, tools, Therapy mode, Factsheets ### Product pages (`src/app/`) diff --git a/src/components/clinical-dashboard/ClinicalSidebar.tsx b/src/components/clinical-dashboard/ClinicalSidebar.tsx index c07ed7ed43..d522d0dd7d 100644 --- a/src/components/clinical-dashboard/ClinicalSidebar.tsx +++ b/src/components/clinical-dashboard/ClinicalSidebar.tsx @@ -41,7 +41,7 @@ function useClientMounted() { ); } import { Sheet } from "@/components/ui/sheet"; -import { type AppModeId, isAppModeId, isAppModeVisible } from "@/lib/app-modes"; +import { appModeDefinition, type AppModeId, isAppModeId, isAppModeVisible } from "@/lib/app-modes"; import { type ResolvedTheme } from "@/lib/theme"; export type SidebarIdentity = { @@ -81,7 +81,12 @@ const sidebarToolItems = [ { id: "formulation", label: "Formulation", icon: Network, href: "/formulation" }, { id: "prescribing", label: "Medication", icon: Pill, href: "/?mode=prescribing" }, { id: "tools", label: "Tools", icon: Wrench, href: "/?mode=tools" }, - { id: "therapy-compass", label: "Therapy", icon: appModeIcons["therapy-compass"], href: "/therapy-compass" }, + { + id: "therapy-compass", + label: appModeDefinition("therapy-compass").label, + icon: appModeIcons["therapy-compass"], + href: "/therapy-compass", + }, { id: "factsheets", label: "Factsheets", icon: appModeIcons.factsheets, href: "/factsheets" }, ] as const; diff --git a/tests/therapy-compass-mode-wiring.test.ts b/tests/therapy-compass-mode-wiring.test.ts index 4fce7c124b..132e95755d 100644 --- a/tests/therapy-compass-mode-wiring.test.ts +++ b/tests/therapy-compass-mode-wiring.test.ts @@ -35,11 +35,16 @@ describe("Therapy Compass production-mode wiring", () => { new URL("../src/components/therapy-compass/workspace.tsx", import.meta.url), "utf8", ); + const sidebarSrc = readFileSync( + new URL("../src/components/clinical-dashboard/ClinicalSidebar.tsx", import.meta.url), + "utf8", + ); expect(appModesSrc).toContain('label: "Therapy mode"'); expect(appModesSrc).toContain('submitAriaLabel: "Open Therapy mode"'); expect(homeSrc).toContain('title="Therapy mode"'); expect(workspaceSrc).toContain("Therapy mode could not load"); + expect(sidebarSrc).toContain('label: appModeDefinition("therapy-compass").label'); for (const filename of therapyMetadataFiles) { const source = readFileSync(new URL(filename, import.meta.url), "utf8");