Skip to content

feat(vscode): make filenames in chat clickable to open editor tab#479

Open
iscekic wants to merge 1 commit intodevfrom
feat/clickable-filenames-461-404
Open

feat(vscode): make filenames in chat clickable to open editor tab#479
iscekic wants to merge 1 commit intodevfrom
feat/clickable-filenames-461-404

Conversation

@iscekic
Copy link
Contributor

@iscekic iscekic commented Feb 19, 2026

Summary

  • Clicking file paths in tool call headers (read, edit, write, apply_patch) and markdown prose opens the file in a VS Code editor tab
  • File references with :line or :line:col suffixes (e.g. src/index.ts:42:5) navigate to the exact position
  • All clickable elements now show cursor: pointer on hover with underline feedback

Closes #461, closes #404

Changes

Shared UI (packages/ui)

  • context/data.tsx — added onOpenFile(path, line?, col?) optional callback to DataProvider
  • components/message-part.tsx — wired click handlers for read, edit, write, apply_patch tool registrations + delegated click handler in TextPartDisplay for file-link elements in markdown prose
  • components/message-part.css.clickable cursor/hover styles for file path slots, loaded-file rows, and user-message attachments
  • context/marked.tsx — custom codespan renderer that detects file path patterns (relative, absolute, with optional :line:col) and wraps them in <code class="file-link" data-file-path="..." data-file-line="..." data-file-col="...">
  • components/markdown.css.file-link styles (dotted underline, pointer cursor, interactive hover color)

VS Code Extension (packages/kilo-vscode)

  • webview-ui/src/types/messages.ts — added OpenFileRequest to WebviewMessage union
  • webview-ui/src/App.tsx — wired onOpenFile in DataBridge to post message to extension host
  • src/KiloProvider.tshandleOpenFile resolves paths (cross-platform, Unix + Windows absolute detection via vscode.Uri.joinPath), opens document with optional line/column selection

Testing

Manually tested in Extension Development Host:

  • Read/edit/write/apply_patch tool header file paths — hover shows pointer, click opens file
  • Loaded file paths below read tool — clickable
  • Markdown prose with backtick file paths (src/foo.ts, src/foo.ts:42, /abs/path.ts:10:5) — dotted underline, click opens at position
  • Non-path inline code (npm install, true) — not affected
  • e.stopPropagation() — clicking filename does not toggle collapsible
  • Windows path detection (C:\...) — handled in extension host

…, #404)

Add onOpenFile callback to shared DataProvider so tool renderers can
trigger file-open in the host environment. In the VS Code extension,
clicking a filename posts an openFile message to the extension host
which resolves the path and opens the document in a preview tab.

Tool call headers (read, edit, write, apply_patch) now show pointer
cursor and underline on hover for file paths. Inline code in markdown
prose that looks like a file path (relative or absolute, with optional
:line or :line:col suffix) is wrapped with a file-link class and opens
on click via delegated event handling. When a line number is present,
the editor scrolls to that line.

Also adds cursor:pointer to user-message attachments to fix the
general clickable-items discoverability issue.
@iscekic iscekic self-assigned this Feb 19, 2026
@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 19, 2026

Code Review Summary

Status: 2 Suggestions Found | Recommendation: Merge (suggestions are non-blocking)

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 2
Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/kilo-vscode/src/KiloProvider.ts 1215 handleOpenFile accepts absolute paths from the webview without workspace-containment validation. Low risk since it only opens files in the editor, but could be hardened.
packages/ui/src/context/marked.tsx 497 file.path interpolated into HTML attribute without escaping. Currently safe due to regex constraints + DOMPurify, but could be hardened as defense-in-depth.

Positive Observations

  • Clean architecture: the openFile capability is properly threaded through the context system (DataProvideruseData) with graceful degradation when unavailable (web/TUI returns undefined)
  • Good security layering: FILE_PATH_RE regex constrains input characters, DOMPurify sanitizes HTML output, and click handlers check for data.openFile availability
  • Proper event delegation pattern in handleMarkdownClick using closest() for file-link clicks
  • The handleOpenFile method correctly handles edge cases: undefined line/column, absolute vs relative paths, and 1-based to 0-based position conversion
  • CSS changes are well-scoped using nested selectors with .clickable and .file-link classes
  • Type safety maintained with proper OpenFileRequest message type and OpenFileFn type alias
Files Reviewed (7 files)
  • packages/kilo-vscode/src/KiloProvider.ts - 1 suggestion (openFile handler)
  • packages/kilo-vscode/webview-ui/src/App.tsx - No issues (DataBridge wiring)
  • packages/kilo-vscode/webview-ui/src/types/messages.ts - No issues (type definitions)
  • packages/ui/src/components/markdown.css - No issues (file-link styling)
  • packages/ui/src/components/message-part.css - No issues (clickable styling)
  • packages/ui/src/components/message-part.tsx - No issues (click handlers for edit/write/read/apply_patch tools)
  • packages/ui/src/context/data.tsx - No issues (OpenFileFn type and context wiring)
  • packages/ui/src/context/marked.tsx - 1 suggestion (codespan renderer)

Fix these issues in Kilo Cloud


export type NativeMarkdownParser = (markdown: string) => Promise<string>

// Matches text that looks like a file path: contains "/" and ends with a file extension,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we want to edit components in ui, i think we should do this in kilo-ui; i already had a pr for this (but vibed 2 days ago and prolly forgot to link) and if you use kilo -ui it also becomes cumbersome

#486

@catrielmuller opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I didn't realize you already did work on this, the ticket had no one assigned. Looks like both PRs achieve the same thing, I'll defer to you @markijbema for which one you want to close vs merge.

Re your comment - what would you suggest?

Copy link
Contributor

Choose a reason for hiding this comment

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

nah, no worries, just continue on, i wasnt happy with mine, and my mistake for not doing the administation.

Please consult with Catriel, he did the original setup with kilo-ai and probably has more insight into it than I what would be best here

Copy link
Contributor

Choose a reason for hiding this comment

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

(tbc, mine does work, but it is a lot more code; i'm not sure we want that)

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

Projects

None yet

2 participants

Comments