cmux NEXT tabs: remote SSH and remote-localhost tab badges wear the machine's sidebar color

Merged
TE
14d ago
+62-6

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.
  • PaneController sets TabItem.machineName from it for remote terminals and remote-localhost browser tabs. TabCell is unchanged, and its ?? badge fallback still covers tabs with no known machine.

Evidence

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 Autofix with [code]smith
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.
  • PaneController uses the color name for remote terminals and remote-localhost browser tabs; TabCell's ?? badge fallback still covers tabs with no known machine.
  • Adds TabMachineColorTests.swift covering SSH-host terminal and remote-localhost badges, plus "this Mac" and unknown-machine fallbacks.