Repository navigation
Studio: stop dialogs and menus from restyling the whole chat on open and close - #16902
Merged
Merged
Conversation
… open and close Radix modal layers (Settings, command palette, search, model picker, modal dropdowns, selects) write pointer-events: none on <body> while open. The property is inherited, so every open and close restyled each element of the chat: about 40k elements at 100 turns, 0.45 s of style recalc in Chromium and 2.4 s in WebKit per toggle, on top of the menu's own work. An explicit, zero-specificity pointer-events on the thread scroller stops the inheritance there. While the lock is up a transparent cover over the thread root keeps the thread unclickable and unhovered as before; it sits under the z-50 layers Radix portals to <body>. No component changes. The long-chat gate now also measures one lock open or close at 200 turns and fails over 30 ms (main: 840 ms, this change: 5.7 ms).
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ 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". |
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Nov 6, 2026
…og is open With a modal menu open (no full-screen overlay), wheel over the browser pane still scrolled its file view: the shown side pane sets its own pointer-events: auto, so it never inherited the body lock, and the unslothai#16902 cover only spans the thread. react-remove-scroll's document listeners used to cancel that wheel. The same transparent cover now sits over the browser and research panes while the lock is up (both roots are position: relative; portaled menus and dialogs stay above at z-50). It needs its own compositing layer, or Chromium's compositor hit-tests the scroller underneath and scrolls it. No listeners are added per open, so WebKit still restyles nothing page-wide. As over the thread, a click on the pane while a modal menu is open now only dismisses the menu instead of also reaching the pane.
oobabooga
pushed a commit
to oobabooga/unsloth
that referenced
this pull request
Nov 6, 2026
… appearance mode (unslothai#16931) Extends the long-chat CI gate from unslothai#16801 / unslothai#16902 so it also catches lag in every interactive area, and a new feature or appearance setting that is itself slow (the way Glass shipped). ## What it measures After the existing long-chat checks (unchanged), on the Linux Frontend CI lane in Chromium, the gate opens the real `/chat` page from the same production build with every `/api` call answered in-process, seeded with 40 and 200 turns of a fixed agent turn (reasoning, web search, tool calls, code, long reply). - 30 areas: typing and scrolling the chat; Settings, every Settings tab (read from the page), a Settings dropdown and scrolling inside Settings; command palette, search chats, model picker; composer, tools, permission, chat options, account, organize and chat row menus; sidebar sections and toggle; browser pane; run settings; API monitor; rename; shortcuts dialog; message action menu, copy, click, reasoning and tool expand/collapse, code copy and source card. - Appearance modes are read from the app's own material and lens lists, so a new material is measured with no gate edit: default, Transparent, frosted, blurred, liquid, liquid-3d, macOS, both lens modes, Glass menus off, dark and dark Glass. - One Chromium trace per page, split per area: elements restyled and layout objects (exact counts), style, layout and paint time, longest task, and CPU time on every browser thread. ## When it fails - An area's restyle or layout count grows more than 2x from 40 to 200 turns (counted above 3000 elements). - A mode makes an area cost more than 4x its baseline in CPU or elements restyled (baseline = default look; lens, menus-off and dark Glass are compared with plain Glass), with at least 150 ms extra CPU. - An area stops running. - Coverage: every visible menu or popup trigger on the chat page must belong to an area or be listed with a reason, and a unit test requires every keyboard shortcut to map to an area or a stated reason. CPU and "did not run" failures are measured again on fresh pages before they count, and the worst CPU failure is re-run with backdrop-filter, box-shadow and filter switched off in turn to name the property responsible. All thresholds can be overridden with `LONG_THREAD_AREAS_*` environment variables. ## CSS lint for whole-chat `:has()` rules Runs first (about 1 s): reads every rule in the built CSS and flags selectors where `:has()` is followed by a combinator (`X:has(...) Y`, `X:has(...) > Y`, including Tailwind `group-has-*`). Those make any change under the anchor re-check every matching element in the chat. The 118 such selectors on main today are listed in `tests/studio/has_subject_allowlist.txt` until they are rewritten; a new one fails with the selector and its likely source, and selectors that disappear are reported so the list can be pruned (`LONG_THREAD_HAS_LINT_WRITE=1` regenerates it). The nine known whole-chat areas also get a fixed ceiling on elements restyled at 200 turns, about 1.2x today's count, so they cannot get worse; deleting an area's entry restores the normal 2x growth check once it is fixed. ## Evidence | Build | Verdict | |---|---| | main, repeated runs | PASS (3 local, 2 on a 4-CPU machine) | | main with the existing-cost allowances removed | FAIL: the same 9 areas every run, plus 13 to 22 Glass cells | | synthetic `[data-wallpaper-workspace]:has(> [data-gate-synthetic]) .aui-thread-viewport [data-role]` rule | FAIL: the lint names it; chat options restyles 56,135 elements against its 17,000 ceiling, chat row menu 68,522 against 32,000 | | synthetic slow build: a new "aurora" material with a large blur and shadow, plus unslothai#16902's thread protection removed | FAIL: aurora on 6 to 8 areas with backdrop-filter named as the cause (0.05x without it); 8 modal areas grow 3.8 to 4.3x with chat length; the existing lock check fails too | Existing costs the gate found on main are allowed explicitly with ceilings about 1.2 to 1.3x above the highest reading, so they cannot get worse and can be tightened as they are fixed (`LONG_THREAD_AREAS_KNOWN=""` holds main to the plain limits): - Nine areas restyle the whole chat when they open (model picker, browser pane, run settings, sidebar sections, sidebar toggle, organize chats, account menu, chat row menu, chat options): 4 to 8k elements at 40 turns, 14 to 37k at 200, 250 to 500 ms of style work per open. A follow-up removes the CSS rules responsible. - Glass: Settings scrolling costs 10 to 22x the solid window in CPU, most other areas 2 to 6x. ## Cost About 4 to 6 minutes added on a GitHub runner (6.1 min on a machine pinned to 4 CPUs, 3.8 min on a fast host), inside the step's existing 15-minute timeout. The step only runs when frontend or gate files change. `LONG_THREAD_AREAS_LONG_MODES=default` trims about 10%; `LONG_THREAD_AREAS_FULL=1` runs the full product (12 modes x 30 areas x 2 lengths). ## Files - `tests/studio/_area_matrix.py` (new): areas, modes, trace split, thresholds, culprit check. - `tests/studio/test_area_matrix.py` (new, 14 tests): registries, shortcut coverage, threshold logic. - `tests/studio/playwright_long_thread_gate.py`: runs the matrix after the existing checks. - `studio/frontend/vite.long-thread.config.ts`: also builds `index.html` for the real chat page. - `tests/studio/_has_lint.py`, `tests/studio/test_has_lint.py`, `tests/studio/has_subject_allowlist.txt` (new): the `:has()` lint. - `.github/workflows/studio-frontend-ci.yml`: path filters and the unit tests.
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Nov 7, 2026
…the browser pane open or close (unslothai#16961) ## Problem On long chats in WebKit (the macOS app, and the Linux app's WebKitGTK), closing any dialog or menu took 5 to 7 seconds, and on Linux WebKit the browser pane took over 20 seconds to open. Chromium (Windows) was not affected. WebKit restyles every element on the page when certain document-level listeners or stylesheets change: | Side effect (Playwright WebKit, 1 -> 100 turns) | WebKit | Chromium | |---|---|---| | Add / remove a non-passive `wheel` or `touch*` listener on document | 27-38 ms -> 2.6-2.8 s | 0 | | Add / remove a `pointermove` / `pointerleave` listener on document | 25-35 ms -> 2.6-2.7 s | 0.1 ms | | Remove an injected `<style>` | 60 ms -> 2.95 s | 11 ms | | Body `data-scroll-locked`, `pointer-events`, `aria-hidden`, focus restore | under 100 ms | under 4 ms | Three things hit those paths: - Radix's scroll lock (`react-remove-scroll`) adds non-passive wheel and touch listeners on the document when a dialog or modal menu opens and removes them on close, and `react-remove-scroll-bar` removes its injected stylesheet on close. - Closing a dialog while focus is still inside it during the exit animation (Settings, command palette, search, rename, shortcuts) costs one more full pass. - `react-resizable-panels` removes and re-adds its document pointer listeners each time the chat's panel group re-registers, which is what the browser pane triggers (3 passes on open, 2 on close, with or without any CSS). ## Fix - `src/lib/remove-scroll.tsx`, aliased for `react-remove-scroll` in `vite.config.ts`: the same component and the same `data-scroll-locked` counter on `<body>`, but no document listeners; the styles the library injected live permanently in `index.css`. Under a modal layer nothing outside it can be wheel-scrolled anyway (body is `pointer-events: none` and the thread sits under the unslothai#16902 cover), and lists inside dialogs scroll on their own. - `src/lib/pointer-listener-pin.ts`: one passive no-op document listener per pointer event type registered at startup, so the panel library's add and remove no longer change the set of listener types WebKit tracks. - `index.css`: the transparent cover unslothai#16902 puts over the thread while a modal is open now also covers the side pane (browser, research). The pane sets its own `pointer-events: auto` once shown, so without the library's document listeners its file view would scroll under a modal menu; the cover blocks it without a per-open listener. - `index.css`: elements that restore their own pointer events stay inert under a modal layer, so a wheel over them cannot scroll what sits behind it. Two class-keyed rules, CSS only: - inside a dialog or menu Radix has turned into a lower layer (for example the Skills list under its actions menu); - in the page while the lock is up (toolbars, the Downloads card, sidebar row actions), except the thread (its cover handles it), the top dialog, popper popups, and window chrome, toasts and overlays meant to work over a modal (marked `modal-pe-live`). - The side-pane cover keys on a static class, so toggling the lock only restyles those elements: about 13 ms at 200 turns in the long-chat gate (budget 30 ms). - `vite.config.ts`: `react-remove-scroll/UI` is pre-bundled for the dev server. It is only imported by the stand-in, so a cold dev server found it late and reloaded the page, which native Safari did not recover from. - `src/lib/closing-dialog-focus.ts`: when a dialog starts its exit animation with focus inside it, the focused element is blurred; Radix still returns focus to the trigger afterwards. ## Results Real macOS (GitHub `macos-15`, real WebKit, 150 turns, 2 reps, all arms on one runner), time to close: | Surface | Before | Scroll-lock replacement only | This PR | |---|---|---|---| | Settings | 4,982 ms | 4,130 ms | 970 ms | | Command palette | 6,948 ms | 734 ms | 677 ms | | Search chats | 6,044 ms | 726 ms | 674 ms | | Rename chat | 4,906 ms | 430 ms | 428 ms | | Composer menu | 5,124 ms | 655 ms | 628 ms | | Tools menu | 5,124 ms | 598 ms | 650 ms | | Chat options | 4,746 ms | 640 ms | 648 ms | Opening was already fast on real macOS and stays so. On Linux WebKit (Colab, 100 turns, 3 reps) the browser pane opens in 1.9 s instead of 22.4 s and closes in 0.9 s instead of 11.1 s; Settings open/close goes from 6.6 / 7.1 s to 1.2 / 1.1 s. Chromium is unchanged or 10 to 40 ms faster. Behaviour is the same in both engines: wheel over the browser pane under the Tools menu moves it 0 px (it scrolls normally with no menu open); the lock attribute is set and the body has `overflow: hidden` and `pointer-events: none` while a dialog or menu is open; wheel over the thread under Settings or the tools menu moves it 0 px while the Settings pane itself still scrolls; focus lands on the same element after close. Screenshots of 10 surfaces, open and after close, show no visible change (pixel differences at 100 turns match a base-vs-base run). ## Tests - New `studio/frontend/tests/webkit-modal-page-restyle.test.ts`: the alias, the static lock styles, the pointer listener pin and the closing-dialog blur. - Long-chat gate (unslothai#16931): PASS. - Full frontend suite: 15,088 pass; the one failure is the KaTeX stylesheet test that also fails on main in a local setup with a symlinked `node_modules`. `node scripts/typecheck.mjs --tests` is clean. One deliberate change: clicking the side pane, or a page control that restores its own pointer events (Downloads button, banners), while a modal menu is open now only closes the menu, as clicking the thread already did. Wheel over the Skills list, the Library toolbar, the Downloads card or the sidebar under a modal menu moves them 0 px (they scroll normally otherwise). Recipe Studio comboboxes inside its dialogs stay usable. Not covered: touch devices such as iPad Safari (the lock's touch cancelling is dropped), and users with reduced motion, for whom the closing-dialog blur does not run.
danielhanchen
added a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Nov 7, 2026
…t above the thread (unslothai#17006) ## Problem On long chats in WebKit (the macOS app's WKWebView, Safari), each modal menu or dialog open and close costs a thread-sized style pass. The cause is not where it first looks. Radix writes `pointer-events: none` on `<body>` while a modal layer is open. `pointer-events` is inherited, but `:where(.aui-thread-viewport) { pointer-events: auto }` (unslothai#16902) already stops the inheritance at the thread scroller. What still scales with the chat are the four rules that depend on the lock (unslothai#16902, unslothai#16961), which were keyed on the body's inline style: - `body[style*="pointer-events: none"] .aui-thread-root::after` (thread cover) - `body[style*="pointer-events: none"] .chat-artifact-pop-surface .side-pane-lock-cover::after` (side pane cover) - `body[style*="pointer-events: none"] :is(.pointer-events-auto, .sidebar-row-action):not(...)` (page restorations) - `:is([role="dialog"], ...)[style*="pointer-events: none"] .pointer-events-auto` (lower layers) When the `[style*=...]` match on an element flips, WebKit walks and re-matches every element under it. On `<body>` that includes the whole thread. The lower-layer rule triggers the same walk for the body flip, because WebKit only looks at the attribute part of that compound. Forced style + layout flush per write, Playwright WebKit with the macOS UA, 150 turns (55.8k elements, 55.0k of them in the thread), median of 5: | Side effect | 1 turn | 150 turns | |---|---|---| | `body.style.pointerEvents = "none"`, as shipped | 24-28 ms | 59-107 ms | | Same, with the four `[style*=...]` rules deleted | 19-23 ms | 17-25 ms | | Inline `pointer-events: none` on the thread scroller's parent, with the rules | 1 ms | 34-47 ms | | Same, rules deleted | 1 ms | 0 ms | | Any attribute on `<html>` used as an ancestor in a rule (even `[x] .one-element`) | 1-5 ms | 27-46 ms | | The same attribute used only on the element it styles | 0 ms | 0-1 ms | In real menus at 150 turns the write accounted for 49-96 ms of each open and 48-72 ms of each close (timed between two forced flushes). With the write stubbed out, the longest frame of a menu open dropped from 255-441 ms to 123-200 ms (command palette, search, composer, chat options, Tools). Chromium pays 9-12 ms per write at both lengths, and the long-chat gate's lock check reads 5.3 ms at 40 turns and 20.6 ms at 200 turns on main. ## Fix Radix's write stays as it is, so everything that reads the body lock still sees it: `tooltip-modal-layer.ts`, the inherited `none`, the Playwright checks. Only the CSS rules move to cheaper keys. - `src/lib/modal-pointer-lock.ts` (installed in `main.tsx` next to the other WebKit guards) watches the body's `style` attribute. While the lock is up it mirrors it onto attributes that never sit above a thread: - `data-modal-lock-thread` on each `.aui-thread-root`. Only used on the element it styles (the cover). - `data-modal-lock-path` on each ancestor of a thread root. Only used on the element it styles. - `data-modal-lock-region` on every other child of those ancestors. Together these are the rest of the page, split into subtrees that hold no thread. Descendant rules key on this, as they did on `body` before. - `data-modal-lock-lower` on a dialog, alert dialog, menu or listbox whose inline `pointer-events` Radix set to `none` because a stacked modal layer opened above it. - `index.css`: the same four rules, keyed on those attributes. Same declarations, same exclusions. A thread root that is not found (say, one mounted inside a region while a modal is open) still gets its cover through `[data-modal-lock-region] .aui-thread-root::after`. - While locked, children added to a thread root's ancestors are picked up by a `childList` observer on just those elements. Anything mounted deeper lands inside a region (covered by the descendant rules) or inside a thread root (excluded, as before). Lower layers are tracked by a `style` attribute observer that only runs while the lock is up, plus a scan of the regions when the lock goes up (for a non-modal menu that turns lower in the same commit). Unlocking clears every mark and disconnects both observers. One watcher per document; installing it again does nothing. - The long-chat gate page installs the watcher too, so its lock check times the rules the app actually uses. ## Results Same host, same build pair, servers on one machine. The host was heavily loaded (load average about 130 on 36 cores), so timings are noisy. The model picker does not take the body lock, so it serves as the noise reference: up to about 55 ms there. Forced flush per body lock write (median of 5-7, 2-4 sessions per arm): | | WebKit 1 turn | WebKit 150 turns | Chromium 1 turn | Chromium 150 turns | |---|---|---|---|---| | Before | 23-28 ms | 59-107 ms | 9-12 ms | 9 ms | | After (includes the marks) | 25-37 ms | 28-48 ms | 12 ms | 10-12 ms | Long-chat gate lock check (Chromium, CDP style recalc per open or close): 5.3 ms at 40 turns and 20.6 ms at 200 turns before, 0.8 ms and 1.0 ms after. Real menus, 150 turns, base and head interleaved, 3 reps x 3 cycles. Each cell is the longest frame in ms, as a median with the range of per-rep medians in brackets: | Surface | WebKit before | WebKit after | Chromium before | Chromium after | |---|---|---|---|---| | Tools menu open | 321 [320-371] | 236 [203-290] | 67 | 50 | | Tools menu close | 159 [146-173] | 120 [114-147] | 50 | 33 | | Command palette open | 404 [257-476] | 326 [269-344] | 167 | 150 | | Command palette close | 221 [208-225] | 198 [198-291] | 117 | 117 | | Search chats open | 446 [379-492] | 394 [358-413] | 150 | 150 | | Chat options open | 340 [319-361] | 293 [285-312] | 83 | 83 | | Chat options close | 177 [141-234] | 164 [159-173] | 50 | 33 | | Rename chat open | 261 [230-290] | 222 [194-236] | 84 | 117 | | Rename chat close | 260 [240-382] | 184 [152-210] | 83 | 83 | | Composer menu open | 329 [327-460] | 379 [235-406] | 100 | 100 | | Composer menu close | 153 [131-160] | 133 [126-134] | 50 | 50 | | Settings open | 518 [482-522] | 513 [509-557] | 233 | 233 | | Settings close | 200 [189-201] | 197 [175-202] | 167 | 133 | | Model picker open (no body lock) | 397 [392-400] | 341 [329-401] | 117 | 117 | The clear wins are the ones above the noise band: Tools menu open (-85 ms), command palette open (-78 ms) and rename close (-76 ms). The rest move by about one write's worth or sit inside the noise. Settings is dominated by other work. In Chromium, elements restyled per open or close go up by 0-37 (the roughly 32 elements that get an attribute; for example Tools open 630 -> 663, close 479 -> 515). Style ms stays the same or drops (Settings close 33 -> 19 ms, chat options open 34 -> 25 ms). What remains in WebKit is the inherited write itself: 17-25 ms, flat from 1 to 150 turns, on the roughly 750 elements outside the thread. Removing it would mean replacing Radix's body lock with a blocker element. That changes hit-testing for window chrome that sits at z-40 to z-120 and is meant to stay live (`.modal-pe-live`: navbar, titlebar, combobox, toasts), so it is not done here. ## Behaviour Behaviour walk at 150 turns, base vs head, in Chromium and in WebKit with the macOS UA. It compares a 792-point `elementFromPoint` grid, the computed `pointer-events` of every restoration (`.pointer-events-auto`, `.sidebar-row-action`, `.modal-pe-live`, the thread scroller), the cover pseudo-elements, and the body and layer state, in 14 states: idle; Tools menu; Tools submenu; chat options; Settings; Settings with its select open; Settings after the select; after Settings; browser pane; browser pane under the Tools menu; Library; Library under its Filter menu; Library after. Result: identical in both engines. - An outside click on another chat's sidebar row closes the menu and does not navigate. - Wheel over the thread or the sidebar under the Tools menu, and over the thread under Settings, moves them 0 px in Chromium. With no modal open it scrolls normally. - Sidebar row actions and the Library toolbar restoration are `none` under a modal and `auto` without one. - The browser pane under a menu hits its cover. - The submenu item and the select option are hit. - The Settings tab under its open select is not hit. - A `.pointer-events-auto` element inside Settings reads `none` while its select is open (the lower-layer rule) and `auto` otherwise. - No marks are left after any close. ## Tests - New `tests/modal-pointer-lock.test.ts`, which fails on main: - no `[style*=...]` selector remains in `index.css`; - the thread and path attributes are only ever used on the element they style; - with a fake DOM, the lock splits the page so that every element outside the thread roots is in exactly one region or on the path, and no message is marked; - children mounted next to the thread while the lock is up join a region; - stacked layers are marked lower and lifted again, including a layer that was already lower when the lock went up; - unlocking clears everything and leaves only the body observer; - a second install is a no-op. - `modal-lock-thread-cover.test.ts` and `webkit-modal-page-restyle.test.ts` now follow the new selectors. - `tests/studio/playwright_keyboard_shortcuts.py`: 232/232 on base and head (Chromium + WebKit). `tests/studio/playwright_find_in_page.py`: 452/452 on base and head. - Long-chat gate (`tests/studio/playwright_long_thread_gate.py`): PASS on head, with and without the watcher on its page. - Full frontend suite: 15,121 pass. The one failure is the KaTeX stylesheet Vite test, which also fails on main with a symlinked `node_modules`. `node scripts/typecheck.mjs --tests` is clean. ## Not covered - Real Safari and WKWebView on macOS. All WebKit numbers come from Playwright WebKit (WebKitGTK) with the macOS UA. Windows WebView2 was not run. - Wheel under a modal in local WebKit is not decisive. After any wheel, with or without a modal, the 150-turn thread jumps by 24-27k px in both arms, so that check only shows the two arms agree. - The Skills list under its actions menu (the case the lower-layer rule was written for) was not driven in the app, because this test home lists no skills. It is covered by the synthetic restoration inside Settings under its select, and by the unit test. - There was no A/A timing run on this loaded host. The model picker, which takes no body lock, is the noise reference instead. - Touch devices (iPad Safari).
iam-knoit
pushed a commit
to SynhalaAI/unsloth
that referenced
this pull request
Nov 9, 2026
…i#17284) ## Problem On macOS WebKit, opening or closing a menu or dialog still cost far more in a long chat than in a short one (Round 11 real runners: composer menu about 200 to 250 ms at 150 turns against 72 to 100 ms at 1 turn; Settings 390 to 560 ms against 232 to 306 ms). unslothai#16902 and unslothai#17006 removed the whole-thread restyles that Radix's body `pointer-events` lock caused in Chromium; WebKit still paid for the scroll lock. ## Cause Every modal open and close sets or clears `body[data-scroll-locked]`, and WebKit re-ran style and layout over the whole page for it: 1. `hub.css` still had `body[data-scroll-locked] .hub-modal-pe-guard`. A body attribute before a descendant combinator makes WebKit re-check every element under `<body>`, every message included. unslothai#17006 removed this pattern from `index.css`, but its test only scanned `index.css`. 2. The lock rule flips `<body>` from `overflow: visible; position: static` to `hidden; relative`, which re-lays out the whole long page in WebKit. WebKit microbenchmark (Playwright WebKit, Mac UA, one lock on and off with a forced style and layout flush, median of 5): 3 ms at 1 turn; 77 to 121 ms at 150 turns on main; 22 to 33 ms with the hub rule removed; 0 ms with the hub rule removed and the body overflow and position preset. ## Change - `hub.css`: the body-keyed rule is removed. Every `.hub-modal-pe-guard` element also carries `pointer-events-auto`, which unslothai#17006's region-keyed rule already sets to `none` behind a modal (and the lower-layer rule covers stacked dialogs). Checked in Chromium and WebKit: the guard reads `auto` at rest, `none` with Settings open and `auto` after close, on main and here alike. - `index.css`: `@media screen { body { overflow: hidden; position: relative; } }`, so the lock changes nothing on `<body>`. Print keeps document flow. Desktop already sets `html.tauri body { overflow: hidden }`. No route scrolls the document itself: on main, every route at 1440x900 and 900x560 has the document's scroll height equal to the viewport (pages scroll their own containers). - `tests/modal-pointer-lock.test.ts` now scans every `src/**/*.css` and fails on `data-scroll-locked`, `aria-hidden` or `data-aria-hidden` before a combinator (it names the hub rule on main). `tests/webkit-modal-page-restyle.test.ts` pins the screen preset. ## Results Real macos-15 Safari WebKit (two runners, main twice as A/A, arms rotated, 3 cycles each), open / close ms at 150 turns, main / main (A/A) / this PR: | Surface | solid | Glass | | --- | --- | --- | | Composer menu open | 228 / 246 / 198 | 314 / 347 / 198 | | Composer menu close | 262 / 304 / 218 | 309 / 314 / 218 | | Command palette close | 315 / 348 / 290 | 382 / 396 / 322 | | Search chats close | 352 / 364 / 318 | 406 / 415 / 333 | | Model picker open | 259 / 310 / 306 | 300 / 330 / 227 | | Settings close | 364 / 414 / 384 | 465 / 455 / 388 | | Settings open | 404 / 436 / 404 | 510 / 618 / 543 | Closes improve on almost every surface beyond the A/A spread, and opens do for the composer menu and, with Glass, the model picker and search. Settings and shortcuts opens stay within noise: their cost is mostly the dialog mount. Long chats still cost more than short ones on macOS WebKit (composer menu about 200 ms against 72 to 100 ms at 1 turn); the remaining growth is not from the attribute toggles measured here. No visible change. Frontend suite 15,326 pass, `tsc` clean, full long-chat gate passes. --------- Co-authored-by: Nilay Yadav <[email protected]>
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.
Problem
On a long chat, opening or closing any dialog or modal menu (Settings, command palette, search chats, model picker, chat options, composer menu, selects) freezes the app. Measured in the real app on a 100-turn thread (Colab CPU, no GPU):
On real macOS WebKit (GitHub
macos-15runner, 150 turns) Settings takes 3.8 s, the composer menu 3.0 s, the tools menu 4.6 s. Windows Edge (WebView2 engine) takes about 1 s for Settings at 150 turns.A Chromium trace shows almost all of it is style recalc: opening Settings restyles 15,882 elements at 100 turns against 3,222 at 1 turn (426 ms against 90 ms), with layout under 12 ms.
Cause
Radix modal layers write
pointer-events: noneon<body>while they are open.pointer-eventsis inherited, so every open and every close restyles each element of the chat. Applying each modal side effect alone on the 100-turn production fixture:pointer-events: nonearia-hiddenon the app rootFix
CSS only, no component changes:
:where(.aui-thread-viewport) { pointer-events: auto; }gives the thread scroller an explicit value at zero specificity, so the inherited change stops there.body[style*="pointer-events: none"]), a transparent::aftercover over.aui-thread-rootkeeps the thread unclickable and unhovered exactly as before. It sits at z-index 49, under the z-50 layers Radix portals to<body>.Behaviour under a modal layer is unchanged in Chromium and WebKit: clicks never reach the thread, no message is hovered, wheel scrolling behaves the same, outside-click dismissal, scroll lock, focus trap and tooltip blocking are unchanged.
Results
Production fixture, same main commit, base vs this change, one lock open or close:
Typing cost is unchanged.
Real app, base vs this PR
Menu bench on Colab CPU (no GPU), heavy production-like thread (code, reasoning, tool calls, web search), short 1-turn vs long 100-turn thread, time to open:
Typing and scrolling are unchanged in both engines. Surfaces that are not modal (browser pane, sidebar toggle, model picker) are unchanged, as expected. WebKit still has a second cost on long threads that this change does not address; it is being tracked separately.
Tests
studio/frontend/tests/modal-lock-thread-cover.test.ts: pins the explicit value on the scroller and the cover under the lock.tests/studio/playwright_long_thread_gate.py: the long-chat gate now also measures one lock open or close at 200 turns and fails over 30 ms (LONG_THREAD_MAX_LOCK_MS), with a hint pointing at inherited properties written on<body>.