Skip to content

fix(web): the pull request Code tab keeps its diff after a refresh - #21734

Open
Brechard wants to merge 1 commit into
pingdotgg:mainfrom
Brechard:fix/pr-code-tab-empty-after-refresh
Open

Brechard wants to merge 1 commit into
pingdotgg:mainfrom
Brechard:fix/pr-code-tab-empty-after-refresh

Conversation

@Brechard

Copy link
Copy Markdown
Contributor

Note

🤖 Claude Sonnet 5.5 writing on behalf of Rodrigo

Problem

The pull request Code tab intermittently shows "This pull request has no file changes." and a "0 files" header for a PR that has changes. It appears a few minutes after the PR opens or after an agent turn, and clears on its own once the diff changes or the tab remounts.

The cause is in PullRequestCodeTab.tsx. A refresh (the panel's refreshToken goes up after a PR sync, an agent turn, or a manual refresh) empties the accumulated diff slices and refetches the first page. The slices were only refilled when the query returned a different data object, cursor or scope. Since #20850, an equal refetch keeps the previous data object, so after the reset data, the cursor and the scope all match what was already applied and nothing refills the slices. This happens whenever nothing beyond the first page is loaded, which is the normal case for a small or new PR.

Change

The tab now decides whether the current page is already applied by looking at the loaded slices, instead of tracking the data object's identity in a separate appliedPage state. A refresh shows the first page again right away and replaces it only if its content changed. The rule that a changed page drops the slices after it is unchanged. The existing content comparison became a small sameSlice helper used in both places.

Scope and approval

Very small, focused fix for an obvious bug, so submitted without a prior issue or discussion: a refresh of an unchanged diff leaves the tab permanently empty. It changes no setting, control or default, and no contract.

Verification

  • New browser test PullRequestCodeTab.browser.test.tsx renders the real component with the real useEnvironmentQuery and useAtomRefresh, loads a one-file diff, bumps refreshToken, and has the refetch return the same page object. It expects the file to stay on screen. On upstream/main it fails with the "no file changes" message; with this change it passes.
  • vp lint on both files and the apps/web typecheck are clean.
  • Observed in the private build of the app: the server's diff request to GitHub returned HTTP 200 three times in eight seconds for a five-minute-old PR while the tab showed "0 files", which matches the client-side cause above.

Not checked: the fix in a live app, since the empty state cannot be staged without altering state, so there are no screenshots. The test fakes the equal refetch with a stand-in atom rather than the real environment query family. A second suspected path (selecting a commit or update range and switching back before its diff loads) is covered by the same change but has no test.

Written by Claude Opus 5.5 (fix and test) and Claude Sonnet 5.5 (PR) in Claude Code.

🤖 Generated with Claude Code

A refresh emptied the accumulated diff slices and refetched the first page,
but slices were only refilled when the query's data changed identity. An
equal refetch keeps the previous value's identity, so the tab showed
"no file changes" until the diff's content changed. Read whether a page is
already applied from the slices instead of a separate identity gate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 68b4e5a599e3561ddd5a23568bb5183a38fb342c)
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 19, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 815842c

Macroscope's review found this PR approvable — This is a focused bug fix that restores an existing pull request diff after an equivalent refresh, with the changed-page behavior preserved and a targeted browser regression test added. It introduces no new capability, schema, product default, deployment change, or static-analysis override.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fae4b529-ad68-4fdd-b2dc-c241502d5701
📥 Commits

Reviewing files that changed from the base of the PR and between 5307c23 and 815842c.

📒 Files selected for processing: 2
  • apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx
  • apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
📝 Walkthrough

PullRequestCodeTab now compares diff pages by their contents when refreshing. A changed page replaces its loaded slice and removes later slices. A browser test checks that an unchanged page keeps the file count visible after refresh.

Changes: Diff slice refresh handling

Layer / File(s) Summary
Diff slice comparison and updates
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
The code tab compares pages by cursor, patch, truncation status, next cursor, and ordered omitted-file statistics. It appends pages with new cursors, replaces changed slices and later pages, and leaves equal slices unchanged.
Refresh regression test
apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx
The browser test mocks a diff-page refresh with unchanged data and checks that the file count remains visible and the no-file-changes message does not appear.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 81584

The Code tab refresh fix has no identified merge-blocking issue. It is ready to merge after normal checks.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title is concise, specific, and accurately describes the main fix: preserving the pull request Code tab diff after a refresh.
Description check Passed The description includes all required sections. It explains the problem, fix, scope rationale, focused verification, limitations, and agent attribution. The missing screenshots are explicitly explaine…
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.
Full details: Description check

Explanation

The description includes all required sections. It explains the problem, fix, scope rationale, focused verification, limitations, and agent attribution. The missing screenshots are explicitly explained because the live empty state could not be staged.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants