Skip to content

feat: allow exiting shell by pressing Ctrl-C 3 times#1753

Open
Yuandiaodiaodiao wants to merge 2 commits intoMoonshotAI:mainfrom
Yuandiaodiaodiao:feat/ctrl-c-exit
Open

feat: allow exiting shell by pressing Ctrl-C 3 times#1753
Yuandiaodiaodiao wants to merge 2 commits intoMoonshotAI:mainfrom
Yuandiaodiaodiao:feat/ctrl-c-exit

Conversation

@Yuandiaodiaodiao
Copy link
Copy Markdown

@Yuandiaodiaodiao Yuandiaodiaodiao commented Apr 3, 2026

Summary

  • Currently pressing Ctrl-C in idle shell only shows "press Ctrl-D or send 'exit' to quit" repeatedly, which can be frustrating
  • This adds a counter so pressing Ctrl-C 3 times within 2 seconds exits the shell, matching common CLI user expectations
  • The tip message now dynamically shows how many more presses are needed (e.g. "press Ctrl-C 2 more times to quit")

Test plan

  • Press Ctrl-C once → shows "press Ctrl-C 2 more times to quit, or press Ctrl-D, or send 'exit'"
  • Press Ctrl-C twice quickly → shows "press Ctrl-C 1 more time to quit..."
  • Press Ctrl-C three times quickly (within 2s) → prints "Bye!" and exits
  • Press Ctrl-C once, wait >2s, press again → counter resets, shows "2 more times"
  • Ctrl-D and exit command still work as before

🤖 Generated with Claude Code


Open with Devin

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>
devin-ai-integration[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +495 to +499
if now - self._last_interrupt_time < 2.0:
self._consecutive_interrupts += 1
else:
self._consecutive_interrupts = 1
self._last_interrupt_time = now
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
@Yuandiaodiaodiao
Copy link
Copy Markdown
Author

Clipboard_Screenshot_1775232905

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