Skip to content

Studio: keep the thread window off a streaming reply's back, and compare long-chat cost with the base build in CI - #17597

Merged
danielhanchen merged 6 commits into
mainfrom
studio-thread-window-stream-fix
Nov 13, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
studio-thread-window-stream-fix

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Problem

#17504 mounts only the messages near the reader. A window slide that is not urgent goes out as a React transition, and every streamed chunk is a synchronous store update, so React restarts that transition from the root on each chunk. A slide issued while a reply streams therefore re-rendered its rows (markdown, KaTeX) for every chunk and landed only after the reply ended. A reader who scrolled up during a reply looked at an empty spacer until it finished, and the wasted renders showed up as main-thread time:

Fix

Windowing stays; only what happens while a reply streams changes (progressive-messages.tsx, thread-window.ts):

  • A slide that can wait is held until the reply pauses (no chunk for 1 s, TailPulse), instead of starting a transition that cannot land.
  • A spacer coming into view is still committed synchronously in the frame that shows it.
  • A transition already in flight when a stream starts is finished synchronously.
  • A full mount a reader is waiting on (find, print) goes in small synchronous passes during a stream.
  • The reply being written is not re-measured on every chunk (each chunk moved the height estimate and every spacer).

Results

studiobench standard 100K, 4 reps, null-controlled, base = main before #17504, treatment = this fix:

metric base this PR verdict
stream_cost_ms_per_kchar 260.9 253.3 within noise (main with #17504: +226%)
stream_busy_pct 7.2 6.7 within noise
thread_reopen.reopen_ms 2130 1586 faster
reasoning_toggle.open_ms 473 281 faster
select_all_copy.select_all_ms 321 62 faster
select_all_copy.copy_ms 748 1435 slower, unchanged from #17504 (follow-up)

Behaviour parity: 20 invariants held, 0 broken. The select-all copy cost (every unmounted row is mounted before the clipboard fills) is left for a follow-up that builds the clipboard from the message store.

CI: compare long-chat cost with the base build

The existing long-chat gate compares a build with itself (40 vs 200 turns), so it passed #17504. tests/studio/long_thread_ab.py builds the PR's base too and runs the same 200-turn chat on both builds, alternating on fresh pages: streaming a reply, typing, scrolling, and a reply streaming while the reader wheels away and then stops to read. It fails when head's median main-thread or long-task time is over 1.5x base with no overlap, or when any head reading leaves the viewport blank while base stayed filled. A new step in studio-frontend-ci.yml runs it on pull requests (5 reps per side, a few minutes; a base that cannot build with the PR's node_modules is a warning).

Validated on clean runners (scroll-away area, 5 reps each):

pair verdict
base vs base, 3 runners pass, 0 false positives
main before #17504 vs main with #17504, 4 runners fail on all 4 (viewport blank in 2 to 4 of 5 reps)
main before #17504 vs this fix pass, never blank
main vs this fix, 2 runners pass; main blanks, this fix never does

Every bisected #17504 commit also measured below its base on stream, typing and scrolling CPU, so the check gates on what readers see as well as on time.

Tests

  • npx tsc --noEmit -p . clean; tests/thread-window.test.ts and tests/progressive-mount-glue.test.ts 88 pass, including new tests for TailPulse and the deferral.
  • tests/studio/playwright_thread_window.py check 14: wheel away from a 600-chunk streaming reply, rows must cover the reader 20 frames later while it still streams; fails on main, passes here.

Declared UI difference (affects UI#)

studiobench's visible-region parity reports one difference, in stop_generation: base shows message 19 on screen during the action, this PR does not. A per-frame trace (IntersectionObserver entries, scrolls, mounts) shows why. On main, when Enter jumps to the bottom, the finished reply is still mounted at a stale mid-stream height (675 px against a real 1371 px), so the jump lands about 700 px short for one frame: message 19 sits at -3..123 px for about 25 ms, then the scroll follows to the true bottom. This PR mounts the reply at its real height in the same frame as the jump, so it lands on the settled view directly; message 19 is mounted, just above the viewport, and no frame shows a spacer. The null control (main against main) shows the same one-frame flash on every cell. Every behavioural invariant holds, the structural mode is clean, and the final screenshots match.

The long-chat check moved to its own job (Long-chat cost against the base build): the build job already runs 29 to 35 minutes against its 40 minute timeout.

Before / after

Before: viewport empty while the reply streams after the reader wheeled away. After: rows fill the viewport

Two isolated Studio installs (merge base b2784e3e6, this PR), the same 400-message chat, a reply streamed into it (answered in the page, no model), the reader wheels up 12 steps and stops while it streams. Each side ran 6 attempts and shows its emptiest one. Before: the viewport was empty in 1 of 6 attempts (rows filled 0% of it). After: filled in 6 of 6.

danielhanchen and others added 2 commits November 12, 2026 07:19
A window slide that is not urgent goes out as a React transition. Every streamed
chunk is a synchronous store update, and React restarts a transition render from
the root on each one, so a slide issued while a reply streams rendered its rows
again for every chunk and landed only once the reply ended. Until then no step
ran, so a reader who had scrolled away looked at a spacer.

- A slide that can wait is held until the reply pauses (no chunk for a second).
  A spacer coming into view is still committed in the frame that shows it.
- A transition a stream starts under is finished synchronously instead.
- A full mount a reader is waiting on goes in small synchronous passes.
- The reply being written is not measured mid-stream: each chunk moved the
  height estimate, and with it every spacer, on every frame.
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T10:48:07.309629Z b0bc9f8 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.

@danielhanchen danielhanchen self-assigned this Nov 12, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8cb857be78

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

[skip ci]
danielhanchen added a commit that referenced this pull request Nov 12, 2026
## Summary

The `pinned-symbol matrix (vLLM, TRL, PEFT, ST, bitsandbytes,
transformers)` job fails on any PR that runs it (seen in the staging run
for #17597):

```
FAILED tests/version_compat/test_peft_conversion_symbol_backfill.py::test_the_fused_snapshot_matches_upstream
E   AssertionError: fused MoE types missing from the snapshot: ['Dots3NoteTextModel']
```

That test is a canary. It reads transformers' `conversion_mapping.py` on
`main` and checks that every fused MoE alias in it is also in
`_PEFT_MOE_CONVERSION_PATTERNS` in `unsloth/import_fixes.py`, the
snapshot used when the live map is not available. transformers added a
new alias today in huggingface/transformers#47844 (dots3-note Preview
support):

```python
"Dots3NoteTextModel": "qwen2_moe",
```

Like the `UnlimitedOcrTextModel` entry already in the snapshot, it is
keyed by class name rather than model type. The canary is right: without
the entry, the stand-in map would let a fused dots3-note checkpoint fall
through without its MoE conversion.

## Change

`unsloth/import_fixes.py`: `"Dots3NoteTextModel": "qwen2_moe"` added to
`_PEFT_MOE_CONVERSION_PATTERNS`, next to the other class-keyed alias,
with a comment saying where it comes from.

## Testing

- `tests/version_compat/test_peft_conversion_symbol_backfill.py` against
the live upstream map: 69 passed.
- With main's `import_fixes.py`,
`test_the_fused_snapshot_matches_upstream` fails with the error above.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: b0bc9f8a99

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

[skip ci]
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
@danielhanchen
danielhanchen merged commit 6c15abd into main Nov 13, 2026
@danielhanchen
danielhanchen deleted the studio-thread-window-stream-fix branch November 13, 2026 11:47
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.

1 participant