🤖 fix: keep immersive sidebar review click on its hunk#3249
Merged
Conversation
Clicking a pending review in the immersive Notes sidebar called navigateToReview, which resolved the target hunk from allHunks and called onSelectHunk. ReviewPanel's selection-validity effect then clobbered the selection on the next render because it only validated against filteredHunks — and the review's hunk had typically been hidden by hide-read after the user submitted the review. The immersive view snapped back to the first visible hunk and the review was nowhere on screen. In immersive mode, validate the selected hunk against the unfiltered hunks so explicit sidebar navigations stick. The non-immersive panel path is unchanged because it only ever renders filteredHunks. Adds two regression tests in ImmersiveReviewView.test.tsx: a contract test for navigateToReview (catches regressions inside the immersive view) and a parent-harness integration test that mirrors ReviewPanel's selection-validity effect (catches regressions in the parent reset).
Collaborator
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
mux-bot Bot
added a commit
that referenced
this pull request
May 7, 2026
Both arms of the immersive vs non-immersive selection-validity check in ReviewPanel did the same shape: `selectedHunkId && X.some(...)`, then `setSelectedHunkId(filteredHunks[0].id)` if false. Only `X` differed (`hunks` for immersive, `filteredHunks` otherwise). Pick the validity list up front and run a single check so both modes stay in lockstep, preserving the immersive-aware behavior added in #3249. Pure refactor — emitted JS, the early-return on `filteredHunks.length === 0`, the effect's dependency list, and the existing 5-test ImmersiveReviewView suite (including the two #3249 regression tests) are all unchanged.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes a bug where clicking a pending review in the immersive Notes sidebar did nothing: the immersive view stayed on the originally selected hunk and the review was nowhere on screen.
Background
When a review is submitted in immersive mode it gets
status: "pending"and the hunk it was attached to is auto-marked read. With hide-read on (the default), that hunk drops out ofReviewPanel'sfilteredHunks. Clicking the pending review in the immersive Notes sidebar callsnavigateToReview(...), which correctly resolves the target hunk id fromallHunks(nothunks) and callsonSelectHunk(targetHunkId). ButReviewPanel's selection-validity effect then ran:That clobbered the explicit sidebar selection on the very next render, so the immersive view snapped back to the first visible hunk and the user never saw the hunk their review was attached to.
Implementation
In
ReviewPanel.tsx, when immersive mode is active, validate the selected hunk against the unfilteredhunkslist instead offilteredHunks. The selection still resets when the hunk truly disappears from the diff (e.g. after a refresh), which is what the original effect was actually trying to defend against. The non-immersive panel path is untouched because that view only ever rendersfilteredHunks.Validation
ImmersiveReviewView.test.tsx:onSelectHunk(catches regressions in the immersive view'snavigateToReview).ReviewPanel's selection-validity effect and verifies the immersive header switches to the reviewed file after the click. Confirmed the test fails (header showssrc/visible.tsinstead ofsrc/reviewed.ts) when the immersive branch is reverted to the buggyfilteredHunks.some(...)check, and passes with the fix.make static-check(typecheck + lint + fmt-check + doc link check) — pass.bun testforRightSidebar/Shared/ReviewsBanner/hooks— 278/278 pass.Risks
Low. The change is gated on
isImmersive, so the non-immersive Code Review panel keeps its exact previous behavior. The new immersive branch only relaxes the reset condition (stale-selection check expands fromfilteredHunksto allhunks), so the only surface where behavior changes is the case the bug already required.Generated with
mux• Model:anthropic:claude-opus-4-7• Thinking:max• Cost:$1.73