-
Notifications
You must be signed in to change notification settings - Fork 0
Unify search filters and document Sources #1184
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
Changes from all commits
5baf75e
88131e7
1630008
9ae78fc
8f74d8b
5f107d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -508,6 +508,7 @@ export function ClinicalDashboard({ | |
| const [mobileSidebarOpen, setMobileSidebarOpen] = useState(false); | ||
| const [sidebarCollapsed, setSidebarCollapsed] = useSidebarCollapsed(); | ||
| const [documentsDrawerOpen, setDocumentsDrawerOpen] = useState(false); | ||
| const documentsDrawerReturnFocusRef = useRef<HTMLElement | null>(null); | ||
| const [documentScopeOpen, setDocumentScopeOpen] = useState(false); | ||
| const [documentsDrawerMode, setDocumentsDrawerMode] = useState<DocumentDrawerMode>("library"); | ||
| const [uploadDrawerOpen, setUploadDrawerOpen] = useState(false); | ||
|
|
@@ -2659,18 +2660,13 @@ export function ClinicalDashboard({ | |
| } | ||
|
|
||
| function openDocumentsDrawer(mode: DocumentDrawerMode) { | ||
| documentsDrawerReturnFocusRef.current = | ||
| document.activeElement instanceof HTMLElement ? document.activeElement : null; | ||
| closeDashboardTransientSurfaces("documents"); | ||
| setSearchMode("documents"); | ||
| setDocumentDrawerStatusFilter("indexed"); | ||
| setDocumentsDrawerMode(mode); | ||
| setDocumentsDrawerOpen(true); | ||
| if (window.matchMedia("(min-width: 1024px)").matches) { | ||
| window.requestAnimationFrame(() => { | ||
| document | ||
| .getElementById("dashboard-documents-drawer") | ||
| ?.scrollIntoView({ block: "start", behavior: resolveScrollBehavior() }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| function openRecentDocuments() { | ||
|
|
@@ -2690,7 +2686,7 @@ export function ClinicalDashboard({ | |
| openDocumentsDrawer("library"); | ||
| setActionNotice({ | ||
| tone: "warning", | ||
| message: "Upload and indexing tools are admin-only. Use the source library to open indexed documents.", | ||
| message: "Upload and indexing tools are admin-only. Use Sources to open indexed documents.", | ||
| }); | ||
| return; | ||
| } | ||
|
|
@@ -3204,7 +3200,7 @@ export function ClinicalDashboard({ | |
| ? "Source PDFs" | ||
| : documentsDrawerIsAdmin | ||
| ? "Document admin" | ||
| : "Source library"; | ||
| : "Sources"; | ||
| const documentsDrawerSummary = dashboardDataLoading | ||
| ? "Loading indexed document status." | ||
| : documentsDrawerMode === "recent" | ||
|
|
@@ -3215,14 +3211,14 @@ export function ClinicalDashboard({ | |
| ? `${indexedDocumentTotal.toLocaleString()} indexed documents available.` | ||
| : "Search and open indexed clinical sources."; | ||
| const documentsDrawerMobileSummary = dashboardDataLoading | ||
| ? "Loading library" | ||
| ? "Loading sources" | ||
| : documentsDrawerMode === "recent" | ||
| ? "Recent sources" | ||
| : documentsDrawerMode === "source" | ||
| ? "PDF sources" | ||
| : documentsDrawerIsAdmin | ||
| ? "Admin" | ||
| : "Library"; | ||
| : "Sources"; | ||
| const DocumentsDrawerIcon = | ||
| documentsDrawerMode === "recent" | ||
| ? Clock3 | ||
|
|
@@ -3231,7 +3227,7 @@ export function ClinicalDashboard({ | |
| : documentsDrawerIsAdmin | ||
| ? UploadCloud | ||
| : FolderOpen; | ||
| const drawerGroupTitle = uploadDrawerOpen || documentsDrawerIsAdmin ? "Library and admin" : "Sources"; | ||
| const drawerGroupTitle = uploadDrawerOpen || documentsDrawerIsAdmin ? "Sources and admin" : "Sources"; | ||
|
|
||
| // Stable-identity handlers for the React.memo children (StagedAnswerResultSurface, | ||
| // DocumentSearchResultsPanel). These close over the draft `query` or call the | ||
|
|
@@ -3247,6 +3243,19 @@ export function ClinicalDashboard({ | |
| const handleDocumentTagSearch = useEventCallback(handleTagSearch); | ||
| const handleOpenRecentDocuments = useEventCallback(openRecentDocuments); | ||
| const handleOpenSourceLibrary = useEventCallback(openSourceLibrary); | ||
| const handleDocumentsDrawerOpenChange = useEventCallback((nextOpen: boolean) => { | ||
| setDocumentsDrawerOpen(nextOpen); | ||
| if (nextOpen) return; | ||
|
|
||
| const returnTarget = documentsDrawerReturnFocusRef.current; | ||
| window.requestAnimationFrame(() => { | ||
| const fallbackTarget = Array.from( | ||
| document.querySelectorAll<HTMLElement>('button[aria-haspopup="menu"][aria-label$=" options"]'), | ||
| ).find((element) => element.isConnected && element.getClientRects().length > 0); | ||
| const focusTarget = returnTarget?.isConnected ? returnTarget : fallbackTarget; | ||
| focusTarget?.focus({ preventScroll: true }); | ||
| }); | ||
| }); | ||
|
Comment on lines
+3246
to
+3258
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check for other elements matching the fallback selector pattern.
rg -nP 'aria-haspopup="menu"' -A2 -B2 src/components
rg -nP 'aria-label=.*options"' -A2 -B2 src/componentsRepository: BigSimmo/Database Length of output: 2178 🏁 Script executed: #!/bin/bash
set -u
echo "== ClinicalDashboard outline (focused on drawer/search refs/labels) =="
ast-grep outline src/components/ClinicalDashboard.tsx --match 'handleDocumentsDrawerOpenChange\|documentsDrawerReturnFocusRef\|Documents drawer\|search' 2>/dev/null | sed -n '1,220p' || true
echo
echo "== Relevant ClinicalDashboard sections =="
sed -n '2600,2720p' src/components/ClinicalDashboard.tsx
echo
sed -n '3220,3280p' src/components/ClinicalDashboard.tsx
echo
sed -n '3500,3750p' src/components/ClinicalDashboard.tsx
echo
echo "== Other aria-haspopup menu labels =="
python3 - <<'PY'
from pathlib import Path
import re
for p in Path('src/components').rglob('*.tsx'):
txt = p.read_text(errors='ignore')
for m in re.finditer(r'<button[^>]*aria-haspopup="menu"[^>]+>(?:.</+?)</button>|<button[^>]*(?:.</+?)>', txt, flags=re.S|re.I):
t = m.group(0)
if 'aria-haspopup="menu"' in t:
label = re.search(r'aria-label=`?\$?\{?([^"'\'}]+)`|aria-label="([^"]+)"', t)
print(f'{p}:{txt[:m.start()].count(chr(10))+1}: label={label.group(1) or label.group(2)} text={t.strip()[:200]}')
PYRepository: BigSimmo/Database Length of output: 21013 🏁 Script executed: #!/bin/bash
set -u
echo "== Locate button trigger for DocumentsDrawerOpenChange =="
rg -n 'handleDocumentsDrawerOpenChange|onOpenChange|Documents.*Drawer|Documents.*Options|Sources.*Options|aria-label=.*[Oo]ption|aria-label=.*Document|aria-label=.*Library' src/components/ClinicalDashboard.tsx | sed -n '1,240p'
echo
echo "== Search exact/dynamic options label generators =="
python3 - <<'PY'
from pathlib import Path
import re
for p in [Path('src/components/ClinicalDashboard.tsx')]:
text = p.read_text(errors='ignore')
lines = text.splitlines()
needles = ['aria-haspopup="menu"', 'More actions', 'options', 'Documents']
for i, line in enumerate(lines, 1):
if any(n in line for n in needles) and i < 4100:
start = max(1, i-4)
end = min(len(lines), i+4)
print(f'--- {p}:{i} ---')
for j in range(start, end+1):
print(f'{j:5}: {lines[j-1]}')
# Also search for string templates producing labels containing options within nearby 80 lines
m = re.search(r'(\w+[\s.]*[=:]\s*)([^;`\n]*)', text, pos=max(0, text.find(line)-800), count=1)
PY
echo
echo "== Find JSX for DocumentsDrawerIcon area in ClinicalDashboard.tsx =="
rg -n 'DocumentsDrawerIcon|drawerGroupTitle|Sources and admin|Sources' src/components/ClinicalDashboard.tsx | sed -n '1,240p'
echo
echo "== Programmatic scan: aria-haspopup menu buttons with label-like attributes nearby =="
python3 - <<'PY'
from pathlib import Path
import re
p = Path('src/components/ClinicalDashboard.tsx')
text = p.read_text(errors='ignore')
lines = text.splitlines()
for pat in re.finditer(r'<button[^>]*aria-haspopup="menu"[^>]*>(?:.(?!</button>))*</button>', text, flags=re.S):
line_no = text[:pat.start()].count('\n') + 1
seg = pat.group(0)
label = re.search(r'aria-label=(?:`.*?`|".*?")', seg)
print(f'{path}:{line_no}: aria-label={label.group(0) if m else None}')
PYRepository: BigSimmo/Database Length of output: 3815 🏁 Script executed: #!/bin/bash
set -u
echo "== ClinicalDashboard.tsx around Documents drawer JSX =="
sed -n '3820,3875p' src/components/ClinicalDashboard.tsx
echo
echo "== ClinicalDashboard.tsx component definitions/usages for DocumentsDrawerIcon =="
rg -n 'function DocumentsDrawerIcon|const DocumentsDrawerIcon|<DocumentsDrawerIcon|aria-label|onOpenChange' src/components/ClinicalDashboard.tsx | sed -n '1,220p'
echo
echo "== All aria-haspopup menu buttons across src/components, with line context =="
python3 - <<'PY'
from pathlib import Path
import re
for p in Path('src/components').rglob('*.tsx'):
text = p.read_text(errors='ignore')
for m in re.finditer(r'<button[^>]*aria-haspopup="menu"', text):
line = text[:m.start()].count('\n') + 1
# scan until </button> or next newline without button close, plus a bit of next lines
end = text.find('>', m.start())
seg = text[m.start(): (text.find(chr(10), end) if end != -1 else end) + 40 or len(text)]
seg = seg.replace('\n', ' ')
print(f'{p}:{line}: {seg.strip()[:320]}')
PYRepository: BigSimmo/Database Length of output: 5544 Scope the fallback focus-restore target to the actual drawer trigger. The current fallback queries the whole document for 🤖 Prompt for AI Agents |
||
| const handleOpenSourcePdfBrowser = useEventCallback(openSourcePdfBrowser); | ||
| const handleCopyAnswer = useEventCallback(() => { | ||
| copyText("answer", answerRenderModel?.copyText || safeAnswerText || answer?.answer || ""); | ||
|
|
@@ -3838,8 +3847,9 @@ export function ClinicalDashboard({ | |
| summary={documentsDrawerSummary} | ||
| mobileSummary={documentsDrawerMobileSummary} | ||
| open={documentsDrawerOpen} | ||
| onOpenChange={setDocumentsDrawerOpen} | ||
| sheetBreakpoint="lg" | ||
| onOpenChange={handleDocumentsDrawerOpenChange} | ||
| sheetBreakpoint={documentsDrawerIsAdmin ? "lg" : "all"} | ||
| sheetReturnFocusRef={documentsDrawerReturnFocusRef} | ||
|
BigSimmo marked this conversation as resolved.
|
||
| sheetHeaderLeading={ | ||
| <span className="grid h-10 w-10 place-items-center rounded-xl border border-[color:var(--clinical-accent-border)] bg-[color:var(--clinical-accent-soft)] text-[color:var(--clinical-accent)] shadow-[var(--shadow-inset)]"> | ||
| <DocumentsDrawerIcon className="h-5 w-5" aria-hidden="true" /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| "use client"; | ||
|
|
||
| import { BookOpen, ChevronDown, type LucideIcon } from "lucide-react"; | ||
| import { useCallback, useEffect, useRef, useState, type CSSProperties, type ReactNode } from "react"; | ||
| import { useCallback, useEffect, useRef, useState, type CSSProperties, type ReactNode, type RefObject } from "react"; | ||
|
|
||
| import { Sheet, type SheetMobileSize } from "@/components/ui/sheet"; | ||
| import { clinicalDivider, cn, iconTilePremium, navPill, panelSubtle, textMuted } from "@/components/ui-primitives"; | ||
|
|
||
| const sheetMediaQueries = { | ||
| sm: "(max-width: 639px)", | ||
| lg: "(max-width: 1023px)", | ||
| all: "(min-width: 0px)", | ||
| } as const; | ||
|
|
||
| type UtilityDrawerSheetBreakpoint = keyof typeof sheetMediaQueries; | ||
|
|
@@ -87,6 +88,7 @@ export function UtilityDrawer({ | |
| sheetDescription, | ||
| sheetBreakpoint = "sm", | ||
| sheetMobileSize, | ||
| sheetReturnFocusRef, | ||
| }: { | ||
| id?: string; | ||
| title: string; | ||
|
|
@@ -113,13 +115,16 @@ export function UtilityDrawer({ | |
| sheetDescription?: string | null; | ||
| sheetBreakpoint?: UtilityDrawerSheetBreakpoint; | ||
| sheetMobileSize?: SheetMobileSize; | ||
| sheetReturnFocusRef?: RefObject<HTMLElement | null>; | ||
| }) { | ||
| const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen); | ||
| const [usesSheet, setUsesSheet] = useState(false); | ||
| const mobileTriggerRef = useRef<HTMLButtonElement>(null); | ||
| const open = controlledOpen ?? uncontrolledOpen; | ||
| const sheetTriggerClassName = sheetBreakpoint === "lg" ? "lg:hidden" : "sm:hidden"; | ||
| const inlineDrawerClassName = sheetBreakpoint === "lg" ? "hidden lg:block" : "hidden sm:block"; | ||
| const sheetTriggerClassName = | ||
| sheetBreakpoint === "all" ? "block" : sheetBreakpoint === "lg" ? "lg:hidden" : "sm:hidden"; | ||
| const inlineDrawerClassName = | ||
| sheetBreakpoint === "all" ? "hidden" : sheetBreakpoint === "lg" ? "hidden lg:block" : "hidden sm:block"; | ||
|
Comment on lines
+118
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Inspect the Sheet component's backdrop / focus-trap / inert handling.
fd -e tsx sheet.tsx --exec cat -n {}Repository: BigSimmo/Database Length of output: 20273 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "## Locate dashboard shell and clinical dashboard"
fd -e tsx 'dashboard-shell\.tsx|ClinicalDashboard\.tsx' .
echo
echo "## dashboard-shell relevant sections"
file="$(fd -e tsx 'dashboard-shell\.tsx' . | head -n 1)"
echo "FILE=$file"
wc -l "$file"
sed -n '1,260p' "$file" | cat -n
echo
echo "## ClinicalDashboard UtilityDrawer usages"
cli="$(fd -e tsx 'ClinicalDashboard\.tsx' . | head -n 1)"
if [ -n "${cli:-}" ]; then
rg -n "UtilityDrawer|UtilityDrawerProps|useDrawer|documentsDrawerOpen|documentsDrawer|sheetBreakpoint|sheetReturnFocusRef" "$cli"
sed -n '1,260p' "$cli" | cat -n
fiRepository: BigSimmo/Database Length of output: 25184 🌐 Web query:
💡 Result: The Shadcn Citations:
🌐 Web query:
💡 Result: Radix UI's Dialog component manages modality and accessibility by dynamically manipulating DOM styles and attributes, which can lead to specific behaviors regarding Citations:
🌐 Web query:
💡 Result: Radix UI Dialog manages focus trapping and body interaction as part of its default modal behavior to ensure WAI-ARIA compliance [1][2]. Focus Trapping and Trigger Interaction: When the Dialog is in modal mode ( Citations:
🌐 Web query:
💡 Result: In Radix UI Dialog components, the Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
cli="$(fd -e tsx 'ClinicalDashboard\.tsx' . | head -n 1)"
echo "## ClinicalDashboard wrapper and UtilityDrawer props"
sed -n '3780,3915p' "$cli" | cat -n
echo
echo "## UtilityDrawer return focus props"
sed -n '3008,3035p' "$cli" | cat -n
sed -n '3090,3125p' "$cli" | cat -nRepository: BigSimmo/Database Length of output: 12657 Hide the externally controlled trigger for At 🤖 Prompt for AI Agents |
||
| const triggerClassName = cn( | ||
| "flex min-h-[56px] w-full cursor-pointer list-none items-center justify-between gap-3 rounded-lg px-4 py-3 text-left transition motion-safe:duration-150 hover:bg-[color:var(--surface-subtle)]", | ||
| className, | ||
|
|
@@ -227,7 +232,7 @@ export function UtilityDrawer({ | |
| contentStyle={sheetContentStyle} | ||
| bodyClassName={sheetBodyClassName} | ||
| mobileSize={sheetMobileSize} | ||
| returnFocusRef={mobileTriggerRef} | ||
| returnFocusRef={sheetReturnFocusRef ?? mobileTriggerRef} | ||
| portal | ||
| > | ||
| <div className={cn("space-y-3", sheetChildrenClassName)}>{children}</div> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Do not record an unrun UI gate as passed.
This row says
npm run verify:uipassed 268/268, but the PR objectives say full UI verification was not run. Remove that claim or mark the gate as not run before using this as merge-readiness evidence. As per PR objectives, “Full UI verification … [was] not run.”🤖 Prompt for AI Agents
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the future-dated review records. Both newly added entries are dated July 25, 2026, which is after the current review date of July 24, 2026.
docs/branch-review-ledger.md#L797-L797: use the actual review date or defer this record until July 25, 2026.docs/branch-review-ledger.md#L799-L799: use the actual review date or defer this record until July 25, 2026.📍 Affects 1 file
docs/branch-review-ledger.md#L797-L797(this comment)docs/branch-review-ledger.md#L799-L799🤖 Prompt for AI Agents