Skip to content

feat: add clickable file paths to agent tool outputs and inline code#13465

Merged
DeJeune merged 5 commits intomainfrom
DeJeune/clickable-file-paths
Mar 16, 2026
Merged

feat: add clickable file paths to agent tool outputs and inline code#13465
DeJeune merged 5 commits intomainfrom
DeJeune/clickable-file-paths

Conversation

@DeJeune
Copy link
Copy Markdown
Collaborator

@DeJeune DeJeune commented Mar 14, 2026

What this PR does

Before this PR:
File paths displayed in agent tool outputs (Edit, Write, Read, Glob, Grep, MultiEdit, NotebookEdit) and inline code blocks were plain, non-interactive text.

After this PR:
File paths are clickable — clicking opens the file directly. An ellipsis dropdown menu provides additional actions: "Reveal in Finder" and "Open in Editor" (VS Code, Cursor, Zed).

Why we need it and why it was done in this way

Clickable file paths improve developer workflow by allowing quick navigation to files referenced in agent tool outputs without manual copy-paste.

The following tradeoffs were made:

  • A shared ClickableFilePath component is used across all agent tools for consistency.
  • Inline code file path detection uses a conservative regex (/^\/[\w.-]+(?:\/[\w.-]+)+$/) to avoid false positives on non-path inline code. This means some edge-case paths (e.g., with spaces or @) won't be detected in inline code, but tool-output paths are always clickable since they come from structured input.

The following alternatives were considered:

  • Detecting file paths via a more permissive regex — rejected due to high false-positive risk on inline code snippets.

Breaking changes

None.

Special notes for your reviewer

  • The ClickableFilePath component reuses existing useExternalApps hook and window.api.file IPC APIs.
  • i18n keys added for open_file, open_file_error, file_not_found, and reveal_in_finder across all locale files.
  • Review fix: hardcoded 'Finder' string on macOS was replaced with t() for proper i18n compliance.
  • Review fix: test mocks for openPath/showInFolder now return Promises to avoid TypeError on .catch().

Checklist

Release note

Add clickable file paths in agent tool outputs — click to open files, with dropdown to reveal in Finder or open in external editors (VS Code, Cursor, Zed).

DeJeune and others added 2 commits March 14, 2026 20:01
Make file paths in agent tool outputs (Edit, Write, Read, Glob, Grep,
MultiEdit, NotebookEdit) and inline code blocks interactive. Clicking
opens the file; a dropdown menu offers "Reveal in Finder" and "Open in
Editor" (VS Code, Cursor, Zed) integration.

- Add ClickableFilePath component with editor dropdown
- Detect absolute file paths in inline code blocks
- Add i18n keys for file operations across all locales
- Add unit tests for ClickableFilePath and CodeBlock detection

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: suyao <[email protected]>
@EurFelux EurFelux self-requested a review March 14, 2026 12:11
Copy link
Copy Markdown
Collaborator

@EurFelux EurFelux left a comment

Choose a reason for hiding this comment

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

Nice feature! The clickable file paths across all agent tool outputs are a solid developer workflow improvement. The implementation is clean and well-tested. A few observations:

Key items:

  1. Code duplicationgetEditorIcon and the openInEditor URL construction pattern are duplicated from OpenExternalAppButton.tsx. Consider extracting into a shared utility.
  2. GrepTool regex/^(\/[^:]+)(:.*)?$/ is quite permissive and could match non-path lines. A tighter pattern would reduce false positives.
  3. NotebookEditTool fallback — Minor inconsistency in the ternary fallback vs other tools in this PR.
  4. Accessibility — The clickable <span> could benefit from keyboard navigation support (tabIndex, onKeyDown).

Overall, this looks good! The conservative inline code path regex is a sensible tradeoff, and the test coverage is appreciated.

@EurFelux
Copy link
Copy Markdown
Collaborator

EurFelux commented Mar 14, 2026

Note

This issue/comment/review was translated by Claude.

image

This is too inconspicuous.


Original Content image

这个也太不显眼了

- Extract getEditorIcon and buildEditorUrl into shared editorUtils
- Reuse shared utility in both ClickableFilePath and OpenExternalAppButton
- Tighten GrepTool regex to reduce false positives on non-path lines
- Fix NotebookEditTool redundant fallback to use undefined explicitly
- Add keyboard accessibility (role="link", tabIndex, Enter/Space)
- Make dropdown trigger more visible (larger font, hover background)
- Add keyboard accessibility tests

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: suyao <[email protected]>
@DeJeune DeJeune requested a review from EurFelux March 15, 2026 14:22
/**
* Build the protocol URL to open a file/folder in an external editor.
* @see https://code.visualstudio.com/docs/configure/command-line#_opening-vs-code-with-urls
* @see https://github.com/microsoft/vscode/issues/141548#issuecomment-1102200617
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

not working for zed. but still ok

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

See #13501

@EurFelux EurFelux self-requested a review March 16, 2026 02:18
@DeJeune DeJeune requested a review from kangfenmao March 16, 2026 05:52
Copy link
Copy Markdown
Collaborator

@kangfenmao kangfenmao left a comment

Choose a reason for hiding this comment

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

LGTM! Clean implementation with good code reuse patterns.

Highlights:

  • ClickableFilePath component is well-structured with proper memo, useCallback, useMemo
  • editorUtils.tsx extraction eliminates duplication with OpenExternalAppButton
  • Good accessibility support (role="link", tabIndex, keyboard handlers)
  • Solid test coverage for both the component and CodeBlock path detection
  • GrepTool regex verified to work correctly via backtracking

Minor nits (non-blocking):

  • getEditorIcon in editorUtils.tsx has no default branch — consider a fallback icon for future editors
  • window.open(buildEditorUrl(...)) in ClickableFilePath lacks error handling if the editor is not installed (same pattern as existing OpenExternalAppButton, so not a regression)

@DeJeune DeJeune merged commit 300920c into main Mar 16, 2026
5 checks passed
@DeJeune DeJeune deleted the DeJeune/clickable-file-paths branch March 16, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants