การกู้คืนเซสชัน

cmux บันทึกรูปร่างงานของคุณ เพื่อให้การเปิด app ใหม่พา window, workspace, pane, terminal context และ browser state เดิมกลับมา

สิ่งที่ cmux กู้คืน

หลังเปิดใหม่ cmux กู้คืน layout และ metadata ที่ app เป็นเจ้าของ:

  • layout ของ window, workspace และ pane
  • working directory
  • terminal scrollback แบบ best effort
  • Browser URL และ navigation history
cmux ไม่ checkpoint สถานะ live process ทั่วไป tmux, vim, shell และ terminal app ที่ไม่รองรับจะเปิดใหม่เป็น terminal ปกติ เว้นแต่จะมี cmux resume integration ของตัวเอง

Resume agent session

AI coding agent ที่รองรับสามารถ resume ได้เมื่อ cmux จับ native session ID ของ agent แล้ว ติดตั้ง hooks หลังติดตั้ง agent CLI เพื่อให้ binary อยู่ใน PATH:

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

cmux hooks setup ติดตั้ง integration ที่รองรับทั้งหมดที่พบ และพิมพ์สรุป agent ที่ข้ามไป ใช้ชื่อ agent เมื่อต้องการ integration เดียว

คำสั่ง surface resume แบบกำหนดเอง

ผู้ใช้ขั้นสูงและ integration สามารถผูก terminal surface ใดก็ได้กับคำสั่ง restart cmux เก็บ binding ที่สร้างผ่าน public CLI หรือ socket ไว้สำหรับตรวจสอบและ resume ด้วยตนเอง

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

prefix ที่อนุมัติแล้วสามารถตรวจสอบหรือแก้ไขได้ใน Settings > Terminal > Resume Commands cmux จะ auto-run เฉพาะ resume binding ที่ถูกทำเครื่องหมายว่า trusted เช่น tmux binding ที่ตรวจพบจาก process ที่กำลังทำงาน หรือ prefix ที่ user อนุมัติแล้ว cmux ยังไม่ checkpoint process memory ทั่วไป คีย์ environment ที่ละเอียดอ่อน เช่น token, password, secret และ API key จะถูกตัดทิ้งก่อนบันทึก resume binding การอนุมัติจะผูกกับไดเรกทอรีทำงานและค่า environment แบบตรงกันทุกค่าเมื่อมีอยู่ด้วย

Agent ที่รองรับ

AgentBinaryคำสั่ง resumeFeed 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>ไม่มี
OMPompomp --session <id>ไม่มี
Ampampamp threads continue <id>ไม่มี
Cursor CLIcursor-agentcursor-agent --resume <id>beforeShellExecution
Geminigeminigemini --resume <id>PreToolUse
Antigravity CLIagyagy --conversation <id>PreToolUse, PostToolUse
Rovo Devacliacli rovodev run --restore <id>ไม่มี
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 ถูกจัดการโดย cmux Claude wrapper เมื่อเปิด Claude integration ใน Settings Antigravity ยังรับ agy เป็น setup alias ด้วย และ Rovo Dev รับ rovo

กู้คืนด้วยตนเอง

cmux กู้คืน snapshot ล่าสุดที่บันทึกไว้ในการเปิดปกติ คุณยังสามารถใช้ snapshot ก่อนหน้าซ้ำด้วยตนเองได้:

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

ปิด automatic agent resume

หากต้องการกู้คืน pane โดยไม่เปิดคำสั่ง agent resume ที่บันทึกไว้ ให้ปิด Settings > Terminal > Resume Agent Sessions on Reopen หรือกำหนด:

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

สิ่งนี้ปิดเฉพาะคำสั่ง agent resume เท่านั้น cmux ยัง restore layout, working directory, scrollback และ browser history

วิธีทำงาน

  1. cmux เขียน JSON snapshot แบบมี version ไปที่ ~/Library/Application Support/cmux/session-<bundle-id>.json และ cache ของ session ก่อนหน้าเพื่อ reopen ด้วยตนเอง
  2. terminal scrollback ถูกเก็บเป็นข้อความจำกัดขนาดและ replay ผ่าน temporary file ตอนกู้คืน เป็น best effort เพราะ terminal app สามารถ redraw หรือ clear หน้าจอได้
  3. Agent hooks เขียน ~/.cmuxterm/<agent>-hook-sessions.json พร้อม agent session ID, cmux workspace ID, surface ID, cwd, process ID ถ้ามี และ sanitized launch command
  4. ตอนกู้คืน cmux สร้าง window และ pane ก่อน หากเปิด automatic agent resume มันจะเริ่ม one-shot shell command ที่รัน native resume command ของ agent ด้วย session ID ที่บันทึกไว้

เอกสาร configuration ปกติครอบคลุม cmux.json Session restore แยก app layout ออกจาก Ghostty terminal rendering settings