From e7a204f3a67aac39f5fdc8d0adce56f765228c35 Mon Sep 17 00:00:00 2001 From: BigSimmo <87357024+BigSimmo@users.noreply.github.com> Date: Tue, 11 Aug 2026 23:28:28 +0800 Subject: [PATCH 1/2] Perfect document source panel layout --- .../document-viewer/source-panels.tsx | 82 ++++++++++--------- tests/ui-smoke.spec.ts | 16 +++- 2 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/components/document-viewer/source-panels.tsx b/src/components/document-viewer/source-panels.tsx index a725fff38..1ede575b1 100644 --- a/src/components/document-viewer/source-panels.tsx +++ b/src/components/document-viewer/source-panels.tsx @@ -32,8 +32,6 @@ import { cn, codeText, eyebrowText, - fieldControl, - fieldLabel, floatingControl, LoadingPanel, panel, @@ -737,36 +735,53 @@ export function PinnedSourceEvidence({
{chunk.section_heading}
)}{visibleContent || "No displayable clinical text was available for this indexed passage."}-
Source passages
{searchEligible ? ( @@ -1198,7 +1202,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({ {documentSearchError} ) : null} -
Enter at least 2 characters to search all indexed passages.
@@ -1239,7 +1243,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({
>
{status}
-
+
Page {chunk.page_number ?? "n/a"} · chunk {chunk.chunk_index}
{chunk.serverRanked ? " · full-document search" : ""}
@@ -1263,7 +1267,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({
{chunk.section_heading}
) : null}
-
+
{teaser || "No displayable clinical text was available for this indexed passage."}
diff --git a/tests/ui-smoke.spec.ts b/tests/ui-smoke.spec.ts
index db4d9afe9..2435ecfdb 100644
--- a/tests/ui-smoke.spec.ts
+++ b/tests/ui-smoke.spec.ts
@@ -4163,7 +4163,10 @@ test.describe("Clinical KB UI smoke coverage", () => {
page.getByTestId("source-chunk-indexed-text-panel").getByTestId("highlighted-indexed-source-chunk"),
).toHaveJSProperty("open", true);
- const sourceSearch = page.getByLabel("Search within indexed source text").last();
+ // The fixed document composer is the single search owner; the indexed-text
+ // disclosure must not duplicate a large search field inside its content.
+ const sourceSearch = page.getByRole("textbox", { name: "Search within this document" });
+ await expect(page.getByLabel("Search within indexed source text")).toHaveCount(0);
await waitForReactEventHandler(sourceSearch, "onChange");
await sourceSearch.fill("safety plan include");
const desktopTextPanel = page.getByTestId("source-chunk-indexed-text-panel");
@@ -4336,14 +4339,21 @@ test.describe("Clinical KB UI smoke coverage", () => {
expect(indexedTextBox!.y).toBeLessThan(imagesBox!.y);
const passageToggle = page.getByTestId("toggle-full-passage").first();
- await expect(passageToggle).toHaveText("Show full passage");
+ await expect(passageToggle).toHaveText("Full passage");
+ await expect(passageToggle).toHaveAttribute("aria-expanded", "false");
// Keyboard activation is intentional here: pdf.js can resize the canvas
// while Firefox is calculating pointer coordinates, but a focused native
// button must keep its expand/collapse behavior through that layout shift.
await activateFocusedControl(page, passageToggle);
- await expect(passageToggle).toHaveText("Show passage preview");
+ await expect(passageToggle).toHaveText("Collapse");
+ await expect(passageToggle).toHaveAttribute("aria-expanded", "true");
const expandedEvidenceBox = await evidence.boundingBox();
expect(expandedEvidenceBox?.height ?? 0).toBeGreaterThan(evidenceBox!.height);
+ await activateFocusedControl(page, passageToggle);
+ await expect(passageToggle).toHaveText("Full passage");
+ await expect(passageToggle).toHaveAttribute("aria-expanded", "false");
+ const collapsedEvidenceBox = await evidence.boundingBox();
+ expect(collapsedEvidenceBox?.height ?? Number.POSITIVE_INFINITY).toBeLessThan(expandedEvidenceBox!.height);
await openSection(/PDF preview/);
await expect(preview).toBeInViewport();
await openSection(/Indexed source text/);
From 6e48bec86500a65afd8d892b60ed0ab81a4f073c Mon Sep 17 00:00:00 2001
From: BigSimmo <87357024+BigSimmo@users.noreply.github.com>
Date: Wed, 12 Aug 2026 07:05:06 +0800
Subject: [PATCH 2/2] Reset active document search hit on query change
---
.../document-viewer/source-panels.tsx | 6 ++
tests/document-section-summary.dom.test.tsx | 59 +++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/src/components/document-viewer/source-panels.tsx b/src/components/document-viewer/source-panels.tsx
index 1ede575b1..97e714c5e 100644
--- a/src/components/document-viewer/source-panels.tsx
+++ b/src/components/document-viewer/source-panels.tsx
@@ -1017,6 +1017,7 @@ export const IndexedTextPanel = memo(function IndexedTextPanel({
// lost across re-renders and left deep-linked hits collapsed in Production UI.
const [manualClosedDriver, setManualClosedDriver] = useState