Repository navigation
feat(pairing): re-pairing the same server keeps its environment - #27197
Conversation
The web client minted a new environment id on every runtime-scope pairing link, even for the same server key, so existing terminals kept the old id and failed as ambiguous. A key-matched re-pair now keeps the id (bumping the pairing revision) and pins the server's host descriptor; a same-key server with a different installation gets a new id, and a downgraded server never replaces the pin. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erver re-pair Re-pairing now keeps the environment id, so fence on the pairing revision too: a request captured before the re-pair can neither reopen a client with the replaced token nor save the old pairing back over the new one. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Same-server re-pairing preserves the environment ID while refreshing credentials. The inspected client lifecycle does not leave requests using the replaced token; no merge blocker was identified. Pre-merge checks |
|
ELI5
When you open a fresh browser link for an Orca server the browser already knows, the browser used to treat it as a brand-new server. Your open terminals still pointed at the "old" server, so they broke with "Workspace identity is ambiguous across hosts". Now the browser recognises the same server and keeps its identity, so the terminals keep working.
What Changed
Before: every runtime browser-access link made the web client mint a new
web-…environment id, even when the link's server key matched the server it was already paired with. New project and workspace data was labelled with the new id while open terminals still held handles with the old id, and terminal routing refused them as ambiguous. An alias list (compatibleEnvironmentIds) let selector lookups find the old ids, but it could not stop two ids naming one server.After: re-pairing the same server keeps its environment id. The device token and endpoint are refreshed and the pairing revision is bumped, so requests captured under the old token are still fenced, exactly as a desktop re-pair of an existing server does. A link from a different server still gets a new id.
How it decides (one shared rule,
classifyRuntimeHostRePair, for the web now and desktop next):installationIdas the one pinned at the last pairing: same server, keep the id.installationId: a deliberate copy that kept the key. It gets a new id.Because the id no longer changes, the web client's own fences now also compare the pairing revision. A request that started before the re-pair can neither reopen a connection with the replaced token nor save the old pairing back over the new one. Before, the id change did this by accident.
The web client stores the pin next to its saved pairing and never exposes it through
runtimeEnvironments.list. The alias list is no longer extended. Aliases saved by earlier builds are still read and carried forward, so terminals that already hold an old id keep resolving.Why
The id is the server's execution-host identity, and everything the client keeps (layouts, terminal handles, workspace rows) is keyed by it. Keeping it stable fixes the root cause. Adding more aliases only hides it, because routing still sees two hosts.
Alternatives considered:
Scope, adapted from the design (I2b-2 grew past one reviewable PR, so it is split):
orca serve --reset-identity.Linked Issue
Fixes #11574
Visual Proof
N/A: the change is in how the browser saves a pairing. Nothing new is drawn. The visible effect, terminals no longer failing as ambiguous after opening a new link, is covered by the tests below.
Testing
web-runtime-environment-repair.test.ts(new): re-pairing the same key keepsweb-server-a, keepscreatedAt, bumps the pairing revision, stores the fresh token and the pin, adds no alias, and does not expose the pin in the public environment. A same-key offer with a different pinned installation gets a new id. A downgraded offer with no descriptor keeps the id and the old pin. A malformed stored pin is dropped, not trusted. All four fail onorigin/main@ cbeb703 (the id changes to a freshweb-…).runtime-host-pairing-identity.test.ts(new): every branch of the rule.web-pairing.test.ts: a readable descriptor in a pairing link is kept; an unreadable one is dropped without refusing the link.web-preload-api-runtime-environment.test.ts(different key never resolves the old id, legacy aliases, malformed aliases) passes unchanged.pnpm tc, oxlint,check:code-quality:changedpass. Tested on macOS; Linux and Windows are covered by CI.Review
Agent skill upstream boundary
Notes
ssh-tunneldependency as before.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)