Skip to content

Add set-color/clear-color workspace actions for tab color via CLI#543

Open
arieltobiana wants to merge 2 commits intomanaflow-ai:mainfrom
arieltobiana:feature/tab-color-cli
Open

Add set-color/clear-color workspace actions for tab color via CLI#543
arieltobiana wants to merge 2 commits intomanaflow-ai:mainfrom
arieltobiana:feature/tab-color-cli

Conversation

@arieltobiana
Copy link

@arieltobiana arieltobiana commented Feb 26, 2026

Summary

  • Expose the existing tab color functionality through the workspace-action CLI command
  • Supports both named colors (Red, Blue, Amber, etc.) and hex values (#RRGGBB)
  • Named colors resolve against WorkspaceTabColorSettings.defaultPalette 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

Implementation

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: Added set_color and clear_color to v2WorkspaceAction. The set_color handler resolves named colors from the built-in palette, falls back to hex validation via normalizedHex(), and returns an error with the list of valid color names if neither matches.

CLI/cmux.swift: Added --color flag parsing to runWorkspaceAction(), updated help text with the new actions, named color list, and examples.

Test plan

  • cmux workspace-action --action set-color --color blue sets tab color to blue
  • cmux workspace-action set-color Amber sets tab color to amber (positional syntax)
  • cmux workspace-action --action set-color --color "#C0392B" sets tab color via hex
  • cmux workspace-action clear-color removes tab color
  • Invalid color name/hex returns error with list of valid named colors
  • cmux workspace-action --help shows new actions, flags, and examples

Summary by CodeRabbit

  • New Features

    • Added color customization for workspaces with support for named colors and hex codes
    • New workspace actions to set and clear workspace colors
    • Color option available as trailing argument or explicit parameter
  • Documentation

    • Updated help text with available color options and usage examples
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
@vercel
Copy link

vercel bot commented Feb 26, 2026

@ariel-wiz is attempting to deploy a commit to the Manaflow Team on Vercel.

A member of the Team first needs to authorize it.

@lawrencecchen
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 2457 to 2460
if let entry = WorkspaceTabColorSettings.defaultPalette.first(where: {
$0.name.caseInsensitiveCompare(colorInput) == .orderedSame
}) {
hex = entry.hex

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Fixed in 1506c65 — now using palette() instead of defaultPalette so user overrides are respected, matching the context menu behavior.

@lawrencecchen
Copy link
Contributor

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

Adds color support for workspace tabs through a new --color CLI option and two new workspace actions (set_color and clear_color). Colors are validated, resolved from named colors or hex values, and applied via tabManager with results included in response payloads.

Changes

Cohort / File(s) Summary
CLI color option
CLI/cmux.swift
Introduces --color option for workspace-action workflow with validation, resolution, and help text updates. Color is appended to payload and summary output.
Workspace color actions
Sources/TerminalController.swift
Implements set_color and clear_color v2 workspace actions with color validation, named/hex color resolution, tabManager integration, and error handling with suggestions.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Issue #635: Directly addresses color support for workspace tabs, aligning with the objective of implementing workspace color customization via --color CLI option and corresponding workspace actions.

Poem

🎨 A rabbit hops through colors bright,
With --color flags of pure delight,
Set or clear, in hex or named with care,
Tab colors blossom everywhere! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding set-color and clear-color workspace actions for tab color functionality accessible via the CLI.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Avoid forwarding title when action is set-color via trailing positional input.

On Line 1998-Line 2019, the same inferred positional token is used for both title and color, so workspace-action set-color Amber sends title=Amber and color=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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2dea894 and 1506c65.

📒 Files selected for processing (2)
  • CLI/cmux.swift
  • Sources/TerminalController.swift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants