feat(vscode): make filenames in chat clickable to open editor tab#479
feat(vscode): make filenames in chat clickable to open editor tab#479
Conversation
…, #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.
Code Review SummaryStatus: 2 Suggestions Found | Recommendation: Merge (suggestions are non-blocking) Overview
Issue Details (click to expand)SUGGESTION
Positive Observations
Files Reviewed (7 files)
|
|
|
||
| export type NativeMarkdownParser = (markdown: string) => Promise<string> | ||
|
|
||
| // Matches text that looks like a file path: contains "/" and ends with a file extension, |
There was a problem hiding this comment.
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
@catrielmuller opinions?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
(tbc, mine does work, but it is a lot more code; i'm not sure we want that)
Summary
:lineor:line:colsuffixes (e.g.src/index.ts:42:5) navigate to the exact positioncursor: pointeron hover with underline feedbackCloses #461, closes #404
Changes
Shared UI (
packages/ui)context/data.tsx— addedonOpenFile(path, line?, col?)optional callback toDataProvidercomponents/message-part.tsx— wired click handlers forread,edit,write,apply_patchtool registrations + delegated click handler inTextPartDisplayfor file-link elements in markdown prosecomponents/message-part.css—.clickablecursor/hover styles for file path slots, loaded-file rows, and user-message attachmentscontext/marked.tsx— customcodespanrenderer 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-linkstyles (dotted underline, pointer cursor, interactive hover color)VS Code Extension (
packages/kilo-vscode)webview-ui/src/types/messages.ts— addedOpenFileRequesttoWebviewMessageunionwebview-ui/src/App.tsx— wiredonOpenFileinDataBridgeto post message to extension hostsrc/KiloProvider.ts—handleOpenFileresolves paths (cross-platform, Unix + Windows absolute detection viavscode.Uri.joinPath), opens document with optional line/column selectionTesting
Manually tested in Extension Development Host:
src/foo.ts,src/foo.ts:42,/abs/path.ts:10:5) — dotted underline, click opens at positionnpm install,true) — not affectede.stopPropagation()— clicking filename does not toggle collapsibleC:\...) — handled in extension host