Skip to content

Wait for managed editor saves before discarding Git changes - #26677

Merged
OrcaWin merged 1 commit into
mainfrom
nwparker/managed-discard-editor-owner
Oct 9, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
nwparker/managed-discard-editor-owner

Conversation

@nwparker

@nwparker nwparker commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​101
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3

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-editor-owner-before-1.png
managed-discard-editor-owner-after-1.png
managed-discard-editor-owner-before-2.png
managed-discard-editor-owner-after-2.png
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

  • I manually tested these changes locally
  • Automated tests added/updated

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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@OrcaWin
OrcaWin force-pushed the nwparker/remote-open-in-owner branch from 88db24b to 486786c Compare October 9, 2026 05:35
@OrcaWin
OrcaWin requested a review from brennanb2025 as a October 9, 2026 05:35
@OrcaWin
OrcaWin force-pushed the nwparker/remote-open-in-owner branch 3 times, most recently from a70ab92 to 9a3416a Compare October 9, 2026 06:27
@OrcaWin
OrcaWin changed the base branch from nwparker/remote-open-in-owner to main October 9, 2026 06:49
…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.
@OrcaWin

OrcaWin commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Rebased onto main now that #26668 has merged, and cut down to the product fix plus its unit regression test (two lines in use-entry-mutations.ts and source-control-discard-editor-owner.test.tsx). The Electron/Docker timing harness and the CI routing changes are no longer part of this PR. All six regression cases fail on current main and pass with the fix. Typecheck, the source-control commit tests, oxlint, the changed-code quality gate and anti-slop all pass locally.

@OrcaWin
OrcaWin force-pushed the nwparker/managed-discard-editor-owner branch from bfb6336 to b4bf9cc Compare October 9, 2026 08:31
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55aa8990-4cd4-4e67-8156-5d8ef9dc5db8

📥 Commits

Reviewing files that changed from the base of the PR and between 39a01f9 and b4bf9cc.


📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/source-control/commit/source-control-discard-editor-owner.test.tsx
  • src/renderer/src/components/right-sidebar/source-control/commit/use-entry-mutations.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.



📝 Walkthrough

Walkthrough

Single 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 b4bf9

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)

Check name Status Explanation Resolution
Description check Warning 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 i… Add a valid issue reference in the Linked Issue section, such as "Fixes #". If the contributor is an internal maintainer and no issue is required, state the applicable repository-approved exception clearly.
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: waiting for managed editor saves before discarding Git changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Description check

Explanation

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.



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin merged commit 3ca1d81 into main Oct 9, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants