Skip to content

fix(vscode): keep transcript selection on copy in VS Code 1.143 - #15472

Merged
marius-kilocode merged 1 commit into
mainfrom
fix-webview-copy
Oct 26, 2026
Merged

marius-kilocode merged 1 commit into
mainfrom
fix-webview-copy

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

In VS Code 1.143, selected text in the Kilo chat transcript cannot be copied with Cmd/Ctrl+C or with right-click > Copy. The selection clears, focus moves to the prompt, and the clipboard keeps its old content. The per-message Copy button still works. This affects the sidebar, Agent Manager and editor chat tabs on macOS, Windows and Linux.

Fixes #15379
Fixes #15382
Fixes #15394
Fixes #15446
Fixes #15449
Fixes #15455

Related: #15457 (same Cmd+C failure; the Cmd+A part of that issue was not verified).

Why This Change Was Made

The cause is in VS Code, not in a Kilo release. microsoft/vscode#341552 (commit f5f64f0, shipped in 1.143.0) changed the webview host. It now records the last focused element in the webview. Before a native clipboard command (execCommand), it focuses that element again if focus is on the document body.

Transcript text is not focusable, so after a mouse selection the focus is on the body. The last focused element is almost always the prompt textarea. VS Code focuses the textarea, the selection collapses, and Copy copies nothing. Upstream issue: microsoft/vscode#344028 (open, no milestone; VS Code main still has the change).

The fix gives the transcript container tabIndex={-1}. A mouse press inside the transcript now moves focus to the transcript (native browser behavior), so VS Code records a non-editable element and does not move focus to the prompt. tabIndex={-1} keeps the transcript out of the Tab order. Mouse focus does not show a focus ring.

The change is in MessageList, so it covers the sidebar, Agent Manager and editor chat tabs. It does not depend on the VS Code version.

User Impact

  • Cmd/Ctrl+C and right-click > Copy work again for selected transcript text in VS Code 1.143.
  • After a click in the transcript, the webview no longer moves focus back to the prompt by itself when the VS Code window becomes active again. The extension restoreInput path is not changed.

Evidence

Real Kilo UI with the vscode-self-test harness. Each run: click the prompt, drag-select transcript text, press Cmd+C, read the clipboard with pbpaste. Before and after use the same origin/main build with only this change removed or added.

VS Code Surface Without fix With fix
1.143.1 Sidebar, code block Selection cleared, focus on prompt, clipboard unchanged Selection kept, clipboard = selected code
1.143.1 Sidebar, paragraph Selection cleared, clipboard unchanged Clipboard = selected text
1.143.1 Agent Manager Selection cleared, clipboard unchanged Selection kept, clipboard = selected text
1.141.0 Sidebar, code block Copy works (VS Code change not present) Copy works

A focus trace on 1.143.1 without the fix shows VS Code's own webview host (index.html, execCommand handler) calls textarea.focus() between the Cmd+C keydown and the copy event. Kilo's own focus restore code does not run during the copy.

Other checks:

  • New Playwright test tests/transcript-copy.spec.ts: fails without the fix, passes with it.
  • bun run compile (typecheck and lint): pass.
  • bun run test:unit: 6965 pass, 2 skip, 0 fail.
  • No focus ring after a mouse click in the transcript (checked by screenshot and computed style).

Not tested: right-click > Copy (the macOS context menu is native and the harness cannot click it; it uses the same webview.copy() > execCommand path as Cmd+C), Windows and Linux.

@github-actions github-actions Bot added the area:vscode VS Code extension label Oct 26, 2026
@marius-kilocode
marius-kilocode merged commit 7e1679b into main Oct 26, 2026
26 checks passed
@marius-kilocode
marius-kilocode deleted the fix-webview-copy branch October 26, 2026 08:39
@kilo-code-bot

kilo-code-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

SUGGESTION

File Line Issue
packages/kilo-vscode/webview-ui/src/components/chat/MessageList.tsx 884 User-visible bug fix without a changeset entry

The tabIndex={-1} fix is sound: it makes the transcript a mouse-focusable, non-editable target so VS Code 1.143 refocuses it instead of the prompt before a native Copy, and -1 keeps it out of the Tab order. The new Playwright test exercises the real mechanism (focus lands on .message-list after a drag selection) and uses an existing story, so no new story or baseline is needed.

The only gap is release hygiene: this PR fixes six user-facing issues in the VS Code extension but ships without a .changeset/*.md entry, unlike comparable vscode fixes in this repo (e.g. .changeset/browser-open-always-allow.md). A short user-facing changeset would give the fix release notes and a kilo-code version bump.

Files Reviewed (2 files)
  • packages/kilo-vscode/tests/transcript-copy.spec.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/chat/MessageList.tsx - 1 issue

Reviewed by deepseek-flash-latest · Input: 151.3K · Output: 23.2K · Cached: 1.6M

Review guidance: REVIEW.md from base branch main

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