[PR #6494] feat: require double Ctrl+C to exit when input is empty #11931

Open
opened 2026-02-16 18:16:52 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6494

State: open
Merged: No


Summary

  • Prevents accidental exits by requiring users to press Ctrl+C twice within 3 seconds when the prompt input is empty
  • Shows a toast warning on the first Ctrl+C press: "Press Ctrl+C again to exit"
  • Adds Undo Support: Press Cmd+Z (or Ctrl+-) to restore input that was cleared by Ctrl+C
  • Matches Claude Code behavior for a more forgiving exit experience

Changes

  • Add exitOnCtrlC: false to render options to prevent opentui from handling Ctrl+C directly
  • Track Ctrl+C press state in Prompt component with 3-second reset timeout
  • Show warning toast on first Ctrl+C with empty input
  • Exit on second Ctrl+C within timeout window
  • Save cleared state when input_clear (Ctrl+C on text) is triggered
  • Restore state on input_undo keybind if a cleared state exists
  • Add empty SIGINT handler to prevent default process termination

Files Modified

  • packages/opencode/src/cli/cmd/tui/app.tsx - Disable default Ctrl+C handling
  • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx - Double Ctrl+C and Undo logic
  • packages/opencode/src/index.ts - Empty SIGINT handler
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6494 **State:** open **Merged:** No --- ## Summary - Prevents accidental exits by requiring users to press Ctrl+C twice within 3 seconds when the prompt input is empty - Shows a toast warning on the first Ctrl+C press: "Press Ctrl+C again to exit" - **Adds Undo Support**: Press `Cmd+Z` (or `Ctrl+-`) to restore input that was cleared by Ctrl+C - Matches Claude Code behavior for a more forgiving exit experience ## Changes - Add `exitOnCtrlC: false` to render options to prevent opentui from handling Ctrl+C directly - Track Ctrl+C press state in Prompt component with 3-second reset timeout - Show warning toast on first Ctrl+C with empty input - Exit on second Ctrl+C within timeout window - **Save cleared state** when `input_clear` (Ctrl+C on text) is triggered - **Restore state** on `input_undo` keybind if a cleared state exists - Add empty SIGINT handler to prevent default process termination ## Files Modified - `packages/opencode/src/cli/cmd/tui/app.tsx` - Disable default Ctrl+C handling - `packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx` - Double Ctrl+C and Undo logic - `packages/opencode/src/index.ts` - Empty SIGINT handler
yindo added the pull-request label 2026-02-16 18:16:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11931