cmux device list: ~/.ssh/config hosts as computers to add
Leo asked: "and why dont i see that the acpmux things are there? how is our setup flow anyways? like cmux-next remote and whatnot" and "plus the fucking qr code or whatever easy setup for my phone just like codex".
This is one of four PRs that make "add a machine" one or two clicks with no terminal step:
- #25822: the daemon a machine gets is kept current;
- #25939: the app's checklist row for #25822's step;
- this one: Add Device also lists
~/.ssh/confighosts; - #25823: an "Add Machine…" row in the environment picker, and New Cloud VM… in Add Device. It reads this PR's
foundfield.
Split out of #25822 to keep each PR under about 800 lines.
What changes
cmux device list --json feeds Add Device's "On your network" list. It now also lists the concrete Host names of ~/.ssh/config, includes followed, after the network's computers.
- Each such row carries
"found": "ssh-config". Network rows say"found": "network". - Machines with no tailnet now show up too. Before, a Mac without Tailscale listed nothing, and the person had to type a host into Add Machine.
- A host is left out when its alias, or its
HostName, is already:- a device;
- a peer (by name or URL host);
- a tailnet node, online or not;
- a git forge (github.com, gitlab.com, …).
machine_runtime's ssh config reader (used by the machine list already) also records each concrete alias's firstHostName, with%hexpanded. It reads it the way ssh does:- the first
HostNameread for a host wins, in the order the lines are read. AHostNamebefore the firstHostline holds for every host, unless that host's own was read earlier (from anIncludeabove it, say); - an
Includecounts where it stands; - an
Includeinside aHostblock counts only for that block's hosts, even when the included file has its ownHostlines; HostName=x,HostName = xandHostName =xall read asx;- a negated pattern (
Host lab !lab,!*.corp) keeps the block, and the includes under it, from the hosts it matches; - wildcard blocks and
Matchare not read.
- the first
The header line of the human output says "Not added yet (your network and ~/.ssh/config):".
Add Device shows these rows under the network's problem when Tailscale is missing or down. That rendering is in #25823. Without it, the card shows the problem as it does today, with no rows.
Risk
Low. This is a read-only listing of the person's own ssh config, and adding a host still goes through Add Machine's enroll, which needs a click.
- An alias may be unreachable or unsuitable (a jump host, say) and still show up as a row. If
reachfails, enrollment stops with an explanation before it changes anything. - The order of
ssh_config_hosts()for the machine list is unchanged.
Tests
devices::tests::ssh_config_hosts_follow_the_network_computers_without_repeats:- rows follow the network's computers;
- devices, peers, tailnet nodes and forges are left out, by alias and by
HostName; - with no network, the ssh hosts still list.
machine_runtime::tests:ssh_config_discovery_reads_each_hosts_first_host_name: first wins,%h, patterns andMatch;a_host_name_from_an_include_counts_where_the_include_stands: an include before a block; an include inside one, whose ownHostlines never reach a host outside that block; a cycle;a_negated_host_keeps_its_block_and_includes_from_that_host: exact and wildcard negations, and an include under one;a_host_name_before_any_host_line_is_every_hostsanda_host_s_own_name_read_before_the_global_one_wins: a globalHostNameagainst a host's own, in both orders;a_host_name_may_be_set_with_an_equals_sign: every=spelling.
- Runs at this head on a Linux testbox:
cargo fmt --all --check;cargo test -p cmux-tui --lib -- devices:: machine_runtime::(35 passed); clippy-D warnings, clean.
Agent session: agent session
🤖 Generated with Claude Code