Add set-color/clear-color workspace actions for tab color via CLI#543
Add set-color/clear-color workspace actions for tab color via CLI#543arieltobiana wants to merge 2 commits intomanaflow-ai:mainfrom
Conversation
Expose the existing tab color functionality through the workspace-action CLI command, enabling programmatic tab color setting without the GUI context menu. Supports both named colors (Red, Blue, Amber, etc.) and hex values (#RRGGBB). Named colors resolve against the built-in palette via case-insensitive matching. Usage: cmux workspace-action --action set-color --color blue cmux workspace-action --action set-color --color "#C0392B" cmux workspace-action set-color Amber cmux workspace-action clear-color
|
@ariel-wiz is attempting to deploy a commit to the Manaflow Team on Vercel. A member of the Team first needs to authorize it. |
abb4bb6 to
4ddd880
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ddd880919
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sources/TerminalController.swift
Outdated
| if let entry = WorkspaceTabColorSettings.defaultPalette.first(where: { | ||
| $0.name.caseInsensitiveCompare(colorInput) == .orderedSame | ||
| }) { | ||
| hex = entry.hex |
There was a problem hiding this comment.
Resolve named tab colors using overridden palette
set_color currently maps names against WorkspaceTabColorSettings.defaultPalette, which is the hardcoded base palette, so users who changed default tab colors in settings get the wrong hex when they run workspace-action set-color <name>. This diverges from existing UI behavior (the context menu uses WorkspaceTabColorSettings.palette() in Sources/ContentView.swift) and from the override-aware helper WorkspaceTabColorSettings.defaultColorHex(...) in Sources/TabManager.swift, so CLI/socket color actions can silently apply unexpected colors for configured environments.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch! Fixed in 1506c65 — now using palette() instead of defaultPalette so user overrides are respected, matching the context menu behavior.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4ddd880919
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolve named colors against palette() instead of defaultPalette so that user-customized color overrides are respected, matching the behavior of the context menu UI.
📝 WalkthroughWalkthroughAdds color support for workspace tabs through a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as CLI Handler
participant Controller as TerminalController
participant TabMgr as TabManager
User->>CLI: Provide --color option with value
CLI->>CLI: Validate color (non-empty for set_color)
CLI->>Controller: Call workspace.action with color in params
Controller->>Controller: Resolve color (named or hex)
alt Valid Color
Controller->>TabMgr: setTabColor(tabId, resolved_hex)
TabMgr->>TabMgr: Apply color to workspace tab
Controller->>Controller: Include color in response payload
Controller->>User: Return success with color
else Invalid Color
Controller->>User: Return invalid_params error with suggestions
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
CLI/cmux.swift (1)
1998-2019:⚠️ Potential issue | 🟡 MinorAvoid forwarding
titlewhen action isset-colorvia trailing positional input.On Line 1998-Line 2019, the same inferred positional token is used for both
titleandcolor, soworkspace-action set-color Ambersendstitle=Amberandcolor=Amber. This couples unrelated params and can cause action-specific payload drift.♻️ Proposed fix
- let inferredTitle = positional.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines) - let title = (titleOpt ?? (inferredTitle.isEmpty ? nil : inferredTitle))?.trimmingCharacters(in: .whitespacesAndNewlines) + let inferredPositional = positional.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines) + let title = titleOpt?.trimmingCharacters(in: .whitespacesAndNewlines) if action == "rename", (title?.isEmpty ?? true) { throw CLIError(message: "workspace-action rename requires --title <text> (or a trailing title)") } - let color = colorOpt ?? (action == "set_color" ? (inferredTitle.isEmpty ? nil : inferredTitle) : nil) + let renameTitle = action == "rename" + ? ((titleOpt ?? (inferredPositional.isEmpty ? nil : inferredPositional))?.trimmingCharacters(in: .whitespacesAndNewlines)) + : title + let color = colorOpt ?? (action == "set_color" ? (inferredPositional.isEmpty ? nil : inferredPositional) : nil) if action == "set_color", (color?.isEmpty ?? true) { throw CLIError(message: "workspace-action set-color requires --color <name|#hex> (or a trailing color)") } var params: [String: Any] = ["action": action] if let workspaceId { params["workspace_id"] = workspaceId } - if let title, !title.isEmpty { - params["title"] = title + if action == "rename", let renameTitle, !renameTitle.isEmpty { + params["title"] = renameTitle } if let color, !color.isEmpty { params["color"] = color }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@CLI/cmux.swift` around lines 1998 - 2019, The inferred positional token is being used for both title and color causing e.g. workspace-action set-color Amber to include title=Amber; change the title construction so the inferredTitle is only used when the action is not "set_color" (keep the existing titleOpt override), i.e. in the title assignment check action != "set_color" before falling back to inferredTitle, and keep the existing guards that only add params["title"] when title is non-empty; reference the variables inferredTitle, titleOpt, colorOpt, action, title, color and params to locate and update the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@CLI/cmux.swift`:
- Around line 1998-2019: The inferred positional token is being used for both
title and color causing e.g. workspace-action set-color Amber to include
title=Amber; change the title construction so the inferredTitle is only used
when the action is not "set_color" (keep the existing titleOpt override), i.e.
in the title assignment check action != "set_color" before falling back to
inferredTitle, and keep the existing guards that only add params["title"] when
title is non-empty; reference the variables inferredTitle, titleOpt, colorOpt,
action, title, color and params to locate and update the logic.
Summary
workspace-actionCLI commandRed,Blue,Amber, etc.) and hex values (#RRGGBB)WorkspaceTabColorSettings.defaultPalettevia case-insensitive matchingUsage
cmux workspace-action --action set-color --color blue cmux workspace-action --action set-color --color "#C0392B" cmux workspace-action set-color Amber cmux workspace-action clear-colorImplementation
No new infrastructure needed — this wires up the existing
tabManager.setTabColor(tabId:color:)method (used by the right-click context menu) to the socket-based CLI.Sources/TerminalController.swift: Addedset_colorandclear_colortov2WorkspaceAction. Theset_colorhandler resolves named colors from the built-in palette, falls back to hex validation vianormalizedHex(), and returns an error with the list of valid color names if neither matches.CLI/cmux.swift: Added--colorflag parsing torunWorkspaceAction(), updated help text with the new actions, named color list, and examples.Test plan
cmux workspace-action --action set-color --color bluesets tab color to bluecmux workspace-action set-color Ambersets tab color to amber (positional syntax)cmux workspace-action --action set-color --color "#C0392B"sets tab color via hexcmux workspace-action clear-colorremoves tab colorcmux workspace-action --helpshows new actions, flags, and examplesSummary by CodeRabbit
New Features
Documentation