Repository navigation
Studio: stop menus, sidebar and browser pane from restyling the whole chat - #16938
Merged
Merged
Conversation
…p restyling the thread Rules shaped X:has(A) Y put Y on Chromium's shared :has() invalidation set: any DOM change under an X it had tested (the workspace, the chat column, any p/div above an image) re-checked every Y-like element below it, so a sidebar toggle, run settings, the model picker, chat options or the browser pane restyled 9-18k thread elements at 150 turns. WebKit re-checks the whole document when something named inside such a :has() changes, so :focus-visible and [data-state] in them cost every keystroke. - Wallpaper and glass rules read host flags (data-wallpaper-ready, -outline-off, -flat, -frame-flat, -image, -preview-outline-off) that the wallpaper layer mirrors onto its parent before paint (chat-background/host-flags.ts); each flag is repeated to keep the old specificity. - The Windows page blur reads data-sidebar-frame from the root instead of a :has() over the sidebar. - Hub README badge rows are marked data-badge-row by a ref callback (hub/lib/badge-rows.ts). - The RAG menu row item lights itself with :has(~ [data-row-action]...). - Sidebar row parts use [&:has(~.sidebar-row-action...)] instead of group-has-*; the queue editor hint, library card time, RAG pin and project chat date read a custom property set by the group's own has-[...]; info hints mark themselves data-near-focus. - tests/has-subject-after.test.ts compiles index.css with Tailwind plus every has- class token in the files Tailwind scans and fails on any new style-after-:has() rule outside a measured allowlist; has-anchor-order.test.ts spells its fixtures so they no longer ship as app CSS.
Member
Author
|
@codex review |
Codex Review Summary: ❌ FailedThis 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. |
…the variant branch that renders them
imaderaya
pushed a commit
to pub-forks/unsloth
that referenced
this pull request
Nov 7, 2026
…unslothai#16978) Follow-up to unslothai#16931. The long-chat gate carried allowances for costs main had when it landed. unslothai#16938 (the `:has()` rewrite), unslothai#16942 and unslothai#16957 removed most of those costs, so this lowers the allowances to today's readings so they cannot creep back. ## Changes - `tests/studio/has_subject_allowlist.txt`: regenerated. 57 selectors are still allowed, 61 are gone. Lint on main: 197 `:has()` rules, 57 non-subject, 0 new, 0 stale. - `tests/studio/_area_matrix.py`: - All 9 per-area element-count ceilings are removed, so those areas get the normal 2x growth check. unslothai#16938 fixed every one of them; none restyles the whole thread on open any more. - Glass ceilings lowered to about 1.2-1.3x the highest reading on current main. - A recheck page that fails to load or measure now keeps the first verdict instead of crashing the gate with a traceback. A recheck can only lower a reading, so this never hides a failure. ## Count ceilings removed (elements restyled at 200 turns) | Area | Old ceiling | Now | 200 vs 40 turns | |---|---|---|---| | model_picker | 44000 | 459 | 0.99x | | chat_options | 17000 | 2091 | 1.45x | | browser_pane | 45000 | 1259 | up to 2.55x | | account_menu | 30000 | 346 | 1.0x | | organize_chats | 30000 | 226 | 1.0x | | chat_row_menu | 32000 | 1817 | 1.55x | | sidebar_sections | 45000 | 163 | up to 1.18x | | sidebar_toggle | 30000 | 365 | 1.06x | | run_settings | 45000 | 1214 | 2.13x | browser_pane and run_settings grow a little faster than 2x but stay under the 3000-element floor (about 4 elements per turn, not a whole-thread restyle). ## Glass ceilings (ratio vs the default look) Highest reading over 3 runs pinned to 4 CPUs and 7 runs on a loaded 36-core host. | Mode | Old | Highest | New | |---|---|---|---| | frosted, other areas | 10 | 5.79 | 7 | | blurred, other areas | 10 | 5.50 | 7 | | liquid, other areas | 10 | 5.65 | 7 | | liquid-3d, other areas | 12 | 5.41 | 7 | | frosted, Settings scroll | 28 | 9.69 | 12 | | blurred, Settings scroll | 28 | 12.18 | 15 | | liquid, Settings scroll | 28 | 10.08 | 13 | | liquid-3d, Settings scroll | 28 | 9.60 | 12 | ## Testing - Full gate on main: PASS 4 times (270-310 s). - Still fails when it should: - a planted subject-after-`:has()` rule is reported by name ("57 allowlisted, 1 new"); - a synthetic Glass material with a 40px backdrop blur fails 8 cells at 4.0-15.7x, with no real mode failing. - `test_area_matrix.py`, `test_has_lint.py`, `test_css_culprit.py`: 58 passed.
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, toggling the sidebar, opening run settings, the model picker, chat options or the browser pane each restyled the whole thread, about 9,200 to 18,400 elements at 150 turns, on every engine (Chromium / Edge for Windows, WebKit for macOS and Linux). Typing in WebKit paid a similar cost on every keystroke.
The cause is CSS rules where the styled element comes after a
:has(), for exampleX:has(...) YorX:has(...) > Y(139 such rules in the built CSS: wallpaper and glass rules, Tailwindgroup-has-*variants, hub README badge rows, menu rows). When anything underXchanges, the browser re-checks every element that could matchY, and their right-hand parts (a,img,[data-slot],[data-state],:focus-visible) match every source chip, favicon, tool card and reasoning row in the thread. Deleting just these rules took a sidebar toggle from 9,216 to 141 elements restyled; no single rule was responsible (14 each caused it alone).Fix
82 of the 139 rules are rewritten so
:has()is in the subject or replaced by a flag; the look is unchanged.index.css): read flags on the host element (data-wallpaper-ready,-outline-off,-flat,-frame-flat,-image,-preview-outline-off).chat-background/host-flags.tsmirrors them from the wallpaper layer before paint, using exactly the old:has()argument for each flag, and only writes on a change. Flags are repeated in the selectors so specificity is unchanged.data-sidebar-frame, set in__root.tsxfrom the sidebar's own condition.hub/lib/badge-rows.tsmarks them withdata-badge-row.group-has-*):[&:has(~.sidebar-row-action...)], since the actions are always the row's last siblings.data-near-focuswhen its row has keyboard focus.has-[...]class and the child reads it.has-anchor-order.test.tswere being picked up by Tailwind and shipped as real rules; they are now spelled so the scan skips them.The remaining 57 rules (shadcn primitives, chat model notice, files panel, sidebar nav hover, composer pills, toasts, sidebar footer fade) are left as they are and listed in an allowlist; keep-only bisects show none of them costs anything on a sidebar toggle or on WebKit typing.
Results
150 turns, base vs this PR side by side, 3 reps (restyle counts identical across reps):
WebKit typing at 150 turns: p50 61 -> 25 ms per key, p95 66 -> 33 ms (
:focus-visibleand[data-state]inside these rules were re-checked across the document on every keystroke). Chromium typing is unchanged.Look: every element's computed style (including
::before/::after) and a pixel diff, base vs this PR, on a solid thread (tool cards, reasoning rows, source chips, favicons), sidebar row hover, an open row menu, keyboard focus on a row's pin, and solid and Liquid Glass 3D over a wallpaper (thread, welcome page, Appearance). Computed styles are identical apart from the per-session wallpaper blob URL and the random welcome greeting; pixel diffs are 0 outside the greeting.Guard
tests/has-subject-after.test.ts(about 1 s) compilesindex.csswith the build's Tailwind plus everyhasclass in the scanned sources and fails on any new rule of this shape outside the allowlist, on stale allowlist entries, and on@custom-variantdefinitions that contain:has(.tests/has-host-flags.test.tschecks the new flags and markers are wired up.Tests
Full frontend suite passes except the KaTeX stylesheet test that also fails on main in a local setup with a symlinked
node_modules;node scripts/typecheck.mjs --testsis clean. Existing tests that matched the old selector text are updated.