Add --name flag to new-workspace CLI command (#2160)

Allow naming a workspace at creation time instead of requiring a
separate rename-workspace call afterward.

Threads a title parameter through:
- CLI: --name <title> flag parsed and sent as "title" in v2 params
- V2 handler: extracts title, passes to TabManager.addWorkspace()
- TabManager: uses provided title instead of auto-generated
  "Terminal N" and calls setCustomTitle() to persist it
- V1 handler: accepts optional name argument

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Usman Ehtesham Gul 2026-03-26 18:18:20 -04:00 committed by GitHub
parent 0978732c93
commit 66b0260442
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 8 deletions

View file

@ -1684,15 +1684,19 @@ struct CMUXCLI {
case "new-workspace":
let (commandOpt, rem0) = parseOption(commandArgs, name: "--command")
let (cwdOpt, remaining) = parseOption(rem0, name: "--cwd")
let (cwdOpt, rem1) = parseOption(rem0, name: "--cwd")
let (nameOpt, remaining) = parseOption(rem1, name: "--name")
if let unknown = remaining.first(where: { $0.hasPrefix("--") }) {
throw CLIError(message: "new-workspace: unknown flag '\(unknown)'. Known flags: --command <text>, --cwd <path>")
throw CLIError(message: "new-workspace: unknown flag '\(unknown)'. Known flags: --name <title>, --command <text>, --cwd <path>")
}
var params: [String: Any] = [:]
if let cwdOpt {
let resolved = resolvePath(cwdOpt)
params["cwd"] = resolved
}
if let nameOpt {
params["title"] = nameOpt
}
let response = try client.sendV2(method: "workspace.create", params: params)
let wsId = (response["workspace_ref"] as? String) ?? (response["workspace_id"] as? String) ?? ""
print("OK \(wsId)")
@ -6338,16 +6342,18 @@ struct CMUXCLI {
"""
case "new-workspace":
return """
Usage: cmux new-workspace [--cwd <path>] [--command <text>]
Usage: cmux new-workspace [--name <title>] [--cwd <path>] [--command <text>]
Create a new workspace in the current window.
Flags:
--name <title> Set a custom name for the new workspace
--cwd <path> Set the working directory for the new workspace
--command <text> Send text+Enter to the new workspace after creation
Example:
cmux new-workspace
cmux new-workspace --name "Build Server"
cmux new-workspace --cwd ~/projects/myapp
cmux new-workspace --cwd . --command "npm test"
"""
@ -12087,7 +12093,7 @@ struct CMUXCLI {
reorder-workspace --workspace <id|ref|index> (--index <n> | --before <id|ref|index> | --after <id|ref|index>) [--window <id|ref|index>]
workspace-action --action <name> [--workspace <id|ref|index>] [--title <text>] [--color <name|#hex>]
list-workspaces
new-workspace [--cwd <path>] [--command <text>]
new-workspace [--name <title>] [--cwd <path>] [--command <text>]
ssh <destination> [--name <title>] [--port <n>] [--identity <path>] [--ssh-option <opt>] [-- <remote-command-args>]
remote-daemon-status [--os <darwin|linux>] [--arch <arm64|amd64>]
new-split <left|right|up|down> [--workspace <id|ref>] [--surface <id|ref>] [--panel <id|ref>]