Repository navigation
fix(web): preserve host identity across same-server re-pairing - #11575
dongwook-chan wants to merge 1 commit into
Conversation
| }) | ||
|
|
||
| expect(paired.environment.id).toBe('web-server-a') | ||
| expect(paired.environment).not.toHaveProperty('compatibleEnvironmentIds') |
There was a problem hiding this comment.
Non-informative assertion on redacted field
redactStoredWebRuntimeEnvironment (called inside addFromPairingCode at line 1366 of web-preload-api.ts) unconditionally strips compatibleEnvironmentIds before returning. The assertion therefore passes regardless of what the internal StoredWebRuntimeEnvironment contains, so it does not verify the fix. The meaningful guard already exists on the preceding line (id === 'web-server-a'). If the intent is to confirm the internal representation has an empty compatibleEnvironmentIds list, the stored value (globals.storage.getItem('orca.web.runtimeEnvironment.v1')) would need to be parsed and inspected directly.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Greptile SummaryThis PR fixes host-identity churn for same-server browser re-pairings. Previously, every call to
Confidence Score: 4/5Safe to merge — the change is narrow, well-tested, and confined to the browser-side environment constructor. Device tokens and endpoints still rotate on every pairing; only the stable identity fields are preserved on a key match. The fix is narrowly scoped and the same-key identity preservation is directly tested. One secondary assertion in the new test is non-informative due to upstream redaction, leaving the internal compatibility-ID state unverified. Files Needing Attention: The test in
|
| Filename | Overview |
|---|---|
| src/renderer/src/web/web-runtime-environment.ts | Replaces getCompatibleEnvironmentIds with getSameServerEnvironment to reuse the previous environment's ID/createdAt when the pinned public key matches, instead of generating a new ID and recording the old one in a compatibility list. Logic is correct for same-key and different-key branches. |
| src/renderer/src/web/web-preload-api.test.ts | Adds a focused regression test for same-key identity preservation. Core assertion id === 'web-server-a' is strong; the secondary not.toHaveProperty('compatibleEnvironmentIds') is always true because redactStoredWebRuntimeEnvironment strips that field unconditionally, making it non-informative. |
Reviews (1): Last reviewed commit: "fix(web): preserve host identity across ..." | Re-trigger Greptile
📝 WalkthroughWalkthroughUpdated runtime environment creation to match pairing offers against existing endpoints by server public key. Matching environments retain their 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/web/web-preload-api.test.ts (1)
350-363: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the complete re-pairing contract.
This test checks only ID reuse and an empty compatibility list. Add assertions for the refreshed endpoint/device token and preserved
createdAt, plus cases proving existingcompatibleEnvironmentIdsare retained and a differentpublicKeyB64generates a newweb-*ID.[details]
Suggested assertions
expect(paired.environment.id).toBe('web-server-a') + expect(paired.environment.createdAt).toBe(1) + expect(paired.environment.endpoints[0]).toMatchObject({ + endpoint: 'wss://server.example:443', + deviceToken: 'server-token' + }) expect(paired.environment).not.toHaveProperty('compatibleEnvironmentIds')[/details]
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d3c76adb-7785-4ffb-b697-794f22ecb936
📒 Files selected for processing (2)
src/renderer/src/web/web-preload-api.test.tssrc/renderer/src/web/web-runtime-environment.ts
|
Thanks @dongwook-chan for tracking this down and writing up the root cause so clearly. This is already fixed on main by #27197 (b80c420). |
|
Thanks for tracing this to #27197 and explaining the same-host identity handling. I understand why preserving the existing web environment ID and incrementing the pairing revision resolves the duplicate-host identity problem. I have no new reproduction on the latest build to report, so I am leaving this closed. |
Summary
Preserve a paired web runtime's execution-host ID when a new pairing offer proves it is the same server by pinned public key. The endpoint and device token still refresh, but existing worktree ownership and mirrored terminal handles keep one host identity.
This prevents existing AI CLI terminal sessions from failing closed with:
A different pinned key still creates a new
web-*environment ID.Root Cause
Runtime-scope browser access links auto-import on every visit.
createStoredWebRuntimeEnvironment()minted a newweb-*ID for each import, even for the same pinned server key.Worktree catalogs then used the new ID while existing mirrored PTY handles could still carry the old ID. PTY routing interpreted those browser-generated IDs as distinct execution hosts and rejected the existing session as ambiguous.
Screenshots
No visual change.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/web/web-preload-api.test.ts src/renderer/src/web/web-workspace-session.test.ts src/renderer/src/runtime/web-session-tabs-sync.test.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts(695 passed)pnpm run typecheck:weboxlintoxfmt --checkgit diff --checkpnpm run check:code-quality:changedcould not run under the installed Node 22 because the repository requires Node 24 and the engine warning corrupts that script's JSON parser. The same touched-file lint and format checks run by the commit hook passed.AI Review Report
Reviewed same-key and different-key pairing boundaries, existing compatible-selector behavior, web startup auto-pairing, session partition ownership, mirrored PTY routing, and current ambiguity fixes. The change is limited to the browser environment constructor and preserves the existing ID only when the pinned public key matches.
Cross-platform review found no platform-specific paths, shells, keyboard behavior, native modules, Git behavior, or Electron APIs. The browser identity rule is the same on macOS, Linux, and Windows and applies to SSH-hosted server worktrees without assuming local execution.
Security Audit
The pinned public key was already the trust boundary for
compatibleEnvironmentIds; this change uses the same proof for stable identity. Device tokens and endpoints continue to rotate from the new offer. Different keys cannot reuse an existing ID. No credentials are logged or exposed, and no auth, IPC, command execution, filesystem, or dependency surface changes.Notes
This fixes browser-generated execution-host churn for one paired server. It does not merge distinct physical servers or unrelated SSH/project host records.
Closes #11574