manaflow-ai / manaflow-ai/cmux
first-class zellij integration for live process preservation across cmd+q / relaunch
@austinywang is already working on this.
Since May 12, 2026.
- Dominant language
- Swift
- Stars
- 27.2k
- Forks
- 2.4k
- Avg merge
- 11h 59m
- Merged PRs (30d)
- 559
Description
## problem
cmux restores layout, working directories, scrollback, and browser urls on relaunch — but **live terminal processes are not restored**. if you cmd+q while claude code, ssh sessions, or long-running tasks are active, they're gone. this is the single biggest gap in cmux's session management.
zellij solves exactly this problem with built-in session persistence and resurrection — no plugins needed (unlike tmux which requires tmux-resurrect + tmux-continuum). a first-class integration would give cmux full process preservation essentially for free.
## why zellij over tmux
| capability | tmux | zellij |
|-----------|------|--------|
| session resurrection | requires plugins | **built-in** |
| kitty keyboard protocol | not supported | **supported** — enables shift+enter in claude code |
| scrollback serialization | plugin, every 15min | built-in, configurable interval |
| layout format | binary/opaque | **human-readable kdl files** |
| auto-attach | manual config | built-in `--generate-auto-start` |
| force close behavior | kills session | configurable: `on_force_close "detach"` |
zellij also has a wasm plugin ecosystem — notably `zellaude`, which shows claude code activity indicators on tabs.
## how the integration would work
### core concept
each cmux pane launches its shell inside a zellij session with a deterministic name derived from the workspace/pane id. when cmux quits and relaunches, it runs `zellij attach --create ` which reattaches to the still-running session (if zellij server survived) or resurrects it from cache.
### key zellij primitives
| primitive | what it does for cmux |
|-----------|----------------------|
| `zellij attach --create ` | attach if exists, create if not — idempotent session management |
| `on_force_close "detach"` | when cmux closes the ghostty surface, zellij detaches instead of quitting — processes stay alive |
| `session_serialization true` | auto-serializes session state to kdl layout files on a timer |
| `scrollback_lines_to_serialize 0` | preserves full scrollback (0 = unlimited) |
| `--force-run-commands` | on resurrection after reboot, auto-restarts commands without "press enter" banner |
| `$ZELLIJ` env var | prevents nesting — cmux checks this before launching zellij inside zellij |
| `zellij action dump-layout` | cmux can capture current zellij layout on demand for its own session export |
### user experience
1. user opens cmux, starts claude code in workspace 1, ssh session in workspace 2
2. user presses cmd+q — cmux closes, zellij sessions detach (processes keep running)
3. user reopens cmux — each pane reattaches to its zellij session
4. claude code is still running, ssh is still connected, scrollback is intact
5. even after a full reboot, zellij resurrects the layout and offers to re-run commands
### configuration
could be as simple as a toggle in cmux settings:
```
session-backend = zellij # or "native" for current behavior
```
cmux would handle the lifecycle: generating session names, passing `on_force_close "detach"`, setting serialization options, and mapping cmux workspaces to zellij sessions transparently.
## related issues
- #1337 — restore live ssh/tmux sessions on relaunch (assigned to @lawrencecchen)
- #1340 — save scrollback on autosave timer, not just clean quit
- #1427 — session save/open with foreground command capture (draft pr)
- #1617 — profiles: save and restore workspace layouts (closed)
this would address all of the above in one integration. zellij's primitives map directly to what each of those issues is asking for.
## prior art
the ghostty + zellij pattern is already well-documented in the community ([example](https://romanzipp.com/blog/ghostty-zellij-fish-shell)). since cmux is built on ghostty, the integration path is natural. the main work is wiring cmux's workspace/pane lifecycle to zellij's session lifecycle.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.