cmux mcp: `current` is the agent's own place; new terminals and links open beside its chat
Merged
LA
12d ago+897+897+012345678901234567890123456789-9-9-0123456789
Problem
Two bugs, one cause: when an agent named no place, the call went to the daemon's notion of "here", not to the agent's chat.
- A
cmux_execscript that splitworkspace: "current"split another workspace. The daemon readscurrentas its active object, and that is neither the chat's workspace nor always the one the app shows. In one live check these were three different workspaces. - A workspace agent (Chief TUI + fast iteration) asked to "open it to the right" opened the Chief TUI in Home.
tab_create_terminalwith no pane went to the daemon's active pane, andworkspace_open_urlwith no workspace defaults to the home workspace.
Change
currentincmux mcp serveis the calling chat's own workspace, screen, pane, or tab. The server asks the app on each call (system.identify), so a moved chat is followed.focusedis new: it means what the app shows (snapshot.get). Under another object,currentkeeps the daemon's meaning (the active child). A caller the app cannot place fails withcaller.unresolved, not with a guess. A client with no caller identity, or a call to another session, keeps the old behavior. (cli/mcp/caller_scope.rs)- Beside the chat (
cli/beside.rs, one rule for the CLI and MCP): an agent's terminal that names no workspace, screen, or pane goes to the column right of its chat. With no such column, a split right of the chat makes one (viewport_width0.66) and the tab gets its name. An MCP link with no workspace goes to the app'sbrowser.open_split, so the existingbeside_callerrule places it. A person's terminal (noCMUX_AGENT_SESSION) and a named place keep their target. - The
cmux-workspaceskill gets these rules and a section on larger layouts beside a chat: dock the chat left, a column per task, splits for views read together, and widths.
Evidence
cargo test -p cmux-tui --lib -- cli::mcp cli::beside: 107 passed (16 new). Fourcli::appandremote_clitests fail in my shell with and without this change (they read the agent env).- Dogfood with the branch binary against cmux NIGHTLY:
currentresolved to the chat's screen while the app showed another workspace.focusedresolved to the shown one.- As the Chief TUI agent:
tab_create_terminalwith no place made a column in its own workspace (Home tab count 15 → 15), a second call reused it, andcmux tab create terminalfrom the CLI used it too. A link went tobeside_callerin its own workspace. A person's terminal with no agent env stayed in its old pane. - Splitting the docked chat is refused by the daemon (
dock-column-agent-chat), as it should be. - Built 3 layouts (3 columns with splits, a 2×2 grid, a browser column) only through
current, then closed them. - Cost: about 97 ms for a
currentcall, against 75 ms by id (one app round trip).
Not done
- The CLI's own
currentstill means the daemon's active object. Moving caller resolution into the daemon would make the CLI and MCP agree. app_column_dock_leftrefuses the chat pane with "not shown in any window" while it is shown. Not fixed here.
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.