fix(web): PR Code tab keeps its files after a refresh with an unchanged diff#22917

merged2
main
takeover/21734-code-tab-refresh
opened17d agobyTtheo
View on GitHubTwo-way sync enabledPR last imported 16d ago

After a PR sync, an agent turn, or a manual refresh, the pull request Code tab could show "0 files" and "This pull request has no file changes." for a PR that has changes. It stayed empty until the diff changed or the tab remounted.

Takeover of #21734 by @Brechard. Their commit is kept with its authorship. I replaced its slice-comparison rewrite with the smallest fix: the refresh effect now also clears appliedPage when it empties the slices. An equal refetch keeps the same data object, so before this the identity gate blocked the refill. I also moved their browser test to the disposable render helper.

Surfaces: this is web-only Code tab state, so desktop gets it too. Mobile has no PR Code tab. No contract or server change.

Proof:

  • PullRequestCodeTab.browser.test.tsx "keeps the diff after a refresh that brings back the same page" fails on origin/main (the empty-state text appears) and passes here.
  • vp test run apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx and vp run check:changed pass.
  • Not checked: a live app run. The test fakes the equal refetch with a stand-in atom.
BeforeAfter
beforeafter

Screenshots are component renders in headless Chromium after a refresh with an unchanged diff, not a full app run.

Made by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Checks

24 successful · 9 skipped
All checks passed
ee157c1

Added 2 commits

  • fix(web): the pull request Code tab keeps its diff after a refresh49dfd01
  • fix(web): reset the applied page on refresh instead of rewriting the slice checkee157c1
Synced from GitHub

Approvability

Verdict: Approved at ee157c1

Macroscope's review found this PR approvable — This is a small, web-only bug fix: clearing the applied-page marker lets an unchanged diff repopulate the PR Code tab after refresh. A focused browser test covers the scenario, with no schema, infrastructure, security, billing, authentication, or default-behavior changes.

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

Synced from GitHub

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: Team
  • Run ID: 9f62da9a-4ccf-467e-af7e-80ccc735a642
📥 Commits

Reviewing files that changed from the base of the PR and between 810e8f62f0eff2f3b6ae4602f781d9bb80607913 and ee157c1f5b9ae4dea7c839e115b0a424c19aa10e.

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

Limit details: You’ve used all 10 included reviews currently available.

📝 Walkthrough

When a refresh returns diff content with the same page identity, PullRequestCodeTab now reapplies the content after clearing its loaded slices. A browser test verifies that the changed file remains visible.

Changes: Code Tab Refresh

Layer / File(s)Summary
Reapply unchanged diff after refresh
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx, apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx
The refresh effect resets appliedPage after clearing diff slices. A browser test confirms that a refresh with identical diff content continues to show one changed file.

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related issues

  • Issue 14483 concerns reloads in the Code tab during background PR fetches. This change addresses an empty-state result after refresh, not the reload behavior.
  • Issue 22886 concerns lost scroll, file expansion, and editor state after PR updates. This change affects the refresh path but does not address those behaviors.

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to ee157

The Code tab retains its changed-file view after an unchanged-diff refresh. No issue requiring a pre-merge fix was identified.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the primary fix: preserving PR Code tab files after refresh when the diff is unchanged.
Description checkPassedThe description covers the problem, change, scope, verification results, screenshots, limitations, and agent attribution. It references issue #21734, but it does not include explicit maintainer approv…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the problem, change, scope, verification results, screenshots, limitations, and agent attribution. It references issue #21734, but it does not include explicit maintainer approval or a clear explanation for why the fix qualifies for the approval exemption.

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

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

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