Repository navigation
fix(tui): allow interrupting running session regardless of prompt focus - #48607
Open
OmarAlaaeldein wants to merge 1 commit into
Open
OmarAlaaeldein wants to merge 1 commit into
OmarAlaaeldein wants to merge 1 commit into
Conversation
When a session is busy/streaming/running, user focus is often not on the prompt text input (e.g. scrolling the transcript or reviewing tool output). Guarding session.interrupt with `!input.focused` caused Escape presses to be silently dropped, preventing users from aborting hung or long-running sessions. Remove the input.focused check so Escape can interrupt whenever the session status is non-idle. Closes anomalyco#42960
|
@adamdotdevin can we get this merged? |
rhighs
reviewed
Sep 27, 2026
Comment on lines
+3
to
+12
| // Regression test for session.interrupt in packages/tui/src/component/prompt/index.tsx | ||
| // | ||
| // Previously, session.interrupt guarded execution with `if (!input.focused) return`. | ||
| // When a session was running/busy, the text prompt input was frequently unfocused | ||
| // (e.g. while scrolling the scrollback transcript or inspecting tool output). | ||
| // As a result, pressing Escape to interrupt had no effect. | ||
| // | ||
| // With the `!input.focused` check removed from session.interrupt, pressing Escape | ||
| // while status is non-idle increments the interrupt counter and aborts the session | ||
| // on double-escape regardless of whether the prompt input has focus. |
This branch has not been deployed
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 for this PR
Closes #42960
Type of change
What does this PR do?
When using the terminal TUI, pressing
Escapeto interrupt a running session frequently failed to work.In
packages/tui/src/component/prompt/index.tsx, thesession.interruptcommand handler guarded execution with:However, while a session is running/busy (executing tool commands, streaming responses, or running background tasks), the user focus is typically not on the prompt text box (e.g. while reviewing the transcript or tool output). Because of this guard:
Escapepress was ignored and never incrementedstore.interrupt.again to interrupt.Escapepress was also dropped, making it impossible to abort running sessions.Since
session.interruptis already explicitly conditioned onenabled: status().type !== "idle", requiringinput.focusedis unnecessary and prevents intended aborts. This PR removes the!input.focusedguard fromsession.interrupt.How did you verify your code works?
packages/tui/test/cli/tui/session-interrupt.test.tsverifying that doubleEscapesuccessfully triggers session abort when the prompt input is unfocused, while respecting autocomplete popups and shell mode.bun test test/cli/tui/session-interrupt.test.ts(3/3 pass).bun run --cwd packages/tui typecheck(tsgo --noEmitpasses with 0 errors).bun turbo typecheck --concurrency=2(30/30 pass).Screenshots / recordings
N/A (TUI keybinding handling)
Checklist