Add sidebar metadata CLI subcommands and API docs (#305)
* Add sidebar metadata CLI subcommands and API docs Expose set-status, clear-status, list-status, set-progress, clear-progress, log, clear-log, list-log, and sidebar-state as proper CLI subcommands with --help support and usage() listing. Previously these only existed as raw socket commands. Also adds a "Sidebar metadata commands" section to the docs site API reference page. * Quote multi-word values in socket command strings Fix set-progress --label and log message forwarding to properly quote values before sending to the socket tokenizer. Without quoting, multi-word labels like "Build step one" would be split into separate tokens. Also quote --source values for consistency. * Fix socket quoting: escape backslashes and quote status values Add socketQuote() helper that escapes both backslashes and double quotes before wrapping in quotes. Apply it to: - set-status value (prevents --flags in values being parsed as options) - set-status --icon and --color values - set-progress --label - log --source and message text Fixes values like "pytest --maxfail=1" or "C:\new\build" being mangled by the socket tokenizer. * Escape newlines in socketQuote to prevent socket framing breakage The socket protocol uses newline as message terminator, so embedded newlines/carriage returns in values would truncate the command. * Parse flags before positionals in set-status, clear-status, set-progress Fixes flags-first invocation like `cmux set-status --workspace workspace:2 build compiling` which previously grabbed `--workspace` as the key. Now all flags are extracted first, then positional args are validated.
This commit is contained in:
parent
6d64ca938e
commit
f7457055f1
2 changed files with 322 additions and 1 deletions
|
|
@ -5,7 +5,7 @@ import { Callout } from "../../components/callout";
|
|||
export const metadata: Metadata = {
|
||||
title: "API Reference",
|
||||
description:
|
||||
"cmux CLI and Unix socket API reference. Workspace management, split panes, input control, notifications, environment variables, and detection methods.",
|
||||
"cmux CLI and Unix socket API reference. Workspace management, split panes, input control, notifications, sidebar metadata (status, progress, logs), environment variables, and detection methods.",
|
||||
};
|
||||
|
||||
function Cmd({
|
||||
|
|
@ -281,6 +281,74 @@ cmux list-notifications --json`}
|
|||
socket={`{"id":"notif-clear","method":"notification.clear","params":{}}`}
|
||||
/>
|
||||
|
||||
<h2>Sidebar metadata commands</h2>
|
||||
<p>
|
||||
Set status pills, progress bars, and log entries in the sidebar for any
|
||||
workspace. Useful for build scripts, CI integrations, and AI coding
|
||||
agents that want to surface state at a glance.
|
||||
</p>
|
||||
|
||||
<Cmd
|
||||
name="set-status"
|
||||
desc="Set a sidebar status pill. Use a unique key so different tools can manage their own entries."
|
||||
cli={`cmux set-status build "compiling" --icon hammer --color "#ff9500"
|
||||
cmux set-status deploy "v1.2.3" --workspace workspace:2`}
|
||||
socket={`set_status build compiling --icon=hammer --color=#ff9500 --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="clear-status"
|
||||
desc="Remove a sidebar status entry by key."
|
||||
cli={`cmux clear-status build`}
|
||||
socket={`clear_status build --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="list-status"
|
||||
desc="List all sidebar status entries for a workspace."
|
||||
cli={`cmux list-status`}
|
||||
socket={`list_status --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="set-progress"
|
||||
desc="Set a progress bar in the sidebar (0.0 to 1.0)."
|
||||
cli={`cmux set-progress 0.5 --label "Building..."
|
||||
cmux set-progress 1.0 --label "Done"`}
|
||||
socket={`set_progress 0.5 --label=Building... --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="clear-progress"
|
||||
desc="Clear the sidebar progress bar."
|
||||
cli={`cmux clear-progress`}
|
||||
socket={`clear_progress --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="log"
|
||||
desc="Append a log entry to the sidebar. Levels: info, progress, success, warning, error."
|
||||
cli={`cmux log "Build started"
|
||||
cmux log --level error --source build "Compilation failed"
|
||||
cmux log --level success -- "All 42 tests passed"`}
|
||||
socket={`log --level=error --source=build --tab=<workspace-uuid> -- Compilation failed`}
|
||||
/>
|
||||
<Cmd
|
||||
name="clear-log"
|
||||
desc="Clear all sidebar log entries."
|
||||
cli={`cmux clear-log`}
|
||||
socket={`clear_log --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="list-log"
|
||||
desc="List sidebar log entries."
|
||||
cli={`cmux list-log
|
||||
cmux list-log --limit 5`}
|
||||
socket={`list_log --limit=5 --tab=<workspace-uuid>`}
|
||||
/>
|
||||
<Cmd
|
||||
name="sidebar-state"
|
||||
desc="Dump all sidebar metadata (cwd, git branch, ports, status, progress, logs)."
|
||||
cli={`cmux sidebar-state
|
||||
cmux sidebar-state --workspace workspace:2`}
|
||||
socket={`sidebar_state --tab=<workspace-uuid>`}
|
||||
/>
|
||||
|
||||
<h2>Utility commands</h2>
|
||||
|
||||
<Cmd
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue