fix: first Ctrl+C at idle prompt exits instead of zombifying the session#17
Merged
Conversation
At an idle prompt, prompt_async() always has a live _pending_input future, so the Ctrl+C binding took the cancel-pending branch: it cancelled the future (which broke the input loop via KeyboardInterrupt) but never called app.exit(). The app kept running with a dead input loop — typed input was echoed and silently dropped, and only a second Ctrl+C exited. Pending input no longer counts as in-flight work when deciding whether to exit: Ctrl+C with no running handler and no active boxes now exits on the first press, matching the documented behavior. The future is still cancelled first so direct prompt_async() callers continue to observe KeyboardInterrupt. The idle-exit unit test previously set _pending_input = None — a state that never occurs at a real idle prompt — which is how this slipped past. It now models the live future, and a new end-to-end regression test drives run_async() with a stubbed Application to assert the session actually terminates on the first Ctrl+C.
This was referenced Jun 13, 2026
Merged
shoom1
added a commit
that referenced
this pull request
Jun 13, 2026
Patch release rolling up #17-#22. Highlights (see CHANGELOG for full list): - Fix: first Ctrl+C at an idle prompt exits instead of zombifying the session - Fix: DialogManager.show() guards against concurrent dialogs - Fix: settings dialog (can_cancel=False) no longer leaks "close" on Escape - Fix: expand_key reflected in the truncation hint; renderer-safe clear(); ANSI-aware line counting; terminal-width header; per-box finish truncation - Refactor: rich_utils module; no global Rich Markdown monkey-patch
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
At an idle prompt,
prompt_async()always has a live_pending_inputfuture, so the Ctrl+C binding took the cancel-pending branch: it cancelled the future (which broke the input loop viaKeyboardInterrupt) but never calledapp.exit(). The app kept running with a dead input loop — typed input was echoed and silently dropped — and only a second Ctrl+C exited.Fix
Pending input no longer counts as in-flight work when deciding whether to exit: Ctrl+C with no running handler and no active boxes exits on the first press. The future is still cancelled first, so direct
prompt_async()callers continue to observeKeyboardInterrupt.Tests
test_ctrl_c_idle_exits_appnow models the live pending future that exists at a real idle prompt (the old version set_pending_input = None, a state that never occurs in a real run — which is how this slipped past).run_async()with a stubbed Application and asserts the session terminates on the first Ctrl+C.Identified in docs/notes/project_review_20260612.md (finding 1).