orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(source-control): refresh branch compare after upstream changes

Open siddqamar opened this issue 5 months ago â€ĸ 1 comments

Summary

Fixes Source Control staying stale after commit/push. The issue happened because branch compare refreshed on local HEAD changes, but a push can update the remote-tracking ref and ahead/behind state without changing local HEAD, so the tree stayed stale until tab switching triggered another refresh.

This PR refreshes branch compare when upstream status changes for the same worktree/base ref, and prevents stale Create PR eligibility from staying clickable while a newer preflight is loading.

Screenshots

No visual change.

Testing

  • [x] pnpm lint
  • [ ] pnpm typecheck
  • [ ] pnpm test
  • [ ] pnpm build
  • [x] Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Focused tests run:

  • vitest ... SourceControl.compare-summary.test.ts source-control-primary-action.create-pr-intent.test.ts

AI Review Report

  • Reviewed the Source Control refresh flow from commit/push through upstream status, branch compare, and Create PR eligibility.
  • Checked that the fix is provider-neutral and applies to GitHub/GitLab/other review providers because it keys off generic Git upstream state, not GitHub-specific behavior.
  • Checked cross-platform impact for macOS, Linux, and Windows: no shortcut, shell, path separator, or platform-specific Electron behavior was changed.
  • Checked SSH/remote compatibility: the refresh uses existing runtime-routed Source Control state and does not assume local-only Git execution.

Security Audit

No new command execution, IPC channel, credential handling, dependency, or filesystem path handling was added.

The change only reacts to existing upstream-status state and existing eligibility preflight state.

No secrets, auth tokens, or user-controlled shell input are introduced.

Fixes #6516

siddqamar avatar Jun 27 '26 22:06 siddqamar

Review Change Stack

[!CAUTION]

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

â„šī¸ Recent review info
âš™ī¸ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6e69454a-66e8-42dc-818a-3c7a8af0ff24

đŸ“Ĩ Commits

Reviewing files that changed from the base of the PR and between 2e67fa18bdf25297f0b0fb520310ad05df346216 and 071c5f7330190dc39feb0e68e00ece931f7eeffd.

📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/source-control-primary-action.create-pr-intent.test.ts

📝 Walkthrough

Walkthrough

SourceControl.tsx now refreshes branch compare when remote-tracking fields change for the same worktree and base ref, using a new snapshot type, helper, ref, and effect. The hosted-review flow now stores a provider hint, suppresses loading eligibility unless hostedReview is null, clears stale eligibility at preflight start, and keeps the header action disabled while loading. Tests were added for the branch-compare helper and for GitHub/GitLab header loading behavior.

đŸšĨ Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage âš ī¸ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: refreshing source control branch compare after upstream changes.
Description check ✅ Passed The description largely follows the template and includes summary, screenshots, testing, AI review, and security sections.
Linked Issues check ✅ Passed The branch-compare refresh and stale eligibility fix address the linked auto-refresh bug after commit and push.
Out of Scope Changes check ✅ Passed The provider-hint and loading changes are directly tied to the stated refresh and eligibility behavior, with no clear unrelated scope.

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[bot] avatar Jun 27 '26 22:06 coderabbitai[bot]