cmux-terminal-multiplexer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

cmux — AI-Native Terminal Multiplexer

cmux — 原生AI终端多路复用器

Skill by ara.so — Daily 2026 Skills collection
cmux is a terminal multiplexer with a programmable socket API designed for AI coding agents. It provides full Playwright-equivalent browser automation, real-time terminal split management, sidebar status reporting, and agent team coordination — all via a simple CLI.

ara.so开发的Skill — 2026每日技能合集
cmux是一款为AI编码Agent设计的、具备可编程Socket API的终端多路复用器。它提供完全等效于Playwright的浏览器自动化、实时终端分屏管理、侧边栏状态报告以及Agent团队协作功能 —— 所有功能均可通过简单的CLI调用。

What cmux Does

cmux的功能

  • Terminal splits — create side-by-side or stacked panes, send commands, capture output
  • Browser automation — full headless Chromium with snapshot-based element refs (no CSS selectors)
  • Status sidebar — live progress bars, log messages, and icon badges visible to the user
  • Notifications — native OS notifications from agent workflows
  • Agent teams — coordinate parallel subagents, each with their own visible split

  • 终端分屏 — 创建并排或堆叠窗格,发送命令,捕获输出
  • 浏览器自动化 — 完整的无头Chromium引擎,基于快照的元素引用(无需CSS选择器)
  • 状态侧边栏 — 实时进度条、日志消息和图标徽章,用户可直接查看
  • 通知功能 — 来自Agent工作流的原生系统通知
  • Agent团队协作 — 协调并行子Agent,每个Agent拥有独立的可视分屏

Orient Yourself

快速定位当前环境

bash
cmux identify --json          # current window/workspace/pane/surface context
cmux list-panes               # all panes in current workspace
cmux list-pane-surfaces --pane pane:1  # surfaces within a pane
cmux list-workspaces          # all workspaces (tabs) in current window
Environment variables set automatically:
  • $CMUX_SURFACE_ID
    — your current surface ref
  • $CMUX_WORKSPACE_ID
    — your current workspace ref
Handles use short refs:
surface:N
,
pane:N
,
workspace:N
,
window:N
.

bash
cmux identify --json          # 当前窗口/工作区/窗格/上下文信息
cmux list-panes               # 当前工作区的所有窗格
cmux list-pane-surfaces --pane pane:1  # 某窗格内的所有上下文
cmux list-workspaces          # 当前窗口的所有工作区(标签页)
自动设置的环境变量:
  • $CMUX_SURFACE_ID
    — 当前上下文引用
  • $CMUX_WORKSPACE_ID
    — 当前工作区引用
句柄采用短引用格式:
surface:N
pane:N
workspace:N
window:N

Terminal Splits

终端分屏

Create splits

创建分屏

bash
cmux --json new-split right   # side-by-side (preferred for parallel work)
cmux --json new-split down    # stacked (good for logs)
Always capture the returned
surface_ref
:
bash
WORKER=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
bash
cmux --json new-split right   # 并排分屏(适合并行工作)
cmux --json new-split down    # 堆叠分屏(适合查看日志)
务必捕获返回的
surface_ref
bash
WORKER=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")

Send commands and read output

发送命令与读取输出

bash
cmux send-surface --surface surface:22 "npm run build\n"
cmux capture-pane --surface surface:22              # current screen
cmux capture-pane --surface surface:22 --scrollback  # with full history

cmux send-key-surface --surface surface:22 ctrl-c  # send key
cmux send-key-surface --surface surface:22 enter
Golden rule: never steal focus. Always use
--surface
targeting.
bash
cmux send-surface --surface surface:22 "npm run build\n"
cmux capture-pane --surface surface:22              # 当前屏幕内容
cmux capture-pane --surface surface:22 --scrollback  # 包含完整历史记录

cmux send-key-surface --surface surface:22 ctrl-c  # 发送按键
cmux send-key-surface --surface surface:22 enter
黄金准则:绝不抢占焦点。始终使用
--surface
指定目标。

Worker split pattern

工作进程分屏模式

bash
WORKER=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux send-surface --surface "$WORKER" "make test 2>&1; echo EXIT_CODE=\$?\n"
sleep 3
cmux capture-pane --surface "$WORKER"
cmux close-surface --surface "$WORKER"   # clean up when done
bash
WORKER=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux send-surface --surface "$WORKER" "make test 2>&1; echo EXIT_CODE=\$?\n"
sleep 3
cmux capture-pane --surface "$WORKER"
cmux close-surface --surface "$WORKER"   # 完成后清理

Pane management

窗格管理

bash
cmux focus-pane --pane pane:2
cmux close-surface --surface surface:22
cmux swap-pane --pane pane:1 --target-pane pane:2
cmux move-surface --surface surface:7 --pane pane:2 --focus true
cmux reorder-surface --surface surface:7 --before surface:3

bash
cmux focus-pane --pane pane:2
cmux close-surface --surface surface:22
cmux swap-pane --pane pane:1 --target-pane pane:2
cmux move-surface --surface surface:7 --pane pane:2 --focus true
cmux reorder-surface --surface surface:7 --before surface:3

Browser Automation

浏览器自动化

cmux embeds a full headless Chromium engine with a Playwright-style API. No external Chrome required. Every command targets a browser surface by ref.
cmux内置完整的无头Chromium引擎,提供类Playwright风格的API。无需外部Chrome,所有命令通过上下文引用目标浏览器分屏。

Workflow pattern

工作流模式

navigate → wait for load → snapshot --interactive → act with refs → re-snapshot
导航 → 等待加载 → 快照--interactive → 基于引用操作 → 重新快照

Open and navigate

打开与导航

bash
cmux --json browser open https://example.com        # opens browser split, returns surface ref
cmux browser surface:23 goto https://other.com
cmux browser surface:23 back
cmux browser surface:23 forward
cmux browser surface:23 reload
cmux browser surface:23 get url
cmux browser surface:23 get title
Capture the surface ref:
bash
BROWSER=$(cmux --json browser open https://docs.example.com | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
bash
cmux --json browser open https://example.com        # 打开浏览器分屏,返回上下文引用
cmux browser surface:23 goto https://other.com
cmux browser surface:23 back
cmux browser surface:23 forward
cmux browser surface:23 reload
cmux browser surface:23 get url
cmux browser surface:23 get title
捕获上下文引用:
bash
BROWSER=$(cmux --json browser open https://docs.example.com | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")

Snapshot and element refs

快照与元素引用

Instead of CSS selectors, snapshot to get stable element refs (
e1
,
e2
, ...):
bash
cmux browser surface:23 snapshot --interactive              # full interactive snapshot
cmux browser surface:23 snapshot --interactive --compact     # compact output
cmux browser surface:23 snapshot --selector "form#login" --interactive  # scoped
Refs are invalidated after DOM mutations — always re-snapshot after navigation or clicks. Use
--snapshot-after
to auto-get a fresh snapshot:
bash
cmux --json browser surface:23 click e1 --snapshot-after
无需CSS选择器,通过快照获取稳定的元素引用(
e1
e2
、...):
bash
cmux browser surface:23 snapshot --interactive              # 完整交互式快照
cmux browser surface:23 snapshot --interactive --compact     # 精简输出
cmux browser surface:23 snapshot --selector "form#login" --interactive  # 范围快照
DOM变更后引用会失效 —— 导航或点击后务必重新快照。使用
--snapshot-after
自动获取新快照:
bash
cmux --json browser surface:23 click e1 --snapshot-after

Interact with elements

元素交互

bash
undefined
bash
undefined

Click and hover

点击与悬停

cmux browser surface:23 click e1 cmux browser surface:23 dblclick e2 cmux browser surface:23 hover e3 cmux browser surface:23 focus e4
cmux browser surface:23 click e1 cmux browser surface:23 dblclick e2 cmux browser surface:23 hover e3 cmux browser surface:23 focus e4

Text input

文本输入

cmux browser surface:23 fill e5 "hello@example.com" # clear + type cmux browser surface:23 fill e5 "" # clear input cmux browser surface:23 type e6 "search query" # type without clearing
cmux browser surface:23 fill e5 "hello@example.com" # 清空后输入 cmux browser surface:23 fill e5 "" # 清空输入框 cmux browser surface:23 type e6 "search query" # 不清空直接输入

Keys

按键操作

cmux browser surface:23 press Enter cmux browser surface:23 press Tab cmux browser surface:23 keydown Shift
cmux browser surface:23 press Enter cmux browser surface:23 press Tab cmux browser surface:23 keydown Shift

Forms

表单操作

cmux browser surface:23 check e7 # checkbox cmux browser surface:23 uncheck e7 cmux browser surface:23 select e8 "option-value"
cmux browser surface:23 check e7 # 复选框 cmux browser surface:23 uncheck e7 cmux browser surface:23 select e8 "option-value"
undefined

Scroll

等待状态

cmux browser surface:23 scroll --dy 500 cmux browser surface:23 scroll --selector ".container" --dy 300 cmux browser surface:23 scroll-into-view e9
undefined
bash
cmux browser surface:23 wait --load-state complete --timeout-ms 15000
cmux browser surface:23 wait --selector "#ready" --timeout-ms 10000
cmux browser surface:23 wait --text "Success" --timeout-ms 10000
cmux browser surface:23 wait --url-contains "/dashboard" --timeout-ms 10000
cmux browser surface:23 wait --function "document.readyState === 'complete'" --timeout-ms 10000

Wait for state

读取页面内容

bash
cmux browser surface:23 wait --load-state complete --timeout-ms 15000
cmux browser surface:23 wait --selector "#ready" --timeout-ms 10000
cmux browser surface:23 wait --text "Success" --timeout-ms 10000
cmux browser surface:23 wait --url-contains "/dashboard" --timeout-ms 10000
cmux browser surface:23 wait --function "document.readyState === 'complete'" --timeout-ms 10000
bash
cmux browser surface:23 get text body        # 可见文本
cmux browser surface:23 get html body        # 原始HTML
cmux browser surface:23 get value "#email"   # 输入框值
cmux browser surface:23 get attr "#link" --attr href
cmux browser surface:23 get count ".items"   # 元素数量
cmux browser surface:23 get box "#button"    # 边界框
cmux browser surface:23 get styles "#el" --property color

Read page content

状态检查

bash
cmux browser surface:23 get text body        # visible text
cmux browser surface:23 get html body        # raw HTML
cmux browser surface:23 get value "#email"   # input value
cmux browser surface:23 get attr "#link" --attr href
cmux browser surface:23 get count ".items"   # element count
cmux browser surface:23 get box "#button"    # bounding box
cmux browser surface:23 get styles "#el" --property color
cmux browser surface:23 is visible "#modal" cmux browser surface:23 is enabled "#submit" cmux browser surface:23 is checked "#agree"
undefined

State checks

定位器(类Playwright风格)

cmux browser surface:23 is visible "#modal" cmux browser surface:23 is enabled "#submit" cmux browser surface:23 is checked "#agree"
undefined
bash
cmux browser surface:23 find role button
cmux browser surface:23 find text "Sign In"
cmux browser surface:23 find label "Email"
cmux browser surface:23 find placeholder "Enter email"
cmux browser surface:23 find testid "submit-btn"
cmux browser surface:23 find first ".item"
cmux browser surface:23 find last ".item"
cmux browser surface:23 find nth ".item" 3

Locators (Playwright-style)

JavaScript执行

bash
cmux browser surface:23 find role button
cmux browser surface:23 find text "Sign In"
cmux browser surface:23 find label "Email"
cmux browser surface:23 find placeholder "Enter email"
cmux browser surface:23 find testid "submit-btn"
cmux browser surface:23 find first ".item"
cmux browser surface:23 find last ".item"
cmux browser surface:23 find nth ".item" 3
bash
cmux browser surface:23 eval "document.title"
cmux browser surface:23 eval "document.querySelectorAll('.item').length"
cmux browser surface:23 eval "window.scrollTo(0, document.body.scrollHeight)"

JavaScript evaluation

框架与对话框

bash
cmux browser surface:23 eval "document.title"
cmux browser surface:23 eval "document.querySelectorAll('.item').length"
cmux browser surface:23 eval "window.scrollTo(0, document.body.scrollHeight)"
bash
cmux browser surface:23 frame "#iframe-selector"   # 切换到iframe
cmux browser surface:23 frame main                  # 返回主框架
cmux browser surface:23 dialog accept
cmux browser surface:23 dialog dismiss
cmux browser surface:23 dialog accept "prompt text"

Frames and dialogs

Cookie、存储与状态

bash
cmux browser surface:23 frame "#iframe-selector"   # switch to iframe
cmux browser surface:23 frame main                  # back to main frame
cmux browser surface:23 dialog accept
cmux browser surface:23 dialog dismiss
cmux browser surface:23 dialog accept "prompt text"
bash
undefined

Cookies, storage, and state

Cookie操作

bash
undefined
cmux browser surface:23 cookies get cmux browser surface:23 cookies set session_token "abc123" cmux browser surface:23 cookies clear

Cookies

本地/会话存储

cmux browser surface:23 cookies get cmux browser surface:23 cookies set session_token "abc123" cmux browser surface:23 cookies clear
cmux browser surface:23 storage local get cmux browser surface:23 storage local set myKey "myValue" cmux browser surface:23 storage session clear

Local/session storage

保存/恢复完整浏览器状态(Cookie+存储+标签页)

cmux browser surface:23 storage local get cmux browser surface:23 storage local set myKey "myValue" cmux browser surface:23 storage session clear
cmux browser surface:23 state save ./auth-state.json cmux browser surface:23 state load ./auth-state.json
undefined

Save/restore full browser state (cookies + storage + tabs)

认证流程示例

cmux browser surface:23 state save ./auth-state.json cmux browser surface:23 state load ./auth-state.json
undefined
bash
BROWSER=$(cmux --json browser open https://app.example.com/login | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux browser $BROWSER wait --load-state complete --timeout-ms 15000
cmux browser $BROWSER snapshot --interactive
cmux browser $BROWSER fill e1 "user@example.com"
cmux browser $BROWSER fill e2 "my-password"
cmux browser $BROWSER click e3
cmux browser $BROWSER wait --url-contains "/dashboard" --timeout-ms 20000

Authentication flow

保存认证状态供后续使用

bash
BROWSER=$(cmux --json browser open https://app.example.com/login | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux browser $BROWSER wait --load-state complete --timeout-ms 15000
cmux browser $BROWSER snapshot --interactive
cmux browser $BROWSER fill e1 "user@example.com"
cmux browser $BROWSER fill e2 "my-password"
cmux browser $BROWSER click e3
cmux browser $BROWSER wait --url-contains "/dashboard" --timeout-ms 20000
cmux browser $BROWSER state save ./auth-state.json
undefined

Save auth for reuse

诊断功能

cmux browser $BROWSER state save ./auth-state.json
bash
cmux browser surface:23 console list     # JS控制台输出
cmux browser surface:23 console clear
cmux browser surface:23 errors list      # JS错误信息
cmux browser surface:23 errors clear
cmux browser surface:23 highlight "#el"  # 视觉高亮元素
cmux browser surface:23 screenshot       # 捕获截图

Reuse in a new surface

脚本与样式注入

BROWSER2=$(cmux --json browser open https://app.example.com | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])") cmux browser $BROWSER2 state load ./auth-state.json cmux browser $BROWSER2 goto https://app.example.com/dashboard
undefined
bash
cmux browser surface:23 addscript "console.log('已注入')"
cmux browser surface:23 addstyle "body { background: red; }"
cmux browser surface:23 addinitscript "window.__injected = true"  # 每次导航时运行

Diagnostics

侧边栏状态与进度

bash
cmux browser surface:23 console list     # JS console output
cmux browser surface:23 console clear
cmux browser surface:23 errors list      # JS errors
cmux browser surface:23 errors clear
cmux browser surface:23 highlight "#el"  # visual highlight
cmux browser surface:23 screenshot       # capture screenshot
无需打断用户即可展示实时状态:
bash
cmux set-status agent "工作中" --icon hammer --color "#ff9500"
cmux set-status agent "已完成" --icon checkmark --color "#34c759"
cmux clear-status agent

cmux set-progress 0.3 --label "运行测试中..."
cmux set-progress 1.0 --label "完成"
cmux clear-progress

cmux log "开始构建"
cmux log --level success "所有测试通过"
cmux log --level error --source build "编译失败"

Script and style injection

通知功能

bash
cmux browser surface:23 addscript "console.log('injected')"
cmux browser surface:23 addstyle "body { background: red; }"
cmux browser surface:23 addinitscript "window.__injected = true"  # runs on every nav

bash
cmux notify --title "任务完成" --body "所有测试通过"
cmux notify --title "需要输入" --subtitle "权限请求" --body "是否批准部署?"

Sidebar Status and Progress

基于cmux的Agent团队协作

Show live status to the user without interrupting their flow:
bash
cmux set-status agent "working" --icon hammer --color "#ff9500"
cmux set-status agent "done" --icon checkmark --color "#34c759"
cmux clear-status agent

cmux set-progress 0.3 --label "Running tests..."
cmux set-progress 1.0 --label "Complete"
cmux clear-progress

cmux log "Starting build"
cmux log --level success "All tests passed"
cmux log --level error --source build "Compilation failed"

使用cmux分屏为每个Agent队友提供独立的可视工作区。通过
SendMessage
和任务列表协作 —— 绝不要通过读取彼此的终端输出协作。

Notifications

协作模式

bash
cmux notify --title "Task Complete" --body "All tests passing"
cmux notify --title "Need Input" --subtitle "Permission" --body "Approve deployment?"

  1. 为每个队友创建分屏
  2. 通过Agent工具生成队友,为每个队友分配cmux上下文引用
  3. 队友通过
    cmux send-surface
    在各自分屏中运行命令
  4. 队友通过
    cmux set-status
    cmux log
    报告状态
  5. 用户可并排查看所有工作进程

Agent Teams with cmux

示例:3-Agent团队

Use cmux splits to give each agent teammate a visible workspace. Coordinate via
SendMessage
and task lists — never via reading each other's terminal output.
bash
undefined

The pattern

为每个队友创建可视分屏

  1. Create splits for each teammate
  2. Spawn teammates via Agent tool — pass each their cmux surface ref
  3. Teammates run commands in their split via
    cmux send-surface
  4. Teammates report status via
    cmux set-status
    and
    cmux log
  5. User sees all work side-by-side
SPLIT_1=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])") SPLIT_2=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])") SPLIT_3=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")

然后在每个队友的提示词中加入:
你拥有一个cmux终端分屏,上下文为surface:42。 运行命令:cmux send-surface --surface surface:42 "command\n" 读取输出:cmux capture-pane --surface surface:42 设置状态:cmux set-status myagent "工作中" --icon hammer 记录进度:cmux log "消息" 绝不抢占焦点 —— 始终使用--surface指定目标。
undefined

Example: 3-agent team

混合布局:终端+浏览器

bash
undefined
bash
BUILD=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
DOCS=$(cmux --json browser open https://docs.example.com | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
TEST=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")

Create visible splits for each teammate

核心规则

SPLIT_1=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])") SPLIT_2=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])") SPLIT_3=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")

Then in each teammate's prompt:
You have a cmux terminal split at surface:42. Run commands: cmux send-surface --surface surface:42 "command\n" Read output: cmux capture-pane --surface surface:42 Set status: cmux set-status myagent "working" --icon hammer Log progress: cmux log "message" Never steal focus — always use --surface targeting.
undefined
  • 绝不要在分屏中运行
    claude -p
    —— 改用带
    team_name
    的Agent工具
  • 先创建分屏再生成队友 —— 在提示词中传递上下文引用
  • 每个队友一个分屏 —— 每个Agent拥有独立的可视工作区
  • 通过SendMessage协作,不要读取彼此的终端输出
  • 完成后清理
    cmux close-surface --surface <ref>

Mixed layout: terminals + browsers

速查手册

bash
BUILD=$(cmux --json new-split right | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
DOCS=$(cmux --json browser open https://docs.example.com | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
TEST=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
任务命令
定位当前环境
cmux identify --json
向右分屏
cmux --json new-split right
向下分屏
cmux --json new-split down
发送命令
cmux send-surface --surface <ref> "cmd\n"
读取输出
cmux capture-pane --surface <ref>
打开浏览器
cmux --json browser open <url>
页面快照
cmux browser <ref> snapshot --interactive
点击元素
cmux browser <ref> click e1
填充输入框
cmux browser <ref> fill e1 "文本"
等待加载
cmux browser <ref> wait --load-state complete --timeout-ms 15000
读取页面文本
cmux browser <ref> get text body
执行JS
cmux browser <ref> eval "表达式"
保存认证状态
cmux browser <ref> state save ./auth.json
设置状态
cmux set-status <key> "文本" --icon <name>
进度条
cmux set-progress 0.5 --label "工作中"
发送日志
cmux log "消息"
发送通知
cmux notify --title "标题" --body "内容"
关闭分屏
cmux close-surface --surface <ref>
捕获截图
cmux browser <ref> screenshot

Key rules

常见模式

在后台分屏运行构建并查看日志

  • Never spawn
    claude -p
    in splits
    — use the Agent tool with
    team_name
    instead
  • Create splits before spawning teammates — pass refs in their prompts
  • One split per teammate — each owns their visible workspace
  • Coordinate via SendMessage, not by reading each other's terminal output
  • Clean up:
    cmux close-surface --surface <ref>
    when done

bash
LOG=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux send-surface --surface "$LOG" "cargo build --release 2>&1 | tee /tmp/build.log\n"

Quick Reference

... 处理其他工作 ...

TaskCommand
Where am I?
cmux identify --json
Split right
cmux --json new-split right
Split down
cmux --json new-split down
Send command
cmux send-surface --surface <ref> "cmd\n"
Read output
cmux capture-pane --surface <ref>
Open browser
cmux --json browser open <url>
Page snapshot
cmux browser <ref> snapshot --interactive
Click element
cmux browser <ref> click e1
Fill input
cmux browser <ref> fill e1 "text"
Wait for load
cmux browser <ref> wait --load-state complete --timeout-ms 15000
Read page text
cmux browser <ref> get text body
Evaluate JS
cmux browser <ref> eval "expression"
Find by role
cmux browser <ref> find role button
Save auth
cmux browser <ref> state save ./auth.json
Load auth
cmux browser <ref> state load ./auth.json
Set status
cmux set-status <key> "text" --icon <name>
Progress bar
cmux set-progress 0.5 --label "Working..."
Log message
cmux log "message"
Notify
cmux notify --title "T" --body "B"
Close split
cmux close-surface --surface <ref>
Screenshot
cmux browser <ref> screenshot

cmux capture-pane --surface "$LOG" --scrollback | tail -20
undefined

Common Patterns

QA测试流程

Run build in background split, tail logs

bash
LOG=$(cmux --json new-split down | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux send-surface --surface "$LOG" "cargo build --release 2>&1 | tee /tmp/build.log\n"
bash
BROWSER=$(cmux --json browser open https://myapp.vercel.app | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux browser $BROWSER wait --load-state complete --timeout-ms 15000
cmux browser $BROWSER snapshot --interactive

... do other work ...

使用e1、e2、e3等引用进行交互...

cmux capture-pane --surface "$LOG" --scrollback | tail -20
undefined
cmux browser $BROWSER screenshot cmux browser $BROWSER errors list cmux close-surface --surface $BROWSER
undefined

QA test flow

状态驱动的长任务

bash
BROWSER=$(cmux --json browser open https://myapp.vercel.app | python3 -c "import sys,json; print(json.load(sys.stdin)['surface_ref'])")
cmux browser $BROWSER wait --load-state complete --timeout-ms 15000
cmux browser $BROWSER snapshot --interactive
bash
cmux set-status task "启动中" --icon clock --color "#ff9500"
cmux set-progress 0.0 --label "初始化..."

Interact using e1, e2, e3 refs...

... 步骤1 ...

cmux browser $BROWSER screenshot cmux browser $BROWSER errors list cmux close-surface --surface $BROWSER
undefined
cmux set-progress 0.33 --label "构建中..."

Status-driven long task

... 步骤2 ...

bash
cmux set-status task "starting" --icon clock --color "#ff9500"
cmux set-progress 0.0 --label "Initializing..."
cmux set-progress 0.66 --label "测试中..."

... step 1 ...

... 步骤3 ...

cmux set-progress 0.33 --label "Building..."
cmux set-progress 1.0 --label "完成" cmux set-status task "已完成" --icon checkmark --color "#34c759" cmux clear-progress cmux notify --title "任务完成" --body "所有步骤已通过"
undefined

... step 2 ...

cmux set-progress 0.66 --label "Testing..."

... step 3 ...

cmux set-progress 1.0 --label "Done" cmux set-status task "complete" --icon checkmark --color "#34c759" cmux clear-progress cmux notify --title "Task complete" --body "All steps passed"
undefined