การกู้คืนเซสชัน
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
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 opencodecmux 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 workprefix ที่อนุมัติแล้วสามารถตรวจสอบหรือแก้ไขได้ใน 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 ที่รองรับ
| Agent | Binary | คำสั่ง resume | Feed bridge |
|---|---|---|---|
| Claude Code | claude | claude --resume <id> | PermissionRequest |
| Codex | codex | codex resume <id> | PreToolUse, PermissionRequest |
| Grok / Grok Build CLI | grok | grok -r <id> | PreToolUse |
| OpenCode | opencode | opencode --session <id> | plugin event bus |
| Pi | pi | pi --session <id> | ไม่มี |
| OMP | omp | omp --session <id> | ไม่มี |
| Amp | amp | amp threads continue <id> | ไม่มี |
| Cursor CLI | cursor-agent | cursor-agent --resume <id> | beforeShellExecution |
| Gemini | gemini | gemini --resume <id> | PreToolUse |
| Antigravity CLI | agy | agy --conversation <id> | PreToolUse, PostToolUse |
| Rovo Dev | acli | acli rovodev run --restore <id> | ไม่มี |
| Hermes Agent | hermes | hermes --resume <id> | pre_tool_call, post_tool_call, pre_approval_request, post_approval_response |
| Copilot | copilot | copilot --resume <id> | PreToolUse |
| CodeBuddy | codebuddy | codebuddy --resume <id> | PreToolUse |
| Factory | droid | droid --resume <id> | PreToolUse |
| Qoder | qodercli | qodercli --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
⌘ ⇧ Ocmux restore-session
ปิด automatic agent resume
หากต้องการกู้คืน pane โดยไม่เปิดคำสั่ง agent resume ที่บันทึกไว้ ให้ปิด Settings > Terminal > Resume Agent Sessions on Reopen หรือกำหนด:
{
"terminal": {
"autoResumeAgentSessions": false
}
}สิ่งนี้ปิดเฉพาะคำสั่ง agent resume เท่านั้น cmux ยัง restore layout, working directory, scrollback และ browser history
วิธีทำงาน
- cmux เขียน JSON snapshot แบบมี version ไปที่ ~/Library/Application Support/cmux/session-<bundle-id>.json และ cache ของ session ก่อนหน้าเพื่อ reopen ด้วยตนเอง
- terminal scrollback ถูกเก็บเป็นข้อความจำกัดขนาดและ replay ผ่าน temporary file ตอนกู้คืน เป็น best effort เพราะ terminal app สามารถ redraw หรือ clear หน้าจอได้
- Agent hooks เขียน ~/.cmuxterm/<agent>-hook-sessions.json พร้อม agent session ID, cmux workspace ID, surface ID, cwd, process ID ถ้ามี และ sanitized launch command
- ตอนกู้คืน 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