Skip to content

[Windows] Pressing Ctrl+C to exit opencode unexpectedly closes the current window / quits Warp application #10051

Closed

Description

@peicodes

I found a report of a very similar issue here but that was apparently fixed already: anomalyco/opencode#6189


Linear: CODE-1763

Activity

  1. warp-for-oss commented on May 4, 2026

    @warp-for-oss
    Contributor

    @peicodes

    Here's what I found while triaging this issue:

    This may overlap with #8670, but I only found one strong in-repo match, so I am not marking it as a duplicate. OpenCode's upstream Ctrl+C handling was changed after anomalyco/opencode#6189, so the current OpenCode version will help determine whether this is still a Warp-specific regression.

    I have a few follow-up questions before I can narrow this down:

    1. Which Warp version/channel and OpenCode version reproduce the window close on Windows?
    2. Which shell is running inside Warp when this happens, for example PowerShell, cmd, Git Bash/MSYS2, or WSL?

    Reply in-thread with those details and the triage workflow will automatically re-evaluate the issue and update the diagnosis, labels, and next steps.

    Maintainer details

    I concluded that windows OpenCode Ctrl+C appears to be a Warp terminal-input/PTY lifecycle bug where Ctrl+C intended for the running TUI can lead to the terminal session/window closing instead of only interrupting OpenCode..

    Initial triage

    This appears to be a Windows-specific bug involving Ctrl+C handling while opencode is running. The expected behavior is that Ctrl+C is delivered to the running OpenCode process/TUI; the reported behavior is that the active Warp window closes, and if it is the only window the app quits.

    A very similar existing Warp issue is #8670, which includes reproduction steps and a video for Windows 11 / Warp v0.2026.02.11.08.23.stable_01. However, only one strong in-repo duplicate candidate was found, so this triage is not marking the issue as a duplicate under the workflow's duplicate threshold.

    The referenced upstream OpenCode issue anomalyco/opencode#6189 was closed after OpenCode added Ctrl+C handling in 1.1.60, with later comments suggesting additional fixes by 1.3.3. That makes the exact current OpenCode version important before assigning full ownership to Warp.

    Maintainer notes:

    • app/src/terminal/view/init.rs registers terminal:cancel_command on ctrl-c for terminal focus.
    • app/src/terminal/view.rs routes Ctrl+C through TerminalAction::CtrlC; on Windows it copies only when a block/alt-screen selection exists, otherwise ctrl_c_to_active_block writes ETX (0x03) to the active long-running PTY.
    • app/src/terminal/writeable_pty/pty_controller.rs forwards those bytes to the PTY event loop.
    • app/src/terminal/local_tty/windows/mod.rs / app/src/terminal/local_tty/event_loop.rs cover ConPTY lifecycle. If the shell/PTY exits, TerminalModel::exit emits an exit event; app/src/terminal/view.rs emits Event::Exited, and app/src/pane_group/pane/terminal_pane.rs closes the pane, which can cascade through tab/window close behavior when this is the last pane/tab.
    • Code inspection did not find evidence that Windows Ctrl+C is directly bound to CloseWindow; CloseWindow's default shortcut is mac-only (cmd-shift-W).

    Suggested next step is to reproduce on Windows with a current Warp build and current OpenCode, capturing whether the shell process exits or only the opencode child exits after Ctrl+C.

    Question reasoning

    1. Which Warp version/channel and OpenCode version reproduce the window close on Windows? — The current report does not include versions, and the referenced upstream OpenCode issue was reportedly fixed in newer OpenCode versions, so version data determines whether this is a stale upstream behavior or a current Warp regression.
    2. Which shell is running inside Warp when this happens, for example PowerShell, cmd, Git Bash/MSYS2, or WSL? — Windows Ctrl+C and process-exit behavior can differ by shell/ConPTY host path, and the report does not specify which shell owns the OpenCode process when the Warp window closes.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  2. added
    area:shell-terminalTerminal input/output, shell integration, prompt behavior, and block rendering.
    area:terminal-inputTerminal command-line input, cursor movement, key handling, and input editing.
    area:window-tabs-panesWindow, tab, pane, and workspace layout management.
    bugSomething isn't working.
    needs-infoMore issue-specific reporter detail is needed before the problem can be confidently triaged.
    os:windowsWindows-specific behavior, regressions, or requests.
    repro:unknownThe report does not provide enough evidence to estimate reproducibility yet.
    triagedIssue has received an initial automated triage pass.
    on May 4, 2026
  3. Zyl0812 commented on May 9, 2026

    @Zyl0812

    Adding host-side root-cause data — hopefully enough to flip repro:unknown → confirmed and unblock the fix.

    Reproduces 100% on

    • Warp on Windows 11 (build 26200)
    • PowerShell 7 (also reproduces in cmd /k opencode and powershell -NoExit -Command "opencode")
    • opencode 1.0.x in default (server + TUI) mode
    • Exiting via /exit or Ctrl+C × 2 — both trigger it

    Captured close chain

    I instrumented the Windows PTY path with log::info! calls around: the ChildExitWatcher callback, the PTY event loop's Message::ChildExited branch, TerminalModel::exit, Pty::drop, TerminalView's ModelEvent::Exit handling, and TerminalPane's Event::Exited handler. After exiting OpenCode the log shows, in order:

    ChildExitWatcher: shell process handle signaled, sending Message::ChildExited
    [1778298010.572] PTY event loop: child_exited=true, calling exit(ShellProcessExited)
    [1778298010.572] TerminalModel::exit(reason=ShellProcessExited), handled_exit=false, alt_screen_active=false
    Windows Pty::drop: closing ConPTY handle
    [1778298010.575] TerminalView: ModelEvent::Exit reason=ShellProcessExited, manual_shutdown=false, pty_spawn_failed=false, is_bootstrapped=true
    [1778298010.575] TerminalView: emitting Event::Exited to pane_group
    [1778298010.575] TerminalPane: Event::Exited, pane_id=PaneId(IPaneId { pane_type: Terminal, pane_view_id: EntityId(1810) }), is_bootstrapped=true
    [1778298010.575] TerminalPane: calling close_pane for pane_id=...

    The first line is the load-bearing one. ChildExitWatcher is registered via RegisterWaitForSingleObject against process_information.hProcess in app/src/terminal/local_tty/windowshosted shell's** handle, notOpenCode's. So the parent PowerShelg* the moment OpenCode tears down.Everything after that (ShellProcessExited→Event::Exited→close_pane`) is Warp correctly reacting to its child shell dying. The pane-close is a symptom, not the bug.

    Why this isn't "PowerShell choo

    Setup Hosted shell dies?
    Native conhost.exe + opencode No
    Warp ConPTY + opencode (default server+TUI) Yes
    Warp ConPTY + `powershell -NoExit**
    Warp ConPTY + cmd /k opencode Yes
    Warp ConPTY + opencode serve … then opencode attach … No

    -NoExit / cmd /k ruling out a bpencode attach(no server child) not reproducing, both point at Openraising a Windows console controlevent that propagates to the entire console process group. Underconhost.exe` the parent shell happens to survive; under a ConPTY it doesn't, because the hosted shell isn't isolated into its own process group.

    Looking at app/src/terminal/local_tty/windows/mod.rs::spawn, the shell is currently created with:

    PROCESS_CREATION_FLAGS(0)
        | EXTENDED_STARTUPINFO_PRESENT
        | CREATE_UNICODE_ENVIRONMENT
        | CREATE_BREAKAWAY_FROM_JOB,

    No CREATE_NEW_PROCESS_GROUP. Addinghat interactive Ctrl+C still reaches
    the shell) should make Warp robustprocess generating CTRL_C_EVENT /CTRL_BREAK_EVENT toward group 0, regardless of whether OpenCode also fixes its side.

    Cross-ref upstream

    Same root behaviour is tracked in O/anomalyco/opencode/issues/6189(closed, but only the /exit path was addressed; Ctrl+C×2 in default mode still kills the parent shell). Even if OpenCode patches it, hardening the Warp side prevents any future TUI agent from being able to take down the hosted shell the same way.

  4. added
    repro:highThe report includes enough evidence that the issue appears highly reproducible.
    and removed
    repro:unknownThe report does not provide enough evidence to estimate reproducibility yet.
    on May 11, 2026
  5. acarl005 commented on May 11, 2026

    @acarl005
    Contributor

    @Zyl0812 Thanks for providing the information. I have added repro:high.

    Have you tried adding CREATE_NEW_PROCESS_GROUP to the flags and verifying that this both fixes the issue and doesn't break ctrl-c's intended behavior in other contexts?

    I checked the Windows Terminal source code and it looks like they don't use CREATE_NEW_PROCESS_GROUP. Therefore, I'm hesitant to use this flag.

    https://github.com/microsoft/terminal/blob/3e3b3ad883d134bdab26850d42e2a8308da40086/src/cascadia/TerminalConnection/ConptyConnection.cpp#L172

  6. removed
    bugSomething isn't working.
    needs-infoMore issue-specific reporter detail is needed before the problem can be confidently triaged.
    area:window-tabs-panesWindow, tab, pane, and workspace layout management.
    warp:prioritizedIssues prioritized by the Warp team.
    on May 11, 2026
  7. acarl005 commented on May 11, 2026

    @acarl005
    Contributor

    I just repro'd this problem in both Alacritty and WezTerm (on Windows) and both have the same behavior. I'm starting to think this is not actually a Warp bug. I'm going to de-prioritize this work on the Warp engineers side for now. If this is affecting multiple terminals then this is probably a deeper issue. If any contributors want to push this forward, please explain why this is affecting those other terminals and why/how Warp can fix this.

    I'm also moving this back to read-to-spec since it's not clear that this is even a Warp problem

  8. added
    ready-to-specThe issue is ready for a product and technical spec.
    and removed
    ready-to-implementThe issue is ready for implementation work.
    on May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:shell-terminalTerminal input/output, shell integration, prompt behavior, and block rendering.area:terminal-inputTerminal command-line input, cursor movement, key handling, and input editing.os:windowsWindows-specific behavior, regressions, or requests.ready-to-specThe issue is ready for a product and technical spec.repro:highThe report includes enough evidence that the issue appears highly reproducible.triagedIssue has received an initial automated triage pass.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions