opencode
opencode copied to clipboard
feat: require double Ctrl+C to exit when input is empty
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(orCtrl+-) to restore input that was cleared by Ctrl+C - Matches Claude Code behavior for a more forgiving exit experience
Changes
- Add
exitOnCtrlC: falseto 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_undokeybind 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
+1,this feature is greatly needed.