Repository navigation
Chat: the composer dock stops searching the whole thread on every com… - #14585
Conversation
…poser resize
The dock's ResizeObserver ran viewport.querySelector(":scope > .aui-thread-viewport-footer")
every time the composer changed height (each new line of a multi-line draft). In Chromium
that query visits every element of the thread, so its cost grows with the chat. Walking the
viewport's direct children returns the same element in Chromium, Firefox and WebKit.
Measured on the unslothai#13919 benchmark harness (Windows Chrome 155, 240 Hz display, both fixtures,
1x and 4x CPU, 3 runs per cell): every table is within run-to-run noise of main.
Measured in a live code-heavy chat of about 62K elements (Playwright Chromium 148, headless,
Linux, 4 sessions x 2 rounds per arm): typing ten composer-growing lines (130 keys) spends
739 -> 539 ms of script at 1x CPU and 2,338 -> 1,914 ms at 4x; total task time -12% and -6%.
The query was 196 ms of self time in that probe on main. Plain typing does not reach this
code and is unchanged; per-keystroke latency to the presented frame stays within the rig's
noise at both CPU rates.
Startup bundle: +88 B raw / +53 B transfer (6,879,345 -> 6,879,433 B raw, 2,071,823 ->
2,071,876 B transfer against 5a955ef, Node 24, 97 chunks), inside the current budget
(156 B raw / 136 B transfer to spare), so the budget is unchanged.
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. |
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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 footer follows every message row, so a forward walk over the viewport's children costs O(rows), which in Chromium and Firefox is slower than the :scope > selector it replaced. Walking back from lastElementChild reaches the footer first and the viewport in two steps. [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". |
|
@codex review |
1 similar comment
|
@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". |
# Conflicts: # studio/frontend/scripts/check-bundle-budget.ts
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! 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". |
Summary
Every time the composer changes height (each new line of a multi-line draft), the composer dock's
ResizeObserverlooked up the thread footer withviewport.querySelector(":scope > .aui-thread-viewport-footer"). In Chromium (Unsloth Web in Chrome/Edge, Unsloth Desktop on Windows) that query visits every element in the thread, so its cost grows with the chat. This PR walks the viewport's direct children instead, which returns the same element.This removes thread-sized work from multi-line typing in long chats. Per-keystroke latency is unchanged within measurement noise, so this is a CPU saving.
What changes
thread.tsx: a smallchildWithClass(parent, className)helper replaces the two:scope >lookups inThreadComposerDock(the thread viewport next to the dock, and the footer inside it).tests/composer-dock-column-lookup.test.ts: four tests. The helper returns the first direct child with the class, skips non-HTML children, never matches a nested descendant, and the dock uses it instead of a selector.Measurements
Typing in a long live chat. A code-heavy chat of about 62K elements, typing ten composer-growing lines (130 keys). Playwright Chromium 148, headless Linux, 4 sessions × 2 rounds per arm.
The lookup was 196 ms of self time in the 1× probe on main. Plain typing never reaches this code. Per-keystroke latency from trace
EventTimingis within the rig's noise: multi-line p98 at 1× is 32.0 vs 30.6 ms.#13919 benchmark harness. Windows Chrome 155, 240 Hz display, saved conversation and answer-only proxy, 1× and 4× CPU, 3 runs per cell. Every table is within run-to-run noise of main. Whole-session renderer time, main vs this PR:
Testing
npm test: 13,396 pass, 0 fail.npm run typecheckpasses.thread.tsxfindings are identical to main; the new test file is clean.npm run bundle:checkis within budget.Follow-up: walk from the last child
The helper now walks back from
lastElementChild. The footer follows every message row, so a forward walk costs one check per row, and in current Chromium and Firefox that was slower than the:scope >selector it replaced. Walking back reaches the footer on the first check and the viewport in two. Per lookup on a 62K-element thread (200 rows, median of 21 samples x 200 calls, headless Linux)::scope >(main)All three lookups return the same element in all three engines, including when a nested descendant carries the footer class. A new test asserts that finding the footer after 500 rows checks a single child.