Skip to content

🤖 fix: keep immersive sidebar review click on its hunk#3249

Merged
ammario merged 1 commit intomainfrom
immersive-review-xm90
May 7, 2026
Merged

🤖 fix: keep immersive sidebar review click on its hunk#3249
ammario merged 1 commit intomainfrom
immersive-review-xm90

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

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 of ReviewPanel's filteredHunks. Clicking the pending review in the immersive Notes sidebar calls navigateToReview(...), which correctly resolves the target hunk id from allHunks (not hunks) and calls onSelectHunk(targetHunkId). But ReviewPanel's selection-validity effect then ran:

const selectionValid = selectedHunkId && filteredHunks.some((h) => h.id === selectedHunkId);
if (!selectionValid) setSelectedHunkId(filteredHunks[0].id);

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 unfiltered hunks list instead of filteredHunks. 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 renders filteredHunks.

Validation

  • Added two regression tests in ImmersiveReviewView.test.tsx:
    1. Contract test — clicking a sidebar review whose hunk is filtered out still propagates the correct hunk id through onSelectHunk (catches regressions in the immersive view's navigateToReview).
    2. Parent-harness integration test — mirrors ReviewPanel's selection-validity effect and verifies the immersive header switches to the reviewed file after the click. Confirmed the test fails (header shows src/visible.ts instead of src/reviewed.ts) when the immersive branch is reverted to the buggy filteredHunks.some(...) check, and passes with the fix.
  • make static-check (typecheck + lint + fmt-check + doc link check) — pass.
  • bun test for RightSidebar / 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 from filteredHunks to all hunks), 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

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).
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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".

@ammario ammario merged commit dd383e6 into main May 7, 2026
24 checks passed
@ammario ammario deleted the immersive-review-xm90 branch May 7, 2026 16:37
@mux-bot mux-bot Bot mentioned this pull request May 7, 2026
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.
Sign up for free to 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.

2 participants