Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/kimi_cli/ui/shell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ def __init__(
self._current_prompt_approval_request: ApprovalRequest | None = None
self._approval_modal: ApprovalPromptDelegate | None = None
self._exit_after_run = False
self._consecutive_interrupts = 0
self._last_interrupt_time = 0.0
self._available_slash_commands: dict[str, SlashCommand[Any]] = {
**{cmd.name: cmd for cmd in soul.available_slash_commands},
**{cmd.name: cmd for cmd in shell_slash_registry.list_commands()},
Expand Down Expand Up @@ -489,7 +491,21 @@ def _can_auto_trigger_pending() -> bool:
continue

if event.kind == "interrupt":
console.print("[grey50]Tip: press Ctrl-D or send 'exit' to quit[/grey50]")
now = time.monotonic()
if now - self._last_interrupt_time < 2.0:
self._consecutive_interrupts += 1
else:
self._consecutive_interrupts = 1
self._last_interrupt_time = now
Comment on lines +495 to +499
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 👍 / 👎.


remaining = 3 - self._consecutive_interrupts
if remaining <= 0:
console.print("Bye!")
break
console.print(
f"[grey50]Tip: press Ctrl-C {remaining} more time{'s' if remaining > 1 else ''} to quit,"
" or press Ctrl-D, or send 'exit'[/grey50]"
)
resume_prompt.set()
continue

Expand All @@ -503,6 +519,7 @@ def _can_auto_trigger_pending() -> bool:

user_input = event.user_input
assert user_input is not None
self._consecutive_interrupts = 0
bg_auto_failures = 0
deferred_bg_trigger = False
if not user_input:
Expand Down