Skip to content

fix: first Ctrl+C at idle prompt exits instead of zombifying the session#17

Merged
shoom1 merged 1 commit into
developfrom
fix/ctrl-c-idle-zombie
Jun 12, 2026
Merged

fix: first Ctrl+C at idle prompt exits instead of zombifying the session#17
shoom1 merged 1 commit into
developfrom
fix/ctrl-c-idle-zombie

Conversation

@shoom1

@shoom1 shoom1 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Problem

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.

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 observe KeyboardInterrupt.

Tests

  • test_ctrl_c_idle_exits_app now 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).
  • New end-to-end regression test drives 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).

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.
@shoom1 shoom1 merged commit 139e15f into develop Jun 12, 2026
4 checks passed
@shoom1 shoom1 deleted the fix/ctrl-c-idle-zombie branch June 12, 2026 20:08
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant