Skip to content

feat: clickable filenames in tool results to open files in VS Code#486

Draft
markijbema wants to merge 6 commits intodevfrom
mark/clickable-filenames-open-in-vscode
Draft

feat: clickable filenames in tool results to open files in VS Code#486
markijbema wants to merge 6 commits intodevfrom
mark/clickable-filenames-open-in-vscode

Conversation

@markijbema
Copy link
Contributor

Summary

Makes filenames in tool results (read, edit, write) clickable in the VS Code extension webview. Clicking a filename opens that file in the VS Code editor.

Changes

VS Code Extension

  • KiloProvider.ts: New openFile message handler that calls vscode.window.showTextDocument
  • App.tsx: DataBridge wires onOpenFile callback through useVSCode().postMessage
  • messages.ts: New OpenFileRequest type added to WebviewMessage union

Shared UI (packages/ui)

  • data.tsx: New OpenFileFn type and onOpenFile prop on DataProvider context
  • message-part.tsx: Filenames in read, edit, and write tool renders are now clickable
  • message-part.css: .clickable styles on filename elements (pointer cursor, underline, hover color)

How it works

  1. User clicks a filename in a tool result in the webview
  2. The click handler calls data.openFile(filePath)
  3. DataBridge posts an openFile message to the VS Code host
  4. KiloProvider receives the message and opens the file via showTextDocument

Add openFile message handler to KiloProvider and wire it through
DataProvider context so that clicking filenames in read/edit/write
tool results opens the file in the VS Code editor.

Changes:
- KiloProvider: handle 'openFile' message via showTextDocument
- App.tsx DataBridge: wire onOpenFile through useVSCode postMessage
- messages.ts: add OpenFileRequest type to WebviewMessage union
- data.tsx: add OpenFileFn type and onOpenFile prop to DataProvider
- message-part.tsx: make filenames clickable in read/edit/write tools
- message-part.css: add .clickable styles for filename elements
…resolution

- Resolve relative paths against workspace root in KiloProvider openFile handler
- Add ClickableFileOutput component for tool output file paths
- Make glob, grep, and list tool output file paths clickable
- Make read tool 'loaded' file paths clickable
- Add CSS styles for clickable file output lines
When the assistant mentions a file path in inline code (e.g. `skills/foo/SKILL.md`),
clicking it now opens the file in VS Code. Uses event delegation on the text-part
container to detect clicks on <code> elements containing file-path-like text.

CSS cursor:pointer applied to inline code when openFile handler is available.
…es/kilo-ui

packages/ui is upstream and should remain immutable. Move all component and
CSS overrides to packages/kilo-ui:

- Revert packages/ui/src/components/message-part.{tsx,css} to upstream
- Add OpenFileFn type + onOpenFile prop to data.tsx with kilocode_change markers
- Override TextPartDisplay, read, list, glob, grep, edit, write tools in kilo-ui
- Add ClickableFileOutput component and isFilePath util in kilo-ui
- Add all clickable CSS in kilo-ui/message-part.css
- Add @opencode-ai/util as peer dependency in kilo-ui
Export DiagnosticsDisplay, getDiagnostics, relativizeProjectPaths, getDirectory,
and createThrottledValue from upstream message-part.tsx with kilocode_change markers.
Import them in kilo-ui instead of re-defining.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments