Remove index-based CLI APIs, make commands workspace-relative
Merged
LA
9mo ago+673+673+012345678901234567890123456789-418-418-012345678901234567890123456789
Summary
- Migrate 14 CLI commands from v1 text protocol to v2 JSON-RPC, making all commands workspace-relative via
CMUX_WORKSPACE_IDenv var fallback - Update 7 more commands to use normalize functions instead of legacy index-based resolvers
- Remove dead code: 5 structs, 5 parsers, 3 utility functions (net -117 lines in cmux.swift)
- Add regression tests for workspace-relative behavior and id-format defaults
Motivation
When Claude Code runs cmux send "echo hello" from a background workspace, the text currently goes to whichever workspace the user is looking at (v1 resolves to tabManager.selectedTabId). After this change, commands use the caller's CMUX_WORKSPACE_ID by default, targeting the correct workspace.
Commands migrated v1āv2 (14)
| Command | V2 Method | New flags |
|---|---|---|
send | surface.send_text | --workspace, --surface |
send-key | surface.send_key | --workspace, --surface |
send-panel | surface.send_text | --workspace |
send-key-panel | surface.send_key | --workspace |
new-split | surface.split | --workspace, --surface |
new-pane | pane.create | --workspace |
new-surface | surface.create | --workspace |
close-surface | surface.close | --workspace |
list-panes | pane.list | --workspace |
list-pane-surfaces | pane.surfaces | --workspace |
list-panels | surface.list | env fallback |
surface-health | surface.health | env fallback |
focus-pane | pane.focus | --workspace |
focus-panel | surface.focus | --workspace |
Commands updated (7)
move-workspace-to-window, list-workspaces, close-workspace, select-workspace, trigger-flash, resolveWorkspaceId, resolveSurfaceId ā switched from v1 parsers to normalize functions with ref handle support.
Dead code removed
- Structs:
WorkspaceInfo,PanelInfo,PaneInfo,PaneSurfaceInfo,SurfaceHealthInfo - Parsers:
parseWorkspaces,parsePanels,parsePanes,parsePaneSurfaces,parseSurfaceHealth - Functions:
formatLegacySurfaceResponse,escapeText,remainingArgs
Test plan
-
xcodebuildCLI target builds successfully - Run
tests_v2/test_workspace_relative.pyon VM - Run
tests_v2/test_cli_id_format_defaults.pyon VM - Manual smoke test:
cmux send,cmux list-panes,cmux new-split rightfrom terminal inside cmux - Verify CMUX_WORKSPACE_ID env var scopes commands correctly