Repository navigation
Conversation
📝 WalkthroughWalkthroughAdds runtime-environment translation for mirrored editor worktrees and uses translated owned editor IDs during web-session synchronization. Mirrored open files now retain sender environment provenance for equality checks and snapshot reconciliation. Editor hydration translates persisted ownership, detects owner changes, and updates hydrated IDs. Closed-tab snapshots omit sender provenance, reopened tabs clear mirrored fields, and host close notifications use stored mirrored environment IDs when available. Tests cover translation, synchronization, hydration, replacement, removal, closing, and reopening behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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/runtime/web-session-tabs-sync.ts (1)
883-914: 📐 Maintainability & Code Quality | 🔵 TrivialUnsafe double-cast bypasses the type contract needed for translation.
state as unknown as WorktreeRuntimeOwnerStateforces the cast, butWebSessionTabsSyncStateis Pick<AppState, 'activeBrowserTabId' | ... | 'sortEpoch'> & Partial<Pick<AppState, 'automaticAgentResumeClaimsByTabId' | 'pendingStartupByTabId'>> and does not structurally includerepos,worktreesByRepo,detectedWorktreesByRepo, orfolderWorkspaces— the fieldstranslateMirroredEditorRuntimeEnvironmentIdactually reads. Production is fine today because callers always pass the full store state (which happens to carry those extra properties), but the type no longer documents/enforces that dependency, and a caller constructing a genuinely narrowWebSessionTabsSyncStatewould silently gethasConcreteRecord === falseand skip translation (the tests already needObject.assign(state, { repos, worktreesByRepo })to backfill this).close-mirrored-editor-tab.ts'sMirroredEditorCloseState = WorktreeRuntimeOwnerState & {...}intersection pattern is the safer approach used elsewhere in this same PR.♻️ Suggested type-safe alternative
-import type { WorktreeRuntimeOwnerState } from '`@/lib/worktree-runtime-owner`' +import type { WorktreeRuntimeOwnerState } from '`@/lib/worktree-runtime-owner`' ... -export type WebSessionTabsSyncState = Pick< - AppState, - ... -> & - Partial<Pick<AppState, 'automaticAgentResumeClaimsByTabId' | 'pendingStartupByTabId'>> +export type WebSessionTabsSyncState = Pick< + AppState, + ... +> & + Partial<Pick<AppState, 'automaticAgentResumeClaimsByTabId' | 'pendingStartupByTabId'>> & + WorktreeRuntimeOwnerStateThen drop the
as unknown as WorktreeRuntimeOwnerStatecast at the call site.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 58e9cf6f-db49-4ef3-ae6e-ef0dcab493e9
📒 Files selected for processing (8)
src/renderer/src/lib/worktree-runtime-owner.test.tssrc/renderer/src/lib/worktree-runtime-owner.tssrc/renderer/src/runtime/close-mirrored-editor-tab.test.tssrc/renderer/src/runtime/close-mirrored-editor-tab.tssrc/renderer/src/runtime/web-session-tabs-sync.test.tssrc/renderer/src/runtime/web-session-tabs-sync.tssrc/renderer/src/store/slices/editor.test.tssrc/renderer/src/store/slices/editor.ts
Summary
Fixes #10859. Mirrored editor tabs were carrying the sender's perspective-relative
runtimeEnvironmentIdacross paired Orca instances unchanged. When the receiver owned that worktree locally, Orca still routed local editor reads and diffs back to the peer, which had never heard of the worktree. The same overloaded field also drove close and cull behavior, so mirrored tabs could reappear or multiply after sync.This change splits those meanings and keeps the fix renderer-local:
runtimeEnvironmentIdbecomes the receiver-frame routing owner for the file.mirroredFromRuntimeEnvironmentIdrecords which remote runtime mirrored the tab to this receiver.The result is that paired machines still mirror editor tabs, but a machine that owns the worktree routes its own file operations locally and can close mirrored tabs authoritatively across the link.
Closes #10859.
Screenshots
No visual change.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/worktree-runtime-owner.test.ts src/renderer/src/store/slices/editor.test.ts src/renderer/src/runtime/web-session-tabs-sync.test.ts src/renderer/src/runtime/close-mirrored-editor-tab.test.tspnpm run typecheck:webpnpm exec oxlinton changed filespnpm exec oxfmt --checkon changed filesFocused coverage:
AI Review Report
Adversarial review found three P1s, all fixed on the final branch and revalidated locally:
Final local revalidation after those fixes:
4 passed, 283 testspnpm run typecheck:weboxlintoxfmt --checkReview focus covered the explicit-owner boundary, shared owned-ID construction across hydration and live sync, mirror-host keyed cull/close, and stripping runtime-only mirror provenance from persisted or reopened tabs.
Security Audit
No new RPC, IPC, or cross-process trust boundary. The fix tightens routing by keeping receiver-owned local file operations on the receiver instead of sending them to a peer runtime that does not own the worktree. Owner translation is guarded by concrete receiver-side records, and peer-only worktrees remain peer-owned.
Notes
runtimeEnvironmentIduntranslated — a machine routes its own local files to a peer that doesn't have the worktree (selector_not_found) #10859 (comment) is the design anchor for this slice. Cross-machine editing is intended behavior; only the untranslated owner semantics are wrong.