Repository navigation
fix(renderer): stop the modal toast rule from freezing large diffs - #23721
Conversation
The rule that lifts toasts above a dialog or sheet backdrop matched body:has(<overlay> anywhere). Chromium re-evaluates a descendant :has() on body for DOM changes anywhere in the page, so with large Monaco diffs open every editor mutation re-scanned the document and the renderer stopped responding. Dialog and sheet overlays portal straight into body, so matching them as direct children keeps the same behaviour while only changes to body's own children can affect the rule.
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
A single CSS selector change in the renderer, narrowing the modal toast rule added in #22423 to keep error toasts above dialog/sheet backdrops.
- Child-combinator
:has()—body:has([data-slot='dialog-overlay'], [data-slot='sheet-overlay']) [data-sonner-toaster]becamebody:has(> [data-slot='dialog-overlay'], > [data-slot='sheet-overlay']) [data-sonner-toaster], so the invalidation set is body's own children rather than the whole subtree. - Comment update documenting the direct-child assumption that makes the narrowing safe.
I verified the load-bearing assumption against the installed Radix source rather than taking it on faith: DialogPortal wraps each child in PortalPrimitive asChild container (node_modules/@radix-ui/react-dialog/dist/index.mjs:87), the custom DialogPortal/SheetPortal never pass a custom container, and no call site uses DialogOverlay/SheetOverlay outside DialogContent/SheetContent. So the overlays are direct children of body and the > narrows the match to exactly the same elements. DialogPortal also drops data-slot="dialog-portal" instead of forwarding it, so overlays retain their own data-slot.
The existing regression spec tests/e2e/add-project-error-toast-stacking.spec.ts already pins this behavior for real: it asserts the toaster's computed z-index exceeds the open overlay's (40 vs 50 if the new selector stopped matching), in both themes. No new test needed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
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 (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe toaster z-index uses the Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The toaster retains its default stacking level and rises above open dialog or sheet overlays. No actionable merge-blocking risk is identified. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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 |
…endant :has() The child-combinator form still ran a whole-page walk after unrelated DOM changes (about 3x cheaper than the original, but still proportional to page size). Setting a custom property from a :has() on body alone takes the rule off that path; only opening or closing a backdrop restyles.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior Pullfrog review, the freeze fix was reworked from a child-combinator selector on the toaster to an inherited custom property set by a :has() whose subject is body alone, plus a test update.
- Body-variable mechanism —
body:has(> [data-slot='dialog-overlay'], > [data-slot='sheet-overlay'])now only sets--toaster-z-index: 60, and[data-sonner-toaster]readsz-index: var(--toaster-z-index, 40) !important. The overlay-dependent:has()no longer appears in the toaster's selector, so unrelated subtree mutations stop re-evaluating it. - Layering test update — the existing
native-chat-stop-layering.test.tsnow pins thevar(--toaster-z-index, 40)declaration and asserts no:has(...) [data-sonner-toaster]selector returns.
I confirmed the variable resolves correctly: the toaster is a descendant of body (sonner renders inline, no createPortal, inside App.tsx's root <div>), no @property or other rule sets --toaster-z-index, and the overlay direct-child assumption is unchanged from the earlier-reviewed commit. So the computed z-index is 60 while a backdrop is open and 40 otherwise — identical to the prior form — and add-project-error-toast-stacking.spec.ts's contract still holds.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ator is dropped The guard only rejected a :has() inside the toaster's selector. Dropping the `>` from the body :has() (or removing the lift rule) still passed, and the unscoped form re-runs on every data-slot element change anywhere in the page, the same freeze the PR fixes. Assert the exact child-only rule shape.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review, the only new commit (6f1e9c7) tightens the regression guard for the freeze fix; the production selector and variable mechanism are unchanged.
- Layering guard now pins the body rule —
native-chat-stop-layering.test.tsgained a positive assertion requiringbody:has(> [data-slot='dialog-overlay'], > [data-slot='sheet-overlay']) { --toaster-z-index: 60; }, so dropping the child combinators (reintroducing a descendant:has()onbody) fails the test rather than staying green. - Toaster assertion updated — the existing check now expects
z-index: var(--toaster-z-index, 40) !important, matching the c076c6a mechanism.
I verified the new guard can actually fail: removing the > combinators from main.css fails at native-chat-stop-layering.test.ts:23, and with the file restored the full test file passes 3/3. This closes greptile's P2 on the same test.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready on substance; CI blocked by main (not this PR)Verdict: the fix is correct, fixes the freeze, and keeps #22423's toast behaviour. Three review passes ran; the third came back clean. Not merged and not marked ready: CI on the head is red because of a break on main, not this change (details below). What changed during review (head
Automated evidence: targeted E2E on Live QA (hidden Electron builds on a Mac, main vs this PR):
CI: red on Not caused by this PR, worth their own follow-ups:
Open design question for a maintainer: a fixed toast layer above modal backdrops and below menus would remove the conditional rule entirely, but it would also lift toasts above the floating terminal. That is a product decision, so it is left out of this fix. |
…3745, #23783, #22971, #22565, #22846, #23724, #23721, #23693, #23810) into #23059 #23671 (group chat rows by the turn that produced them) is ported onto #23059's turn-scope model, so there is one grouping mechanism, not two: - A host that states each row's turn scope groups by that scope, as before. #23671's journal-order derivation (rows between one turn record and the next belong to it) moves from the timing selector into src/shared/native-chat-turn-grouping.ts and runs only for a host that states no scope, replacing the positional fallback there. - #23671's anchor rules live in structuredAgentTurnAnchors, which membership, settled timing and the live clock all read: a turn whose opener key nothing resolves yet takes the send still in flight ahead of its record (Codex before its echo), else its own record. - The live turn is one key again. #23671 made row liveness follow the owning turn, so the bar key and the liveness key are always the same; nativeChatTurnMembership now returns only liveTurnKey (barTurnKey, activeTurnOpenedBy and turnKeysByItemId are gone). - A turn with no user bubble draws its bar above its first row (nativeChatTurnBarRows, desktop and mobile), and a turn's diff rollup goes under its last row. - The Codex full-history restore writes each record ahead of its items; that also fixes the derived turn scope on #23059's journal. #23026 (Stop from the moment a message is sent) is ported onto #23059's command turns: the cancel paths ask the translator for a command's provider turn instead of the removed compaction tracker, and a Stop that names no turn still ends a running /compact through its child. performCancel moved to structured-agent-session-turns-cancel.ts to keep the turns module under the line limit. #22090's awaitingInput replaces showTurnStatus/showLiveTurnActivity; the waiting-behind-/compact rows are kept.
… 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]>





What it fixes and where
With a large diff open in Source Control (for example a Staged Changes view of several big files), a burst of file changes on disk, such as a rebase, a branch switch or a formatter run, could freeze the Orca window until it was killed. The regression came from #22423, which added a style rule that lifts error toasts above an open dialog or sheet backdrop.
Scope: the desktop renderer only, on every platform (it is plain CSS that Chromium evaluates the same way on macOS, Linux and Windows). Nothing changes for SSH, mobile, the wire protocol or stored data. What users see stays the same: toasts still appear above dialog and sheet backdrops, and still sit below menus, popovers and selects when no dialog is open.
ELI5
A style rule asked the browser "is there a dialog backdrop anywhere on the page?", and the browser re-asked that question by scanning the whole page after every tiny change inside the diff editors. Now the page body answers it once, only when a backdrop is added or removed, and the toast reads the answer.
What Changed
Before, #22423's rule was
body:has([data-slot='dialog-overlay'], [data-slot='sheet-overlay']) [data-sonner-toaster] { z-index: 60 !important }. Opening a Staged Changes diff of several large files and then changing those files on disk froze the window.Now body sets a variable when a dialog or sheet backdrop is one of its direct children, and the toaster reads it:
body:has(> [data-slot='dialog-overlay'], > [data-slot='sheet-overlay']) { --toaster-z-index: 60 }and[data-sonner-toaster] { z-index: var(--toaster-z-index, 40) !important }. The same diff stays responsive through the same burst.Mechanism
When a
:has()on an ancestor is part of the toaster's own selector, Chromium has to re-check that:has()and look for toasters across the page after DOM changes that might affect it. Monaco's diff editors change the DOM constantly, so every style update paid for a walk of the whole document, and the renderer never caught up.Only narrowing the old rule to
body:has(> …) [data-sonner-toaster](this PR's first commit) was not enough. It fixed the reported freeze, but it still paid a page-wide walk whenever an element was added near body, for example each tooltip or menu mounting (about 9 ms per mount on a page of 150k elements, against 0.04 ms with no rule), and that cost grew with page size.With the
:has()alone on body, Chromium only re-checks body, and the answer only changes when one of body's direct children is a backdrop that is added or removed. Unrelated DOM changes then cost the same as with no rule at all, at every page size we measured. The cost moves to opening and closing a dialog, where the inherited variable restyles the page once; the dialog library already restyles the page at that moment (it setspointer-events: noneon body for modal dialogs), so a full open-and-close cycle costs about the same with or without this rule.Why
Dialog and sheet backdrops are portaled straight into
document.body: the dialog portal renders each child, including the backdrop element itself, directly into the default container (body), nothing wraps it, and neither ourDialogContentnor ourSheetContentpasses a custom container. So "direct child of body" selects exactly the backdrops #22423 targeted, and the rule still keys off the real modal backdrops rather than scroll-lock state (which menus and selects also set), with no new state.Alternatives considered. Keeping the
:has()inside the toaster's selector with only the>added: still a page-wide walk near body. An attribute set on body from the dialog and sheet components: a second record of "a modal is open" that has to be kept in step with the real backdrops, which #22423 deliberately avoided. A fixed toast layer above modal backdrops (no conditional rule at all): the simplest shape, but it would also lift toasts above non-modal floating surfaces such as the floating terminal (layers 45 to 50), which is a product decision outside this fix. Reverting #22423: brings back the unreadable error behind the Add Project dialog.Linked Issue
No issue. Found from the scheduled E2E run on main, where
combined-diff-invalidation-freeze-repro.spec.ts("a rebase-style burst of external file changes keeps the diff responsive and loaded") timed out on every run since 2026-09-26. Bisected with targeted E2E runs of only that spec: it passes before #22423 (run 36494532122), fails at #22423 (36494538490), and passes on main with just that rule removed (36494544695).Visual Proof
Live hidden Electron builds on a Mac (production renderer, isolated profile), comparing main with this PR. The toast CSS at head
6f1e9c7eb12is identical to thec076c6a2b1fbuild shown here (the last commit only changes a test).Error toast above the Add Project dialog backdrop, dark and light (toast layer 60, backdrop 50):
After the dialog closes, the same toast drops back to layer 40:
No dialog open: the Resource Manager popover (60) and the Keep-awake menu (70) still cover the toast (40):
The 8-file × 15,000-line Staged Changes diff after three rounds of real on-disk rewrites, loaded and responsive on this PR:
Responsiveness during that burst (360 timer ticks expected in the window; three runs per build):
Swapping only the toast rule inside a running page confirms the rule alone causes it: main with the old rule rewritten to the child-only form stays healthy, and this PR's first commit with its rule rewritten back to the old form freezes like main.
Testing
native-chat-stop-layering.test.tsnow pins the shape of the rule: toasts default to 40 through the variable, the lift is exactly the child-only rule on body, and a:has()placed in the toaster's own selector fails the test. That is a cheap guard that runs on every PR, because E2E does not gate merges and this regression kept main's freeze spec red for two days. Checked in vitest: passes on this branch, fails with #22423's rule and with the>removed.Targeted E2E on
c076c6a2b1f(same CSS as the head): the freeze spec passed twice (runs 36499928046 and 36499933417; worst 95th-percentile lag during the burst 0.2 ms), andadd-project-error-toast-stacking.spec.ts, #22423's regression test, passed in dark and light (run 36499928046).Headless Chrome benchmark of the rule shapes on a Monaco-sized page, style-recalc time for unrelated DOM churn: #22423's rule was many times slower than no rule and grew with page size, the child-only form was cheap for deep edits but still paid a page-wide walk for elements added near body, and the variable form matched no rule in every case measured.
Live QA (above) on macOS: toast above dialog in both themes, back to 40 on close, below popovers and menus with no dialog, a popover opened inside a dialog still above the lifted toast, and the freeze comparison with main. A toast above a sheet backdrop could not be shown live, because every sheet with a backdrop needs a connected Linear or Jira account or an agent artifact; a backdrop element added directly under body lifts the toast to 60, and one nested inside the app root does not. Popout windows load the same CSS but have no toaster, so the rule has nothing to do there.
Review
Two things to check. First, the assumption that dialog and sheet backdrops are direct children of body (see Why). If that ever stops holding, the failure is harmless and visible: the toast drops back behind the backdrop, as before #22423, and never a freeze. Second, the trade-off: opening or closing a dialog or sheet now restyles the page once, in exchange for removing a cost that was paid on every DOM update and grew with page size.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Not changed here, and true before this PR: the command palette's backdrop has no
data-slot, so toasts stay below it; and a toast at the bottom right is partly covered by the floating terminal when no dialog is open.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)