From 4e3270a37924edc1d21544d90e34cb5684b52e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Sl=C3=ADva?= Date: Fri, 24 Jul 2026 21:13:05 +0200 Subject: [PATCH] feat(chat): enable jump-to-file in regular chat diff accordions (#997) --- webview-ui/src/components/chat/ChatRow.tsx | 7 +++--- .../__tests__/ChatRow.diff-actions.spec.tsx | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index f973c7929f..fa73d998d6 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -420,8 +420,8 @@ export const ChatRowContent = ({ return (tool.content ?? tool.diff) as string | undefined }, [tool]) - const onJumpToCreatedFile = useMemo(() => { - if (!tool || tool.tool !== "newFileCreated" || !tool.path) { + const onJumpToFile = useMemo(() => { + if (!tool || !tool.path) { return undefined } @@ -497,7 +497,7 @@ export const ChatRowContent = ({ isLoading={message.partial} isExpanded={isExpanded} onToggleExpand={handleToggleExpand} - onJumpToFile={onJumpToCreatedFile} + onJumpToFile={onJumpToFile} diffStats={tool.diffStats} /> @@ -536,6 +536,7 @@ export const ChatRowContent = ({ isLoading={message.partial} isExpanded={isExpanded} onToggleExpand={handleToggleExpand} + onJumpToFile={onJumpToFile} diffStats={tool.diffStats} /> diff --git a/webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx b/webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx index 7876420959..adf6572e67 100644 --- a/webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx +++ b/webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx @@ -165,6 +165,30 @@ describe("ChatRow - inline diff stats and actions", () => { }) }) + it("shows jump-to-file affordance for appliedDiff", () => { + const message = createToolAskMessage({ + tool: "appliedDiff", + path: "src/file.ts", + diff: "@@ -1,1 +1,1 @@\n-old\n+new\n", + diffStats: { added: 1, removed: 1 }, + }) + + const { container } = renderChatRow(message) + const openFileIcon = container.querySelector(".codicon-link-external") as HTMLElement | null + + expect(openFileIcon).toBeInTheDocument() + if (!openFileIcon) { + throw new Error("Expected external link icon for appliedDiff") + } + + fireEvent.click(openFileIcon) + + expect(mockPostMessage).toHaveBeenCalledWith({ + type: "openFile", + text: "./src/file.ts", + }) + }) + it("preserves protected and outside-workspace messaging in unified branch", () => { const outsideWorkspaceMessage = createToolAskMessage({ tool: "searchAndReplace",