Skip to content

Keep worktree PR badges stable during refresh - #6397

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/continue-task
Jun 26, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/continue-task

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Keep legacy detailed worktree cards from briefly losing their right-side PR badge when hosted-review metadata writes an older transient miss while the branch PR cache already has a newer PR.

The card now uses the GitHub PR cache only when hosted-review data is still warming, or when the PR cache is strictly newer than a hosted-review null miss. Equal or older PR cache entries do not resurrect a stale badge. When the PR cache supplies an unlinked branch review, the display path also gets the neutral review hint needed to render branch-discovered GitHub PR metadata.

The GitHub-only PR cache is blocked from masking durable linked metadata for GitLab, Bitbucket, Azure DevOps, and Gitea worktrees.

Design And Review

  • Design approach: scoped renderer-side cache selection in WorktreeCard, no provider calls, polling changes, cache-key changes, or visual styling changes.
  • Design review outcome: the design was revised to avoid stale PR resurrection by using a strict fetchedAt comparison, and later tightened so the neutral hint follows the same fallback decision.
  • Implementation deviations: added a provider guard so GitHub prCache cannot override durable non-GitHub linked review metadata.
  • Completeness verification: final read-only verification found no blockers after the provider and hint-key fixes.
  • Performance audit: no actionable perf issues. The render path keeps exact-entry Zustand subscriptions and adds only constant-time scalar checks plus an existing PR-to-review projection when eligible.

Code Review

  • Review round 1 found that a broad hosted-review null fallback could resurrect stale PR cache data. Fixed with strict timestamp ordering and negative tests.
  • Review round 2 found that an older hosted-review hint could still suppress the PR-cache fallback. Fixed by tying the neutral hint to the PR-cache fallback decision.
  • Review round 3 found GitHub PR cache could mask durable non-GitHub linked metadata. Fixed with a provider guard and regression test.
  • Final round: WorktreeCard changes were clean. One reviewer surfaced an unrelated base-code concern outside this PR diff, so it was treated as non-actionable for this PR.

Tests

  • git diff --check
  • pnpm run typecheck
  • pnpm run lint (exited 0; existing warning in useGitStatusPolling.ts)
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx (24 tests)
  • Electron validation from exact worktree:
    • verified window.api.app.getIdentity() root /Users/thebr/orca/workspaces/orca/velvetfish
    • verified branch brennanb2025/continue-task
    • used real demo-project PR stablyai/demo-project#21
    • real branch/worktree: brennanb2025/pr-badge-real-pr-20260626
    • configured legacy detailed cards with PR metadata enabled
    • fetched real GitHub PR data through the app provider path
    • clicked the real worktree card and verified the right-side PR badge remained visible as Linked PR #21

Screenshots

Manual validation evidence was captured from the exact PR worktree:

  • .playwright-cli/page-2026-06-26T02-21-34-854Z.png
  • .playwright-cli/page-2026-06-26T02-20-51-705Z.png
  • .playwright-cli/page-2026-06-26T02-00-03-688Z.png
  • .playwright-cli/page-2026-06-26T01-59-37-287Z.png

The latest clean screenshot shows the real demo-project PR #21 in the Checks panel after clicking the legacy detailed worktree card. DOM inspection after the click showed the selected card's metadata node contained Linked PR #21.

Accepted validation notes:

  • A synthetic cache-race pass was run first to deterministically cover older hosted-review null plus newer PR cache.
  • A follow-up real-PR pass used stablyai/demo-project#21 for reproduction/manual validation through the actual provider data path.
  • Demo-project PR #21 intentionally remains open as a throwaway validation PR.

Security Audit

  • No new network calls, filesystem writes, subprocesses, IPC handlers, shell commands, permissions, or secrets handling.
  • The change is renderer-only cache selection over already-loaded store entries.
  • SSH/runtime boundaries are preserved by the existing hosted-review and PR-cache key construction; no cache-key construction changed.

AI Review Report

  • Design review: completed and incorporated strict timestamp ordering plus neutral-hint coupling.
  • Completeness verification: completed after each review fix; final pass found no blockers.
  • Performance audit: completed; no actionable performance issues.
  • Code review: multiple independent review rounds completed. Actionable findings were fixed. Final WorktreeCard review was clean; one unrelated base-code finding outside this PR diff was treated as non-actionable for this PR.
  • Platform coverage: no platform-specific behavior changed. The code path uses existing cache keys for local, SSH, and runtime-owned repos and avoids path, shell, shortcut, or OS assumptions.

Notes

  • This PR is intentionally scoped to keeping the existing PR badge stable during hosted-review cache races. It does not change provider refresh semantics globally.
  • The validation used deterministic synthetic demo-project PR cache data because the original click race is transient.

Post-PR Stabilization

  • First sweep after the required 8-minute wait: CodeRabbit generated no actionable code comments or review threads.
  • CodeRabbit description warning requested explicit Screenshots, Security Audit, Notes, and AI Review Report sections; this PR body update addresses that warning.
  • Final check sweep: verify passed and track-community-pr passed.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

WorktreeCard changes how PR badge display is chosen when hosted-review data is missing or stale. It now derives explicit linked PR and MR values, uses a new cached-branch-review condition based on linked-review presence and fetchedAt ordering, and updates reviewHintKey selection. The tests add coverage for transient hosted-review misses, linked GitLab MR precedence, and stale cache resurrection cases, including same-timestamp updates.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: stabilizing worktree PR badges during refresh.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description check ✅ Passed The PR description includes all required sections and enough detail on summary, testing, screenshots, security, notes, and review work.
✨ 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.

@brennanb2025
brennanb2025 merged commit ef47719 into main Jun 26, 2026
2 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/continue-task branch June 26, 2026 02:23
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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