From 1af528ae5109e025e76aa37efed027b95736d473 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Mon, 29 Jun 2026 13:04:42 +0800 Subject: [PATCH] Revert "chore: production readiness improvements and E2E fixes" --- scripts/classify-documents.ts | 2 +- src/app/mockups/evidence-option/page.tsx | 870 ++++++++++++------ src/components/ClinicalDashboard.tsx | 85 +- .../clinical-dashboard/dashboard-shell.tsx | 13 +- .../medication-prescribing-workspace.tsx | 372 +++----- .../settings-search-mockup-page.tsx | 14 +- src/components/ui/sheet.tsx | 26 +- src/lib/document-organization.ts | 89 +- src/lib/rag.ts | 317 +++++-- src/lib/source-governance.ts | 2 +- tests/source-governance.test.ts | 4 +- 11 files changed, 1021 insertions(+), 773 deletions(-) diff --git a/scripts/classify-documents.ts b/scripts/classify-documents.ts index d9740730c..1340885e9 100644 --- a/scripts/classify-documents.ts +++ b/scripts/classify-documents.ts @@ -110,7 +110,7 @@ async function loadDocuments(supabase: SupabaseAdmin, args: ClassifyArgs) { .from("documents") .select("id,owner_id,title,file_name,source_path,status,metadata") .eq("status", "indexed") - .order("id", { ascending: true }) + .order("created_at", { ascending: true }) .range(args.documentId ? 0 : args.offset, args.documentId ? 0 : args.offset + args.limit - 1); if (args.documentId) query = query.eq("id", args.documentId); diff --git a/src/app/mockups/evidence-option/page.tsx b/src/app/mockups/evidence-option/page.tsx index df0e23f5d..1c1108b85 100644 --- a/src/app/mockups/evidence-option/page.tsx +++ b/src/app/mockups/evidence-option/page.tsx @@ -1,120 +1,134 @@ import Image from "next/image"; import type { Metadata } from "next"; import { + ArrowRight, BadgeCheck, + BookOpen, CheckCircle2, ChevronRight, Copy, ExternalLink, + Eye, FileImage, FileSearch, FileText, Filter, - FolderOpen, - Image as ImageIcon, Layers3, + Library, ListChecks, + PanelRightOpen, Quote, Search, ShieldCheck, Sparkles, + SplitSquareHorizontal, Table2, + Target, type LucideIcon, } from "lucide-react"; import type { ReactNode } from "react"; export const metadata: Metadata = { - title: "Evidence Option Mockups - Clinical KB", - description: "Clinical KB evidence mockups in the app visual style.", + title: "Premium Evidence Mockups - Clinical KB", + description: "Premium ChatGPT-style evidence workspace mockups.", }; -type Tone = "source" | "success" | "warning" | "info" | "neutral"; +type Tone = "green" | "amber" | "blue" | "graphite"; const evidenceItems = [ { title: "ANC monitoring frequency table", kind: "Table", source: "Clozapine physical health protocol", - meta: "p.12 - 97% direct", - body: "Blood monitoring cadence, baseline checks, and action thresholds.", + meta: "p. 12 - 97% direct support", + summary: "Baseline and ongoing blood monitoring cadence with hold thresholds.", icon: Table2, - tone: "source", + tone: "green", }, { title: "Constipation escalation passage", kind: "Quote", source: "Clozapine safety bulletin", - meta: "p.4 - exact quote", - body: "Same-day review wording for severe constipation symptoms.", + meta: "p. 4 - exact quote", + summary: "Same-day review wording for severe constipation and abdominal symptoms.", icon: Quote, - tone: "info", + tone: "blue", }, { - title: "Observation pathway image", + title: "Observation pathway crop", kind: "Image", source: "Acute behavioural disturbance pathway", - meta: "p.8 - visual", - body: "Page crop, diagram labels, and neighbouring source text.", + meta: "p. 8 - visual extraction", + summary: "Diagram labels, observation frequency, and escalation checkpoints.", icon: FileImage, - tone: "neutral", + tone: "graphite", }, { - title: "Lithium toxicity document span", + title: "Lithium toxicity threshold span", kind: "Document span", source: "Lithium monitoring guideline", - meta: "p.6 - review due", - body: "Threshold wording retained with governance warning.", + meta: "p. 6 - review due", + summary: "Older local passage retained with date and governance warning.", icon: FileText, - tone: "warning", + tone: "amber", }, ] as const; const tableRows = [ ["Baseline", "FBC, LFT, U&E, lipids, glucose", "Before initiation"], - ["Weekly", "FBC/ANC", "Initial titration"], - ["Escalate", "Chest pain, fever, constipation", "Urgent review"], + ["Weekly", "FBC/ANC", "Initial titration phase"], + ["Escalate", "Chest pain, fever, severe constipation", "Urgent medical review"], ] as const; -const evidenceTypes = [ +const sourceKinds = [ ["Tables", "621", Table2], ["Quotes", "8,904", Quote], ["Images", "2,840", FileImage], ["PDF regions", "4,221", FileSearch], - ["Documents", "1,834", FileText], + ["Document pages", "1,834", FileText], ] as const; -function toneClass(tone: Tone) { - if (tone === "source") return "border-[color:var(--clinical-chat-teal)]/25 bg-[color:var(--clinical-chat-teal-soft)] text-[color:var(--clinical-chat-teal)]"; - if (tone === "success") return "border-[color:var(--success-border)] bg-[color:var(--success-soft)] text-[color:var(--success)]"; - if (tone === "warning") return "border-[color:var(--warning-border)] bg-[color:var(--warning-soft)] text-[color:var(--warning)]"; - if (tone === "info") return "border-[color:var(--info-border)] bg-[color:var(--info-soft)] text-[color:var(--info)]"; - return "border-[color:var(--border)] bg-[color:var(--surface-subtle)] text-[color:var(--text-muted)]"; +function tone(t: Tone) { + if (t === "green") return "border-emerald-200 bg-emerald-50 text-emerald-800"; + if (t === "amber") return "border-amber-200 bg-amber-50 text-amber-800"; + if (t === "blue") return "border-sky-200 bg-sky-50 text-sky-800"; + return "border-zinc-200 bg-zinc-100 text-zinc-700"; } -function Pill({ children, tone = "neutral" }: { children: ReactNode; tone?: Tone }) { +function Badge({ children, variant = "graphite" }: { children: ReactNode; variant?: Tone }) { return ( - + {children} ); } -function IconTile({ icon: Icon, tone = "source" }: { icon: LucideIcon; tone?: Tone }) { +function Glyph({ icon: Icon, variant = "graphite" }: { icon: LucideIcon; variant?: Tone }) { return ( - + ); } -function Action({ children, icon: Icon, primary = false }: { children: ReactNode; icon?: LucideIcon; primary?: boolean }) { +function GhostButton({ + children, + icon: Icon, + primary = false, +}: { + children: ReactNode; + icon?: LucideIcon; + primary?: boolean; +}) { return ( @@ -209,74 +209,80 @@ function EvidenceCard({ item, compact = false }: { item: (typeof evidenceItems)[ function EvidenceTable() { return ( -
-
- Stage - Evidence - Action +
+
+ Stage + Evidence + Action
{tableRows.map(([stage, evidence, action]) => ( -
- {stage} - {evidence} - {action} +
+ {stage} + {evidence} + {action}
))}
); } -function MockupHome() { +function TopNav() { return ( - -
- -
- -
- -
-
- -

Tables as first-class evidence

-

Rows, image crop, source page, confidence, and provenance together.

-
- +
+ {sourceKinds.slice(0, 3).map(([label, count, Icon], index) => ( +
+ +

{label}

+

{count}

-
-
- -

Images with inspection tools

-

Page crops, labels, region highlights, and neighbouring text.

- Risk flow evidence preview -
+ ))}
-
-