opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(tui): implement double Ctrl+C to quit

Open shoaibansari5398 opened this issue 16 hours ago • 1 comments

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 quitArmed state to the Prompt component.
  • Updated app_exit keybinding 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).

shoaibansari5398 avatar Jan 17 '26 08:01 shoaibansari5398