Repository navigation
fix(remote-ssh): distinguish SSH servers by port - #3670
Merged
Merged
Conversation
Servers behind one address that differ only by SSH port (cluster nodes mapped to different ports) shared a connection id, saved profile, workspace stable id, runtime root, and session mirror. - New non-22 profiles use ssh-user@host#port ids; port 22 keeps ssh-user@host. '#' was never generated by released builds, so legacy ssh-user@host:port aliases still canonicalize as before and older peers treat the new ids as opaque. - Workspace identity (stable id, runtime key, session/runtime paths, permission project id, session recovery runtime key) derives from host#scope only for port-scoped ids; every existing id keeps its identity and on-disk layout byte-for-byte. - Saving a profile no longer replaces a profile for another port; only the same id or a legacy :port alias for the exact endpoint is replaced. - The dialog reuses an existing profile id for the same endpoint and never takes an id owned by another port. Fixes openBitFun#3451
Collaborator
Author
|
接手审查状态:当前已发布 head 的绿色 CI 还不能作为合入依据,后续兼容补丁尚未验证完毕。 已在未提交的后续补丁中复现一个阻断问题:如果为了兼容旧 workspace record,按 connection ID 在进程内全局固定 host-only identity,加载 正确修复需要由具体持久化 workspace record 决定旧/新身份,不能影响同连接的其他 root,也不能改写或删除用户会话。ssh_config 快捷入口、旧 alias 与删除后重建、容器派生 ID、旧 Peer capability gate 的补测也仍在收尾。此 PR 暂保留开放,不宣称 #3451 已解决。 |
- Resolve ~/.ssh/config preset ids against saved profiles; when they cannot be listed, route to the connection dialog instead of a one-click connect. - Count pre-openBitFun#710 ssh-user@host:port aliases as taken, and reuse an orphaned legacy id that workspace records still reference. - Advertise ssh_port_scoped_identity_v1 from Desktop hosts. Against older peers the controller keeps legacy ids and blocks adding a second port for the same host and user; the peer adapter rejects port-scoped ids. - Pin the host-only identity per (connection, root) for records an older host stored under the legacy stable id, including session recovery. - Connection-less legacy workspace references never select port-scoped records (Rust, Web UI, mobile web, Kotlin mobile). - Parse port scopes through synthetic workspace-host container wrappers.
- Reuse an orphaned legacy id only through an exact ssh-user@host:port alias; a port-less orphan never moves to a non-default port. - List workspace records once per ~/.ssh/config discovery pass. - Reject malformed percent escapes (sign, short, invalid UTF-8) in the Rust and Kotlin workspace-host decoders, matching decodeURIComponent.
# Conflicts: # src/crates/contracts/product-domains/src/generated/remote-surface-registry.json # src/mobile-web/tests/workspace-identity.test.mjs # src/web-ui/src/infrastructure/api/generated/remoteSurface.ts
# Conflicts: # src/crates/contracts/product-domains/src/generated/remote-surface-registry.json # src/crates/contracts/product-domains/src/remote_surface/capabilities.rs # src/web-ui/src/infrastructure/api/generated/remoteSurface.ts
This was referenced Nov 2, 2026
bobleer
added a commit
to Raing5Days/OpenBitFun
that referenced
this pull request
Nov 2, 2026
Regenerate the remote surface registry artifacts after openBitFun#3670.
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
SSH profiles on the same host that differ only by port now get distinct connection ids, saved profiles, workspace ids, runtime roots, and session stores. Default-port (22) users see no change.
Fixes #3451
Type and Areas
Type: bug fix
Areas: Rust core (services-core workspace identity, services-integrations remote SSH, assembly workspace/session/snapshot paths), desktop/Tauri commands, web UI (SSH connection dialog)
Motivation / Impact
On clusters behind one address with port-mapped nodes, every node collapsed into one identity:
ssh-user@host);save_connectiondeduped by host+user, so saving port 2202 overwrote the 2201 profile;Design:
ssh-user@host. Other ports usessh-user@host#port. The issue suggestedhost:port, but git history (feat(ssh): stable connection IDs and session hydration after port changes #710) shows released builds wrotessh-user@host:portfor every port, andcanonical_ssh_connection_id(also in older peers) treats that as an alias ofssh-user@host. Reusing that spelling would make an older peer fold a 2222 node into the port-22 profile. No build ever wrote#, so older builds treat the new ids as opaque.ssh_workspace_identity_host(ssh_host, connection_id)returnsssh_hostunchanged for every id without a port scope, andhost#scopefor port-scoped ids. This is applied at the stable id, runtime root/key, session dir, snapshot context, permission project id, and session-recovery runtime key call sites.#is a valid path component on all client OSes and never appears in a real SSH host, so a new identity can't pick up or migrate another host's legacy mirror.sshHostmetadata is unchanged (still the plain host). Port scope comes from the opaque connection id, so no new persisted field is needed.:portalias of the exact same endpoint (host+port+user+container+wsl). A profile for another port is never replaced. A different, non-alias id for the same endpoint is kept, because records may still point to it.#22or#port~ninstead.Verification
cargo test --locked -p openbitfun-services-core --no-default-features --features workspace-persistence --lib workspace_identity: 9 passed. New tests cover: default-port ids, scope parsing (every legacy id shape, plus syntheticworkspace-host-container wrappers), byte-for-byte legacy identity, distinct port identities, per-root legacy pinning, and pinning one root leaving other roots of the same connection alone.cargo test --locked -p openbitfun-services-integrations --no-default-features --features remote-ssh-concrete --lib remote_ssh::manager: 72 passed. New tests cover: two ports keep both profiles, a port edit keeps the id, and an oldssh_connections.jsonpayload round-trips.TMPDIR=/private/tmp/ cargo test --locked -p openbitfun-services-core --no-default-features --features session-recovery --lib session_recovery: 13 passed. The default macOS/vartemp dir trips the existing linked-path guard, hence the override.cargo test --locked -p openbitfun-product-domains --lib remote_surface: 20 passed (capability map).cargo test --locked -p openbitfun-core --no-default-features --features agent-runtime,git,remote-workspace --lib -- service::workspace:: service::remote_ssh service::snapshot service::workspace_runtime agentic::workspace: 99 passed. New tests cover: an old session payload with no connection id ignores#portrecords; an old-host record (port-scoped id, legacy stable id) imported and round-tripped keeps its identity; port-scoped session paths; separate workspaces with no rebind conflict.cargo check --locked -p openbitfun-desktop: okpnpm --dir src/web-ui run test:run src/features/ssh-remote src/infrastructure/api/service-api/legacyWorkspaceCompatibility src/infrastructure/peer-device src/infrastructure/api/adapters: 395 passed. New tests cover: id rules (:portalias taken, orphan reuse, legacy ids for older peers plus the conflict they would cause), the resolver,~/.ssh/configpresets resolved against saved profiles (and routed to the dialog when the list fails), the peer adapter guard, and a connection-less legacy session reference.pnpm --dir src/web-ui run type-check, eslint on touched files,pnpm run i18n:audit,pnpm run capabilities:check: okpnpm --dir src/mobile-web run test:workspace-identity(25 passed, one new) andpnpm --dir src/mobile-web run type-check: okpnpm run fmt:rsLegacyWorkspaceCompatibilityTest(no Java runtime on this machine).pnpm run check:core-boundariesfails here because this worktree is nested inside the main checkout; that is an environment issue, not this change.Remote scenarios exercised (unit and integration tests only): remote workspace identity and persistence; Peer Device Mode capability gating (adapter tests); legacy references from Remote Control / mobile web. No live SSH host, peer pairing, or Detached Dispatch run.
Reviewer Notes
Upgrade compatibility
ssh-user@host,ssh-user@host:port, container, WSL, andworkspace-host-wrappers around them) has no port scope.#portprofile beside them.:portaliases:canonical_ssh_connection_idand the BitFun migration adapter are unchanged. A new profile never takes a bare id that a saved:portalias on another port already owns (it gets#22), so an old workspace is never silently rebound.#portrecord in the Rust resolver, Web UI, mobile web, or Kotlin mobile, so old(sshHost, root)references don't become ambiguous.ssh_port_scoped_identity_v1. Against a peer without it, the controller keeps legacy ids. If saving would replace another port's profile for the same host and user, the dialog blocks with a localized message instead. The peer adapter also refuses to send a port-scoped id to such a peer. The CLI peer host has no SSH profile commands and does not advertise the capability.(connection, root)when records are loaded or imported, and in session recovery. Its sessions stay where they are, and other roots of the same connection keep the port-scoped identity.~/.ssh/configshortcut: preset ids are resolved against the host's saved profiles. If those can't be listed, the entry opens the connection dialog instead of connecting in one click.workspace-host-<encoded id>-container-<name>ids keep the wrapped id's port scope, so containers on different ports stay separate.:portid keeps host-only identity. A new port-22 profile then gets#22and a separate identity. Existing data is not migrated.Rollback
Reverting leaves
#portprofiles readable as opaque ids. Their workspaces would fall back to host-only identity, so their sessions would be hidden until re-upgrade, not deleted.