Repository navigation
Description
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
- Open Alacritty (which auto-launches Zellij via PowerShell profile).
- Ensure there is only one pane in the Zellij session.
- Run
opencodeinside the pane. - Execute
/exitinside opencode. - Observed: Zellij closes entirely, returning to PowerShell with message
Bye Zellij!!.
Variant A (Ctrl+C intermittent)
- Open Alacritty → Zellij (one pane).
- Run
opencode. - Press
Ctrl+C. - Observed (intermittent): Sometimes returns to shell in the same pane (expected), sometimes closes the entire Zellij session (bug).
Variant B (multiple panes workaround)
- Open Alacritty → Zellij.
- Create a second empty pane (
Ctrl+P). - In the first pane, run
opencode. - Execute
/exit. - Observed: Only the opencode pane closes; the second pane survives, and Zellij stays alive.
Expected Behavior
/exitshould terminate opencode and return control to the shell in the same Zellij pane.Ctrl+Cshould 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:
/exitkills the entire Zellij session (not just the pane). - With multiple panes:
/exitcorrectly kills only the pane. Ctrl+Cbehaves 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
- Always keep a second empty pane open before running opencode. This prevents Zellij from closing the session when the opencode pane exits.
- Use
Ctrl+Crepeatedly until it works, though this is unreliable. - Run Zellij without named sessions (
zellijinstead ofzellij --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 runsalacritty.exe. - No custom Zellij configuration (
on_force_closecommented out inconfig.kdl). - The issue appeared after cleaning up ~19 orphaned
zellij --serverprocesses 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+Cshare 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
- Open Alacritty (which auto-launches Zellij via PowerShell profile).
- Ensure there is only one pane in the Zellij session.
- Run
opencodeinside the pane. - Execute
/exitinside opencode. - Observed: Zellij closes entirely, returning to PowerShell with message
Bye Zellij!!.
Variant A (Ctrl+C intermittent)
- Open Alacritty → Zellij (one pane).
- Run
opencode. - Press
Ctrl+C. - Observed (intermittent): Sometimes returns to shell in the same pane (expected), sometimes closes the entire Zellij session (bug).
Variant B (multiple panes workaround)
- Open Alacritty → Zellij.
- Create a second empty pane (
Ctrl+P). - In the first pane, run
opencode. - Execute
/exit. - Observed: Only the opencode pane closes; the second pane survives, and Zellij stays alive.
Expected Behavior
/exitshould terminate opencode and return control to the shell in the same Zellij pane.Ctrl+Cshould 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:
/exitkills the entire Zellij session (not just the pane). - With multiple panes:
/exitcorrectly kills only the pane. Ctrl+Cbehaves 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
github-actions commentedon Sep 12, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.