Skip to content

🤖 refactor: clean up immersive review reveal performance#3473

Open
ammar-agent wants to merge 2 commits into
mainfrom
review-perf-t98b
Open

🤖 refactor: clean up immersive review reveal performance#3473
ammar-agent wants to merge 2 commits into
mainfrom
review-perf-t98b

Conversation

@ammar-agent
Copy link
Copy Markdown
Collaborator

@ammar-agent ammar-agent commented Jun 5, 2026

Summary
Refactors immersive review's reveal pipeline so file-content hydration, overlay identity, highlight readiness, and reveal scheduling live behind a focused hook instead of the monolithic view. The branch still includes the original immersive hunk-iteration perf benchmark, and now also removes the remaining compact-diff/full-file flash path and adds real Electron coverage for minimap and same-file J/K stability.

Background
Immersive review was still visibly flashy during file switches, mark-read advancement, and compact-to-full hydration. The old flow scattered reveal state across file-loading effects, highlight callbacks, scroll layout effects, sticky measured overlays, and full-content string keys inside ImmersiveReviewView, which made it easy to render or reveal intermediate geometry.

Implementation

  • Extracted full-file loading, overlay construction, compact contentKey identity, highlight readiness, and reveal scheduling into useImmersiveOverlay.
  • Extracted the shimmer loading cover into ImmersiveDiffRevealLoadingState.
  • Changed the reveal cover from a sticky measured-height child to an absolute scrollport sibling, removing the ResizeObserver/height state and stale first-frame coverage risk.
  • Deferred compact diff rendering while an in-budget full-file read is pending, so hidden compact hunks are not rendered/highlighted only to be discarded by the hydrated full-file overlay.
  • Made useHighlightedDiff avoid rebuilding fallback chunks on preloaded cache hits and avoid redundant state churn.
  • Added cheap immersive debug attributes used by E2E sampling instead of per-frame textContent reads.

Validation

  • bun test src/browser/features/RightSidebar/CodeReview/ImmersiveReviewView.test.tsx
  • bun test src/browser/features/Shared/DiffRenderer.test.tsx src/browser/features/Shared/SelectableDiffRenderer.dragSelect.test.tsx
  • make typecheck
  • make static-check
  • make build
  • xvfb-run -a env MUX_E2E_LOAD_DIST=1 MUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 bun x playwright test --project=electron tests/e2e/scenarios/reviewHydration.spec.ts
  • xvfb-run -a env MUX_E2E_RUN_PERF=1 MUX_PROFILE_REACT=1 MUX_E2E_LOAD_DIST=1 MUX_E2E_SKIP_BUILD=1 PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 bun x playwright test --project=electron tests/e2e/scenarios/perf.reviewHunkIteration.spec.ts tests/e2e/scenarios/perf.reviewMarkHunkRead.spec.ts

Risks

  • Moderate UX risk around reveal timing and scroll behavior; mitigated by Electron frame-sampling tests for mark-read, Shift+M, compact-to-full hydration, minimap hiding, and same-file J/K stability.
  • Moderate shared-renderer risk from the useHighlightedDiff cache-hit change; covered by targeted shared diff renderer tests and static checks.

Generated with mux • Model: openai:gpt-5.5-pro • Thinking: xhigh • Cost: $1249.04

@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. More of your lovely PRs please.

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Updated the perf scenario to wait until all rendered diff rows are syntax-highlighted before resetting profiler samples and measuring hunk iteration.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Updated this from measurement-only to include the immersive review optimization. The new highlighted harness now reports TaskDuration 0.505s for 60 hunk iterations.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2ccc6dc06

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the read-action sync finding by committing the immersive-local selected hunk back to the parent before hunk read / mark-file-read actions, then revalidated the highlighted perf scenario at TaskDuration 0.565s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c02d491434

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the unmount path by committing the immersive-local selected hunk in cleanup as well as on explicit exit/read actions. Revalidated the highlighted perf scenario at TaskDuration 0.739s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87f8f56eb8

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

Comment thread src/browser/features/RightSidebar/CodeReview/ImmersiveReviewView.tsx Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the mark-file-read stale closure by making the parent handler consult selectedHunkIdRef.current and revalidated the highlighted perf scenario at TaskDuration 0.506s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2e29f1b412

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the visible multi-line hunk range finding by applying an imperative selected-range highlight for J/K hunk jumps without re-rendering the syntax-highlighted diff tree. Revalidated at TaskDuration 0.570s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbcc416f01

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

Comment thread src/browser/features/RightSidebar/CodeReview/ReviewPanel.tsx
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed persisted selection during page teardown by persisting parent selected-hunk state on change, while immersive hot-path J/K iteration remains local. Revalidated at TaskDuration 0.561s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3a5c82cc1c

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed parent teardown by writing the immersive-local selected hunk directly to persisted state during immersive cleanup, using a shared selected-hunk storage key helper. Revalidated at TaskDuration 0.605s.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the viewport jump feedback by using nearest scroll alignment for same-file J/K hunk iteration while keeping centering for file switches, note jumps, undo, and overlay hydration. Revalidated the highlighted perf scenario at TaskDuration 0.569s.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10b3e2b810

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Small follow-up: made the hydration/parent-echo regression tests robust in CI while preserving the same coverage.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Follow-up only adjusts the new regression tests to avoid happy-dom/full-suite timing assumptions; production code unchanged from the addressed review round.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

I replaced the happy-dom hydration assertions with a real Electron frame-sampling regression. It reproduces the vertical jump as overlayTopRange=7283 before the fix and now passes with the reveal overlay pinned to the scrollport while hidden hydration scrolls underneath.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Follow-up for user-reported m-key tearing: added an Electron frame-sampling E2E for mark-read iteration overlay sizing. It failed before the fix with a 598px overlay/scrollport height mismatch and now passes after sizing the reveal overlay to the scrollport.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

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

Add a perf fixture and Electron profiling scenario that reproduces large-file immersive review hunk iteration across 60 J-key steps after the full-file diff is syntax highlighted. Optimize immersive hunk navigation to keep selection local while iterating, avoid per-step localStorage writes, and keep diff renderer callbacks stable so the highlighted diff tree is not re-rendered on each jump.\n\nOptimized highlighted baseline captured locally: 1,500-line file, 150 hunks, 1,650 rendered diff rows syntax-highlighted, 60 iterations, 300 ms wall time, 0.505 s TaskDuration, median 4.70 ms, p95 5.50 ms, max 12.60 ms.\n\n---\n\n_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `unknown`_\n\n<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=unknown -->
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Follow-up after three independent review sub-agents: addressed the remaining Shift+M stale-file flash path, updated stale reveal comments, and added a bounded fail-open for full-file hydration/highlight stalls.

@ammar-agent ammar-agent changed the title 🤖 bench: profile immersive hunk iteration 🤖 refactor: clean up immersive review reveal performance Jun 7, 2026
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

I refactored the immersive review reveal pipeline and expanded the Electron hydration coverage. Please review the updated branch.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 466e8cef81

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

Comment thread src/browser/features/RightSidebar/CodeReview/useImmersiveOverlay.ts
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the same-file compact→full hydration gate: full-file-context waits now apply to any pending overlay content-key swap, not just file-path swaps, and I added a regression test for the same-file far-hunk-to-near-hunk transition.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f663fb1d3b

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

Comment thread src/browser/features/RightSidebar/CodeReview/useImmersiveOverlay.ts Outdated
@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Pushed the same-file hydration gate fix and regression test. Please take another look.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

Addressed the CRLF overlay feedback by normalizing hunk rows in compact overlay construction and added a regression test for CRLF hunk content.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

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

@ammar-agent
Copy link
Copy Markdown
Collaborator Author

@codex review

One more small CI fix: the loading skeleton no longer exposes data-line-index, so happy-dom selectors cannot click skeleton rows while the hidden diff stage is still hydrating.

@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".

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.

1 participant