cmux NEXT tabs: remote SSH and remote-localhost tab badges wear the machine's sidebar color
What was wrong
Machine identity (#22763) colors a tab's machine badge with MachineColor(name: item.machineName ?? badge). Plain terminal tabs on a remote tree set machineName to the machine's sidebar name, but two kinds of tab set only the badge text:
- remote SSH terminal tabs (
RemoteTerminalService.badge) - remote-localhost browser tabs (
RemoteLocalhostService.badge)
Both badges show MachineRegistry.machineBadge, which for an SSH host is its destination (leo@huge-blue.tail1.ts.net gives "huge-blue"). The sidebar name is MachineRegistry.machineName, which for an SSH host is its label (for example "lab"). These tabs therefore hashed "huge-blue" and showed a different color from the machine's sidebar rows and composer chip, which hash "lab".
The fix
- New
MachineRegistry.tabColorName(_:badge:): when the badge is that machine's own short name, it returns the machine's sidebar name. It returns nil for any other badge (a "this Mac" chip) and for a machine not known here. RemoteTerminalService.badge(for:)now returns the badge text together with that color name.PaneControllersetsTabItem.machineNamefrom it for remote terminals and remote-localhost browser tabs. TabCell is unchanged, and its?? badgefallback still covers tabs with no known machine.
Evidence
- Red (test-only commit 67767296b2460224406ec94d8df1057913f9046d): pending (fleet step 8383b9b6d6d16ada00f4c7fe, queued)
- Green (head 064c81ba9768453e8af48cda6b5b22a0909bc6d9): pending (fleet step 74051e3bcbb3406921dfadb9, queued)
cmux-ci compile-check --appat the head: passed (job 5231ff6c1a133534f5c7f7bc, 44 s).
Test: CmuxNextAppTests/TabMachineColorTests.swift adds an SSH host named "lab" at leo@huge-blue. It checks that the terminal badge and the remote-localhost badge both take their color from "lab", and that other badges and unknown machines keep the badge text.
No capture: the badge's color changes only for a remote SSH terminal or remote-localhost browser tab whose SSH host has a label different from its destination. No capture scene or showcase fixture has an SSH machine or a remote-terminal tab (CaptureSceneRegistry*, DebugShowcase), so a fleet capture would show the same stills before and after. TabMachineColorTests checks the color name instead. Badge text and layout do not change.
Agent session: cosmic-gray
🤖 Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Summary by cubic
Fixes remote SSH terminal and remote-localhost browser tab badges so they take the machine's sidebar color instead of hashing the badge text (an SSH host's destination, e.g. "huge-blue", rather than its label "lab"). Adds MachineRegistry.tabColorName(_:badge:) to return the sidebar name when the badge is the machine's own short name, and has RemoteTerminalService and PaneController feed it to TabItem.machineName. Other badges (a "this Mac" chip) and machines not known here keep the badge text's color.
RemoteTerminalService.badge(for:)now returns the badge text and its color name.PaneControlleruses the color name for remote terminals and remote-localhost browser tabs;TabCell's?? badgefallback still covers tabs with no known machine.- Adds
TabMachineColorTests.swiftcovering SSH-host terminal and remote-localhost badges, plus "this Mac" and unknown-machine fallbacks.