Repository navigation
fix: bound combined diff editors and scope chat style invalidation - #23725
Conversation
|
| rangeExtractor: (range) => | ||
| getCombinedDiffRenderRange( | ||
| range, | ||
| estimateSize, | ||
| scrollContainerRef.current?.clientHeight ?? 0 |
There was a problem hiding this comment.
Image heights exceed the budget
The new height limit uses an estimate of 88px for an image diff that renders at its natural height. If several large image diffs are near the visible section, they can all fit within the estimated budget and mount offscreen. That leaves image-heavy combined diffs exposed to the rendering work this change aims to avoid. Please account for their measured heights when choosing the render range.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
ℹ️ No critical issues — one defer-able scope question and a render-path nit.
Reviewed changes
- Height-bounded render range — new
getCombinedDiffRenderRangeextends the visible range by at mostoverscanneighbors per side but stops before the first neighbor that pushes cumulative estimated height past one viewport. - Virtualizer wiring —
use-combined-diff-virtualizer.tsliftsestimateSizeand adds arangeExtractorthat reads the scroll container'sclientHeight(0 before measured → visible only). - Unit tests — 5 cases pin visible large sections, one-viewport neighbor pre-render, stopping at an oversized neighbor (both directions), the row-count/boundary case, and the unmeasured viewport.
- E2E assertion — the 8×15k-line freeze fixture now asserts exactly one section row mounts.
ℹ️ Sibling PR-file combined-diff viewers keep the unbounded overscan
The new bound is wired only into the worktree viewer. Both PR-file viewers render the same DiffSectionItem (full Monaco), pass the same getDiffSectionRowEstimatedHeight, and keep overscan: PR_DIFF_OVERSCAN with no height budget, so an oversized offscreen section there still mounts its full editor. This is a scope question rather than a defect in this diff — the reported freeze is watcher-driven and worktree-specific — but the helper is now generic enough to reuse if the same pathology shows up on PR review pages.
Technical details
# Should the PR-file viewers adopt the height-bounded range extractor?
## Affected sites
- `src/renderer/src/components/pull-request-page/files/combined-diff-viewer.tsx:199` — inline `useVirtualizer`, `overscan: PR_DIFF_OVERSCAN`, no `rangeExtractor`.
- `src/renderer/src/components/github-item-dialog/inspect-pull-request/pr-files-combined-diff-viewer.tsx:240` — same shape.
## Required outcome
- Confirm whether these surfaces can hit the same offscreen large-section rendering cost. If they can, route them through `getCombinedDiffRenderRange` too; if the freeze is genuinely watcher-specific, a one-line note in the PR body saying so would settle it.
## Open questions for the human
- Is the regression STA-3420 reproduces specific to watcher-driven invalidation, or does it also apply to opening/scrolling a large PR diff?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| }, | ||
| estimateSize, | ||
| // Offscreen Monaco sections render their full height; bound that work by pixels, too. | ||
| rangeExtractor: (range) => |
There was a problem hiding this comment.
Nit: this inline closure changes identity every render, and TanStack uses rangeExtractor as a memo key for getVirtualIndexes (the previous default extractor was stable). That forces getVirtualIndexes → getVirtualItems to rebuild — and the renderedIndicesRef layout effect to re-run — on every render, not just when the range or sizes change. A useCallback keyed on [sections, sectionHeights] (with a matching stable estimateSize) restores memoization; clientHeight is still read fresh at call time because options are re-set each render. Low impact, but this PR is a render-path perf fix.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe combined-diff virtualizer now uses Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The height-bounded range should reduce unnecessary offscreen diff rendering. A Linux burst run reportedly still stalled, but available evidence does not connect that stall to this change; no actionable merge-blocking risk is established. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — the selector rewrite is match-equivalent and registers a narrower invalidation subject; one minor cleanup nit inline.
Reviewed changes
- Rewrote the seven native-chat relational variants (message-row copy/timestamp reveal, code-block copy button, background-task dock rules) from Tailwind's
group-has-*/group-[…]forms to direct ancestor selectors ([.group:has(:focus-visible)_&],[class~='group/code']:has(:focus-visible)_&,[data-native-chat-background-tasks]:has(…)_&), dropping the:is(… *)wildcard subject Chromium was invalidating document-wide. - Updated the two tests that pin the exact class tokens (
NativeChatMessageRow.test.tsx, the goal-dockSTRIP_DOCK_RULE).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| > | ||
| {/* When the goal tab is the next sibling, take its width and share its top edge. */} | ||
| <div className="mx-auto w-full max-w-4xl group-has-[+[data-native-chat-thread-goal]]/tasks:px-2"> | ||
| <div className="mx-auto w-full max-w-4xl [[data-native-chat-background-tasks]:has(+[data-native-chat-thread-goal])_&]:px-2"> |
There was a problem hiding this comment.
With the dock selectors now keyed on [data-native-chat-background-tasks], the group/tasks marker on the parent (line 178) is no longer referenced by any selector, yet NativeChatStructuredSession.goal-dock.test.tsx:101 still asserts it as load-bearing. Drop the marker and that assertion, or keep the marker with a note if a future variant needs it.
…oal-dock selector Main's #23725 rewrote the strip's goal-dock variants from `group-has-[...]/tasks:` to an ancestor-scoped `[[data-native-chat-background-tasks]:has(+[data-native-chat-thread-goal])_&]:` selector. The merged head renders byte-identically to main for this fixture; only the golden was captured before that change.
… Mermaid renders Opening a Markdown preview with many Mermaid diagrams froze scrolling for tens of seconds. Mermaid measures each label with getBBox / getComputedTextLength / getTotalLength, and every call forces a style recalc. Three rules made each of those recalcs cover the whole document: - body:has(> overlay) .app-layout > :not(.window-controls) (modal blur) - group-has-[:focus-visible]/row (SshTargetCard) - group-has-[:focus-visible]/reasoning (NativeChatReasoningDisclosure) Each one alone was enough. The blur now flows through a body custom property set by a subject-only body:has(), the same shape stablyai#23721 used for the toaster z-index. The two Tailwind utilities use the scoped [[class~='group/x']:has(:focus-visible)_&] form from stablyai#23725. On the issue's 19-diagram repro (dev build), all diagrams render in 4.2 s instead of 47.5 s, style recalc during open drops from ~35 s to 0.36 s, and scrolling while diagrams render goes from about 1 fps to a 16.7 ms median frame. Refs stablyai#34312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ole subtrees
Tailwind compiles group-has-* to `.x:is(:where(.group\/g):has(...) *)`: a
non-subject :has() whose subject is `*`. Together with any attribute :has()
in the sheet (e.g. card.tsx has-data-[slot=card-action]) and a non-subject
:has() on a large ancestor, Blink restyles the whole subtree under the
anchor on every mutation, so Mermaid label measurement, streaming code
blocks and rich-editor edits paid for thousands of elements per forced
style read.
(a) SshTargetCard and NativeChatReasoningChevron use the scoped
[[class~='group/x']:has(:focus-visible)_&] shape from #23725, keeping
the keyboard-only reveal (#19426). This is the whole measured win.
(b) rich-markdown-editor.css drops a redundant :has(): .markdown-toc-header
only renders inside .markdown-toc-panel. Defence in depth; measured
close to neutral once (a) lands.
Guard: check-has-restyle-scope.mjs compiles the renderer's Tailwind CSS
with Tailwind's own API, adds the plain renderer stylesheets, lowers
nesting with lightningcss and walks its selector AST. It flags any
non-subject :has() (outside sibling-only arguments) whose subject compound
has no class, id or attribute, carrying context through :is/:where/:not.
Reading compiled output covers the Tailwind spellings, @apply and nested
CSS forms tested so far. It runs in pnpm lint, check:changed and PR CI.
Hidden Electron 43.8.1, real compiled Tailwind, ~8.3k-node DOM, per
iteration, all from (a): rich editor with TOC 19.4 -> 1.6 ms; native-chat
code block append 12.5 -> 3.6 ms (3,184 -> 3 elements restyled); large
group row 8.0 -> 2.4 ms (2,003 -> 2).
Fixes #34312
Co-authored-by: Naufaldi <[email protected]>

ELI5
Opening a large combined diff could freeze Orca for seconds when files changed. Keep nearby editors bounded by screen height and stop unrelated chat styles from making Chromium recalculate the entire document.
What Changed
:is(), which Chromium invalidated on the document body when Monaco changed its DOM. The resulting styles and keyboard-focus/goal-docking conditions stay the same.Why
Profiling separated two costs. The old range mounted six editors and over 42,000 Monaco line nodes. Bounding the range helped but still failed Linux CI: traces showed two document-wide style recalculations over roughly 238,000 elements, lasting 2.8 and 2.3 seconds. Invalidation tracking named the seven chat selectors. Narrowing those rules avoids the broad invalidation without removing keyboard access, changing the diff viewport, or relaxing test limits.
Linked Issue
STA-3420; failures in https://github.com/stablyai/orca/actions/runs/36497243185
Visual Proof
The visible diff remains the same; fewer offscreen editors mount.
Before:

After:

Keyboard-focused native-chat copy controls still reveal:

Testing
Review
No timeouts or responsiveness thresholds increased. No wire, execution-host, filesystem, or git-provider changes. SSH/folder-workspace diffs use the same renderer path. Linux and macOS exercised; Windows and live SSH rendering remain untested here. Large initial editor construction can still be expensive; this change addresses excess neighboring mounts and repeated document-wide style work.
Agent skill upstream boundary
Checklist