Skip to content

Fix folder workspace PR status icon from branch cache#7449

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-folder-pr-status-branch-cache
Jul 5, 2026
Merged

Fix folder workspace PR status icon from branch cache#7449
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/fix-folder-pr-status-branch-cache

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Make the left folder workspace PR status icon consume the same parent PR-checks row projection used by the right sidebar.
  • Centralize hosted-review and GitHub PR cache acceptance for parent PR-check rows, including linked-review provider/number matching, merged-review current-head guards, newer hosted-review miss precedence, and local legacy PR-cache fallback.
  • Keep the left folder card path lightweight: it resolves attached child worktrees, adapts the shared row identity/classified status into the compact icon display, and avoids check-detail cache fanout.

Why

The right PR checks sidebar was usually correct because it projected hosted-review/PR cache state through buildParentPrChecksProjection(...). The left folder workspace icon had a separate lookup path, so branch-discovered PRs and cache edge cases could show as a branch icon or stale status on the left while the right sidebar showed the PR.

Consistency

Source of truth: parent PR-checks rows in the right sidebar.
Compared surfaces: folder workspace status icon, right sidebar folder PR checks panel, WorktreeCard PR display/cache guards, PR-status grouping legacy cache behavior, hosted-review refresh, and GitHub checks status sync.
Result: the left folder icon now follows the same review identity and classified status as the right sidebar, while deliberately omitting right-panel-only check detail names.

Perf / No-Regression Audit

  • Checked hot paths: virtualized WorktreeList render, folder-card PR display derivation, parent row projection, PR/hosted-review cache lookup, refresh path.
  • Fixed avoidable work found during audit: removed per-folder repo enumeration by using the existing repoMap; removed the left-sidebar checksCache subscription/fanout because the icon only needs review identity/classified status, not check-detail rows.
  • No new polling, timers, listeners, subprocesses, IPC/RPC, or provider/API fanout. Refresh remains bounded by the existing parent-checks concurrency.
  • Deterministic guards: lookup-only repo-map test, no WorktreeList checksCache subscription, legacy/local cache tests, stale/mismatched cache tests, and refresh current-head propagation test.

AI Review Report

  • Dedicated perf audit found the repo-enumeration issue; fixed and covered by test.
  • Multi-round two-lane code review found and fixed: checksCache fanout, linked stale PR cache, classified conflict status mismatch, hosted-review linked/provider mismatch, local legacy fallback, stale merged hosted-review cache, refresh current-head propagation, and CodeRabbit follow-up comments.
  • Final clean review round returned no issues before the CodeRabbit follow-up commit; CodeRabbit comments addressed in the latest push.

Security Audit

  • No auth, secrets, permissions, command execution, network request, persistence format, or user-content exposure changes.
  • Cache keys continue to respect repo id/path plus connection/execution-host boundaries; legacy cache fallback is limited to local/explicit-local repos.

Screenshots

  • No visual screenshot captured. This is a cache/projection correctness change covered through targeted unit tests; the visible icon consumes the same existing card display path.

Testing

  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts src/renderer/src/components/right-sidebar/parent-pr-checks-rows.test.ts src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.test.ts src/renderer/src/components/sidebar/WorktreeCard.pr-display.test.tsx src/renderer/src/components/sidebar/WorktreeCard.merged-pr-display.test.tsx src/renderer/src/components/sidebar/WorktreeCard.hosted-review-refresh.test.tsx src/renderer/src/store/slices/hosted-review.test.ts src/renderer/src/store/slices/github-checks.test.ts - 9 files / 91 tests passed.
  • pnpm run typecheck:web - passed.
  • pnpm exec oxlint ...changed files... - passed.
  • git diff --check && git diff --cached --check - passed.

Notes

  • CI and automated PR review need to rerun after the latest force-push.
  • The local .npmrc still prints the existing ${GITHUB_TOKEN} substitution warning during pnpm commands; commands completed successfully.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change updates parent PR checks cache validation, row projection, and refresh inputs to account for worktree head and linked-review state. It extends the row and cache types with review number/status and a linked-review hint key, and reuses the shared parent PR checks projection in folder workspace card display. The refresh flow now includes the current head OID when fetching hosted reviews. Tests were updated to cover cache selection, stale-entry invalidation, and the folder card display path.

Related PRs: None identified.

Suggested labels: area:right-sidebar, area:sidebar, tests

Suggested reviewers: None identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately summarizes the main change to the folder workspace PR status icon.
Description check ✅ Passed The description follows the template closely and includes all required sections with substantive details.

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 (2)
src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts (1)

305-312: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Align hasNonGitHubLinkedReview with the canonical presence check.

This helper diverges from the equivalent logic in checks-panel-review.ts and WorktreeCard.tsx, which OR explicit presence checks. The ?? chain short-circuits on the first non-nullish value, so a legitimately-set later field can be masked by an earlier 0 (e.g. 0 ?? 50), and Boolean(0) then yields false. While PR/MR numbers are 1-based today, this behavioral divergence undercuts this PR's goal of matching the child/right-sidebar selection exactly. A per-field != null check (which also covers undefined optional fields) is both correct and consistent.

♻️ Proposed alignment
 function hasNonGitHubLinkedReview(worktree: Worktree): boolean {
-  return Boolean(
-    worktree.linkedGitLabMR ??
-    worktree.linkedBitbucketPR ??
-    worktree.linkedAzureDevOpsPR ??
-    worktree.linkedGiteaPR ??
-    null
-  )
+  return (
+    worktree.linkedGitLabMR != null ||
+    worktree.linkedBitbucketPR != null ||
+    worktree.linkedAzureDevOpsPR != null ||
+    worktree.linkedGiteaPR != null
+  )
 }
src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts (1)

167-186: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider covering the hosted-review-miss staleness path.

Both new tests pass hostedReviewCache: null, so the new hostedReviewMissFetchedAt staleness rejection branch (reject when (entry?.fetchedAt ?? 0) <= hostedReviewMissFetchedAt and PR isn't a current-head merged PR) is never exercised. Adding a case with a hosted-review miss entry whose fetchedAt is newer than the cached PR's would guard this new logic against regressions.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5c3d823f-1226-4dbc-b252-1d3b5db73d7a

📥 Commits

Reviewing files that changed from the base of the PR and between 4b2e473 and c5c694a.

📒 Files selected for processing (2)
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts

@brennanb2025 brennanb2025 force-pushed the brennanb2025/fix-folder-pr-status-branch-cache branch from c5c694a to dab2f68 Compare July 5, 2026 20:19

@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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts (1)

37-45: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

?? chain only checks the first non-nullish field, not "any field set".

a ?? b ?? c ?? d ?? null short-circuits on the first field that isn't null/undefined, then only tests that value's truthiness — it never inspects the remaining fields once one is non-nullish. If an earlier field happened to be 0 (falsy but non-nullish), a genuinely linked later field (e.g. linkedGiteaPR) would be silently ignored. PR/MR numbers are 1-indexed in practice so this is unlikely to trigger, but the logic doesn't actually express "is any non-GitHub review linked".

♻️ Proposed fix
 function hasNonGitHubLinkedReview(worktree: Worktree): boolean {
-  return Boolean(
-    worktree.linkedGitLabMR ??
-    worktree.linkedBitbucketPR ??
-    worktree.linkedAzureDevOpsPR ??
-    worktree.linkedGiteaPR ??
-    null
-  )
+  return (
+    worktree.linkedGitLabMR != null ||
+    worktree.linkedBitbucketPR != null ||
+    worktree.linkedAzureDevOpsPR != null ||
+    worktree.linkedGiteaPR != null
+  )
 }
src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts (1)

111-115: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Unchecked type cast bypasses type safety for cache inputs.

coerceParentPrChecksCache blindly casts Record<string, unknown> to Record<string, ParentPrChecksCacheEntry<T>> via as, with no runtime shape validation. If any cache entry doesn't actually match { data, fetchedAt }, downstream consumers (e.g. the fetchedAt comparisons in the guard) will silently operate on malformed data rather than failing fast. Consider typing hostedReviewCache/prCache/checksCache more precisely at the boundary where they're produced, so this function isn't needed as an escape hatch.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cee6d0e0-fef2-4900-bb15-76ed0e6d5934

📥 Commits

Reviewing files that changed from the base of the PR and between c5c694a and dab2f68.

📒 Files selected for processing (8)
  • src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx
  • src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-row-types.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.ts
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts

Comment thread src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts Outdated
@brennanb2025 brennanb2025 force-pushed the brennanb2025/fix-folder-pr-status-branch-cache branch from dab2f68 to 000d94a Compare July 5, 2026 21:39

@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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/renderer/src/components/right-sidebar/parent-pr-checks-rows.ts (1)

158-197: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Non-obvious cache-precedence logic could use a short "why" comment.

The fallback order here (hosted-review cache → GitHub PR cache → null/undefined based on hostedReviewEntry?.data === null) encodes a subtle precedence rule that isn't obvious from the code alone, similar to the pattern already flagged in parent-pr-checks-github-pr-cache.ts. A one-line comment on why hosted-review cache is checked before the GitHub PR cache, and why a confirmed-null hosted review yields null while an absent/rejected entry yields undefined, would help future readers.

As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."

Source: Coding guidelines

src/renderer/src/components/right-sidebar/parent-pr-checks-hosted-review-cache.ts (1)

59-88: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract shared linked-review helpers. This duplicates the provider switch in src/renderer/src/components/sidebar/worktree-card-pr-display.ts and the linked-review guard in src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts; sharing that mapping would keep provider handling in one place and reduce drift when new providers are added.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7e8f0136-3ac4-49b2-87dc-b2512b57d8f0

📥 Commits

Reviewing files that changed from the base of the PR and between dab2f68 and 000d94a.

📒 Files selected for processing (10)
  • src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx
  • src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-hosted-review-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-row-types.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/right-sidebar/parent-pr-checks-row-types.ts
  • src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx

Comment thread src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts Outdated
@brennanb2025 brennanb2025 force-pushed the brennanb2025/fix-folder-pr-status-branch-cache branch from 000d94a to 0c2a49c Compare July 5, 2026 21:52
@brennanb2025 brennanb2025 force-pushed the brennanb2025/fix-folder-pr-status-branch-cache branch from 0c2a49c to 812b2e8 Compare July 5, 2026 21:53

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 829a6ba9-3288-4226-a303-cf7ff69e79e5

📥 Commits

Reviewing files that changed from the base of the PR and between 0c2a49c and 812b2e8.

📒 Files selected for processing (11)
  • src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx
  • src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-hosted-review-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-row-types.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.ts
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.ts
✅ Files skipped from review due to trivial changes (1)
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.test.ts
🚧 Files skipped from review as they are similar to previous changes (9)
  • src/renderer/src/components/right-sidebar/parent-pr-checks-refresh.ts
  • src/renderer/src/components/right-sidebar/FolderWorkspacePrChecksRow.test.tsx
  • src/renderer/src/components/sidebar/WorktreeList.tsx
  • src/renderer/src/components/right-sidebar/parent-pr-checks-row-types.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-hosted-review-cache.ts
  • src/renderer/src/components/sidebar/folder-workspace-card-pr-display.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-github-pr-cache.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.test.ts
  • src/renderer/src/components/right-sidebar/parent-pr-checks-rows.ts

@brennanb2025 brennanb2025 merged commit 8aecc0b into main Jul 5, 2026
1 check passed
@brennanb2025 brennanb2025 deleted the brennanb2025/fix-folder-pr-status-branch-cache branch July 5, 2026 22:23
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