Repository navigation
Isolate code editor text and Undo history by execution host - #25174
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📥 CommitsReviewing files that changed from the base of the PR and between b432dd43bf5679f2d71287a8da32032b71e6a8b4 and 17adc1f. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughEditor model URIs now include an owner key derived from file and worktree route state. Monaco content synchronization and closed-tab cleanup use owner-specific model identities. Added tests cover same-path model separation, synchronization, undo history, and model disposal across ownership routes. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No actionable issue is established in these changes; they are mergeable after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change strengthens separation between files opened on different execution hosts. No introduced security regression was established in the reviewed flows, but incomplete coverage leaves some residual uncertainty. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
✅ No new issues found.
Reviewed changes
This run read the complete diff (16 files, 1 commit) at 24c6399.
- Owner-scoped model identity —
toEditorModelUrinow appends the execution-host owner key as the URI fragment, so equal paths on different hosts get distinct Monaco models while local files keep the legacy path-only model. - Owner derivation and isolation — new
editor-model-owner.tsderives a stable[runtimeEnvironmentId, executionHostId]key from captured provenance or the worktree/folder route, with a per-file unresolved key so an unplaceable tab cannot borrow another host's retained text. - Threaded through sync and cleanup —
MonacoEditor.tsx,use-monaco-editor-mount.ts, the closed-tab controller/disposal, and the programmatic-sync suppression map all key by the owner-scoped model URI; the controller subscription now also reacts to owner-affecting catalog changes. - Tests — unit, component, and Electron/CDP e2e coverage for same-host sharing, cross-host isolation, owner changes, disposal, and Windows drive/UNC URI round-trips.
ℹ️ Editor view state is still keyed by path, not by owner
Text and Undo are now isolated per host, but scroll and cursor view state is not: editorViewStateKey is the raw activeFile.filePath (EditorContent.tsx:96-99), and scrollTopCache/editorSelectionCache entries are keyed by path, so same-path local and remote tabs restore each other's position and closing one clears the other's cached entry. This is outside the PR's stated scope (text and Undo), and the codebase already scopes durable PDF zoom per owner via buildPdfScalePreferenceKey, so it reads as a candidate follow-up rather than a blocker.
Technical details
# Editor view state not owner-scoped
## Affected sites
- `src/renderer/src/components/editor/EditorContent.tsx:96-99` — `editorViewStateKey` is `activeFile.filePath` (or `...::scope`).
- `src/renderer/src/components/editor/closed-editor-tab-disposal.ts:98-104` — deletes `scrollTopCache`/`editorSelectionCache` by `closedFile.filePath`, shared across same-path owners.
- Contrast `src/renderer/src/components/editor/EditorContent.tsx:111-113` — `buildPdfScalePreferenceKey(activeFile)` already scopes PDF zoom by owner.
## Open questions for the human
- Is view-state sharing across same-path hosts intentional (harmless convenience), or an oversight to fix in a follow-up?deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
188d7fb to
108ed7a
Compare
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review at 24c6399: commit 188d7fb (Verify editor owner resolution and Windows model path isolation), which changes only tests.
- Ownership-resolution remount test — mocked the editor to record mount/unmount transitions and added a component test that drives an unresolved tab to a resolved local owner, asserting the widget remounts onto a new model while keeping the latest draft.
- Windows-shaped path coverage — parameterized the host-isolation test over a POSIX path, a Windows drive path, and a UNC path.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| expect(editorProps.current?.defaultValue).toBe('latest dirty draft') | ||
| expect(editorProps.mounts).toEqual([unresolvedModel, resolvedModel]) | ||
| expect(editorProps.unmounts).toEqual([unresolvedModel]) | ||
| expect(onContentChange).not.toHaveBeenCalled() |
There was a problem hiding this comment.
The mock Editor never invokes onChange (or onMount), so onContentChange has no reachable call site in this test and this assertion can never fail — it cannot catch the spurious-dirty regression it looks like it guards. Either have MockEditor emit a change after the remount, or drop the assertion so the suite doesn't imply coverage it lacks.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review (188d7fb): commit 108ed7a (Respect native model line endings in content sync history coverage), a test-only change.
- Line-ending-aware assertion — the read-only live-tail undo test now compares against
['first line', 'appended'].join(model.getEOL())instead of a hard-coded\n, so it holds on native CRLF hosts too.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
1391fb2 to
b432dd4
Compare
b432dd4 to
17adc1f
Compare

ELI5
Files with the same path on different hosts now keep their text and Undo history separate.
What Changed
The code editor previously identified a document by its path alone. Its model identity now includes the execution host, using the file's captured owner and existing host resolver. Synchronization and closed-tab cleanup use that same identity. Late owner resolution snapshots the caret and scroll before the widget changes. Tabs for the same local file still share one model.
Why
Opening a remote file after editing a local file with the same path could expose the local text through Undo. Scoping the existing model registry preserves Undo and tab reopening without rebuilding every model or clearing useful history.
Linked Issue
Found during the editor integration review; no linked issue.
Visual Proof
Edit the local file, open the same path under a different host identity, then Undo. Before, Undo reveals
LOCAL_MARKERin the remote tab. After, it restoresREMOTE_MARKER, and the local edit remains intact.Actual SSH workspace after the remote save, followed by the retained local draft at the identical path. Actual SSH integration receipts.
Testing
Native Windows passes 136/136 tests across 17 files on head
17adc1f8ce21d5be016ac0f02662f6f41699be84. Exact-head Windows receipts.The real editor wrapper regression fails before the owner-change cleanup fix and passes after it: the dirty draft, selection on lines 80–82, and scroll position survive; Undo remains isolated. A positive user-edit control verifies that the content-change callback is reachable. Remote-owner close/reopen tests cover POSIX, Windows drive, and UNC paths.
A hidden macOS Electron app connected through Orca's actual SSH provider to Linux. A local folder and remote Git workspace used the identical absolute file path. Actual reads, independent dirty drafts and Undo, remote save with independent SSH readback, and the unchanged local file all pass. The temporary target, app, and owned fixture directories were removed. The earlier rendered baseline reproduces the local-text leak.
The combined macOS editor suite passes 2,272 tests in 304 files, with three tests skipped. Full
pnpm tc, fullpnpm lint, the changed-code quality gate, and a fresh background Electron build pass on main plus these three changes. All three PRs are rebased onto main at6c0757004053; their owned source files match that tested integration. Current-head CI is green, including static analysis/typecheck, all five full-unit shards, the Linux rendered regression, packaging, and final verification.Native window focus was not exercised. Global E2E typecheck has existing unrelated errors; the changed editor spec has no diagnostics.
Review
Checked authoritative file ownership, unresolved-owner isolation, model disposal, shared local tabs, Undo, and synchronization during owner changes, including late catalog-only resolution and deferred cleanup after detach.
Agent skill upstream boundary
Notes
Resolving a previously unknown owner remounts the editor under the correct host. The current unsaved draft, selected range, and scroll position are preserved. Earlier Undo history and Find state may reset. Tabs for the same local file still share their model and Undo history.
Uses existing host routing for remote and folder workspaces. No wire format changes or new platform-specific commands.
Checklist