Skip to content

fix(git): stop stale conflict batches after hide or cleanup - #35682

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-stale-conflict-poll-admission
Oct 30, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-stale-conflict-poll-admission

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​79 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​79
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​3

Problem

The poller that clears conflict badges (merge/rebase in progress) on inactive worktrees checked window visibility only once, before a batch started, and checked whether its effect was still current only after a probe succeeded. As a result:

  • A batch already running when the window was hidden kept sending conflict-operation probes (IPC/SSH/runtime RPC) for the remaining worktrees.
  • After the effect was retired (disabled, worktree list changed, unmount), a probe that rejected fell through to the catch and the loop kept probing the remaining worktrees.

No visible behavior changes; this removes wasted background requests.

Fix

Before each worktree probe, pollStale returns early when the effect is retired or the window is hidden. In-flight requests are not cancelled. The early return resolves normally in the coalesced runner, and runOnVisible re-runs the full batch, so badges still recover when the window becomes visible again.

Validation

  • Added one regression test (stale-conflict-operation-poll.test.tsx): the effect is retired while the first probe is pending, that probe rejects, and the second worktree is never probed. It fails on main (2 calls) and passes with the fix.
  • pnpm check:changed --maxWorkers=2 passes (format, lint, typecheck, ratchets, affected unit tests).

@OrcaWin
OrcaWin force-pushed the OrcaWin/git-stale-conflict-poll-admission branch from ef1a369 to a932960 Compare October 30, 2026 10:10
@OrcaWin
OrcaWin marked this pull request as ready for review October 30, 2026 10:11
@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The polling hook now checks whether its effect is active and the window is visible before probing each stale worktree. A new test disables the hook while its first probe is pending, rejects the probe, advances timers by 10 seconds, and verifies that no additional request occurs.

Priority: Low

Merge Risk: Minimal · up to a9329

The polling change is mergeable; a hide-and-resume test would improve confidence in future changes.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description clearly explains the problem, fix, regression test, and validation command. However, it omits required template sections, including the linked issue, visual proof or an explicit N/A ex… Add the missing template sections. Include an actual issue link after “Fixes #”, provide visual proof or write N/A with a reason, document manual and platform testing, complete the AI Disclosure section when applicable, and address the re…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: stopping stale conflict polling when the window is hidden or the effect is cleaned up.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.

Full details: Description check

Explanation

The description clearly explains the problem, fix, regression test, and validation command. However, it omits required template sections, including the linked issue, visual proof or an explicit N/A explanation, testing checklist details, AI disclosure, review checklist, and cross-platform or compatibility notes.

Resolution

Add the missing template sections. Include an actual issue link after “Fixes #”, provide visual proof or write N/A with a reason, document manual and platform testing, complete the AI Disclosure section when applicable, and address the review, compatibility, performance, and checklist items.

Finishing Touches
📝 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick comments: 1
src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.test.tsx: 1

1-79: Trivial · Maintainability & Code Quality · Quick win

Add coverage for the hidden-window branch of pollStale.

The new test keeps visibilityState at 'visible' and never hides the window. It disables the hook instead. The only guard it exercises is the !active check. Removing the in-loop !isWindowVisible() check at stale-conflict-operation-poll.ts:69 would leave this test passing, because the disabled effect already stops the loop.

No test in this file covers the stated hide-and-resume behavior:

  • The window hides while the first probe is pending. The loop must not probe the second worktree.
  • The window becomes visible again. The remaining stale worktrees must be probed.

Without that coverage, a change can remove the hidden-window skip and restart probes while the window is hidden. The suite would still pass.

Keep the effect enabled. Set visibilityState to 'hidden' while the first probe is pending, resolve it, and assert that the second worktree is not probed. Then restore 'visible', trigger the same recovery path the window-visibility interval uses, and assert that the remaining worktree is probed.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e8c57f8e-fede-446c-9760-3a371f29ac3a
Commits

Reviewing files that changed from the base of the PR and between fad768d and a932960.

Files selected for processing: 2
  • src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.test.tsx
  • src/renderer/src/components/right-sidebar/stale-conflict-operation-poll.ts

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

@OrcaWin
OrcaWin merged commit 8d4e619 into main Oct 30, 2026
69 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/git-stale-conflict-poll-admission branch October 30, 2026 10:22
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