Repository navigation
Studio: CI gate that fails when typing in a long chat gets slower as the chat grows - #16801
Conversation
…space With Glass on, the workspace wallpaper rules still searched the whole chat for the welcome screen and the compare view, and the conversation viewport searched itself for the welcome block. Chromium re-runs those searches while typing, so long chats stayed slow for Glass users after the fade fix. The welcome and compare views now set data-chat-welcome / data-chat-compare on <html> in a layout effect (counted, so compare panes and remounts stay correct), and the viewport rule uses the fixed child path to the welcome block. Every visual state computes the same as before. The guard test now covers every :has() anchored on an element that holds the thread, including ones nested in :not(), instead of only wallpaper paths. [skip ci]
The fixture toggled the welcome class by hand, so with the root flag the welcome view was already dimmed and the conversation opacity check passed before the toggle. Mount useMarkChatWelcome with ThreadWelcome's nesting and check the undimmed welcome view before toggling. [skip ci]
…he chat grows Builds the thread-weight fixture for production inside the app's own ancestors and seeds it with reasoning, tool cards, web sources, compaction markers, code, KaTeX and tables. Compares Chromium's style-recalc time per keystroke at 200 turns against 40 turns in one run, so a slow runner cannot fail it while a selector that walks the whole thread (#16603) does.
…lc time Selector statistics separate a whole-thread :has() from everything else even on a loaded runner: 80 -> 423 ms per keystroke (5.3x) and 74 ms of :has() at 200 turns with it, 0.73 -> 0.75 ms and 0.19 ms without. Style-recalc and scroll figures stay in the log, not the verdict.
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6d9c6f4276
ℹ️ 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".
| ) | ||
| page.wait_for_timeout(1500) | ||
| page.mouse.move(720, 420) | ||
| m1 = metrics(cdp) |
There was a problem hiding this comment.
Preserve the typing metrics snapshot before preparing to scroll
Every measurement overwrites the post-typing m1 snapshot after jumping the viewport to the middle, waiting 1.5 seconds, and moving the pointer over the thread. Consequently, type_style_ms and type_layout_ms include the style/layout work caused by that scroll and hover, rather than just typing. This contaminates the reported per-keystroke measurements and can misleadingly attribute scroll-related work to long-chat typing. Keep the original post-typing snapshot and use a separate baseline for the wheel measurements.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch, the scroll baseline overwrote the typing snapshot, so the reported style recalc per keystroke included the scroll setup. Fixed in bedf9ac: the scroll window now starts from its own snapshot. Only the reported figures were affected, not the gated ones.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
…ehind a failure Measures the large chat first and stops there when :has() is over budget; repeats only when the growth ratio is near its limit. Times 10 keys instead of 30. A failure now prints matching time per key at each size, how far over budget it is, and the top selectors by cost (or by growth from the small chat to the large one) with their match attempts per key. Step timeout 10 minutes. [skip ci]
For the slowest selectors, a text match against studio/frontend/src CSS rules (exact, else by shared classes and attributes) gives file:line, and whether this branch changed that line; a Tailwind utility is traced to the TSX using its class. A :has() that searches descendants is called out with the element it hangs off and where that element is set. Every hint is worded as a possibility, not a verdict, and a lookup error never hides the failure. Unit tests cover the mapping and the :has() shape check. [skip ci]
… failure to its rule Frontend CI (Linux, Windows), Composer compatibility (all four) and Inline images (all three) run the gate right after npm ci, before their other tests. An untraced pre-check shortens the traced window to 2 keys on a slow page, so a regressed build fails in minutes. On a failure, selectors tried on most of the DOM are marked as likely victims of a whole-page restyle, and a time-boxed bisection switches :has() rules off in fresh pages to name the rule that costs the time on its own, with its likely CSS source. npx runs through the shell on Windows. [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
The new "Chromium for the long-chat typing gate" step in env:
RETRY_ATTEMPTS: '2'
RETRY_ATTEMPT_TIMEOUT: '420'
# apt's own retries multiply stalled transfers inside the attempt budget.
APT_ACQUIRE_RETRIES: '0'
|
…nder 2 minutes The pin-down now edits the stylesheet text before each fresh page load: switching rules off in a page that already rendered left Chromium's :has() flags behind and blamed the wrong rule. It searches for the rule whose removal makes the keystroke cheap (the cost is not additive: one rule restyles a subtree and the others pay for it), trying rules that search an element holding the thread first, and reports the keystroke without that rule and the rule on its own. A page hundreds of times slower than healthy fails on the untraced number without tracing, and the FAIL line prints before the diagnosis. The gate's Chromium step bounds apt like the other browser steps (APT_ACQUIRE_RETRIES=0, 10 minute timeout).
|
Fixed in 052c322: all four "Chromium for the long-chat typing gate" steps now set |
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
|
One more on the next staging run (danielhanchen#3929):
|
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
## What changed Typing in a long, idle chat could stall in Unsloth Desktop on Windows. The wallpaper fade rule used a descendant search inside `:has()`, so editing the composer could trigger a costly style recalculation across the chat. The slowdown reproduced with turn navigation disabled and no model running. Use direct-child selectors for the two wallpaper layouts. The plain Glass backdrop contains the image directly, and an uploaded wallpaper wraps it in a frame. Both keep their existing fade behavior. ## Verification - In Windows WebView2, median keydown-to-second-frame latency in the same synthetic 600-message chat fell from **160.1 ms to 5.0 ms**. The same source builds passed all 16 wallpaper fade cases. - Extended the existing thread-ancestor performance guard to check every combinator in wallpaper paths inside `:has()`. On the original stylesheet, the three prior checks pass and the new check fails on the fade selector. All 28 tests across the thread-ancestor, wallpaper and appearance suites pass with the fix. Playwright sent the final key at 1.88 seconds in both recordings. The full phrase appeared at 4.09 seconds before the fix and 1.88 seconds after it. The capture compares the parent and implementation commit. The follow-up commits only change the regression tests.  ## Glass users and the latest main The fade selector was one of four whole-thread `:has()` searches on the workspace that holds the chat. With Glass on (stored per origin, so Desktop can have it on while the same chat at 127.0.0.1:8888 does not), the other three still made every keystroke re-walk the thread: - `:not(:has(.aui-thread-welcome-center))` and `:has([data-tour="chat-compare-view"])` on the workspace (wallpaper dim, plus two Glass rules added in unslothai#16643) - `.aui-thread-viewport:has(.aui-thread-welcome-center)` on the thread scroller itself The welcome and compare views now set `data-chat-welcome` / `data-chat-compare` on `<html>` in a layout effect (counted, so compare panes and remounts stay correct), and the viewport rule uses the fixed child path to the welcome block. The branch is merged with main. The guard test now checks every `:has()` anchored on an element that holds the thread, including ones nested in `:not()`. Typing into an idle 600-message chat, headless Chromium, same server, JS and DOM, only the stylesheet differs, arms interleaved, 6 reps each, median [min-max]: | Glass | Arm | Style recalc per key | 88-char burst | Keydown to 2nd frame | |---|---|---|---|---| | on | main (A/A: two arms) | 26.4 / 23.4 ms | 2.97 / 2.87 s | 36.7 / 33.1 ms | | on | fade fix only | 23.4 ms [20.6-30.1] | 2.85 s | 34.0 ms | | on | this PR | 1.4 ms [1.4-2.4] | 0.68 s | 13.7 ms | | off | main (A/A: two arms) | 22.7 / 20.8 ms | 2.51 / 2.41 s | 31.2 / 30.0 ms | | off | fade fix only | 1.1 ms [1.0-1.4] | 0.62 s | 15.8 ms | | off | this PR | 1.1 ms [0.9-2.4] | 0.65 s | 13.9 ms | No visual change: 192 wallpaper states (workspace and chat root, backdrop / frame / crossfade, ready, fade, welcome / conversation / compare / compare with an empty pane, Glass on and off) compute the same display, opacity, viewport wash and composer glass values on main and on this PR in Chromium, Firefox and WebKit (576 cells, 0 differ; dropping the rules flips 96 of 192, so the check is live). The real app shows the same computed values on main and on this PR for welcome, conversation and compare, with and without Glass. Typing a 57-character question at 80 ms per key into the same 600-message chat with Glass on (4.6 s is the floor):  ## Issue unslothai#16603 Fixes unslothai#16603. Bisecting the Studio frontend from `v0.1.913` to `main` on a seeded 200-turn agent chat (about 427K tokens: reasoning, tool cards, web sources, compaction markers, code, KaTeX), headless Chromium, same server and data for every build: | Build | Style work per keystroke | 88-key burst | Scroll long tasks | | --- | --- | --- | --- | | before unslothai#16333 | 15.6 ms | 1.29 s | 189 ms | | unslothai#16333 (the fade `:has()` this PR bounds) | 619 ms | 58.1 s | 268 ms | | `v0.1.914-beta` | 144 ms | 13.9 s | 280 ms | | `main` | 136.5 ms | 11.4 s | 935 ms | | `main` + this PR | 4.6 ms | 1.32 s | 27 ms | unslothai#16751 (Reduce Motion default off) made scroll pay the same walk more often (61 ms to 188 ms per wheel step); this PR removes the walk, so no separate change is needed there, and it is why turning Reduce Motion on did not help typing. A spoofed agent session that grows to 30 turns with tool calls, file edits, web search and compaction rounds goes from 23.7 to 100.3 ms per key on `main` and stays near 1.2 ms per key with this PR. unslothai#16801 adds a CI gate that fails when selector matching per keystroke grows with chat length; it should merge after this PR. --------- Co-authored-by: Daniel Han <[email protected]>
… 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.
Adds a browser CI gate that fails when typing in a long chat costs more as the chat grows, the shape of #16603.
Stacked on #16656. Please merge #16656 first: this branch contains its commits, and the gate fails on current
mainby design (that is the regression it catches).Why
#16603 came back because nothing in CI measured per-keystroke cost against chat length. Bisecting the Studio frontend from
v0.1.913tomain::has())v0.1.914-betamainmain+ #16656#16333 added a descendant
:has()on elements that hold the whole thread ([data-wallpaper-workspace],[data-chat-content-root]), so Chromium (Desktop, Chrome, Edge) walks every message on each keystroke. Firefox is not affected, which matches the "browser is fine" reports. #16751 (Reduce Motion default off) then made scroll pay that walk more often (61 ms to 188 ms per wheel step), which is why turning Reduce Motion back on did not help typing. #16300 (d56738f40) already removed two other #16333 rules that restyled the whole page on every key (real-app bisect: 563.8 to 91.2 ms per key), which is why 0.1.914 was slow but not as slow as #16333. The fade rule stayed. #16656 removes every such rule and adds a static guard test; this PR adds the runtime gate so a new rule of that shape, or anything else that scales with chat length, cannot ship again.What the gate does
tests/studio/playwright_long_thread_gate.pyruns first in every frontend lane, right afternpm ci: Frontend CI (Linux, Windows), Composer compatibility (Ubuntu, macOS, Windows, Safari) and Inline images (Ubuntu, macOS, Windows).smoke-thread-weight.htmlfor production (vite.long-thread.config.ts) and seeds an agent-style history inside the real app ancestors (?shell=1: sidebar workspace, wallpaper, chat content root) with open reasoning, tool cards, web sources, compaction markers, code, KaTeX and tables. The fixture shape is checked, so a fixture that stops rendering something fails.:has()matching costs more than 5 ms per key at 200 turns, or if total selector matching per key grows more than 2x from 40 to 200 turns. A second repeat runs only when the ratio is near the limit. Both checks are ratios or tiny budgets on selector matching, so a slow runner cannot fail them.What a failure says
A failure prints ms per key at each size, how far over budget it is and the top selectors with their match attempts. Selectors tried on most of the DOM are marked as likely victims of a whole-page restyle. It then pins down the trigger: it removes
:has()rules from the stylesheet text before fresh page loads (rules switched off in a page that already rendered leave Chromium's:has()state behind and blame the wrong rule) and bisects for the rule whose removal makes typing cheap, trying rules that search an element holding the thread first. Each rule found is mapped to its likely source with a text match, worded as a possibility. On currentmain:tests/studio/test_css_culprit.pycovers the source mapping and the:has()shape check.Replay against past stylesheets
The gate on this branch, with only
index.cssswapped in from each commit (CPU runner):index.cssfrom4ce36bc3b5)65e868dcf5)6401ceda29)v0.1.914-betamainOn GitHub runners a passing gate takes 30 to 77 s per lane plus 12 to 24 s for Chromium (staging run of every lane on Linux, Windows and macOS).
Other changes
richagent content (markdown, table, list) and the?shell=1app shell.retry-with-apt-lock.shwithAPT_ACQUIRE_RETRIES=0and a 10 minute step timeout, like the other browser steps.