Repository navigation
fix(vscode): restore undo and redo in the chat input - #14200
Merged
Merged
Conversation
VS Code's webview preload intercepts Ctrl/Cmd+Z and Ctrl+Y and forwards them to the workbench, so the prompt input stopped propagation but never performed the edit. A webview keypress has no native undo default action on macOS, so the undo stack stayed untouched and the shortcuts did nothing. Perform the edit with document.execCommand on the same native undo stack real typing builds, and match keyCode like VS Code does so non-Latin keyboard layouts no longer leak the key back to the workbench. The Agent Manager New Worktree prompt had the same gap with no guard at all; it now shares the same helper through prompt-input-utils.
marius-kilocode
enabled auto-merge
September 16, 2026 07:30
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (6 files)
Previous Review Summary (commit 78a4d93)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 78a4d93)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (4 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
The specs asserted that the webview never cancels the host default for Ctrl/Cmd+Z, Ctrl+Shift+Z, and Ctrl+Y, which is the behavior that left undo broken inside VS Code. The prompt now cancels the default and performs the edit itself, so the expectations move to prevented: true. Add coverage for the keyCode match, which keeps non-Latin layouts in lockstep with VS Code's own detection.
Exercises the Ctrl/Cmd+z undo mapping, the Shift+z and y redo mappings, the keyCode fallback that keeps non-Latin layouts in lockstep with VS Code, and the chords that must keep forwarding.
# Conflicts: # packages/kilo-vscode/tests/unit/prompt-input-utils.test.ts
eshurakov
approved these changes
Sep 16, 2026
This was referenced Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Undo and redo did nothing in the Kilo chat input. After typing, Cmd+Z and Cmd+Shift+Z (Ctrl+Z and Ctrl+Y on Windows and Linux) left the text unchanged, while Edit > Undo from the macOS menu bar worked. The same gap existed in the Agent Manager New Worktree prompt.
This is the unfixed half of #13724. The earlier guard stopped the shortcut from leaking into an active markdown editor, but nothing performed the undo in the webview, so the reported "does not undo/redo the typed text" symptom remained.
Fixes #14191
Why This Change Was Made
VS Code's webview preload intercepts Ctrl/Cmd+Z and Ctrl+Y and forwards them to the workbench, so a webview cannot rely on the key event reaching an editor. The existing guard called
stopPropagation()to block that forwarding, which stops the leak but also removes the only path that would have performed the edit.A keypress inside a VS Code webview has no native undo default action on macOS. With the forwarding blocked, the event arrived clean and died, which is why the code read as correct while the feature stayed broken.
The fix performs the edit explicitly with
document.execCommand("undo" | "redo"), which operates on the same native undo stack real typing builds. It also matcheskeyCode90 and 89 in addition toe.key, mirroring how VS Code's preload detects the shortcut. On a non-Latin layout (for example Hebrew) Cmd+Z reportse.key === "ז"withkeyCode === 90, so the olde.key-only check missed it and the leak returned.The New Worktree prompt had its own textarea with no undo guard at all, so its handling is now shared through
prompt-input-utils.ts. The existing "undo the last Enhance" behavior keeps priority and is unchanged.User Impact
Undo and redo now work in the sidebar chat input, the Agent Manager chat composer, and the New Worktree prompt. This includes Ctrl+Y and Cmd+Shift+Z for redo, and non-Latin keyboard layouts.
Evidence
Verified in an isolated VS Code dev host with real trusted key events, before and after the change:
hello worldthen Ctrl+Z"", Send disabledhello world, Send enabledhistoryUndohistoryRedo""then restored""then restoredwindowlistenerPlaywright maps
Meta+KeyZto Chromium's nativeundo:editing command, which a real VS Code keypress never carries, soMetapresses are not a faithful before-state in the harness.Control+zandControl+yhave no such mapping and arrive as plain trusted key events, so those were used for the before and after comparison. The handler treatsctrlKeyandmetaKeyidentically.bun run compile(types, webview types, lint, bundle),bun run knip, and the changeset are included.