Skip to content

feat(chat): enable jump-to-file in regular chat diff accordions (#997)#1011

Open
TrawenCZ wants to merge 1 commit into
Zoo-Code-Org:mainfrom
TrawenCZ:feat/jump-to-file-in-regular-chat-diff
Open

feat(chat): enable jump-to-file in regular chat diff accordions (#997)#1011
TrawenCZ wants to merge 1 commit into
Zoo-Code-Org:mainfrom
TrawenCZ:feat/jump-to-file-in-regular-chat-diff

Conversation

@TrawenCZ

@TrawenCZ TrawenCZ commented Jul 24, 2026

Copy link
Copy Markdown

Related GitHub Issue

Description

Previously the jump-to-file icon in regular chat diff accordions only appeared for newFileCreated tools. Edited files (appliedDiff, editedExistingFile, searchAndReplace, etc.) and insertContent shared the same CodeAccordion but had no jump-to-file option.

This PR generalizes the existing onJumpToCreatedFile handler in ChatRow.tsx to onJumpToFile, and wires it up for every file-edit and insert-content tool that renders a CodeAccordion.

Test Procedure

  • Added a regression test in webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx asserting that appliedDiff now renders the external-link icon and posts openFile with the correct ./ prefixed path.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Previous state

2026-07-24.21-51-33.mp4

New state

2026-07-24.21-52-48.mp4

Documentation Updates

  • No documentation updates are required.

Additional Notes

None.

Get in Touch

@trawen at Discord

Summary by CodeRabbit

Summary by CodeRabbit

  • Bug Fixes
    • Expanded “jump to file” behavior for tool responses so it’s triggered whenever a tool includes a file path (including applied changes and inserted content).
    • Normalized the opened file path to use the expected relative ./ format.
  • Tests
    • Consolidated and expanded jump-to-file test coverage across multiple file-related tool types, including new negative cases when path is missing or when the tool isn’t file-based.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: afea5f91-a96d-4098-8aaf-8beba00285a2

📥 Commits

Reviewing files that changed from the base of the PR and between b750b8c and d3fde81.

📒 Files selected for processing (2)
  • webview-ui/src/components/chat/ChatRow.tsx
  • webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • webview-ui/src/components/chat/tests/ChatRow.diff-actions.spec.tsx
  • webview-ui/src/components/chat/ChatRow.tsx

📝 Walkthrough

Walkthrough

Chat diff previews now provide a jump-to-file action for tool responses with paths. The callback normalizes paths for openFile messages, and tests cover supported tools, missing paths, and non-file tools.

Changes

Jump-to-file action

Layer / File(s) Summary
Path-based jump action
webview-ui/src/components/chat/ChatRow.tsx, webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx
The generalized callback opens available tool paths, both diff accordion paths use it, and tests cover positive and negative cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: taltas

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: enabling jump-to-file in chat diff accordions.
Description check ✅ Passed The description follows the template and covers the issue link, implementation summary, testing, checklist, and notes.
Linked Issues check ✅ Passed The code changes implement #997 by adding jump-to-file access in diff previews and updating tests accordingly.
Out of Scope Changes check ✅ Passed The changes stay focused on jump-to-file behavior and related tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
webview-ui/src/components/chat/ChatRow.tsx (1)

423-429: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve an existing ./ path prefix.

This currently produces ././src/file.ts when tool.path is already workspace-relative with a ./ prefix. Match FileChangesPanel.tsx and normalize conditionally so the openFile payload remains canonical.

Proposed fix
 	return () => vscode.postMessage({ type: "openFile", text: "./" + tool.path })
+	return () =>
+		vscode.postMessage({
+			type: "openFile",
+			text: tool.path.startsWith("./") ? tool.path : "./" + tool.path,
+		})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@webview-ui/src/components/chat/ChatRow.tsx` around lines 423 - 429, Update
onJumpToFile in ChatRow.tsx to preserve an existing "./" prefix instead of
always prepending another one. Normalize tool.path conditionally, matching
FileChangesPanel.tsx, so the openFile message receives a canonical
workspace-relative path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@webview-ui/src/components/chat/ChatRow.tsx`:
- Around line 423-429: Update onJumpToFile in ChatRow.tsx to preserve an
existing "./" prefix instead of always prepending another one. Normalize
tool.path conditionally, matching FileChangesPanel.tsx, so the openFile message
receives a canonical workspace-relative path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 96ba4f81-6396-46e1-89e1-2788d1f7977e

📥 Commits

Reviewing files that changed from the base of the PR and between 2634d5c and 4e3270a.

📒 Files selected for processing (2)
  • webview-ui/src/components/chat/ChatRow.tsx
  • webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
webview-ui/src/components/chat/ChatRow.tsx 75.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Jul 24, 2026

@edelauna edelauna left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looking forward to this feature, can you increase test coverage a bit.

type: "openFile",
text: "./src/file.ts",
})
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers appliedDiff — do editedExistingFile, searchAndReplace, and insertContent also need a click-asserts-openFile test? They share the same onJumpToFile code path in ChatRow.tsx (lines 500 and 539), so a future gate on tool type there would go uncaught.

const { container } = renderChatRow(message)
const openFileIcon = container.querySelector(".codicon-link-external") as HTMLElement | null

expect(openFileIcon).toBeInTheDocument()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding a negative case — when path is omitted from the tool message, is the icon confirmed absent? ChatRow.tsx:424 returns undefined for onJumpToFile when tool.path is falsy, and CodeAccordion only renders the icon when both onJumpToFile and path are truthy — so the guard exists, but it is untested.

})
})

it("shows jump-to-file affordance for appliedDiff", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a test anywhere that asserts the icon is absent for a non-file tool (e.g. executeCommand or listFilesTopLevel)? A render path that unconditionally injected .codicon-link-external would pass all current tests.

const onJumpToCreatedFile = useMemo(() => {
if (!tool || tool.tool !== "newFileCreated" || !tool.path) {
const onJumpToFile = useMemo(() => {
if (!tool || !tool.path) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return statement below unconditionally prepends "./", while the sibling in FileChangesPanel.tsx:168 guards with path.startsWith("./") ? path : "./" + path to stay idempotent. Currently safe since getReadablePath always returns bare relative paths, but worth mirroring for consistency?

@github-actions github-actions Bot added awaiting-author PR is waiting for the author to address requested changes and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Jul 26, 2026
@TrawenCZ

Copy link
Copy Markdown
Author

Thanks! Looking forward to this feature, can you increase test coverage a bit.

Sure, will update those. I just wanted to go with minimal changes (and not change the logic where not needed), but I agree we can improve this a bit as part of the PR.

@TrawenCZ
TrawenCZ force-pushed the feat/jump-to-file-in-regular-chat-diff branch from 4e3270a to b750b8c Compare July 26, 2026 08:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx`:
- Around line 192-200: Update the message fixture in “does not show jump-to-file
affordance for non-file tools” to include a valid path such as “src/file.ts”,
while keeping the non-file tool and existing assertion unchanged.
- Around line 144-179: Update the parameterized test around renderChatRow and
mockPostMessage to clear the shared mock immediately before clicking the
external-link icon, then assert the click produces exactly one call with the
expected openFile payload. Keep the existing icon lookup and message values
unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 529f0ac0-1e66-4525-8f2c-f25b41f81449

📥 Commits

Reviewing files that changed from the base of the PR and between 4e3270a and b750b8c.

📒 Files selected for processing (2)
  • webview-ui/src/components/chat/ChatRow.tsx
  • webview-ui/src/components/chat/__tests__/ChatRow.diff-actions.spec.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • webview-ui/src/components/chat/ChatRow.tsx

@TrawenCZ
TrawenCZ force-pushed the feat/jump-to-file-in-regular-chat-diff branch from b750b8c to d3fde81 Compare July 26, 2026 09:02
@TrawenCZ

Copy link
Copy Markdown
Author

@edelauna the test coverage check is now failing because of that line for idempotency, and I'm not sure if that something you want me to test and if so, than how, eg write the case for each of the tools that use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author PR is waiting for the author to address requested changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Jump to file" indicator at diff preview

2 participants