Skip to content

[FEATURE]: Require double Ctrl+C to exit the CLI (first press interrupts, second exits) #26371

Closed as not planned

Description

@dhruv-anand-aintech

Describe the enhancement you want to request

Currently, pressing Ctrl+C immediately exits the entire OpenCode CLI. This is surprising and disruptive — it's easy to accidentally exit during a long session.

Claude Code and Codex both use a two-press pattern:

  1. First Ctrl+C — interrupts the current agent action / cancels the in-progress operation
  2. Second Ctrl+C — exits the CLI entirely

OpenCode should adopt the same behavior. This gives users a safe escape hatch for cancelling operations without losing their session context.

The first Ctrl+C could show a message like "Press Ctrl+C again to exit" so the user knows what's happening.

Suggested implementation path

  • In the TUI key handler, intercept the first Ctrl+C as a session interrupt (same as Esc or /exit light)
  • On a second Ctrl+C within a short window (e.g., the same keybind cycle or within a few seconds), trigger the full exit
  • Optionally display a brief toast/hint after the first press

Additional context

Related issue (clarifying docs): #23478

Activity

  1. github-actions commented on May 8, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  2. kommander commented on May 11, 2026

    @kommander
    Contributor

    You can change the default keybindings to something else. ctrl+c only exits when the prompt is empty. I have remapped mine for this reason, but changing the default binding or behaviour would just make everybody else complain.

  3. verils commented on May 21, 2026

    @verils

    ctrl+c only exits when the prompt is empty.

    That was not enough.

    Every time I hit Ctrl + C while opencode was working with an empty prompt, the damn program quit. It's weird and dangerous.

    Why do you deliberately go against what most agents do?

  4. CharlesMcquade commented on May 24, 2026

    @CharlesMcquade

    This double-Ctrl-C request has been brought up a ridiculous amount of times. Why can it not at least be a config option?

  5. added a commit that references this issue on Jul 13, 2026
    20a7270
  6. github-actions commented on Jul 24, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions