Skip to content

PR conflict previews fetch the base branch through the shared fetch controller - #30654

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/conflict-fetch-controller
Oct 21, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/conflict-fetch-controller

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210 $\color{#cf222e}{\Huge{\mathbf{−}}}$​50 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​160
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​172 $\color{#cf222e}{\Huge{\mathbf{−}}}$​75 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​97

ELI5

When a pull request has conflicts, Orca downloads its base branch to list the conflicting files. That preview used a separate fetch path, so creating a worktree could download the same branch again. Simply sharing the worktree-creation fetch also let a stuck preview delay Create long after the preview stopped waiting.

This change gives both paths one download owner while keeping the preview's ten-second budget. A successful preview can save Create a second download. A failed or expired preview leaves Create free to make its normal attempt once the Git runner settles.

What Changed

  • Conflict previews ask the existing repository fetch controller to refresh the exact base branch. The controller shares a recent successful download and serializes work for the same remote.
  • A preview has one absolute ten-second deadline covering repository lookup, queueing, admission, and execution. Expiry ends the preview's wait and cancels work that preview started. Expired queued work cannot start later. The conflict list falls back to the local tracking ref, then the base commit supplied by GitHub, as before.
  • Create keeps its existing refresh, priority, sharing between Create callers, sixty-second process timeout, and failure behavior. Create cannot inherit a preview's short-lived attempt. A preview observing an existing Create fetch can stop waiting without cancelling Create.
  • Canceled repository lookups do not save an alternative repository identity. After recovery, linked worktrees keep sharing the same repository download. Ordinary lookup failures retain their existing fallback.
  • Both exact-base paths use the same Git command and success recording. The maintenance busy check includes queued previews; the actual operation's settlement controls queue release and maintenance.

The conflict list, controls, and notices are unchanged. No saved-data or remote-protocol change is required.

Why

The common pattern is a repository owner that shares work already in progress and bounds background work. Here, sharing successful downloads removes duplicate work without tying a user action to a preview's lifetime. Copying fetch flags into the old preview path would retain two policy owners; letting Create join a preview attempt would share its failure and short deadline.

Ordinary full-fetch maintenance remains enabled under #8039. Only exact-base refreshes suppress automatic maintenance and arm Orca's existing idle sweep. This PR corrects the controller's old comment; it does not change ordinary full-fetch arguments.

Intended differences: previews share successful freshness with Create, while their attempts remain private; the preview deadline now includes queue time, so expired work cannot start after the card stops waiting. Required refresh-before-Create behavior remains. The existing forced tracking-ref update and no-tags command are reused. Hard-coded origin selection and the conflict summary's existing caching remain outside this change.

Merge maintenance

The final merge of current main includes formatter-only merge-hook churn in six unrelated incoming-main files: src/main/agent-hooks/server/server-status-application.ts, src/main/agent-hooks/server/server-status-update.ts, src/main/daemon/pty-subprocess-spawn-file-foreground.test.ts, src/main/daemon/terminal-host-process-inspection.test.ts, src/main/providers/local-pty-child-process-verdict.test.ts, src/main/providers/local-pty-provider-foreground-process.test.ts. Five are whitespace-only; local-pty-child-process-verdict.test.ts also removes two semicolons. Direct diff review found the changes behavior-equivalent. These add 32 production lines and 71 test lines to the physical diff and are excluded from the repair line count. Normal hooks ran; no hook bypass or commit amendment was used.

Linked Issue

N/A: maintainer cleanup of background Git work.

Visual Proof

Real hidden-renderer Electron QA ran through qa-gate ticket 575 on Windows high spec, with a real Codex driver, comparing the exact head with its merged-main parent 9f37fcdf706fed694ecb4ef9e374818c1b7ea75c. Real Git used a disposable bare remote; provider metadata was a read-only fixture, while the store, IPC, controller and summary were unchanged. Both versions displayed one conflicting file at B1, then two at B2; normal Create used B2, release Create used its selected base, and offline Create retained its local fallback. Actual UI creation verified setup output, Shell A → Shell B → Setup, initial Shell A selection and subsequent Setup DOM focus. Plain folders still opened without a Git conflict surface.

Companion integration through the real store → IPC → controller → Git path exercised recovery around eleven seconds and overlapping normal fetches. The head rendered a preview fallback while a fifteen-second normal fetch continued, and healthy overlap used one fetch versus main's three. These are integration timings, not precise UI-click/deadline proof; actual UI creation verified startup separately. The head's B2 download occurred on automatic refresh; a later manual Refresh displayed that result.

Coverage limits: no SSH execution target was configured. Supplemental WSL cancellation evidence is unverified because the guest HOME was not isolated; no guest app or agent ran, and real config hashes remained unchanged. The real lower-admission/operation-lock expiry scenario was not exercised in Electron; targeted tests cover no late spawn. Windows named tests had 61 passes and six existing missing-/repo harness failures; matched main reproduced the same six. PowerShell profile/PSReadLine warnings occurred on both versions; no machine policy was changed. No live provider, Git 2.25 binary or mixed-peer QA is claimed. Original normal-Create screenshots differ in theme; offline screenshots used the same light input. The folder-main toast reflects preceding Git context. The initial default-agent attempt was aborted and is not successful signed-in-agent or cancellation coverage. All 336 recorded process identities were audited with none remaining, reserved ports were released, copied QA auth was removed and real configuration hashes were unchanged.

Flow Matched main PR head
Initial conflict main-conflict-before.png head-conflict-before.png
Updated conflict after remote base advances main-conflict-after.png head-conflict-after.png
Normal Create: setup and default tabs main-setup-output.png head-create-setup-output.png
Offline Create: setup and default tabs main-offline-created.png head-offline-created.png
Plain folder main-folder-open.png head-offline-folder-open.png

The original gh image attachments returned 404. These replacement attachments were fetched back as PNGs and matched the original hashes; they are stored outside the PR branch.

Testing

The full PR workflow, including its final aggregate, passed on head 23743a13edd5bf9b206c22de245c0bd9028efc70. The single CI watch also completed successfully for every registered platform check.

  • 116 tests passed in seven named files through the machine's test queue on macOS: client-pr-conflict-summary.test.ts, conflict-summary.test.ts, fetch-remote-cache.test.ts, client-merge-queue-auto-merge.test.ts, client-pr-linked-lookup.test.ts, git-exec-admission-lifetime.test.ts, and canonical-repo-key.test.ts, using Node and config/vitest.config.ts.

  • The flow cases cover healthy sharing, Create after network recovery for the same and a different base, overlapping Create callers, and a preview that stops waiting while a Create-owned fetch succeeds after fifteen seconds.

  • A real resolver/controller regression cancels a cold linked-worktree lookup, then verifies root and linked paths share one successful download after recovery. It covers both an aborted signal with a custom error and a deadline rejection while the signal remains live.

  • The real Git runner test holds admission beyond preview expiry, then releases it and verifies no child starts. It also covers delayed timer delivery, where the absolute-deadline eligibility check must reject a late start.

  • Existing tests retain the ten-second local-ref fallback, WSL routing and admission priority, Git compatibility fallback, and ordinary full-fetch maintenance. Duplicate argument and absolute subprocess-count assertions were pruned; the sharing cases reuse the controller directly and share a base fixture; unchanged previews must still start zero new subprocesses.

  • Repair scope: 140 added production lines and 139 added test lines. The physical diff after merging main is 172 added production lines and 210 added test lines; the difference is unrelated incoming-main formatting produced by the required merge hooks. No local typecheck or full lint run; CI is the static-analysis gate. Precommit hooks passed.

  • Git 2.25 compatibility is unchanged: no new Git option or refspec. WSL identity and caller options remain host-specific; SSH-backed summary callers still skip local derivation. No new Git requirement is imposed on folder workspaces, and mixed client/server response shapes are unchanged.

  • Automated tests added/updated

  • Main/branch Electron QA and screenshots complete (coverage limits above)

  • Full PR workflow green on head 23743a13edd5bf9b206c22de245c0bd9028efc70

Review

Full review path: the change touches concurrency, cancellation, and process lifetime, so it does not qualify for the light path. Two adversarial review rounds, independent architecture review, bounded design adjudication, readiness/performance review, narrow final-main-merge inspection and gated Electron QA are complete. Both proven P2 findings were fixed and independently checked; only an unproven future multiple-owner embedding concern remains deferred. The final status comment records completion on the exact head.

Agent skill upstream boundary

  • Not applicable: no upstream skill-installer source or fixtures copied.

Notes

Cancellation uses the Git runner's existing behavior. The queue follows operation settlement, not the card's return; this does not claim verified death of every descendant at exactly ten seconds. No new termination mode or unbounded cleanup wait is introduced.

Checklist

  • Focused on conflict-preview fetch ownership and lifetime
  • Explained the problem, user-facing result, mechanism, and alternatives
  • Cross-platform, SSH, folder workspace, and mixed-peer impact considered
  • Before/after QA evidence attached
  • Full PR workflow passed

…etch controller

The conflict summary on a PR card spawned its own `git fetch origin <base>`,
outside RuntimeRemoteFetchController: it refetched a base a worktree create
had just refreshed (and vice versa), ran git's auto-maintenance in the
background, and never armed the idle loose-ref sweep.

It now asks the runtime's controller for the exact-base refresh creates
already use (same argv, per-remote queue, dedupe and freshness), waiting at
most the old 10 s before falling back to the local ref. The runtime registers
its controller at construction, since the IPC and poller paths have no
runtime handle.

Also corrects the controller comment that claimed every fetch skips
auto-maintenance: full fetches keep it on purpose (#8039).
@brennanb2025
brennanb2025 marked this pull request as ready for review October 19, 2026 08:21
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 168520b0-0b33-485a-8cef-d4b9250d51f5
📥 Commits

Reviewing files that changed from the base of the PR and between 9f37fcd and 23743a1.

📒 Files selected for processing: 16
  • src/main/agent-hooks/server/server-status-application.ts
  • src/main/agent-hooks/server/server-status-update.ts
  • src/main/daemon/pty-subprocess-spawn-file-foreground.test.ts
  • src/main/daemon/terminal-host-process-inspection.test.ts
  • src/main/git/canonical-repo-key.ts
  • src/main/git/command-runner/git-exec-admission-lifetime.test.ts
  • src/main/github/client-merge-queue-auto-merge.test.ts
  • src/main/github/client-pr-conflict-summary.test.ts
  • src/main/github/client-pr-linked-lookup.test.ts
  • src/main/github/conflict-summary.test.ts
  • src/main/github/conflict-summary.ts
  • src/main/providers/local-pty-child-process-verdict.test.ts
  • src/main/providers/local-pty-provider-foreground-process.test.ts
  • src/main/runtime/construction/runtime-construction.ts
  • src/main/runtime/fetch-remote-cache.test.ts
  • src/main/runtime/runtime-remote-fetch-controller.ts
  • 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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Conflict previews downloaded their base branch through a separate path from worktree creation. That duplicated downloads; sharing the long-running attempt directly also let a stuck preview keep Create waiting after the card stopped waiting.

The PR now uses the repository fetch controller while keeping the preview's ten-second budget. Create can reuse a successful download and keeps its normal refresh and timeout. Ordinary full-fetch maintenance remains enabled under #8039.

The full review fixed two proven P2 problems: Create inheriting a stuck preview attempt, and a canceled repository lookup saving an incorrect identity that prevented linked worktrees from sharing later downloads. Implementation-only assertions were pruned. A possible future embedding with multiple controller owners is deferred: current construction paths register their owner before use, and no shipping failure was reproduced. Existing origin selection is unchanged. There are no open proven findings.

Verification: two review rounds, independent architecture and readiness/performance review, bounded design adjudication, 116 targeted tests on the merged head, and the full PR workflow including its aggregate passed on 23743a13edd5bf9b206c22de245c0bd9028efc70. The unrelated merge-hook formatting in six incoming-main files is labelled in the PR body; scoped additions are 140 production / 139 test lines. No local lint or typecheck ran.

Real hidden-renderer Electron QA ran through qa-gate ticket 575 on Windows high spec, with a real Codex driver, comparing the exact head with its merged-main parent 9f37fcdf706fed694ecb4ef9e374818c1b7ea75c. Real Git used a disposable bare remote; provider metadata was a read-only fixture, while the store, IPC, controller and summary were unchanged. Both versions displayed one conflicting file at B1, then two at B2; normal Create used B2, release Create used its selected base, and offline Create retained its local fallback. Actual UI creation verified setup output, Shell A → Shell B → Setup, initial Shell A selection and subsequent Setup DOM focus. Plain folders still opened without a Git conflict surface.

Companion integration through the real store → IPC → controller → Git path exercised recovery around eleven seconds and overlapping normal fetches. The head rendered a preview fallback while a fifteen-second normal fetch continued, and healthy overlap used one fetch versus main's three. These are integration timings, not precise UI-click/deadline proof; actual UI creation verified startup separately. The head's B2 download occurred on automatic refresh; a later manual Refresh displayed that result.

Coverage limits: no SSH execution target was configured. Supplemental WSL cancellation evidence is unverified because the guest HOME was not isolated; no guest app or agent ran, and real config hashes remained unchanged. The real lower-admission/operation-lock expiry scenario was not exercised in Electron; targeted tests cover no late spawn. Windows named tests had 61 passes and six existing missing-/repo harness failures; matched main reproduced the same six. PowerShell profile/PSReadLine warnings occurred on both versions; no machine policy was changed. No live provider, Git 2.25 binary or mixed-peer QA is claimed. Original normal-Create screenshots differ in theme; offline screenshots used the same light input. The folder-main toast reflects preceding Git context. The initial default-agent attempt was aborted and is not successful signed-in-agent or cancellation coverage. All 336 recorded process identities were audited with none remaining, reserved ports were released, copied QA auth was removed and real configuration hashes were unchanged.

For Brennan's review

Whole-window comparisons below use the same fixture inputs. The conflict list still appears and updates; setup, tab order, selected workspace and folder behavior remain intact. The unchanged PowerShell warnings are visible rather than hidden.

Flow Matched main PR head
Initial conflict main-conflict-before.png head-conflict-before.png
Updated conflict after remote base advances main-conflict-after.png head-conflict-after.png
Normal Create: setup and default tabs main-setup-output.png head-create-setup-output.png
Offline Create: setup and default tabs main-offline-created.png head-offline-created.png
Plain folder main-folder-open.png head-offline-folder-open.png

Additional branch capture: preview fallback while a normal fetch continues (timing established by trace, not the still image).

head-create-first-preview.png

Three judgment points:

The original gh image URLs returned 404; replacement PR attachments above were downloaded and hash-verified, outside the source branch.

@brennanb2025
brennanb2025 merged commit 1a0e1e9 into main Oct 21, 2026
42 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.

1 participant