From 4a319423702453cd27c3eab22dce22c8b44580e5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 6 Jul 2026 09:40:39 +0000 Subject: [PATCH] Fix search page defects across documents, services, forms, favourites, and differentials Review of every search surface found and fixed: - app-modes: appModeHomeHref built malformed double-? URLs for prescribing/tools mode homes (e.g. /?mode=prescribing?focus=1), which dropped users into Answer mode; run=1 is now only emitted with a query on namespaced modes as well. - Documents search: result filter OR-ed the query, type, and default-slug predicates so the query never filtered anything; now query AND type with an explicit no-results state. Result rows surface evidence matching the active type tab instead of always evidence[0] with a hardcoded table icon, documents without extracted evidence no longer borrow the clozapine fixture on search rows, reader evidence tab counts are derived from the document, and Open document links from evidence context keep the viewed evidence page/chunk. Evidence sidebar shows the document's own source path and updated date. - Services: navigator no longer flashes "No matches" while the registry loads (skeleton + loading header band), the ATSI-specific chip now searches terms that exist in the catalogue, and the server wrapper normalizes an array-valued run param like it already did for q/query. - Forms: empty state gains a working "try an example" action, result badge codes map to the form record instead of row position (so codes agree with the pathway panel), and the "Matched because" column reflects the actual query instead of a hardcoded "transport". - Favourites: quick views clear a lingering (and hidden) set filter, the sort control is disabled in the Recently used view it cannot affect, the continue strip respects command scopes, and run-action saved searches are labelled "Saved search" instead of "Source". - Differentials: generated snapshot loaders drop markdown-header preset artifacts ("# Scenario Presets" pill) and numeric field-weight entries that polluted search alias expansion with substring matches like "1.1". Verified with npm run typecheck, lint, test (1097 passing), format:check, and verify:cheap. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_015rc3tTjs65D4gFBuCQhZGs --- src/app/services/page.tsx | 2 +- .../favourites-command-library-page.tsx | 13 +- .../favourites-library-nav.tsx | 15 +- .../forms/forms-search-results-page.tsx | 48 ++- .../master-document-flow-mockups.tsx | 319 +++++++++++------- .../services/services-navigator-page.tsx | 30 +- src/lib/app-modes.ts | 5 +- src/lib/differentials.ts | 13 +- 8 files changed, 301 insertions(+), 144 deletions(-) diff --git a/src/app/services/page.tsx b/src/app/services/page.tsx index bc4fbff80..f8a8883ca 100644 --- a/src/app/services/page.tsx +++ b/src/app/services/page.tsx @@ -16,7 +16,7 @@ export default async function ServicesIndexRoute({ searchParams }: { searchParam readFirstSearchParam(resolvedSearchParams.query) ?? "" ).trim(); - const hasSubmittedSearch = resolvedSearchParams.run === "1" && query.length > 0; + const hasSubmittedSearch = readFirstSearchParam(resolvedSearchParams.run) === "1" && query.length > 0; if (!hasSubmittedSearch) { return ; diff --git a/src/components/clinical-dashboard/favourites-command-library-page.tsx b/src/components/clinical-dashboard/favourites-command-library-page.tsx index 98cfb3b0e..cb6593489 100644 --- a/src/components/clinical-dashboard/favourites-command-library-page.tsx +++ b/src/components/clinical-dashboard/favourites-command-library-page.tsx @@ -143,7 +143,10 @@ function isSourceBacked(item: FavouriteItem): boolean { } function toCommandItem(item: PrototypeFavouriteItem): FavouriteItem { - const type = typeByPrototypeType[item.type] ?? (item.primaryAction === "Run" ? "Saved search" : "Source"); + const type = + item.type === "sources" && item.primaryAction === "Run" + ? "Saved search" + : (typeByPrototypeType[item.type] ?? "Source"); return { id: item.id, title: item.title, @@ -544,9 +547,11 @@ function FavouritesTable({