Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/web/src/components/ChatMarkdown.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@
).toMatchObject({
isOpen: true,
activeSurfaceId: "file:apps/web/src/components/ChatMarkdown.tsx",
surfaces: [
expect.objectContaining({
relativePath: "apps/web/src/components/ChatMarkdown.tsx",
revealLine: 978,
revealRequestId: 1,
}),
],
});
expect(openInPreferredEditorMock).not.toHaveBeenCalled();
expect(openFileInPreviewMock).not.toHaveBeenCalled();
Expand Down Expand Up @@ -533,7 +540,7 @@

try {
const titles = [...document.querySelectorAll(".chat-markdown-codeblock-title")];
expect(titles).toHaveLength(3);

Check failure on line 543 in apps/web/src/components/ChatMarkdown.browser.tsx

View workflow job for this annotation

GitHub Actions / Test Browser

[browser (chromium)] src/components/ChatMarkdown.browser.tsx > ChatMarkdown > code block chrome > shows icon-only language titles, text fallbacks, and filename overrides

AssertionError: expected [] to have a length of 3 but got +0 - Expected + Received - 3 + 0 ❯ Proxy.<anonymous> ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/expect/index.js?v=3b769b5e:1389:22 ❯ Proxy.<anonymous> ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/expect/index.js?v=3b769b5e:1156:19 ❯ Proxy.methodWrapper ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/vendor/chai.mjs?v=3b769b5e:1333:23 ❯ toHaveLength src/components/ChatMarkdown.browser.tsx:543:23 ❯ ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/runner/chunk-artifact.js?v=3b769b5e:1903:22

// Language with a known icon: icon XOR text — never the redundant pair.
const languageOnly = titles[0]!;
Expand Down Expand Up @@ -568,7 +575,7 @@

try {
const block = document.querySelector(".chat-markdown-codeblock");
expect(block?.getAttribute("data-wrap")).toBe("false");

Check failure on line 578 in apps/web/src/components/ChatMarkdown.browser.tsx

View workflow job for this annotation

GitHub Actions / Test Browser

[browser (chromium)] src/components/ChatMarkdown.browser.tsx > ChatMarkdown > code block chrome > toggles line wrapping per block

AssertionError: expected undefined to be 'false' // Object.is equality - Expected: "false" + Received: undefined ❯ toBe src/components/ChatMarkdown.browser.tsx:578:49 ❯ ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/runner/chunk-artifact.js?v=3b769b5e:1903:22

const toggle = page.getByRole("button", { name: "Wrap lines" });
await expect.element(toggle).not.toHaveAttribute("title");
Expand Down
8 changes: 6 additions & 2 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ interface MarkdownFileLinkProps {
iconPath: string;
displayPath: string;
workspaceRelativePath: string | null;
line?: number | undefined;
label: string;
copyMarkdown: string;
theme: "light" | "dark";
Expand Down Expand Up @@ -996,6 +997,7 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
iconPath,
displayPath,
workspaceRelativePath,
line,
label,
copyMarkdown,
theme,
Expand Down Expand Up @@ -1028,8 +1030,8 @@ const MarkdownFileLink = memo(function MarkdownFileLink({
handleOpenInEditor();
return;
}
useRightPanelStore.getState().openFile(threadRef, workspaceRelativePath);
}, [handleOpenInEditor, threadRef, workspaceRelativePath]);
useRightPanelStore.getState().openFile(threadRef, workspaceRelativePath, line);
}, [handleOpenInEditor, line, threadRef, workspaceRelativePath]);

const handleOpenInBrowser = useCallback(() => {
if (!threadRef) return;
Expand Down Expand Up @@ -1170,6 +1172,7 @@ function areMarkdownFileLinkPropsEqual(
previous.iconPath === next.iconPath &&
previous.displayPath === next.displayPath &&
previous.workspaceRelativePath === next.workspaceRelativePath &&
previous.line === next.line &&
previous.label === next.label &&
previous.copyMarkdown === next.copyMarkdown &&
previous.theme === next.theme &&
Expand Down Expand Up @@ -1332,6 +1335,7 @@ function ChatMarkdown({
iconPath={fileLinkMeta.filePath}
displayPath={fileLinkMeta.displayPath}
workspaceRelativePath={fileLinkMeta.workspaceRelativePath}
line={fileLinkMeta.line}
label={labelParts.join(" · ")}
copyMarkdown={`[${fileLinkMeta.basename}](${normalizedHref})`}
theme={resolvedTheme}
Expand Down
94 changes: 89 additions & 5 deletions apps/web/src/components/ChatView.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@
await vi.waitFor(
() => {
element = query();
expect(element, errorMessage).toBeTruthy();

Check failure on line 1217 in apps/web/src/components/ChatView.browser.tsx

View workflow job for this annotation

GitHub Actions / Test Browser

[browser (chromium)] src/components/ChatView.browser.tsx > ChatView timeline estimator parity (full app) > filters the open picker menu and opens VSCodium from the menu

AssertionError: Unable to find Open picker button.: expected null to be truthy - Expected: true + Received: null ❯ toBeTruthy src/components/ChatView.browser.tsx:1217:36 ❯ checkCallback ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/chunks/test.DNmyFkvJ.js?v=dd79f406:3383:23

Check failure on line 1217 in apps/web/src/components/ChatView.browser.tsx

View workflow job for this annotation

GitHub Actions / Test Browser

[browser (chromium)] src/components/ChatView.browser.tsx > ChatView timeline estimator parity (full app) > shows Kiro in the open picker menu and opens the project cwd with it

AssertionError: Unable to find Open picker button.: expected null to be truthy - Expected: true + Received: null ❯ toBeTruthy src/components/ChatView.browser.tsx:1217:36 ❯ checkCallback ../../node_modules/.pnpm/@voidzero-dev+vite-plus-test@0.1.24_@types+node@24.12.4_@voidzero-dev+vite-plus-core@0._5c1a90b7fd71e48080dbb1bef168bb9c/node_modules/@voidzero-dev/vite-plus-test/dist/chunks/test.DNmyFkvJ.js?v=dd79f406:3383:23
},
{
timeout: 8_000,
Expand Down Expand Up @@ -2700,13 +2700,97 @@
expect(fileTree.shadowRoot?.activeElement).toBe(fileSearchInput);
expect(useComposerDraftStore.getState().draftsByThreadKey[THREAD_KEY]?.prompt ?? "").toBe("");

useRightPanelStore.getState().openFile(THREAD_REF, "src/large.ts");
const codeVirtualizer = await waitForElement(
() => document.querySelector<HTMLElement>(".file-preview-virtualizer"),
"Unable to find the virtualized file preview.",
);
const previousCodeVirtualizer = document.querySelector<HTMLElement>(
".file-preview-virtualizer",
);
useRightPanelStore.getState().openFile(THREAD_REF, "src/large.ts", 4_000);
const codeVirtualizer = await waitForElement(() => {
const current = document.querySelector<HTMLElement>(".file-preview-virtualizer");
return current !== previousCodeVirtualizer ? current : null;
}, "Unable to find the virtualized file preview.");
expect(codeVirtualizer.querySelector("diffs-container")).not.toBeNull();
expect(codeVirtualizer.classList.contains("overflow-auto")).toBe(true);
await vi.waitFor(
() => {
const fileHost = codeVirtualizer.querySelector<HTMLElement>("diffs-container");
const targetLine = fileHost?.shadowRoot?.querySelector<HTMLElement>('[data-line="4000"]');
const targetLineNumber = fileHost?.shadowRoot?.querySelector<HTMLElement>(
'[data-column-number="4000"]',
);
const previousLine =
fileHost?.shadowRoot?.querySelector<HTMLElement>('[data-line="3999"]');
const previousLineNumber = fileHost?.shadowRoot?.querySelector<HTMLElement>(
'[data-column-number="3999"]',
);
expect(codeVirtualizer.scrollTop).toBeGreaterThan(0);
expect(targetLine).not.toBeNull();
expect(previousLine).not.toBeNull();
expect(targetLine?.hasAttribute("data-file-link-reveal")).toBe(true);
expect(targetLineNumber?.hasAttribute("data-file-link-reveal")).toBe(true);
expect(targetLine?.hasAttribute("data-selected-line")).toBe(false);
expect(targetLineNumber?.hasAttribute("data-selected-line")).toBe(false);
expect(targetLineNumber?.querySelector("[data-gutter-utility-slot]")).toBeNull();
expect(window.getComputedStyle(targetLine!).backgroundColor).not.toBe(
window.getComputedStyle(previousLine!).backgroundColor,
);
expect(window.getComputedStyle(targetLineNumber!).backgroundColor).not.toBe(
window.getComputedStyle(previousLineNumber!).backgroundColor,
);

const viewportRect = codeVirtualizer.getBoundingClientRect();
const lineRect = targetLine!.getBoundingClientRect();
expect(lineRect.top).toBeGreaterThanOrEqual(viewportRect.top);
expect(lineRect.bottom).toBeLessThanOrEqual(viewportRect.bottom);
},
{ timeout: 8_000, interval: 16 },
);

const fileHost = codeVirtualizer.querySelector<HTMLElement>("diffs-container");
const targetLineNumber =
fileHost?.shadowRoot?.querySelector<HTMLElement>('[data-column-number="4000"]') ?? null;
const previousLineNumber =
fileHost?.shadowRoot?.querySelector<HTMLElement>('[data-column-number="3999"]') ?? null;
expect(targetLineNumber).not.toBeNull();
expect(previousLineNumber).not.toBeNull();

targetLineNumber!.dispatchEvent(
new PointerEvent("pointermove", {
bubbles: true,
cancelable: true,
composed: true,
pointerType: "mouse",
}),
);
await vi.waitFor(() => {
expect(targetLineNumber?.querySelector("[data-gutter-utility-slot]")).not.toBeNull();
});

previousLineNumber!.dispatchEvent(
new PointerEvent("pointermove", {
bubbles: true,
cancelable: true,
composed: true,
pointerType: "mouse",
}),
);
await vi.waitFor(() => {
expect(targetLineNumber?.querySelector("[data-gutter-utility-slot]")).toBeNull();
expect(previousLineNumber?.querySelector("[data-gutter-utility-slot]")).not.toBeNull();
});

codeVirtualizer.scrollTop = 0;
useRightPanelStore.getState().openFile(THREAD_REF, "src/large.ts", 4_000);
await vi.waitFor(
() => {
const fileHost = codeVirtualizer.querySelector<HTMLElement>("diffs-container");
const targetLine = fileHost?.shadowRoot?.querySelector<HTMLElement>('[data-line="4000"]');
expect(targetLine).not.toBeNull();
expect(targetLine?.hasAttribute("data-file-link-reveal")).toBe(true);
expect(targetLine?.hasAttribute("data-selected-line")).toBe(false);
expect(codeVirtualizer.scrollTop).toBeGreaterThan(0);
},
{ timeout: 8_000, interval: 16 },
);
} finally {
await mounted.cleanup();
}
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,8 @@ function ChatViewContent(props: ChatViewProps) {
const activeRightPanelSurface = useRightPanelStore((store) =>
selectActiveRightPanelSurface(store.byThreadKey, activeThreadRef),
);
const activeFileSurface =
activeRightPanelSurface?.kind === "file" ? activeRightPanelSurface : null;
const activePreviewState = usePreviewStateStore((state) =>
selectThreadPreviewState(state.byThreadKey, activeThreadRef),
);
Expand Down Expand Up @@ -4799,6 +4801,8 @@ function ChatViewContent(props: ChatViewProps) {
relativePath={
activeRightPanelSurface.kind === "file" ? activeRightPanelSurface.relativePath : null
}
revealLine={activeFileSurface?.revealLine ?? null}
revealRequestId={activeFileSurface?.revealRequestId ?? 0}
onOpenFile={openFileSurface}
onPendingChange={handleFilePendingChange}
/>
Expand Down
Loading
Loading