Repository navigation
Studio: long chats stop re-rendering source badges per token and tool cards per run - #16277
Merged
Merged
Conversation
… cards per run A streamed token rebuilt the reply's source list, so every source badge (and its hidden measuring copy) re-rendered on each token of a web search answer. SourcesGroup now selects the message's URL sources as a string and hands an unchanged list to a memoized view. Every python / terminal card in the history subscribed to thread.isRunning for the stdout fallback, so each run start and end re-rendered all of them. The hook now selects the fallback string itself, which stays "" for cards without a fallback entry. Rendered output is unchanged. Adds a browser check that counts renders while a reply with sources streams into a chat with tool cards.
# Conflicts: # .github/workflows/studio-frontend-ci.yml
Member
Author
|
@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. |
|
Codex Review: Didn't find any major issues. Another round soon, 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". |
# Conflicts: # .github/workflows/studio-frontend-ci.yml
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.
Long chats did two pieces of avoidable render work while a reply streamed. Neither changes what is drawn.
What changes
SourcesGroupread the whole message withuseMessage()and rebuilt its source list each render. Every streamed token of a web search answer therefore re-rendered all of its source badges twice, once for the visible row and once for the hidden copy used to measure rows, each with a Radix HoverCard tree. On a streamed token that was about 190 of the roughly 200 components React rendered.SourcesGroupnow selects the message's URL sources as a string key (memoized on the content array), parses it once per key, and passes the list to a memoizedSourcesGroupView. The view is the old body, unchanged.useToolOutputForsubscribed tothread.isRunningfor its stdout fallback, so every python and terminal card in the chat re-rendered twice per turn. At 1000 messages the end-of-stream commit rendered about 7,100 components. The hook now selects the fallback string itself. It returns the same value in every case, and for cards without a fallback entry it stays"".smoke-thread-weight-main.tsxgets an opt-inagent.sourcesseed option and a&sources=1stream option. The defaults are unchanged.tests/studio/playwright_long_chat_renders.py, wired into the frontend workflow. It counts renders through a React DevTools hook while a 60-chunk reply with sources streams into a 30-message chat with tool cards and sources.Results, base vs head
Setup: a production build of the real
Threadwith a seeded local runtime, headless Chromium at 1440x900 with 4x CPU throttle. Each assistant reply has reasoning, a tool call (web search with 6 sources, terminal or python), and markdown with a table and a code fence. A compaction marker appears every 25 replies. The streamed reply is 100 chunks behind a web search call with 6 sources. Each arm ran 3 times, interleaved base/head. Values are median [min-max].Opening a chat did not change: first paint, full mount time, heap and DOM node count were all within the base spread. Stream wall time at 200 messages was also unchanged (4249 vs 4229 ms, overlapping ranges).
Identical output:
innerText, its ARIA snapshot and itsouterHTMLare identical. InouterHTML, assistant-ui's random message ids are renamed to their order of appearance.Identical output while streaming, not only at the end: a stepped model advanced one chunk at a time, so both arms are captured at the same point. The stream covers text only, a python call with partial arguments reusing a history call id, a terminal call, the result arriving, fallback and own output changing mid-run, and sources appearing, renamed, reordered, duplicated with a different id, gaining a description and losing a title, up to 17 sources (the "+N more" collapse). It ends with the run finishing and the output store being cleared. It ran as a straight stream, cancel at step 2, switching threads and back mid-run, and hovering a badge mid-stream, each with tools expanded and with the default visibility: 126 frames per arm.
innerTextis identical in all 126 frames. The fallback output appears and disappears in the same frames in both arms, and badge counts match at every step.outerHTMLis identical apart from one scroll timing attribute (--aui-scroll-stabilizer/data-aui-following), which varies by the same amount between two runs of the same arm.Tests
npm test: 14524 tests, 14523 pass, 1 skipped, 0 fail, on base and on head.npm run typecheckandnpm run buildpass on both.npm run bundle:checkis within budget.python3 tests/studio/playwright_long_chat_renders.pyfails on base (366 badge renders) and passes on head.Not covered
ThreadClientmaps all messages throughtapClientLookup). At 1000 messages, unthrottled, that is about 11 to 15 ms per streamed token. This PR does not touch it.