fix(coding-agent): prevent input corruption in external editors - #878
Open
andrewneilson wants to merge 1 commit into
Open
fix(coding-agent): prevent input corruption in external editors#878andrewneilson wants to merge 1 commit into
andrewneilson wants to merge 1 commit into
Conversation
Pop screen-local keyboard protocols before leaving the alternate screen, drain pending input before editor handoff, and share the lifecycle across both external-editor entry points. Add regressions for protocol negotiation ordering, delayed responses, fallback cancellation, and editor cleanup. fixes PrimeIntellect-ai#811
zhengr
pushed a commit
to zhengr/prime-agent
that referenced
this pull request
Aug 8, 2026
…tellect-ai#878) * feat(tui): add Alt+Delete as hotkey for delete word forwards * docs(coding-agent): update keybindings table with Alt+Delete
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.
Problem
(premise of #811) Opening an external editor (vim) from the fullscreen TUI could leak terminal keyboard events into the child process. In Ghostty with Vim, this appeared as corrupted input such as
wbecomingww,:becoming:;, and:qbecoming:;qq.Root cause
Kitty keyboard protocol state is scoped to the active terminal screen. The TUI could leave the alternate screen before popping its keyboard protocol state, causing cleanup to target the primary screen instead. Delayed negotiation responses or the
modifyOtherKeysfallback could also reactivate a protocol while input was being drained.Fix
write, drain, stop, spawn, clean up, restart, and render.
Scope
This does not change the external-editor keybinding, editor command selection, or daemon protocol.
Validation
npm run checkpackages/coding-agent/test/external-editor.test.ts: 3 tests passedpackages/tui/test/terminal.test.ts: 10 tests passedpackages/tui/test/fullscreen.test.ts: 37 tests passedalternate screen.
:q, a singlew, clean:q!, and TUIrestoration.
Fixes #811
Note
Fix duplicate/corrupted key presses when opening external editors from the composer
runExternalEditor, a centralized utility that drains pending terminal input, stops the TUI, synchronously spawns the configured editor, then restarts the TUI — preventing buffered keystrokes from corrupting input after the editor exits.ExtensionEditorComponentandInteractiveMode.openExternalEditorto use this shared utility; editor content is only applied on a zero exit status, and errors are surfaced via the TUI rather than propagating synchronously.terminal.tsby introducingpushKittyProtocol/popKittyProtocolhelpers that rebind the protocol to the active screen when toggling fullscreen.drainInputnow disables keyboard protocols before draining and re-enables them after, preventing new escape sequences from being generated mid-drain.Macroscope summarized b780cfc.