Skip to content

Studio: CI gate that fails when typing in a long chat gets slower as the chat grows - #16801

Merged
danielhanchen merged 20 commits into
mainfrom
studio-long-thread-perf-gate
Nov 6, 2026
Merged

danielhanchen merged 20 commits into
mainfrom
studio-long-thread-perf-gate

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

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 main by 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.913 to main:

Build (200-turn agent chat, about 427K tokens) Style work per keystroke
before #16333 15.6 ms
#16333 (wallpaper fade :has()) 619 ms
v0.1.914-beta 144 ms
main 136.5 ms
main + #16656 4.6 ms

#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.py runs first in every frontend lane, right after npm ci: Frontend CI (Linux, Windows), Composer compatibility (Ubuntu, macOS, Windows, Safari) and Inline images (Ubuntu, macOS, Windows).

  1. Builds smoke-thread-weight.html for 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.
  2. Measures the 200-turn chat first. Two untraced keys decide how much to trace: a healthy page traces 10 keys, a slow one 2, and a page hundreds of times slower than healthy fails on the untraced number alone.
  3. Fails if :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 current main:

FAIL: :has() matching costs 63.6 ms per keystroke at 200 turns, budget 5.0 ms (12.7x over); total selector matching 358.9 ms/key
  pin-down at 60 turns, untraced style recalc per keystroke: 48.5 ms with all 262 :has() rules, 1.1 ms with none of them
  Measured: removing only this rule takes the keystroke from 48.5 to 1.8 ms (no :has() rules: 1.1 ms); this rule on its own costs 4.9 ms:
    :is([data-wallpaper-workspace], [data-chat-content-root]):has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"]) .thread-bottom-fade
    It is possible this section caused the issue, but we cannot be sure (a text match):
      studio/frontend/src/index.css:6210 (exact text match)
    Pattern: `:has(> .chat-wallpaper[data-ready] .chat-wallpaper-image[data-fade="false"])` on `:is([data-wallpaper-workspace], [data-chat-content-root])` searches all descendants (no leading `>`, or a space inside), so Chromium re-walks everything under that element after each DOM change, whether or not anything matches.
      `[data-wallpaper-workspace]` (first found in studio/frontend/src/app/routes/__root.tsx:720) holds the whole thread, so every keystroke walks every message.

tests/studio/test_css_culprit.py covers the source mapping and the :has() shape check.

Replay against past stylesheets

The gate on this branch, with only index.css swapped in from each commit (CPU runner):

index.css from Verdict Time Pin-down
before #16333 (4ce36bc3b5) PASS 25 s
#16333 (65e868dcf5) FAIL 104 s fade rule: 276.0 to 1.5 ms without it
#16442 (6401ceda29) FAIL 105 s fade rule
v0.1.914-beta FAIL 101 s fade rule
main FAIL 104 s fade rule: 48.5 to 1.8 ms without it
this branch PASS 28 s

On 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

  • The smoke fixture gains rich agent content (markdown, table, list) and the ?shell=1 app shell.
  • The gate's Chromium step installs missing Linux libraries only when Chromium cannot launch, through retry-with-apt-lock.sh with APT_ACQUIRE_RETRIES=0 and a 10 minute step timeout, like the other browser steps.

Imagineer99 and others added 11 commits November 4, 2026 12:10
…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]
…s off the thread

Light Glass welcome rules (#16751) read the data-chat-welcome root flag, and the
Windows page blur rule (#16671) uses the child path to the pinned sidebar container.
The guard now also covers data-windows-wallpaper-page, which holds the hidden chat.

[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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T06:33:28.293617Z a8e2faa Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: bedf9acafc

ℹ️ 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".

…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]
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: e9bbaec5a3

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member Author

Repo tests (CPU, studio) and workflow-trigger lint fail on this PR's latest staging run (danielhanchen#3929) and pass on main. Both report the same one test:

FAILED tests/studio/test_apt_steps_are_bounded.py::test_install_deps_does_not_let_apt_retry_inside_the_attempt
AssertionError: step 'studio-composer-compatibility.yml: Chromium for the long-chat typing gate' runs `playwright install-deps` without setting APT_ACQUIRE_RETRIES, so apt falls back to 3 internal retries and a stalled mirror costs roughly four times the per-URI timeout

The new "Chromium for the long-chat typing gate" step in studio-composer-compatibility.yml needs the same env as the existing "Install Chromium for browser smokes" step in studio-frontend-ci.yml:

        env:
          RETRY_ATTEMPTS: '2'
          RETRY_ATTEMPT_TIMEOUT: '420'
          # apt's own retries multiply stalled transfers inside the attempt budget.
          APT_ACQUIRE_RETRIES: '0'

test_the_retry_budget_fits_inside_the_step_timeout may then also want a matching timeout-minutes on the step.

…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).
@danielhanchen

Copy link
Copy Markdown
Member Author

Fixed in 052c322: all four "Chromium for the long-chat typing gate" steps now set APT_ACQUIRE_RETRIES: '0' and timeout-minutes: 10. I left out RETRY_ATTEMPTS: '2' / RETRY_ATTEMPT_TIMEOUT: '420', since 2 x 420 s would not fit inside a 10 minute step under test_the_retry_budget_fits_inside_the_step_timeout; the helper's defaults fit. tests/studio/test_apt_steps_are_bounded.py passes locally.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 052c322c6f

ℹ️ 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".

@danielhanchen

Copy link
Copy Markdown
Member Author

One more on the next staging run (danielhanchen#3929): Repo tests (CPU, rest-2) fails on a file this PR adds:

AssertionError: 1 file reads in the test trees touch a checked-in file with the platform default encoding, so they break on Windows as soon as that file gains a non-ASCII byte. Pass encoding = "utf-8": ['tests/studio/playwright_long_thread_gate.py:144: read_text()']

read_text(encoding = "utf-8") at tests/studio/playwright_long_thread_gate.py:144 clears it. The Composer (macos-latest, browsers) red in the same run is an artifact upload DNS failure (Failed to CreateArtifact: ENOTFOUND), not this PR.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: a8e2faa9f3

ℹ️ 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".

danielhanchen added a commit to NilayYadav/unsloth that referenced this pull request Nov 6, 2026
## 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.

![Before and after typing in an idle 600-message chat on Windows
WebView2](https://raw.githubusercontent.com/Imagineer99/unsloth/8fd91c242dc7fc4461a96973630e1f9da4016468/pr-media/long-chat-typing.gif)



## 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):

![Typing into an idle 600-message chat with Glass on, main above and
this PR
below](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/16656/typing-edd898b05ecd.gif)


## 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]>
@danielhanchen
danielhanchen merged commit 8f4206c into main Nov 6, 2026
@danielhanchen
danielhanchen deleted the studio-long-thread-perf-gate branch November 6, 2026 08:03
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants