opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: require double Ctrl+C to exit when input is empty

Open noah79 opened this issue 3 weeks ago • 1 comments

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

noah79 avatar Dec 31 '25 01:12 noah79

image

noah79 avatar Dec 31 '25 01:12 noah79

+1,this feature is greatly needed.

coulsontl avatar Jan 06 '26 03:01 coulsontl