You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(mobile): a rewritten guide stop no longer shows the previous push's diff - #37989
On mobile, a review guide stop read the pull request diff through a cache keyed without the push it was written for, so opening a rewritten guide could show code from the previous push. The diff hook now takes the stop's guide head and passes it as the diff query's cacheHeadSha, as the web guide already does, so each push gets its own cached pages and the previous push's patch is never shown.
On the T3 Code phone app, open a pull request that has review guides turned on, open Changes, and wait until the code is on screen. Note one line in a file the guide covers.
From git, push a commit that replaces the text of that line and leaves the surrounding lines in place. Leave the phone on the pull request and do not pull to refresh or tap Reload changes.
On the phone, select Guide. When it says there are new changes since this guide, tap Rewrite guide, and wait until that notice is gone and the new stops are listed.
Open the stop that shows an excerpt of the file you changed.
The stop's explanation is about the commit you just pushed, and the code in the excerpt is still the line from before that commit. Expected: The code in the excerpt is the line from the commit you just pushed.
The cause is at apps/mobile/src/features/pull-requests/usePullRequestDiff.ts:118. Ran cd apps/mobile && pnpm exec vp test run src/features/pull-requests/usePullRequestDiff.test.tsx with the repro test added: it failed in 2 of 2 runs on a clean checkout, with not to contain '+previous code' in the output.
Evidence
Environment: Linux x64, the repository's own tests
Macroscope's review found this PR approvable — Mobile guide stops now separate cached diffs by guide head, preventing reuse of a previous push’s cached patch. The change is limited to client-side cache identity and leaves server requests and ordinary diff reads unchanged.
You can add or adjust custom eligibility rules. Learn more.
Reviewing files that changed from the base of the PR and between c4fe7d4 and 81d43e9.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The pull request adds an optional guide head SHA to the mobile diff hook and maps it to the diff target’s cache head. A regression test checks that changing guide heads does not show the previous head’s patch.
Changes: Guide diff cache
Layer / File(s)
Summary
Map guide head to diff cache and test head changes apps/mobile/src/features/pull-requests/usePullRequestDiff.ts, apps/mobile/src/features/pull-requests/usePullRequestDiff.test.tsx
The hook maps the optional guide head SHA to the diff target’s cache head. The test changes from an old guide head to a new one and checks that the old patch is absent and the new patch appears.
This change keys mobile diff pages by the guide's head SHA, so a rewritten review guide shows the newly pushed code instead of the previous push's patch. The guide screen already supplies that head to the hook, and a regression test covers the switch. No concrete merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(mobile): a rewritten guide stop no longer shows the previous push's diff" states the main change. The diff hook now passes the guide head SHA as cacheHeadSha, so a rewritten guide stop …
Description check
The description follows the template. It has a problem statement (the stale diff from a cache keyed without the push), a change section (the hook passes the guide head as cacheHeadSha), a scope sectio…
Linked Issues check
[#37988] The issue requires that a rewritten guide stop show the code from the newly pushed commit, not a cached diff from the previous push. The cause named in the issue is apps/mobile/src/features/p…
Out of Scope Changes check
The changes cover two files under apps/mobile/src/features/pull-requests/: usePullRequestDiff.ts (guideHeadSha type field and cacheHeadSha mapping, plus the existing commit mapping kept unchanged) and…
Full details: Title check
Explanation
The title "fix(mobile): a rewritten guide stop no longer shows the previous push's diff" states the main change. The diff hook now passes the guide head SHA as cacheHeadSha, so a rewritten guide stop no longer shows the previous push's patch. The title uses a conventional commit prefix and plain language. It is 76 characters, which is slightly long but still clear.
Full details: Description check
Explanation
The description follows the template. It has a problem statement (the stale diff from a cache keyed without the push), a change section (the hook passes the guide head as cacheHeadSha), a scope section that links the issue (#37988) and a related PR, and a verification section with a reproduction, a before/after test result table, and the checks that ran. It also lists the models that did the work, which the template asks for. The Scope section does not state explicitly that the change is a bug fix rather than a feature, but the issue link shows the bug. The description is mostly complete.
Full details: Linked Issues check
Explanation
[#37988] The issue requires that a rewritten guide stop show the code from the newly pushed commit, not a cached diff from the previous push. The cause named in the issue is apps/mobile/src/features/pull-requests/usePullRequestDiff.ts. At head, PullRequestDiffParams gains an optional guideHeadSha. usePullRequestDiff maps it to target.input.cacheHeadSha, so the diff query key differs per guide head. Base lacks this mapping. The added test 'does not show the previous push's patch when a rewritten guide opens' covers the requirement at hook level: it checks that a remount with a new guide head does not return the old patch and that the new head's patch is shown. The author reports that this test fails on base c2eb8f3 and passes on head c4fe7d4. This review did not run the test. The hook change matches the issue's root cause. Not verified in this review: that the guide stop caller passes guideHeadSha. The changed-file summary lists no caller change, so the end-to-end path depends on existing wiring.
Full details: Out of Scope Changes check
Explanation
The changes cover two files under apps/mobile/src/features/pull-requests/: usePullRequestDiff.ts (guideHeadSha type field and cacheHeadSha mapping, plus the existing commit mapping kept unchanged) and usePullRequestDiff.test.tsx (test helper keyed by cursor and head, plus the regression test). The test helper changes support the new regression test and do not alter other behavior. No unrelated change was found in the reviewed evidence.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
The automated pipeline stopped on this pull request and will not merge it:
the capture step could not show the problem on the base commit, so there is nothing to prove fixed.
On both commits, generate a guide describing PREVIOUS_PUSH; leave the PR open before loading Changes; open greeting.ts and capture PREVIOUS_PUSH; publish a commit replacing it with CURRENT_PUSH while preserving context; return without refreshing or choosing Reload changes; open Guide; select Rewrite guide after the new-changes notice; wait for the CURRENT_PUSH explanation; open its stop. Both commits displayed CURRENT_PUSH in the explanation and code excerpt. Result screenshots matched pixel-for-pixel across captures taken more than 500 ms apart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:S10-29 changed lines (additions + deletions).takeover:blockedTakeover blocked; reason in the PR bodyvouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On mobile, a review guide stop read the pull request diff through a cache keyed without the push it was written for, so opening a rewritten guide could show code from the previous push. The diff hook now takes the stop's guide head and passes it as the diff query's cacheHeadSha, as the web guide already does, so each push gets its own cached pages and the previous push's patch is never shown.
Fixes #37988
Related: #35324
Reproduction on main
Commit bb29ee3e71 (main), in the running app:
The stop's explanation is about the commit you just pushed, and the code in the excerpt is still the line from before that commit. Expected: The code in the excerpt is the line from the commit you just pushed.
The cause is at
apps/mobile/src/features/pull-requests/usePullRequestDiff.ts:118. Rancd apps/mobile && pnpm exec vp test run src/features/pull-requests/usePullRequestDiff.test.tsxwith the repro test added: it failed in 2 of 2 runs on a clean checkout, withnot to contain '+previous code'in the output.Evidence
Environment: Linux x64, the repository's own tests
Proven: the test fails on base c2eb8f3369 and passes on head c4fe7d43c5.
not to contain '+previous code'in the outputTests
pnpm exec vp run check:changedpassed on head.Who did the work
Made in T3 Code by Grok 4.7, Claude Opus 5.5 and GPT 6.1 Sol