opencode
opencode copied to clipboard
feat(tui): implement double Ctrl+C to quit
What does this PR do?
Fixes #9041 Implements a "double Ctrl+C to quit" mechanism to prevent accidental session termination.
How did you verify your code works?
Changes
- Modified packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx.
- Added
quitArmedstate to the Prompt component. - Updated
app_exitkeybinding handler:- First Press (on empty prompt): Shows a toast "Press Ctrl+C again to exit" and sets a 3-second timeout.
- Second Press (within 3s): Exits the application.
Testing
- Verified manually:
- Pressing Ctrl+C once on empty prompt shows the toast.
- Pressing again within 3s exits.
- Pressing again after 3s shows the toast again (timeout reset).
- Ctrl+C with text still clears the input (existing behavior).