fix(tui): release keybind suspension when autocomplete unmounts - #2141
Open
anandlo wants to merge 1 commit into
Open
fix(tui): release keybind suspension when autocomplete unmounts#2141anandlo wants to merge 1 commit into
anandlo wants to merge 1 commit into
Conversation
command.keybinds() gates all leader (ctrl+x) chords on suspendCount. Autocomplete show()/hide() increment/decrement it but had no idempotency guard, and the component had no unmount cleanup: if the prompt unmounts while the autocomplete is visible (session switch, permission prompt, agent switch), hide() never runs and suspendCount stays above 0, leaving every command keybind dead until restart. Add idempotency guards to show()/hide() and an onCleanup that releases the suspension on unmount.
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.
Issue / context (if applicable)
Fixes #1897 — "Ctrl+X keybindings stop working until user types and clears text". This issue was closed on 2026-07-26 but the fix never actually landed: PR #1913 (merged that day) only touches
packages/opencode/src/provider/transform.ts(DeepSeek provider scoping) and does not touch the keybind suspension code. The contributor branchfix/ctrl-x-keybinds-suspend-racewith the real fix (2f0f8940,d7e0d451) was never merged to mainline — verified withgit merge-base --is-ancestor.Type of change
Bug fix
What does this PR do?
command.keybinds()indialog-command.tsxgates ALL command keybinds — including<leader>(ctrl+x) chords likectrl+x l(session list) andctrl+x m(model list) — onsuspendCount > 0.Two independent sources increment that counter:
Autocomplete show()/hide() (this PR).
autocomplete.tsxshow()unconditionally callscommand.keybinds(false)andhide()unconditionally callskeybinds(true)— no idempotency guard — and the Autocomplete component has no unmount cleanup. When the prompt unmounts while an@-mention autocomplete is visible (session switch, permission/question prompt arriving, agent switch, plugin prompt-slot replacement atsession/index.tsx:1456-1471),hide()never runs andsuspendCountstays > 0 permanently — keybinds stay dead until the app is restarted. Typing does not recover this one.Ghost-text prediction (reported symptom). After each idle turn,
fetchGhost()(prompt/index.tsx:428-444) shows a next-prompt prediction as inline ghost text; while visible, the effect atprompt/index.tsx:470-474callscommand.keybinds(false), gating every chord until the ghost is dismissed. Typing any character clears the ghost and re-arms keybinds — the reported "type random text + backspace" workaround. The interaction-design fix (dismiss the ghost when the leader is pressed) is deliberately out of scope for this PR per CONTRIBUTING.md (interaction-design changes need an issue first).This PR fixes #1: idempotent
show()/hide()plus anonCleanupthat releases the suspension when the component unmounts.How did you verify your code works?
bun typecheckfrompackages/opencode— PASSbun lint(oxlint) — PASS (0 errors)bunx prettier --checkon the changed file — PASSbun test test/cli/cmd/tui/autocomplete-detect.test.ts test/config/tui.test.ts— 52 pass / 4 skip / 0 failScreenshots / recordings
If this is a UI change, please include a screenshot or recording. N/A — TUI behavior fix.
Checklist