Skip to content

/exit and Ctrl+C close entire Zellij session instead of just the pane (Windows) #36671

Closed as not planned

Description

@kraso

Description

Bug Report: /exit and Ctrl+C close entire Zellij session instead of just the pane (Windows)

Summary

When running opencode inside a Zellij pane on Windows, both /exit and Ctrl+C intermittently close the entire Zellij session (all panes) instead of just terminating opencode and returning to the shell in the same pane.

This behavior is intermittent — sometimes Ctrl+C works correctly (returns to shell), and sometimes it behaves like /exit, killing the whole session.

Environment

Component Version / Details
OS Windows 10/11
Terminal Alacritty (launched via VBScript shortcut)
Shell PowerShell 7 (pwsh.exe)
Multiplexer Zellij (installed via WinGet)
opencode v1.17.18 (installed via npm)
Zellij session mode Named sessions (zellij --session <name>)

Steps to Reproduce

  1. Open Alacritty (which auto-launches Zellij via PowerShell profile).
  2. Ensure there is only one pane in the Zellij session.
  3. Run opencode inside the pane.
  4. Execute /exit inside opencode.
  5. Observed: Zellij closes entirely, returning to PowerShell with message Bye Zellij!!.

Variant A (Ctrl+C intermittent)

  1. Open Alacritty → Zellij (one pane).
  2. Run opencode.
  3. Press Ctrl+C.
  4. Observed (intermittent): Sometimes returns to shell in the same pane (expected), sometimes closes the entire Zellij session (bug).

Variant B (multiple panes workaround)

  1. Open Alacritty → Zellij.
  2. Create a second empty pane (Ctrl+P).
  3. In the first pane, run opencode.
  4. Execute /exit.
  5. Observed: Only the opencode pane closes; the second pane survives, and Zellij stays alive.

Expected Behavior

  • /exit should terminate opencode and return control to the shell in the same Zellij pane.
  • Ctrl+C should always terminate opencode without affecting Zellij.
  • If it is the only pane, Zellij should ideally keep the session alive with an empty shell, not exit entirely.

Actual Behavior

  • With one pane: /exit kills the entire Zellij session (not just the pane).
  • With multiple panes: /exit correctly kills only the pane.
  • Ctrl+C behaves unpredictably — sometimes pane-safe, sometimes session-killing.

Root Cause Hypothesis

opencode appears to detect the Zellij environment via the ZELLIJ* family of environment variables (ZELLIJ, ZELLIJ_PANE_ID, ZELLIJ_SESSION_NAME, ZELLIJ_SERVER_MODE).

When detected, opencode seems to send a Zellij IPC command on shutdown (/exit or Ctrl+C). If the IPC command is interpreted as "close the current pane" but Zellij decides the session has no other panes, it may terminate the entire session. Alternatively, opencode may be sending a session-kill command rather than a pane-kill command.

This behavior was not present in earlier versions or when Zellij sessions were in a corrupted state (e.g., zombie server processes prevented opencode from successfully communicating with Zellij).

Workarounds

  1. Always keep a second empty pane open before running opencode. This prevents Zellij from closing the session when the opencode pane exits.
  2. Use Ctrl+C repeatedly until it works, though this is unreliable.
  3. Run Zellij without named sessions (zellij instead of zellij --session <name>). In limited testing, this appeared to change opencode's detection behavior, but this is not a confirmed fix.

Additional Context

  • The user's PowerShell profile auto-launches Zellij inside Alacritty:
    if ($env:ALACRITTY_LOG -and -not $env:ZELLIJ) {
        $timestamp = Get-Date -Format "HHmmssfff"
        $sessionName = "a-$timestamp"
        zellij --session $sessionName
    }
  • Alacritty is launched via a VBScript (Launch-Alacritty.vbs) that simply runs alacritty.exe.
  • No custom Zellij configuration (on_force_close commented out in config.kdl).
  • The issue appeared after cleaning up ~19 orphaned zellij --server processes that had accumulated due to prior OOM crashes (unrelated to opencode). Once Zellij was healthy, opencode's Zellij integration began working "too well" (closing the session instead of just the pane).

Request

Please investigate opencode's Zellij shutdown handler on Windows. Specifically:

  • What IPC command is sent to Zellij on /exit?
  • Does Ctrl+C share the same shutdown path?
  • Can the integration be made pane-safe (never close the entire session unless explicitly requested)?

Thank you!

Plugins

No response

OpenCode version

1.17.18

Steps to reproduce

  1. Open Alacritty (which auto-launches Zellij via PowerShell profile).
  2. Ensure there is only one pane in the Zellij session.
  3. Run opencode inside the pane.
  4. Execute /exit inside opencode.
  5. Observed: Zellij closes entirely, returning to PowerShell with message Bye Zellij!!.

Variant A (Ctrl+C intermittent)

  1. Open Alacritty → Zellij (one pane).
  2. Run opencode.
  3. Press Ctrl+C.
  4. Observed (intermittent): Sometimes returns to shell in the same pane (expected), sometimes closes the entire Zellij session (bug).

Variant B (multiple panes workaround)

  1. Open Alacritty → Zellij.
  2. Create a second empty pane (Ctrl+P).
  3. In the first pane, run opencode.
  4. Execute /exit.
  5. Observed: Only the opencode pane closes; the second pane survives, and Zellij stays alive.

Expected Behavior

  • /exit should terminate opencode and return control to the shell in the same Zellij pane.
  • Ctrl+C should always terminate opencode without affecting Zellij.
  • If it is the only pane, Zellij should ideally keep the session alive with an empty shell, not exit entirely.

Actual Behavior

  • With one pane: /exit kills the entire Zellij session (not just the pane).
  • With multiple panes: /exit correctly kills only the pane.
  • Ctrl+C behaves unpredictably — sometimes pane-safe, sometimes session-killing.

Screenshot and/or share link

https://opncd.ai/share/ca4r06PO

Operating System

Windows 11 Home

Terminal

Alacritty

Activity

  1. github-actions commented on Sep 12, 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