Repository navigation
Wait for managed editor saves before discarding Git changes - #26677
Conversation
88db24b to
486786c
Compare
a70ab92 to
9a3416a
Compare
…scard Single and bulk discard quiesced editor autosaves for the globally focused runtime, so a managed repo's in-flight save could land after git restored the file and bring the discarded edits back. Use the repo-owner-routed settings the discard itself already uses.
|
Rebased onto main now that #26668 has merged, and cut down to the product fix plus its unit regression test (two lines in |
bfb6336 to
b4bf9cc
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughSingle and bulk source-control discards now derive the runtime environment ID from active repository settings instead of the app store. Tests cover managed and desktop repository focus scenarios. They verify that discard waits for editor-save quiescence and checks the quiesce and notification targets. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to Source Control discard now waits for editor saves using the repository's own runtime owner. No actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)✅ Passed checks (3 passed)Full details: Description checkExplanation The description explains the problem, implementation, rationale, testing, visual evidence, platform coverage, and checklist status. However, the required Linked Issue section states that no existing issue is linked.
✨ 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 |
ELI5
Orca can have a remote editor save still on its way when you click Discard. Discard was waiting for saves on the globally focused machine instead of the project’s machine. Git restored the file, then the remote save put the discarded edits back. Both discard actions now wait for the project’s editor saves before restoring its files.
What Changed
Single-file and bulk Source Control discard use the existing repository-owner-routed settings for their editor-save wait and external-change notification, just as they already do for Git. Removes the direct global-settings read. No change to Git routing, save queues, IPC or remote messages.
Why
A managed repository can be selected while global runtime focus is local or points at another host. The editor’s explicit owner filter excludes its remote tab when passed that global focus. Reusing the owner already captured by Source Control aligns all three steps without adding another owner lookup, a second queue, or a wait for unrelated projects.
Linked Issue
Found while exercising SSH-to-managed-server conversion. No existing issue linked.
Visual Proof
managed-discard-owner-held-save-runtime.log
managed-discard-editor-owner-final-managed-runtime-red.log
managed-discard-editor-owner-full-runtime-green.log
managed-discard-editor-owner-unit-red.log
The owned-app test holds only the matching real editor-write IPC invocation, then releases the original handler. It fabricates no response: the real managed server returns a positive write response and a separate file-read RPC confirms actual host content. Before the fix, Git restores COMMITTED_OWNER while the save is held; release puts CHANGED_ON_DISK plus PENDING_EDITOR_DRAFT back on the host. Afterward Git waits until that write completes, restores the committed file and sends the existing notification to the correct owner. The barrier is bounded and restored during cleanup.
This is a timing-controlled reproduction of an in-flight save, not evidence of a naturally occurring network outage. A separate desktop-control display probe retains its old rendered buffer despite correct disk restoration; that display behavior is recorded for a follow-up and is not claimed fixed here. The original reproduction also includes the existing remote file-watch fix, which prevents the ordinary pending-timer case but does not stop this already-started write.
Testing
Six checked single/bulk owner-and-ordering regressions fail before the change and pass afterward; existing mutation-failure and editor controls pass. 98 affected tests across eight files pass. Required full pnpm tc passes. Full lint, changed-code/design-system/React Doctor checks and fresh builds pass. The final 15-case conversion/stdio/port/update/idle/reboot/menu/discard suite passes in 4.3 minutes.
First corrected real suite passes all four managed/desktop single/bulk cases in 1.5 minutes. The final matching baseline and corrected suites additionally verify positive original write responses, second-file bulk behavior and that the timing barrier did not expire. Both matching unchanged-parent managed single/bulk cases fail in 14.3 seconds after the real wrong-content write. All four corrected managed/desktop cases pass within the final suite.
Optional E2E-only typecheck retains three unchanged errors in tests/e2e/helpers/store.ts (missing customTitle and optional activeGroup); there are no type errors in the new spec/barrier. That optional project is explicitly outside the repository’s required typecheck chain. Commit hooks pass.
Actual platforms: hidden macOS Electron plus disposable Linux Docker SSH hosts. Local and remote files are owned fixtures. Native Windows runtime was not exercised. CI routes save/discard sources and the timing harness to the Docker/template lane and excludes the spec from the general lane.
CI is fully green on bfb6336: 22 successful checks and 22 conditional skips.
Review
P1 / Low merge risk for this change. Two owner reads in one existing hook, with ordering and real-write controls. Stacked on own #26668 (Medium merge risk), which must merge first. No dependency on the previously handed-off editor-watch PR; its corrected watch path was used in the first defect isolation.
Agent skill upstream boundary
Notes
Uses the repository owner already present in the callback and dependency list. Legacy SSH and local null-owner matching remain intact; other focused runtimes cannot select the wrong editor for a managed Git operation. No new effects, polling, Git commands, wire changes or provider-specific behavior in product code. Folder workspaces retain their existing non-Git handling.
Checklist