Fix #3075: accept named colors in cmux.json and degrade gracefully on parse errors
Summary
Fixes #3075. Before this PR, a single command in cmux.json with a named color (e.g. "color": "Indigo") caused the entire config file to be silently rejected — no commands loaded, cmux reload-config returned OK, and the sidebar showed no error. The decoder only accepted #RRGGBB hex strings, and one rejected command failed the whole top-level JSONDecoder().decode(CmuxConfigFile.self, ...) call.
Two-part fix:
- Accept named palette colors.
CmuxWorkspaceDefinitionnow resolves thecolorfield via a newresolveColor(_:)helper that accepts either a 6-digit hex (with/without#) or a case-insensitive match againstWorkspaceTabColorSettings.defaultPalette(Red, Navy, Indigo, Purple, Charcoal, ...)."Indigo"now resolves to#283593. - Degrade gracefully on parse errors. New
CmuxConfigFile.parseLenient(_:)decodes each command independently. One malformed command (bad color, bad layout, missing fields, etc.) no longer poisons its siblings — it is returned as a warning alongside the commands that did load.CmuxConfigStore.parseConfignow uses this path and logs each warning viaNSLogso misconfigured entries are visible.
This matches the issue's expected behavior: "Both commands appear, or at minimum Echo still appears and a parse warning is logged."
Two-commit structure (per project policy)
- First commit adds failing regression tests only (named-color resolution + lenient parsing). CI should be red.
- Second commit adds the fix. CI should be green.
Repro (from the issue)
{
"commands": [
{
"name": "Indigo Workspace",
"workspace": { "name": "Indigo", "color": "Indigo" }
},
{ "name": "Echo", "command": "echo hi" }
]
}
- Before: neither command appeared; no error shown.
- After: both commands appear; the Indigo workspace uses
#283593. If the color were a typo like"Indigoo", only that command is skipped (with a logged warning), andEchostill appears.
Test plan
- CI: unit tests in
cmuxTests/CmuxConfigTests.swiftpass on the fix commit. - CI: the first commit fails the new tests (proves the tests exercise the bug).
- Manual: place the repro
cmux.jsonin the project root,cmux reload-config, confirm both commands appear in the command palette with the Indigo color on the workspace. - Manual: swap
"Indigo"for"NotARealColor"and confirmEchostill appears in the palette and the system log shows a[CmuxConfig] Skipped commandwarning.
[!NOTE]
Medium Risk
Changes config decoding behavior and error handling, which can affect which commands load from user cmux.json files. Risk is mitigated by added unit tests covering named colors and partial-failure parsing.
Overview
Fixes cmux.json regressions by accepting named palette colors (e.g. "Indigo", case-insensitive) for workspace color, resolving them to normalized hex.
Updates config loading to degrade gracefully on per-command decode failures via CmuxConfigFile.parseLenient, so malformed commands are skipped with logged warnings while valid sibling commands still load, instead of rejecting the entire file.
Reviewed by Cursor Bugbot for commit 62b87418c2da090af5915e4416351ea684c919a1. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
-
New Features
- Added support for named workspace colors (e.g., "Indigo", "Navy") with case-insensitive matching.
-
Bug Fixes
- Configuration parsing is now more resilient; invalid individual commands no longer prevent the entire configuration from loading, with warnings logged for skipped items.
-
Tests
- Added test coverage for named color resolution and lenient parsing behavior.
Summary by cubic
Fix #3075 by accepting named palette colors in cmux.json and making config loading tolerant. A bad command no longer drops the whole file; valid commands still load and a warning is logged.
- Bug Fixes
- Color resolution:
CmuxWorkspaceDefinition.resolveColoraccepts 6-digit hex (with/without#) and case-insensitive names fromWorkspaceTabColorSettings.defaultPalette(e.g. "Indigo" ->#283593). - Lenient loading:
CmuxConfigFile.parseLenientdecodes commands independently and returns warnings;CmuxConfigStore.parseConfiguses it and logs each warning viaNSLog.
- Color resolution: