GeezerVison is showing github.com — fix(desktop): SSH suggestions from known_hosts keep their port by juliusmarminge · Pull Request #35556 · pingdotgg/t3code
Conversation
Item 1 is correct and fixed. sshHostSuggestionValue joined alias and port as alias:port, so a known_hosts IPv6 host on an explicit port ([fd7a:115c:a1e0::1]:2222 -> fd7a:115c:a1e0::1:2222) collided with the bare IPv6 address fd7a:115c:a1e0::1:2222, and the item-press lookup picked the first match. A suggestion with a port is now encoded as OpenSSH's known_hosts form [alias]:port, and portless suggestions stay as the bare alias. This is unambiguous for known_hosts input: a ported value's host part comes from the bracket regex [^\]]+, so it never contains ]. Any portless raw entry of the shape [A]:digits would have matched that regex and been parsed with a port (or dropped when out of range), so no portless known_hosts suggestion can equal a ported one. I checked this by running parseKnownHosts on both reported entries and on adversarial ones ([x]:99999, [x]:abc, [a:b]:22x, [[x]:22]:23, [x]]:22); all produced distinct values. No new regex was added. The rest of the fix from the previous round is unchanged: discovery keeps known_hosts ports and keys suggestions by host and port, and the dialog prefers a suggestion's explicit port over the ssh -G default.
Fixes #35531
Reproduction on main
On origin/main b428418 (Linux, OpenSSH, vp i in a fresh worktree): (1) saved the reporter's test verbatim as packages/ssh/src/zzrepro-ssh-mobile-known-host-ports.test.ts and ran vp test run on it; it failed with AssertionError: expected 2 to equal 3, so three known_hosts entries ([100.64.0.1]:2222, [100.64.0.1]:2223, [fd7a:115c:a1e0::1]:2222) produced two suggestions. The file was then deleted. (2) Added a focused case to packages/ssh/src/config.test.ts that calls production discoverSshHosts on a temporary home directory with those three entries; on main it returns ["100.64.0.1 null", "fd7a:115c:a1e0::1 null"] instead of the three host/port pairs, and the file's other 5 tests pass. Confirmed that the desktop IPC handler (apps/desktop/src/ssh/DesktopSshEnvironment.ts:76) returns discoverSshHosts output unchanged to the Add environment dialog. The Electron dialog itself was not driven.
Evidence
Seed three known_hosts entries: [100.64.0.1]:2222, [100.64.0.1]:2223, and [fd7a:115c:a1e0::1]:2222. In Settings → Environments → Add environment → SSH, open suggestions, then select the first IPv4 entry. Both captures use real Linux Electron, fresh isolated data, light theme, and 1280×900.
The synthetic endpoints time out; OpenSSH's errors confirm the actual attempted ports.
Reproduction: instructions, launcher, interaction and capture driver, synthetic seed, supporting captures and redacted logs.
AI-assisted; verified with the tests and tools listed above.
Not shown:
- Successful SSH authentication and tunnel establishment were not demonstrated because the synthetic endpoints time out.
- IPv6 selection and IPv6 address/port collision handling were not driven; the IPv6 suggestion retaining port 2222 is visible.
Tests
Ran parseKnownHosts on the reported and adversarial entries with node: all suggestion values were distinct. vp run check:changed: format, lint, knip, typecheck (6 packages), tests (3 files), react compiler all pass.
Not in this change
- AddEnvironmentDialog hides known-hosts suggestions whose alias matches a saved environment's alias. After one port of a host is saved, suggestions for that host on its other ports are hidden too.
- Unbracketed IPv6 known_hosts entries and
host:port without brackets are still parsed as before (no port). OpenSSH never writes the latter form.
- Earlier PR fix(ssh): retain known-host ports when connecting #12433 also taught the command builder
ssh:// URI destinations and changed remote-open links. Not needed for this fix.
- An ~/.ssh/config Host alias that is literally
[host]:port (port null) could still match a known_hosts suggestion for that host and port. No real config uses names like that.
AI-assisted; verified with the tests and tools listed above.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Failing regression for #35531: discovery collapses known_hosts entries
that share a host but differ in port, and drops the port.
AI-assisted; verified with the tests and tools listed above.
known_hosts entries recorded as [host]:port lost their port during
discovery, entries for one host on several ports merged into one
suggestion, and picking it connected on port 22.
Discovery now keeps the port and keys known-hosts suggestions by host
and port. The Add environment dialog keeps a suggestion's explicit port
over the `ssh -G` default and tells same-host suggestions apart by port.
Fixes #35531
AI-assisted; verified with the tests and tools listed above.
…esses
Encode a ported suggestion as OpenSSH's bracketed [host]:port so
fd7a::1 on 2222 no longer collides with the bare address fd7a::1:2222.
AI-assisted; verified with the tests and tools listed above.
Approvability
Verdict: Approved at 698ba22
Macroscope's review found this PR approvable — SSH suggestions now retain ports recorded in known_hosts and distinguish the same host on different ports. The change is limited to user-selected connections and leaves product defaults unchanged.
You can add or adjust custom eligibility rules. Learn more.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
21.5 KiB |
21.5 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Codex |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.9 KiB |
21.9 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Claude |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
Other scenarios
All 64 scenario measurements match main.
All 64 scenario measurements
| Provider |
Scenario |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
short turn resume |
WebSocket decoded |
10.5 KiB |
10.5 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Codex |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn running, cold open |
HTTP decoded |
281.7 KiB |
281.7 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Codex |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn running, history page |
HTTP decoded |
92.4 KiB |
92.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Codex |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn finished, cold open |
HTTP decoded |
381.5 KiB |
381.5 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket decoded |
381.6 KiB |
381.6 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, work page |
HTTP decoded |
186.2 KiB |
186.2 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Codex |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Codex |
idle thread resume |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell snapshot |
HTTP decoded |
41.6 KiB |
41.6 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
fleet shell subscribe |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Codex |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Codex |
stale shell reload |
HTTP decoded |
41.6 KiB |
41.6 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Codex |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
HTTP decoded |
72.4 KiB |
72.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Codex |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
short turn resume |
WebSocket decoded |
10.6 KiB |
10.6 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Claude |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn running, cold open |
HTTP decoded |
283.3 KiB |
283.3 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Claude |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn running, history page |
HTTP decoded |
93.4 KiB |
93.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Claude |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn finished, cold open |
HTTP decoded |
384.2 KiB |
384.2 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket decoded |
384.3 KiB |
384.3 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, work page |
HTTP decoded |
188.1 KiB |
188.1 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Claude |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Claude |
idle thread resume |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell snapshot |
HTTP decoded |
42.2 KiB |
42.2 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
fleet shell subscribe |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Claude |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Claude |
stale shell reload |
HTTP decoded |
42.2 KiB |
42.2 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Claude |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
HTTP decoded |
73.4 KiB |
73.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Claude |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
Baseline: 77f40af · PR result: 698ba22 · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 12, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
Known-host parsing and SSH host discovery now retain explicit ports and distinguish destinations that share a hostname. The environment dialog displays port-aware suggestions and applies a discovered port when resolving the selected host.
Changes: SSH known-host port preservation
| Layer / File(s) |
Summary |
Parse and discover hostname-port destinations packages/ssh/src/config.ts, packages/ssh/src/config.test.ts |
Known-host parsing returns hostname-and-port records, and discovery retains entries with distinct ports. Tests cover bracketed ports and separate IPv4 and IPv6 destinations. |
Display and select port-aware suggestions apps/web/src/components/settings/AddEnvironmentDialog.tsx |
Suggestions include the discovered port when present. Selection matches the formatted value and applies the discovered port when resolving the host. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: t3dotgg, maria-rcks
Merge Risk: Minimal · up to 698ba
-
This change keeps explicit SSH ports from known_hosts when suggestions are shown and selected. No actionable merge-blocking risk was identified. The real Electron dialog was not exercised, which is a normal validation gap.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the fix (SSH suggestions from known_hosts keep their port) and the scope (desktop). It matches the main change in config.ts discovery and the AddEnvironmentDialog suggestion value. It … |
| Linked Issues check |
 |
Issue #35531 requires that known_hosts SSH destinations keep their explicit ports, that the same host on different ports stays distinct, and that selecting a suggestion uses the recorded port. The dif… |
| Out of Scope Changes check |
 |
Every changed hunk in packages/ssh/src/config.ts and AddEnvironmentDialog.tsx serves the known_hosts port fix. parseKnownHosts and its KnownHost type replace parseKnownHostsHostnames because the port … |
| Description check |
 |
The description follows the template's main sections: Problem is missing, Change is present, Scope is partly addressed through the linked issue #35531, and Verification is detailed. The author lists t… |
Full details: Title check
-
Explanation
The title names the fix (SSH suggestions from known_hosts keep their port) and the scope (desktop). It matches the main change in config.ts discovery and the AddEnvironmentDialog suggestion value. It uses the conventional commit form the template asks for.
Full details: Linked Issues check
-
Explanation
Issue #35531 requires that known_hosts SSH destinations keep their explicit ports, that the same host on different ports stays distinct, and that selecting a suggestion uses the recorded port. The diff covers each point. In packages/ssh/src/config.ts, parseKnownHostsHost reads the port from the bracketed form [host]:port and keeps it in a KnownHost record. parseKnownHosts keys entries by hostname and port, so [100.64.0.1]:2222 and [100.64.0.1]:2223 both survive. discoverSshHosts sets port on each known-hosts target instead of null. In apps/web/src/components/settings/AddEnvironmentDialog.tsx, sshHostSuggestionValue emits [alias]:port for ported targets. The item-press lookup matches that value. The dialog then overrides the resolved port with target.port when it is present. For [fd7a:115c:a1e0::1]:2222, the hostname is fd7a:115c:a1e0::1 and the port is 2222. The PR also adds config.test.ts coverage for the distinct-port cases. I did not read that test file, so the test result relies on the PR description and summary. The author reports the reproduction failed on main and passes on this head. The real Electron dialog was not driven. Those are verification gaps, not missing code for the requirements.
Full details: Out of Scope Changes check
-
Explanation
Every changed hunk in packages/ssh/src/config.ts and AddEnvironmentDialog.tsx serves the known_hosts port fix. parseKnownHosts and its KnownHost type replace parseKnownHostsHostnames because the port must be carried. The sort and dedupe changes follow from the new record type. The known-hosts discovery key and port assignment carry the port into the target. The dialog changes encode and match the ported suggestion value and prefer the explicit port. None of the changed code touches unrelated behavior. The PR description's 'Not in this change' items (alias hiding in the dialog, unbracketed IPv6 parsing, ssh:// URI support, and the [host]:port config alias edge case) are not part of this diff, so they do not count as out-of-scope changes.
Full details: Description check
-
Explanation
The description follows the template's main sections: Problem is missing, Change is present, Scope is partly addressed through the linked issue #35531, and Verification is detailed. The author lists tests, reproduction steps, and before/after evidence. The title is not in the description. The Problem section is not explicit, although the issue link and the PR objectives make the bug clear. The Scope section does not explain why a bug fix needs no feature review, but it links the issue that shows the bug. The description is mostly complete and substantive.
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 77f40af and 698ba22.
Files selected for processing: 3
-
apps/web/src/components/settings/AddEnvironmentDialog.tsx
packages/ssh/src/config.test.ts
packages/ssh/src/config.ts
Limit details: You’ve used all 10 included reviews currently available.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:M
30-99 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|