feat: allow exiting shell by pressing Ctrl-C 3 times#1753
feat: allow exiting shell by pressing Ctrl-C 3 times#1753Yuandiaodiaodiao wants to merge 2 commits intoMoonshotAI:mainfrom
Conversation
Currently pressing Ctrl-C only shows "press Ctrl-D or send 'exit' to quit" repeatedly. This adds a counter so that pressing Ctrl-C 3 times within 2 seconds exits the shell, matching common CLI user expectations. The tip message now shows how many more presses are needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 508f515612
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if now - self._last_interrupt_time < 2.0: | ||
| self._consecutive_interrupts += 1 | ||
| else: | ||
| self._consecutive_interrupts = 1 | ||
| self._last_interrupt_time = now |
There was a problem hiding this comment.
Reset interrupt counter on non-interrupt activity
This logic only checks elapsed time between interrupts and never clears the counter when normal prompt activity occurs, so Ctrl-C can accumulate across unrelated actions. In practice, a user can press Ctrl-C once, quickly submit a command, then press Ctrl-C twice and still exit, even though the interrupt attempts were not consecutive. That makes accidental termination more likely than the tip message implies.
Useful? React with 👍 / 👎.
The consecutive interrupt counter was only managed inside the interrupt branch. If a user pressed Ctrl-C once, then typed a normal command, the counter would not reset — meaning a later Ctrl-C press could unexpectedly count toward exiting. Now the counter resets whenever the user sends any actual input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Summary
Test plan
exitcommand still work as before🤖 Generated with Claude Code