Codemux

Session Persistence

Scrollback save/restore, automatic agent resume, and the extensible session adapter system.

Session Persistence

Codemux saves terminal scrollback when you close and restores it when you reopen. Agents like Claude Code automatically resume where they left off.

Scrollback Save & Restore

When a pane closes or the app shuts down, Codemux serializes the terminal's scrollback buffer to disk. On reopen, the saved output is written back into the terminal so you see exactly what was on screen before.

A ── session restored ── marker separates restored content from new output.

Auto-Resume for Agents

For supported agents, Codemux goes beyond restoring scrollback — it resumes the agent session itself. Claude Code sessions automatically pick up where they left off using the --resume flag with the saved session ID.

This means closing and reopening a workspace doesn't lose your agent conversation. The agent continues with its full context intact.

Session Adapters

The adapter system determines how different tools are detected and resumed. Adapters are configured in ~/.config/codemux/session-adapters.toml.

Each adapter defines:

  • detect_pattern — Regex matched against the command that launched the pane
  • resume_command — Template for the command that resumes a session, with {capture} placeholders
  • capture_patterns — Regexes applied to PTY output to extract session IDs and other state

The default configuration ships with a Claude Code adapter. You can add adapters for any tool that supports session resumption.

Example Adapter

[adapters.claude]
detect_pattern = "\\bclaude\\b"
resume_command = "claude --resume {claude_session_id}"
validate_command = "claude --version"

[[adapters.claude.capture_patterns]]
name = "claude_session_id"
pattern = '"sessionId":"([^"]+)"'

Shift+Click Preset

Hold Shift and click a preset button to open it in a new split pane instead of creating a new tab. This lets you quickly launch a second agent side-by-side with an existing session.

Settings

Two settings control session persistence in Settings > Terminal:

SettingDefaultDescription
session_restore.enabledtrueToggle scrollback save/restore on or off
scrollback_lines5000Maximum number of scrollback lines saved per pane