Repository navigation
Conversation
onKey() ended with an unconditional refresh(). When the key was a quit (Ctrl-D at an empty prompt, or the second Ctrl-C), onControl() had already run quit() -> finish() -> Screen.finish(), which clears the live composer and footer and restores the cursor. The refresh then painted the input box and the shortcut hint again, leaving them on screen after the process exited with code 0. Skip the refresh once the session is quitting, as the other refresh call sites in chat.ts already do. Add tests for Ctrl-D and for the second Ctrl-C that check nothing drawing the prompt is written after the quit begins. Ctrl-D in a non-empty draft (delete forward) and Ctrl-C while a task runs are unchanged. Fixes TaewoooPark#32 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Fixes #32
Ctrl-D at an empty prompt (and the second Ctrl-C of a double Ctrl-C) exits with code 0, but the live input box and the shortcut hint were painted again after the terminal had been cleaned up, so they stayed on screen as if the prompt were still interactive.
Chat.onKey()ends with an unconditionalthis.refresh(). For a quit keypress,onControl()has already runquit()->finish()->Screen.finish(), which clears the composer and footer and restores the cursor. The refresh then callssetHint/setComposerand paints the box again. This follows the starting point in the issue.The change is one line:
if (!this.quitting) this.refresh();, the same guard the other refresh call sites inchat.tsalready use. Ctrl-D in a non-empty draft (delete forward) and Ctrl-C while a task runs do not quit, so they still refresh as before.Tests
Two tests in
packages/cli/test/chat.test.ts, using the existing in-processsession()harness: Ctrl-D at an empty prompt, and a second Ctrl-C after the first one armed the quit. Each checks the prompt is on screen before the key, that the session exits 0, and that nothing written after the quit began draws the prompt text, the box or theauto-approvehint. Both fail without the change and pass with it.npx vitest runon every test file that importschat.ts(chat.test.ts,dashboard.test.ts,mcp-ui.test.ts,mcp/audit-regressions.test.ts): 7 tests fail identically on an unmodifiedmainand with this change on my Windows machine (the Ctrl-O output test, the signing-in file mode test, and several signal and path tests); 2 more tests pass with the change.pnpm typecheckpasses.Generated with Claude Code