Skip to content

fix: flag a config host whose machine is already registered under another name - #15750

Closed
kaluli123123 wants to merge 5 commits into
stablyai:mainfrom
kaluli123123:fix/orca-ssh-duplicate-endpoint
Closed

kaluli123123 wants to merge 5 commits into
stablyai:mainfrom
kaluli123123:fix/orca-ssh-duplicate-endpoint

Conversation

@kaluli123123

@kaluli123123 kaluli123123 commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Add a machine by IP, then open the ssh-config picker: the same box shows up as new, because Orca compared the names and 172.16.203.131 is not the string aimp. Now it also compares where the entry actually connects, so the picker says it is already there.

What Changed

Endpoint identity is a NUL-separated tuple of case-insensitive hostname, validated port, case-sensitive SSH username, saved jump host, and saved proxy command. The parser-only picker passes each entry's ProxyJump and ProxyCommand to that shared identity; it does not spawn ssh -G per row.

searchSshConfigHosts marks a row alreadyInOrca when its alias/label or complete configured endpoint matches a saved target. Different users, ports, jump hosts, and proxy commands remain distinct. Entries without HostName retain alias-only matching.

Why

The duplicate check was name-only, so two names for one machine both pass:

manual   { label: 'AI Box', configHost: '172.16.203.131', host: '172.16.203.131' }
picker   Host aimp / HostName 172.16.203.131

Nothing there is string-equal. Both targets then connect to the same endpoint and attach to the same relay daemon, so they list the same remote sessions and operating either one drives the same underlying ones — from the UI it looks like clicking one host also clicks the other.

alreadyInOrca disables a picker row and makes Add all skip it; it is an admission gate, not merely a display flag. The route fields prevent distinct private endpoints behind different jump hosts or proxy commands from being incorrectly blocked, addressing the maintainer request. This change does not add a non-blocking possible-duplicate UI or resolve DNS aliases.

Scope: this does not cover the reporter's own config

Only entries carrying HostName participate in the endpoint check, guarded by entry.hostname. Without it, sshConfigHostsToTargets degrades the candidate host to the alias itself (entry.hostname || entry.host), and matching on that would both re-run the alias check and let unrelated aliases collide — there is a test pinning that alpha/beta/gamma stay unflagged.

That bounds what this fixes. In #15478 the persisted record is:

{"label": "aimp", "configHost": "aimp", "host": "aimp"}

host landed as aimp, not the IP — so that Host aimp block has no HostName, and the address resolves through DNS or /etc/hosts. The suggested fix of resolving through ssh -G would not close it either: ssh -G aimp echoes hostname aimp when no HostName is configured, because it does not resolve names. Covering that case needs real name resolution in the duplicate check, which is network I/O whose answer moves with the environment — a separate decision, not something to fold in here.

I have posted that finding on the issue.

Linked Issue

Related: #15478 — configured endpoint duplicate detection only; this does not claim to resolve the hostname-only/DNS case described below.

Visual Proof

Not attached. The duplicate decision changes row availability and bulk-add behavior. Parser/picker regressions and a production-module smoke are not before/after UI proof; real dialog/platform validation remains outstanding.

Testing

  • Manually tested through the actual Add-Remote-Host dialog. Direct function/parser execution is automated/local smoke evidence, not a human UI attestation.
  • Automated tests added/updated, or explained why not below

Three picker cases: same machine under a different label, flagged; a different machine, unflagged; config entries with no HostName, still unflagged and non-colliding. Pure-function cases cover port defaulting and valid boundaries, NUL separation, hostname case folding, case-sensitive SSH usernames, empty/whitespace/missing hosts, and invalid ports falling back to 22.

Check Result
src/main/ssh + new pure-function suite + IPC + sidebar consumers 111 files / 1615 passed
pnpm run typecheck (node + cli + web) exit 0
oxlint / oxfmt clean

Red to green: the "same machine, different label" assertion was written first and observed failing. The other two picker cases passed before and after — which is the point, since this widens the match rather than changing existing behaviour.

Historical verification recorded on 2026-10-21 (8daf21370b, not the current head): 28 focused helper/picker regressions and a real OpenSSH parser → production picker smoke passed, including distinct Admin/admin accounts. All configured typechecks, full lint, formatting and seven changed-code quality gates passed. Desktop/mobile-web build stages and built CLI help passed. The full suite was attempted for 1800 seconds but did not finish; full native packaging failed at the Swift 6.4 output-layout mismatch. No full-suite or native-build pass is claimed. Exact diagnostics and remaining platform/SSH/UI/current-head CI gates are in the existing validation comment. These are historical executions, not a new test run on 2026-10-22.

Unrelated flakiness observed: src/renderer/src/components/sidebar fails a varying set of tests under concurrency (7 failures on one run, 3 on the next, all green when the file is run alone). Pre-existing and unrelated — these are renderer component tests with no path to the main-process picker — but flagging it rather than leaving a red run unexplained.

Latest published-head validation, recorded on 2026-10-28 (a29d91ea4a8ba962ddd4571d828cf2b78fcc1d53): 80 focused tests, all four project typechecks, and a production OpenSSH parser-to-picker smoke passed, including distinct jump/proxy routes. check:changed passed 22 of 23 gates; the affected-test gate remained failed. The existing validation comment records the broader failures and pinned-production controls. These are historical results, not fresh 2026-10-29 executions. Full/native packaging, real SSH/platform/UI proof, and current-head PR Checks remain gates.

AI Disclosure

Claude Opus 5 (via Claude Code) investigated, implemented, and verified this change.

Review

  • Security: no new input surface; the identity is derived from values already persisted, and the extra comparison is in-memory.
  • Cross-platform: pure string handling, no path or platform branches.
  • Remote SSH: this is the SSH path — it makes the picker's duplicate detection see the machine rather than the name.
  • Backwards compatibility: widens alreadyInOrca only. The existingTargets parameter takes the three new fields as Partial, so callers that pass only names keep type-checking and behave exactly as before.
  • Performance: one extra Set built per picker query, sized by target count.
  • Mobile / shortcuts: no new shortcut or mobile code; real client/platform execution is unverified. Visual/interaction proof: outstanding.

Agent skill upstream boundary

  • Not applicable

Notes

Deliberately narrow: it does not touch sshConfigHostsToTargets, whose empty-exclusion-set call is documented as intentional with reconciliation happening in ssh-connection-store.ts, and it does not add merge/dedupe of already-persisted duplicates.

One observation while reading: existingAliases already collects both configHost and label, so the reporter's own case — manual target labelled aimp, config alias aimp — should have matched on the name alone. Either the manual target was labelled differently and the JSON was reconstructed afterwards, or existingTargets did not include it at that moment. Worth a maintainer eye, since it may be a second, distinct defect in how the picker is fed.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for the changed picker availability behavior
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass — typecheck, oxlint and the affected suites pass locally; full-suite attempt incomplete and native packaging failed; see dated Testing update

Generated with Claude Code

…ther name

searchSshConfigHosts decided "already in Orca" by comparing normalized alias
strings — a target's configHost and label — against the config entry's Host
pattern. Two names for one machine therefore both pass:

  manual   { label: 'AI Box', configHost: '172.16.203.131', host: '172.16.203.131' }
  picker   Host aimp / HostName 172.16.203.131

Nothing in either record is string-equal, so the picker lists `aimp` as new and
the user gets a second target for a box they already added. Both connect to the
same endpoint and attach to the same relay daemon, so the two entries list the
same remote sessions and operating either one drives the same underlying ones.

Add sshEndpointIdentity — host, port and user, normalized and NUL-separated —
and treat a candidate as already registered when either its alias or its
endpoint matches. Multiple pathspecs of identity, same as before, just no
longer name-only.

Only entries carrying HostName participate: without it the candidate host
degrades to the alias itself, and matching on that would re-run the alias check
while letting unrelated aliases collide. That also bounds what this fixes —
a Host block that resolves through DNS rather than HostName still yields two
targets, because neither the parser nor `ssh -G` resolves names.

alreadyInOrca is a display flag, not a gate, so a deliberate second target for
the same endpoint (different identity file, different jump host) still gets
added — it just says so first.

Fixes stablyai#15478

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b1067c63-cf09-4e6a-bced-8f1422e93129

📥 Commits

Reviewing files that changed from the base of the PR and between e753003060fcf46306f5f7a99b07daba4eb35309 and 8f518144aef217c3183f9e053ad71af209e4a002.

📒 Files selected for processing (2)
  • src/shared/ssh-config-alias.test.ts
  • src/shared/ssh-config-alias.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

Adds sshEndpointIdentity to normalize SSH host, port, and username values. Updates SSH configuration host search to match existing targets by endpoint identity or alias. Hosts without HostName do not create endpoint identities. Expands existing target types for search and listing functions. Adds tests for endpoint normalization and host registration matching.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Linked Issues check Warning The change fixes the picker case with an explicit HostName but does not resolve aliases, cover manual additions, or warn or merge duplicates as broadly suggested by issue #15478. Extend duplicate detection to the manual and picker paths, compare resolved hostname, port, and username, and define the required warning or merge behavior.
Passed Passed checks: 3 passed
Check name Status Explanation
Out of Scope Changes check Passed The helper, picker logic, and tests directly support endpoint-based duplicate detection and remain within the linked issue's scope.
Title check Passed The title clearly and concisely describes the main change: flagging an SSH config host when its machine is already registered under another name.
Description check Passed The description is complete, relevant, and follows the required section structure. It explains the user impact, implementation, scope, linked issue, testing, limitations, AI use, and checklist status.…
Full details: Description check

Explanation

The description is complete, relevant, and follows the required section structure. It explains the user impact, implementation, scope, linked issue, testing, limitations, AI use, and checklist status. It also clearly discloses that visual proof, manual UI testing, full-suite completion, native packaging, and current-head validation remain outstanding.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: aba43e7a-416c-4e53-89ad-5bb5ebb7e9f0

📥 Commits

Reviewing files that changed from the base of the PR and between 59892a2 and e753003060fcf46306f5f7a99b07daba4eb35309.

📒 Files selected for processing (4)
  • src/main/ssh/ssh-config-host-picker.test.ts
  • src/main/ssh/ssh-config-host-picker.ts
  • src/shared/ssh-config-alias.test.ts
  • src/shared/ssh-config-alias.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment thread src/shared/ssh-config-alias.ts Resolved
@kaluli123123

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor
❌ Action failed

Review failed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kaluli123123
kaluli123123 force-pushed the fix/orca-ssh-duplicate-endpoint branch from 8f51814 to a5575ce Compare September 7, 2026 08:56
@kaluli123123

kaluli123123 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Merged current upstream main (bf866505e8) in 792ff60. Registered-machine detection is preserved at the relocated src/main/ssh/config/ssh-config-host-picker.ts path, including endpoint identity imports and existing alias/tombstone behavior. Documented how the picker recognizes an existing endpoint under a different label.

Validation:

  • Focused final regression suites: 27 passed, rerun with the lockfile-pinned dependencies after isolated installation.
  • Full native-compiler typecheck passed across all configured projects after pnpm install --frozen-lockfile --ignore-scripts and pnpm run build:packages.
  • All changed-code-quality gates passed on the merged tree with the locked dependencies.
  • Actual production-path smoke: parsed OpenSSH config, called the relocated picker, and verified the same endpoint is marked already registered while a different host remains new with the correct count.

Remaining gates: full build/full suite and native-platform UI validation are not claimed. The pinned Bun binary is unavailable with install scripts disabled, so typechecking used the supported native compiler. Previous failed workflow runs had zero jobs, not failing test executions; exact-head PR CI still needs to run and complete.

AI review: endpoint comparison remains pure and platform-neutral; local/SSH behavior and supported agent/integration routing are unchanged. It adds no network requests or credential access. Native rendering has not been visually revalidated.

@kaluli123123

kaluli123123 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Fixed an additional endpoint-identity bug in 8daf21370b: DNS hostnames still compare case-insensitively, but SSH usernames now retain case, so Admin and admin on the same host/port are not incorrectly marked as the same saved target. Added helper/picker regressions and updated the SSH documentation.

Validation: all 28 focused tests passed; a direct real OpenSSH parser → production picker smoke passed for both case-distinct users and hostname folding. All project typechecks, full lint, formatting and all seven changed-code quality gates passed. The built CLI help smoke and desktop/mobile-web build stages passed. The full test attempt was stopped at its 240-second limit after reporting six process-host development-rebuild test failures; it is not a full-suite pass and no baseline attribution is claimed. Full pnpm build reached native packaging but failed because lipo could not find the expected macOS computer-helper architecture binaries. Native/SSH/UI execution and a successful exact-head PR Checks aggregate remain required; local focused checks do not replace them.

Follow-up validation: the earlier watcher failures were isolated to lexical /var versus canonical /private/var temporary paths in unchanged upstream fixtures/plugin code. Canonical-temp controls pass all eight watcher tests plus the two related folder-import cases on the companion routing branch. An adequate 1800-second full run on this head still did not finish and exposed broader failures; it is not a full-suite pass. A second isolated control using the short canonical TMPDIR=/private/tmp passed 37 daemon, built-CLI subprocess and OpenCode lifecycle tests, avoiding both alias mismatches and Unix-socket length/relocation fixture failures. Remaining full-run failures are not blanket-attributed to a baseline.

The native packaging failure now has a concrete toolchain/layout diagnosis: this host's Swift 6.4 default reports .build/out/Products/Release, whereas the unchanged build script expects .build/<triple>/release for lipo. The companion build's actual executable exists in Swift's reported location; explicit --build-system native reports the old per-triple layout but is deprecated. No unrelated build-policy changes were added to this SSH fix. Full-suite, native/platform and exact-head CI gates remain open.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks @kaluli123123, this is the right shape for #15478: it's parser-only and doesn't spawn ssh -G per row.

One change before we can merge. In the picker, alreadyInOrca disables the row and "Add all" skips it (AddRemoteHostSshConfigPicker.tsx), so the identity decides whether a host can be added at all. sshEndpointIdentity uses only hostname, port and user. Two config entries for the same 10.0.0.5 reached through different jump hosts are different machines, but they would collide, and the second one couldn't be added.

Could you either:

  • add jumpHost and proxyCommand to sshEndpointIdentity, or
  • keep the hard alreadyInOrca for alias/label matches only, and show endpoint-only matches as a non-blocking "possible duplicate" hint?

Either works for us. A test with two entries that share a HostName but have different ProxyJump values would cover it.

@kaluli123123

kaluli123123 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the route-identity concern from #15750 (comment) in a29d91e, together with integration of upstream main ee09f97.

Endpoint identity now includes the saved jumpHost and proxyCommand in addition to hostname, port, and case-sensitive username. The parser-only picker supplies ProxyJump/ProxyCommand from each config entry; it still does not spawn ssh -G per row. Identical private endpoints through different jump hosts or proxy commands stay selectable, while the identical saved route remains marked In Orca. Alias/label matching, tombstones, hostname case folding, valid port boundaries, and case-sensitive SSH users are preserved. Added helper and production parser-to-picker regressions and updated the SSH guide.

Validation on macOS: 80 focused tests passed; all four configured native-compiler project typechecks passed; a direct production OpenSSH parser → picker smoke verified identical saved routes and distinct jump/proxy routes. The required check:changed gate passed 22 of 23 checks, including its static/format/quality/typecheck gates. Its broader 573-file affected test selection reported 7,038 passing tests, eight failing PTY assertions, and three cross-version suites unable to resolve local release refs v1.4.190, v1.4.224, and v1.4.219. Independent controls with production sources pinned to ee09f97 have now reproduced each of those same eight specific PTY assertions, including the single materialization-race case; that does not classify the entire affected suite. After fetching those exact release refs, the three previously blocked cross-version suites completed successfully: 3 files and 57 tests passed with maxWorkers=1. The broader sweep was not repeated merely to reconfirm the controlled PTY failures. No full-wrapper pass is claimed.

No real SSH endpoint, physical phone, Linux/Windows execution, native packaging, or manual/visual proof is claimed. Full validation and the exact-head .github/workflows/pr.yml aggregate PR checks passed remain required; exact-head PR Checks https://github.com/stablyai/orca/actions/runs/40634511395 reports action_required with zero executed jobs, while the successful clean job is from Clean obsolete PR work and does not satisfy that gate. The PR remains open and is not being presented as merge-ready.

nwparker added a commit that referenced this pull request Oct 29, 2026
…35792)

* fix(ssh): flag a config host whose route is already registered under another name

The ssh-config picker compared names only, so a machine added by IP showed up
again under its config alias. It now also compares the endpoint: hostname
(case-insensitive), validated port, case-sensitive user, jump host and proxy
command. Entries without HostName still match by alias only.

Squashed from #15750 (3c3a3c6, a5575ce, 8daf213, a29d91e).

* fix(ssh): skip importing a config alias whose ssh -G route is already in Orca

Each config import now builds one snapshot: the config it read, and which new
aliases resolve, through ssh -G, to a route an existing target already has.
The duplicate check and the inserts both read only that snapshot. Imports and
picker refreshes run one at a time through a single queue, so none can race
another, and the picker reads the latest snapshot for its In Orca flags and
Add all count without waiting (alias-only until one exists).

A route is keyed only when ssh2's rules and system ssh's (OpenSSH run with
system ssh's own destination args, including an unclaimed alias's stored
endpoint) agree on host, port, user and proxy, with each transport's token
rules. Anything uncertain, or a failed ssh -G, gives no key, so nothing is
matched by guess. At most four ssh -G run at once. Restore brings back the
hosts it lists, previouslyRemoved stays alias-only, and DNS isn't consulted.

Co-authored-by: vam <[email protected]>

* fix(ssh): rebuild the route snapshot after an import changes targets

An import that inserts or updates a target outdates its own snapshot, which
left the picker alias-only until the next refresh. It now queues a rebuild
behind itself. The picker also ignores a snapshot past its reuse window, and
the system-route shortcut requires a config alias.

Co-authored-by: vam <[email protected]>

---------

Co-authored-by: vam <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @kaluli123123! Your fix landed in #35792 with your authorship kept. You found that the duplicate came from comparing names, and that the route fields (jump host, proxy command) belong in the identity. We built on that: the config import now asks OpenSSH (ssh -G) where each alias really connects, and skips one that's already in Orca. The picker reads that same decision. We run CI only on in-repo branches, so we carried it over. Closing this one in favor of it. Fixes #15478.

@nwparker nwparker closed this Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants