fix(vscode): make message copy buttons reliable - #12123
Conversation
Route message and response copy actions through the VS Code extension host so webview focus changes do not block clipboard writes.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (5 files)
Previous Review Summary (commit 01fc303)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 01fc303)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (8 files)
Reviewed by gpt-5.6-sol · Input: 61.6K · Output: 7.7K · Cached: 183.9K Review guidance: REVIEW.md from base branch |
Correlate clipboard requests with extension-host results so copy controls only report success after the system clipboard write completes.
|
Hey @mjnaderi, I couldn’t reproduce the issue described in the latest releases. Could you share the OS, Kilo version, and exact reproduction steps where you observed it? Also, please link any existing GitHub issue or user report for this problem. |
|
Hi @johnnyeric OS: Linux (Arch Linux, kernel: 7.1.3-arch2-2, desktop: Gnome 50.3) Reproduction steps:
Related issue: #11092 |
|
This note from MDN is for chrome browser extensions, but maybe applies here too.
|
|
@mjnaderi Thanks for sharing all these details. I couldn't reproduce it on Mac but was able in a linux VM. The fix looks good thanks for working on this! |
* fix(vscode): make message copy buttons reliable Route message and response copy actions through the VS Code extension host so webview focus changes do not block clipboard writes. * fix(vscode): await host clipboard writes Correlate clipboard requests with extension-host results so copy controls only report success after the system clipboard write completes.
Route message and response copy actions through the VS Code extension host so webview focus changes do not block clipboard writes.
Issue
No linked issue. This fixes the focus-related copy-button failure described below.
Context
The message and response copy buttons previously called
navigator.clipboard.writeTextdirectly inside the webview. After switching focus away from VS Code and returning, that API could reject the clipboard write. The handlers would then exit before copying the text or displaying the check mark.Implementation
Added a small clipboard context to
kilo-ui. It defaults tonavigator.clipboardfor standalone consumers such as Storybook.The shared VS Code provider overrides that implementation once for both the sidebar and Agent Manager. Copy requests are routed through the extension host and written using
vscode.env.clipboard, avoiding the webview clipboard permission and focus behavior.The existing Agent Manager clipboard message contract is reused. Sidebar requests are handled by the existing early-message router, keeping clipboard routing out of the main
KiloProvidermessage switch.Screenshots / Video
N/A — this is a behavior-only fix with no visual changes.
How to Test
Manual/local verification
bun test tests/unit/early-message.test.ts --dots; both clipboard-routing regression tests passed.check-kilocode-change, message-contract tests, andgit diff --check; all passed.Reviewer test steps
Blocked checks and substitute verification
bun run test:unitcompleted with 3,083 passing tests and one unrelated failure inWorktreeManager.resolveStartPoint, where an existing worktree fixture expectedremotebut receivedlocal-tracking. The failure reproduced when that test file was run in isolation. Substitute verification included the passing clipboard-routing regression tests, message-contract tests, typecheck, lint, formatting, and Kilo marker checks.Checklist