Skip to content

Keep PR checks aligned with branch switches#6458

Merged
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/agent-cli-layout
Jun 28, 2026
Merged

Keep PR checks aligned with branch switches#6458
brennanb2025 merged 3 commits into
mainfrom
brennanb2025/agent-cli-layout

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Keeps the Checks/PR sidebar aligned with the active worktree branch when terminal/git status observes a branch switch.

  • Clears branch-scoped hosted review links and review-derived push targets when branch identity changes, so stale exact PR/MR links do not win over the current branch.
  • Makes the explicit Checks Refresh button perform one targeted git status read, commit fresh empty-state eligibility, and restart on discovered branch changes instead of refreshing stale PR data.
  • Adds generation, tombstone, and migration guards so stale worktree refetches cannot rehydrate old review links or push targets.

Screenshots

Product validation captured local screenshot evidence:

  • Before: .playwright-cli/page-2026-06-27T00-33-20-080Z.png
  • After: .playwright-cli/page-2026-06-27T00-33-50-204Z.png

Testing

  • pnpm lint (passed with one existing warning in useGitStatusPolling.ts, outside this diff)
  • pnpm typecheck
  • pnpm test (not run in full; focused Vitest below covered changed modules)
  • pnpm build (not run locally; CI built the unpacked app)
  • Added or updated high-quality tests that would catch regressions
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/right-sidebar/checks-panel-git-status-snapshot.test.ts src/renderer/src/store/slices/worktrees.test.ts (202 passed after CodeRabbit fix)
  • pnpm run typecheck:web
  • git diff --check
  • Pre-commit staged checks: oxlint, React Doctor oxlint config, oxfmt --write
  • PR verify check passed, including lint, typecheck, test, unpacked app build, and packaged CLI smoke

Product validation:

  • Launched Electron from this worktree and verified the app identity pointed at /Users/thebr/orca/workspaces/orca/yellowtail on branch brennanb2025/agent-cli-layout.
  • Used demo-project via a temporary git worktree; did not use the Orca repo or real Orca PRs/issues.
  • Seeded stale state with linkedPR: 4908 and a pushTarget, switched the underlying branch externally, then clicked the real Checks pane Refresh button.
  • Verified backing state updated to the new branch, cleared GitHub/GitLab/Bitbucket/Azure/Gitea links, and removed pushTarget.
  • Verified visible UI showed fresh empty-state eligibility: Branch not published, Publish Branch, and Refresh.
  • Ran an authoritative worktree refresh afterward; stale review metadata did not rehydrate.

AI Review Report

Design review completed cleanly after adding explicit performance constraints from recent git refresh/coalescing work.

Implementation/completeness review flagged several branch-switch and stale-refetch edge cases during the process, including push-target clearing, stale refetch protection, migration-during-persist behavior, list-lag behavior, tombstone lifecycle, and repeated branch switches before clear persistence. Those issues were fixed and covered with focused regression tests.

Perf review checked the recent Windows/git subprocess risk areas: polling, subprocess fanout, store churn, worktree list refresh hot paths, persistence write fanout, SSH/runtime boundaries, and alias/tombstone memory bounds. No new background polling was added; the extra git status read is only from an explicit user Refresh click.

Final pre-PR code-review round: two independent reviewers returned No issues found. The review explicitly checked macOS/Linux/Windows compatibility, SSH/runtime parity, provider compatibility, stale async guards, and persistence/state consistency.

Post-PR CodeRabbit/check stabilization:

  • CodeRabbit flagged a repeated branch-switch persistence race; fixed in fa86135a6 with a regression test.
  • Latest CodeRabbit pass reports no actionable comments.
  • PR verify check passed.
  • Remaining CodeRabbit docstring coverage warning is non-actionable for this TS UI/state change.

Security Audit

Reviewed risks:

  • Input/command execution: no new shell commands or user-controlled command execution paths in product code.
  • Path handling: no new path parsing or platform-specific separators.
  • Auth/secrets: no new tokens, secrets, credentials, or provider auth flows.
  • IPC/runtime: existing runtime git helpers are used with existing settings, worktreeId, worktreePath, and connectionId boundaries preserved for local, SSH, and runtime environments.
  • Persistence: hosted-review metadata clears are generation guarded and avoid stale async writes overwriting newer manual relinks.
  • Provider compatibility: clearing is generic across GitHub, GitLab, Bitbucket, Azure DevOps, Gitea, and push targets; provider-specific review fetching remains behind existing provider paths.

No follow-up security work is required.

Notes

  • No live SSH pass was run because this diff uses existing runtime/git helper boundaries and does not change SSH/remoting implementation; perf and code review checked runtime/connection propagation.
  • Residual accepted performance risk: active tombstones can retain old-id aliases across migrations until superseded or purged; this is bounded to affected worktrees and is not on a polling/render/subprocess hot path.

Co-authored-by: Orca <help@stably.ai>
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: 17e58922-74bc-4a14-9079-d4e55485bd5f

📥 Commits

Reviewing files that changed from the base of the PR and between fa86135 and 799e578.

📒 Files selected for processing (1)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx

📝 Walkthrough

Walkthrough

The PR adds git identity tracking to ChecksPanel refresh handling, including snapshot-based refresh checks, explicit gitIdentity storage, and branch-change detection. It also adds hosted-review link clear bookkeeping in the worktrees slice across refresh, branch-switch, removal, purge, and migration paths, with expanded unit tests for both areas.

🚥 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 is concise and accurately reflects the main branch-switch alignment change.
Description check ✅ Passed The description follows the template and includes summary, screenshots, testing, AI review, security audit, and notes.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/store/slices/worktrees.ts (1)

2375-2496: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Persist clears when a tombstoned worktree switches branches again.

After the first branch switch clears links, a second updateWorktreeGitIdentity before the queued clear runs updates the tombstone here but leaves shouldPersistHostedReviewClear false. The queued task can then return at Line 2439 because current.branch !== clearedBranch, so the clear survives only in memory and stale persisted review metadata can rehydrate after restart.

Suggested fix
         } else {
           const tombstone = hostedReviewLinkClearTombstonesByWorktreeId.get(worktreeId)
           if (tombstone) {
-            hostedReviewLinkClearTombstonesByWorktreeId.set(worktreeId, {
+            const nextTombstone = {
               ...tombstone,
               branch: nextBranch,
               branchIdentity: canonicalHostedReviewBranchIdentity(nextBranch),
               head: nextHead
-            })
+            }
+            hostedReviewLinkClearTombstonesByWorktreeId.set(worktreeId, nextTombstone)
+            if (hostedReviewBranchChanged) {
+              shouldPersistHostedReviewClear = true
+              clearedBranch = nextBranch
+              clearGeneration = tombstone.generation
+            }
           }
         }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dde227d7-ab4c-4bbe-b86b-522f7fc5e672

📥 Commits

Reviewing files that changed from the base of the PR and between e1f9323 and 5c53f2d.

📒 Files selected for processing (5)
  • src/renderer/src/components/right-sidebar/ChecksPanel.tsx
  • src/renderer/src/components/right-sidebar/checks-panel-git-status-snapshot.test.ts
  • src/renderer/src/components/right-sidebar/checks-panel-git-status-snapshot.ts
  • src/renderer/src/store/slices/worktrees.test.ts
  • src/renderer/src/store/slices/worktrees.ts

brennanb2025 and others added 2 commits June 26, 2026 17:46
Co-authored-by: Orca <help@stably.ai>
@brennanb2025 brennanb2025 merged commit 7019693 into main Jun 28, 2026
1 check 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