cmux NEXT: machine name uses the local host name, not a DHCP/reverse-DNS gethostname

Merged
TE
13d ago
+74-6

What was wrong

MacName fell back to the kernel host name (gethostname) for the machine identity. On a Mac on DHCP or with reverse DNS, gethostname returns a name like dhcp-10-0-1-5 or an ISP reverse-DNS label instead of the name the owner chose. So the name cmux shows for the Mac (sidebar, tab machine badge, composer) and the color hashed from it could be junk and could change from one network to the next.

Fix

  • MacName.hostName() (new): the Bonjour LocalHostName the owner set in System Settings > General > Sharing (SCDynamicStoreCopyLocalHostName, a configd read with no DNS lookup). It falls back to the kernel host name only when that is empty.
  • displayName() and the computerName() fallback (resolve) now use it. The choice is a pure nonisolated static func hostName(localHost:kernel:) / displayName(computer:localHost:kernel:).
  • The local daemon's identity fallbacks in RemoteTerminalService.machineName and RemoteTerminalService+Moves.sessionName use MacName().hostName().
  • Unchanged on purpose: linkDeviceName() (it names an existing Cloud link device, so renaming it would break linking), plus TerminalLinkResolver and ServerReachService (they match every name the Mac answers to, gethostname included).

Tests

MacNameHostTests in Packages/macOS/CmuxNext/Tests/CmuxNextAppTests/MacNameTests.swift: the local host name beats a DHCP kernel name (in both hostName and displayName), and the kernel name is used when the local host name is nil, empty or blank.

  • Red, test-only commit 47e124e6e94227a8d9f3d717c48da58390b28cf5: fleet step aacfa5cfc5b52b1313c94dcf (cmux-ci log aacfa5cfc5b52b1313c94dcf): queued on the fleet; result to follow
  • Green, head 01377c63bc7c56aca452c5b1635fb1f03abba403: fleet step 335fabd9a2fc03747410333d (MacNameTests,MacNameHostTests): queued on the fleet; result to follow
  • App compile, head 01377c63bc7c56aca452c5b1635fb1f03abba403: cmux-ci compile-check --app job b9496797694eac539175fcdb: passed (61 s)
  • Local: check-no-godfiles.sh --only swift --base origin/feat-cmux-next on the changed files passes. crash_ratchet.py has no hits in this diff; its one hit (rust acpmux unwrap 179 -> 180) is on base.

No capture: name-source logic, no visual 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 the Mac machine name cmux shows (sidebar, tab badge, composer, and the color hashed from it) so it's the owner-set Bonjour local host name from Sharing, not the kernel host name, which DHCP or reverse DNS can replace with unstable names like dhcp-10-0-1-5.

  • New MacName.hostName() returns the local host name via SCDynamicStoreCopyLocalHostName (no DNS lookup) and falls back to the kernel host name only when empty; it answers from a cached read done off the main actor, so main-actor paths never wait on configd.
  • displayName(), the computer-name fallback, and the local daemon's identity fallbacks in RemoteTerminalService now use it.
  • linkDeviceName, TerminalLinkResolver, and ServerReachService intentionally keep the kernel host name.