Session Restore

coterm saves the shape of your work so relaunching the app can bring back the same windows, workspaces, panes, terminal context, and browser state.

What coterm restores

After relaunch, coterm restores app-owned layout and metadata:

  • Window, workspace, and pane layout
  • Working directories
  • Terminal scrollback, best effort
  • Browser URL and navigation history
coterm does not checkpoint arbitrary live process state. tmux, vim, shells, and unsupported terminal apps reopen as normal terminals unless they have their own coterm resume integration.

Agent session resume

Supported AI coding agents can resume when coterm has captured the agent's native session ID. Install hooks after installing the agent CLI so the agent binary is on PATH:

coterm hooks setup
coterm hooks setup codex
coterm hooks setup grok
coterm hooks setup antigravity
coterm hooks setup omp
coterm hooks setup --agent opencode

Running coterm hooks setup installs every supported integration it can find and prints a summary for skipped agents. Use an agent name when you only want one integration.

Custom surface resume commands

Advanced users and integrations can bind any terminal surface to a restart command. coterm stores public CLI and socket-created bindings for inspection and manual restore unless you approve a signed command prefix.

coterm surface resume set --kind tmux --checkpoint work --shell "tmux attach -t work"
coterm surface resume show --json
coterm surface resume clear --checkpoint work

Review or edit approved prefixes in Settings > Terminal > Resume Commands. coterm only auto-runs resume bindings it marks trusted, such as live process-detected tmux bindings or user-approved prefixes. coterm still does not checkpoint arbitrary process memory. Sensitive environment keys such as tokens, passwords, secrets, and API keys are dropped before a resume binding is stored. Approved prefixes are also bound to the working directory and exact environment values when present.

Supported agents

AgentBinaryResume commandFeed bridge
Claude Codeclaudeclaude --resume <id>PermissionRequest
Codexcodexcodex resume <id>PreToolUse, PermissionRequest
Grok / Grok Build CLIgrokgrok -r <id>PreToolUse
OpenCodeopencodeopencode --session <id>plugin event bus
Pipipi --session <id>none
OMPompomp --session <id>none
Ampampamp threads continue <id>none
Cursor CLIcursor-agentcursor-agent --resume <id>beforeShellExecution
Geminigeminigemini --resume <id>PreToolUse
Antigravity CLIagyagy --conversation <id>PreToolUse, PostToolUse
Rovo Devacliacli rovodev run --restore <id>none
Hermes Agenthermeshermes --resume <id>pre_tool_call, post_tool_call, pre_approval_request, post_approval_response
Copilotcopilotcopilot --resume <id>PreToolUse
CodeBuddycodebuddycodebuddy --resume <id>PreToolUse
Factorydroiddroid --resume <id>PreToolUse
Qoderqodercliqodercli --resume <id>PreToolUse

Claude Code is handled by the coterm Claude wrapper when Claude integration is enabled in Settings. Antigravity also accepts agy as the setup alias, and Rovo Dev accepts rovo.

Manual restore

coterm restores the last saved snapshot on normal launch. You can also reapply the previous snapshot manually:

  • History > Restore Previous App Launch
  • ⌘ ⇧ O
  • coterm restore-session

Disable automatic agent resume

To restore panes without launching saved agent resume commands, turn off Settings > Terminal > Resume Agent Sessions on Reopen or set:

~/.config/coterm/coterm.json
{
  "terminal": {
    "autoResumeAgentSessions": false
  }
}

This only disables agent resume commands. coterm still restores layout, working directories, scrollback, and browser history.

How it works

  1. coterm writes a versioned JSON snapshot to ~/Library/Application Support/coterm/session-<bundle-id>.json, plus a previous-session cache for manual reopen.
  2. Terminal scrollback is stored as bounded text and replayed through a temporary file on restore. This is best effort because terminal apps can redraw or clear their screen.
  3. Agent hooks write ~/.coterm/<agent>-hook-sessions.json with the agent session ID, coterm workspace ID, surface ID, cwd, process ID when available, and a sanitized launch command.
  4. On restore, coterm rebuilds windows and panes first. If automatic agent resume is enabled, it launches a one-shot shell command that runs the agent's native resume command with the saved session ID.

The regular configuration docs cover coterm.json. Session restore keeps app layout separate from Ghostty terminal rendering settings.