Skip to content

Chat Prs Panel Live Refresh - #670

Merged
arul28 merged 6 commits into
mainfrom
ade/prs-panel-insdie-ade-doenst-88589df4
Jun 30, 2026
Merged

Chat Prs Panel Live Refresh#670
arul28 merged 6 commits into
mainfrom
ade/prs-panel-insdie-ade-doenst-88589df4

Conversation

@arul28

@arul28arul28 commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

ADEOpen in ADE · ade/prs-panel-insdie-ade-doenst-88589df4 branch · PR #670

Summary by CodeRabbit

  • New Features

    • Opened PR panes and chat PR views now refresh linked pull request details more reliably, so you see more up-to-date status and title information.
    • PR check indicators now appear only when relevant, reducing clutter for non-open PRs.
  • Bug Fixes

    • Improved handling of PR updates so the displayed PR can update or clear correctly when related activity arrives.
    • Reduced repeated refreshes for the same PR, helping keep the UI responsive.

Greptile Summary

Adds targeted live refresh for linked PRs in the chat surfaces (ChatGitToolbar, ChatPrPane) using a new coalesced, cooldown-throttled refreshLinkedPrCoalesced cache function in prReadCache.ts. Check indicators are now suppressed for terminal PR states (merged/closed) to avoid stale CI labels.

  • prReadCache.ts: Introduces refreshLinkedPrCoalesced with a 5-second module-level cooldown (linkedPrRecentRefresh) and in-flight deduplication; errors are cached (returning the input PR) so that transient failures don't trigger repeated API hammering.
  • ChatPrPane.tsx: Replaces direct setPr with a setCurrentPr wrapper that syncs a currentPrIdRef ref, avoiding stale closure captures in the prs-updated event handler; live refresh runs on mount and the prs-updated handler switches to setCurrentPr(null) when the batch contains no PR for the current lane.
  • ChatGitToolbar.tsx: Adds a targeted live-refresh effect triggered when prPaneOpen or prMenuOpen opens; checksIcon receives the PR state and returns null for non-open/draft states.

Confidence Score: 5/5

Safe to merge — the live-refresh path is well-isolated behind the existing request-cancellation pattern and a module-level cooldown, and the two open concerns (partial-batch PR clearing and onEvent re-registration) were flagged in a prior review round and have not worsened.

Both ChatPrPane and ChatGitToolbar use the new refreshLinkedPrCoalesced correctly: request IDs guard against stale writes, the cooldown prevents repeated API hammering, and the checks-icon state gate is a clean improvement. The two behaviors already under discussion from the previous review — the prs-updated else-branch clearing on partial batches and the linkedPr dep causing subscription churn in ChatGitToolbar — are unchanged from what was already reviewed. New tests cover the lane-switch race condition and throttling logic thoroughly.

ChatGitToolbar.tsx retains linkedPr in the onEvent effect dependency array (flagged previously); ChatPrPane.tsx retains the else { setCurrentPr(null) } branch on partial prs-updated batches (also flagged previously).

Important Files Changed

FilenameOverview
apps/desktop/src/renderer/lib/prReadCache.tsAdds refreshLinkedPrCoalesced with cooldown throttling and in-flight deduplication; error path caches the input PR to prevent repeated calls; freshestLinkedPr comparison logic is correct and well-tested.
apps/desktop/src/renderer/components/chat/ChatPrPane.tsxRef-based currentPrIdRef avoids stale closure issues in the event handler; the else { setCurrentPr(null) } branch on partial prs-updated batches (previously flagged) remains; setLoading flow is correct across all paths.
apps/desktop/src/renderer/components/chat/ChatGitToolbar.tsxLive refresh on pane/menu open is cleanly gated by linkedPrId and request cancellation; linkedPr remains in the onEvent dep array (previously flagged), causing re-registration on every refresh; checksIcon state-gate is a clean fix.
apps/desktop/src/renderer/lib/prReadCache.test.tsGood coverage of cooldown throttling, null preservation, and freshness comparison for refreshLinkedPrCoalesced.
apps/desktop/src/renderer/components/chat/ChatPrPane.test.tsxNew test file; covers mount-time live refresh, stale running-check suppression, and lane-switch race condition prevention.
apps/desktop/src/renderer/components/chat/ChatGitToolbar.test.tsxAdds tests for targeted PR refresh on pane open and stale-result rejection after lane switch; deferred helper cleanly models async timing.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant UI as ChatGitToolbar / ChatPrPane
participant Cache as prReadCache
participant IPC as window.ade.prs
UI->>IPC: getForLane(laneId)
IPC-->>UI: cached PrSummary
UI->>Cache: "refreshLinkedPrCoalesced(pr, { projectRoot })"
alt within 5s cooldown
Cache-->>UI: freshestLinkedPr(current, recent.result)
else cooldown expired / first call
Cache->>IPC: "refresh({ prIds: [prId] })"
IPC-->>Cache: PrSummary[]
Cache->>Cache: linkedPrRecentRefresh.set(key, result)
Cache-->>UI: "result (PrSummary | null)"
end
UI->>UI: setCurrentPr(refreshed)
IPC-->>UI: prs-updated event
alt event includes lane PR or current PR id
UI->>IPC: getForLane(laneId) [non-live]
IPC-->>UI: PrSummary
UI->>UI: setCurrentPr(pr)
else no matching PR in batch
UI->>UI: setCurrentPr(null)
end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant UI as ChatGitToolbar / ChatPrPane
participant Cache as prReadCache
participant IPC as window.ade.prs
UI->>IPC: getForLane(laneId)
IPC-->>UI: cached PrSummary
UI->>Cache: "refreshLinkedPrCoalesced(pr, { projectRoot })"
alt within 5s cooldown
Cache-->>UI: freshestLinkedPr(current, recent.result)
else cooldown expired / first call
Cache->>IPC: "refresh({ prIds: [prId] })"
IPC-->>Cache: PrSummary[]
Cache->>Cache: linkedPrRecentRefresh.set(key, result)
Cache-->>UI: "result (PrSummary | null)"
end
UI->>UI: setCurrentPr(refreshed)
IPC-->>UI: prs-updated event
alt event includes lane PR or current PR id
UI->>IPC: getForLane(laneId) [non-live]
IPC-->>UI: PrSummary
UI->>UI: setCurrentPr(pr)
else no matching PR in batch
UI->>UI: setCurrentPr(null)
end
Loading

Reviews (3): Last reviewed commit: "Avoid stale linked PR cooldown results" | Re-trigger Greptile

@vercel

vercelBot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
adeIgnoredIgnoredPreviewJun 30, 2026 1:09am

@coderabbitai

coderabbitaiBot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds refreshLinkedPrCoalesced to prReadCache with a 5-second cooldown and in-flight coalescing. Wires live PR refresh into ChatGitToolbar (triggered when the PR pane or menu opens) and ChatPrPane (on mount and on pr-notification/prs-updated events). Updates checksIcon to show only for open/draft PRs and refactors ChecksLabel to accept a full PrSummary. New unit tests cover all layers.

Changes

Live PR Refresh Coalescing

Layer / File(s)Summary
refreshLinkedPrCoalesced utility
apps/desktop/src/renderer/lib/prReadCache.ts, apps/desktop/src/renderer/lib/prReadCache.test.ts
Adds module-level linked-PR caches, LINKED_PR_LIVE_REFRESH_COOLDOWN_MS = 5_000, and refreshLinkedPrCoalesced with cooldown short-circuit, coalesceInFlight deduplication, fallback-on-error, and cache clearing in clearPrReadInFlightForTest. New test verifies cooldown and force override behavior.
ChatGitToolbar live refresh wiring
apps/desktop/src/renderer/components/chat/ChatGitToolbar.tsx, apps/desktop/src/renderer/components/chat/ChatGitToolbar.test.tsx
Imports refreshLinkedPrCoalesced, derives projectRoot from app store, updates refreshPr to accept { live?: boolean }, adds an effect to trigger live refresh when the PR pane or menu is open, and gates checksIcon to open/draft states. Tests add prs.refresh mock, clearPrReadInFlightForTest in beforeEach, and a new async test asserting the toolbar triggers a target refresh on pane open.
ChatPrPane live refresh and event handling
apps/desktop/src/renderer/components/chat/ChatPrPane.tsx, apps/desktop/src/renderer/components/chat/ChatPrPane.test.tsx
Adds useRef for current PR id tracking, useAppStore for projectRoot, reworks refresh to be projectRoot-aware with live coalescing, refactors ChecksLabel to accept full PrSummary, and expands event subscription to handle both pr-notification and prs-updated with conditional refresh-or-clear logic. New test file verifies mount refresh, merged PR rendering, prs.refresh/prs.onEvent call counts, and prs-updated clearing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

desktop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 6.25% 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 nameStatusExplanation
Title check✅ PassedThe title clearly reflects the main change: live refresh behavior for the chat PR panel.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade/prs-panel-insdie-ade-doenst-88589df4

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.

@arul28

Copy link
Copy Markdown
OwnerAuthor

@copilot review but do not make fixes

Comment threadapps/desktop/src/renderer/components/chat/ChatPrPane.tsx
Comment threadapps/desktop/src/renderer/components/chat/ChatPrPane.tsx Outdated
@mintlify

mintlifyBot commented Jun 30, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

ProjectStatusPreviewUpdated (UTC)
ade-ac1c6011🟢 ReadyView PreviewJun 30, 2026, 12:11 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:32c61c8142

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/desktop/src/renderer/components/chat/ChatPrPane.tsx
@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit:25032c9b23

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28
arul28force-pushed the ade/prs-panel-insdie-ade-doenst-88589df4 branch from 25032c9 to d026481CompareJune 30, 2026 00:50
@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:d026481101

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/desktop/src/renderer/components/chat/ChatPrPane.tsx Outdated
Comment threadapps/desktop/src/renderer/components/chat/ChatGitToolbar.tsx Outdated

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/desktop/src/renderer/components/chat/ChatPrPane.tsx`:
- Around line 129-153: The refresh flow in ChatPrPane’s refresh useCallback is
keeping loading true until refreshLinkedPrCoalesced finishes, so the cached PR
never renders immediately. Update refresh to clear loading right after
window.ade.prs.getForLane(laneId) resolves and setCurrentPr(cached) runs, then
let the live update proceed asynchronously when options.live is true. Keep the
existing handleCreated and useEffect wiring intact, but ensure the pane can show
the cached PrSummary before the background refresh completes.
In `@apps/desktop/src/renderer/lib/prReadCache.ts`:
- Around line 103-106: The targeted refresh path in prReadCache is masking a
missing PR by falling back to the stale pr object. Update the refresh handling
around refreshPrsCoalesced in prReadCache to return and cache result as-is,
including null when the PR is no longer present, instead of using result ?? pr.
Then adjust the callers in ChatGitToolbar and ChatPrPane so they propagate a
null refresh result into local state rather than coercing it back to the old
summary.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4848ca28-f6a5-4e7e-b3a4-dff026b3aeda

📥 Commits

Reviewing files that changed from the base of the PR and between 64b198d and d026481.

⛔ Files ignored due to path filters (3)
  • docs/features/chat/README.md is excluded by !docs/**
  • docs/features/chat/composer-and-ui.md is excluded by !docs/**
  • docs/features/pull-requests/README.md is excluded by !docs/**
📒 Files selected for processing (6)
  • apps/desktop/src/renderer/components/chat/ChatGitToolbar.test.tsx
  • apps/desktop/src/renderer/components/chat/ChatGitToolbar.tsx
  • apps/desktop/src/renderer/components/chat/ChatPrPane.test.tsx
  • apps/desktop/src/renderer/components/chat/ChatPrPane.tsx
  • apps/desktop/src/renderer/lib/prReadCache.test.ts
  • apps/desktop/src/renderer/lib/prReadCache.ts

Comment threadapps/desktop/src/renderer/components/chat/ChatPrPane.tsx
Comment threadapps/desktop/src/renderer/lib/prReadCache.ts Outdated
@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:82d80df210

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/desktop/src/renderer/lib/prReadCache.ts Outdated
@arul28

Copy link
Copy Markdown
OwnerAuthor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit:803cd9a0e8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@arul28
arul28 merged commit 99cb900 into mainJun 30, 2026
5 checks passed
@arul28
arul28 deleted the ade/prs-panel-insdie-ade-doenst-88589df4 branch June 30, 2026 01:51
@coderabbitaicoderabbitaiBot mentioned this pull request Jul 8, 2026
Sign up for freeto 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

@arul28