Skip to content

Studio: show long thinking in a capped box that scrolls on its own instead of Expand thinking - #16876

Merged
danielhanchen merged 9 commits into
mainfrom
studio-thinking-capped
Nov 7, 2026
Merged

danielhanchen merged 9 commits into
mainfrom
studio-thinking-capped

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Long Thinking traces under the Auto setting were clipped to a fixed box with an "Expand thinking" button below it, and reading the rest meant expanding the whole trace into the page (12,229 px for a long trace in testing). The box now scrolls on its own, and an expand button in the header still shows the whole trace in one click.

What changes

  • A capped box that scrolls. Under Auto, an open Thinking block stops at min(22rem, 48vh) (was min(18rem, 40vh)) and scrolls inside. No border, and the scrollbar is always visible, sits 8 px right of the text, and has a stable gutter so the text width never changes with it. Focusing a link deep in the trace now just scrolls it into view instead of lifting the cap.
  • Expand thinking beside Copy. An icon button in the header, 4 px from Copy, (shown only while the box holds more than it shows) lifts the cap for the round and shows the whole trace at once; Collapse thinking puts the scroll box back. Expanding only lifts the height cap: the trace keeps its position and its width (measured 0 px shift and the same 733 px text width, with classic and overlay scrollbars). A new round or a change of the Thinking setting restores the cap, like the old button.
  • Streaming follows the newest line until the reader scrolls up inside the box, and follows again once they scroll back to the bottom. Only the reader's own wheel, touch, key or pointer input stops the follow: rows mounting above shift scrollTop too, and without that guard the box stopped following on its own partway through a stream.
  • Edge fades. The top fades once scrolled (lines run under the "Worked for" header) and the bottom fades while there is more below; each edge fades only while something is past it. A second mask layer keeps a strip on the right unfaded so the scrollbar never fades. Print drops the masks.
  • Spacing. The box starts 8 px under the header so scrolled text stops short of it, the first line sits 14 px under the header at rest, and a capped box ends 8 px above the closing rule while scrolling; its own bottom padding puts the last line 20 px above the rule only once scrolled to the end. The rule has 8 px more space below it, and uncapped thinking gets 24 px above it (was 16 px).
  • reasoningTailFlexBox and the flex layout it guarded are removed, since a scroll box does not need justify-end to show the newest lines.

This reverses the earlier choice of a clipped box over an inner scroller. While the box is capped the transcript already skips thread scroll corrections (bounded), and live testing showed no anchoring problems, but it is worth a look.

Performance

Same as main within run-to-run noise (headless Chromium, long seeded trace and live streaming with Gemma 4 E2B):

main this PR
Opening the block, CPU 4x, main thread stalls 303 to 308 ms 289 to 298 ms
Reading the rest, CPU 4x Expand: 0 to 53 ms stalls, page grows to 12,229 px scroll inside: 0 ms stalls, page stays 900 px
Live streaming, CPU 4x, stalls per second 178 to 198 ms 185 to 202 ms
Live streaming, normal CPU, stalls 0 to 64 ms 0 ms

Verification

  • npm run typecheck, npm test (14,993 pass), npm run build.
  • reasoning-live-tail.test.ts is rewritten for the scroll box: the cap, always-visible scrollbar and stable gutter, the header expand button, follow and stop rules, the per-edge fades and the scrollbar strip. thinking-fold.test.ts follows the end rule's new prop.
  • In a local Studio with a live model: the box followed the newest line, held its place after a 150 px scroll up while about 500 px more streamed in, and showed the bottom fade; the top fade, header gap, box height rule gap mid-scroll and at the end, and the scrollbar position were measured, with classic scrollbars.

Not tested here

  • Safari, Firefox and the Desktop app webviews; timings are Chromium only.
  • Overlay scrollbars do not render in headless screenshots, so the unfaded scrollbar strip was checked from computed styles, not pixels.

Screenshots

Same scripted 70-step Thinking trace streamed into main (left) and this PR (right), default Auto setting, Chromium 1500x1000. The headless browser hides scrollbars, so the always-visible scrollbar does not show here.

Mid-stream: both follow the newest line. This PR shows the top fade and the expand button in the header.

Thinking box while streaming, main vs this PR

Finished and reopened: main clips the trace with an "Expand thinking" link under it; this PR scrolls inside the box (352 px shown of 869 px), with a bottom fade and the expand button beside Copy.

Finished Thinking box, main vs this PR

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-07T08:25:36.558758Z 52df67b 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: 27f7a40a76

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

className={cn(
// A mask paints only inside its box: bleed into the side padding so list markers survive.
capped &&
"-mx-[calc(1.25rem*var(--ui-space-scale,1))] min-w-0 max-h-[min(22rem,48vh)] overflow-x-hidden overflow-y-auto px-[calc(1.25rem*var(--ui-space-scale,1))]",

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 Connect transcript demand-loading to the inner scroller

When a long trace is opened under Auto and the reader scrolls beyond the initially mounted rows before progressive mounting completes, the new inner scroller can display blank reserve blocks instead of reasoning. ReasoningTranscript still attaches its scroll listener exclusively to .aui-thread-viewport and runs its reserve-demand calculation from that listener; scrolling this nested box does not dispatch a scroll event on the thread viewport. Wire the inner scroller into the transcript's demand-loading logic so newly visible passages mount immediately rather than waiting for background mounting to reach them.

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.

Fixed in 2f84c79: the transcript now listens for scrolls on the capped box and runs its demand pass on the next frame, so passages the box scrolls to mount right away.

Comment on lines +545 to +547
const onScroll = () => {
const atBottom = below() < 24;
if (atBottom || performance.now() - readerAt < 250) following.current = atBottom;

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 Track scrollbar interaction beyond the initial pointer-down

During streaming, a reader who presses the scrollbar thumb, pauses for more than 250 ms, and then drags upward does not disable following: pointerdown is the only pointer event that updates readerAt, so this condition ignores the subsequent scroll. The next content resize immediately snaps the box back to the bottom. Track an active pointer interaction until release, or otherwise recognize continued scrollbar dragging, so the reader can reliably hold a position while reasoning streams.

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.

Fixed in 2f84c79: a press that starts in the box now counts as reader input for as long as it is held, so a paused scrollbar drag still stops the follow.

shimmyshimmer and others added 4 commits November 5, 2026 22:23
… and a stable scrollbar gutter for the thinking box
…pace around the closing rule once scrolled to the end, wider gap between header buttons
… held scrollbar drag from snapping the box back while streaming
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2f84c7975d

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

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 52df67b27c

ℹ️ 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 pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 7, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 7, 2026
@danielhanchen
danielhanchen merged commit 340b48c into main Nov 7, 2026
@danielhanchen
danielhanchen deleted the studio-thinking-capped branch November 7, 2026 10:13
danielhanchen added a commit to Etherll/unsloth that referenced this pull request Nov 7, 2026
…(Settings scroll) (unslothai#17003)

Follow-up to unslothai#16978. Its Glass ceiling of 7x per area was set from too
few readings and fails unrelated PRs.

## Problem

Staging for unslothai#16876 (which does not touch source cards) failed the
long-chat gate: `appearance mode frosted makes area source_card cost
1,111 ms CPU against 159 in the default appearance at 40 turns = 7.0x
(limit 7.0x)`. Across 7 local runs of the gate on main, several small,
cheap areas read close to or over 7x under Glass on main itself:

| Mode | Area | Highest reading on main |
|---|---|---|
| blurred | api_monitor | 7.8x |
| blurred | source_card | 7.0x |
| blurred | account_menu | 6.8x |
| liquid-3d | run_settings | 6.2x |
| blurred | reasoning_toggle | 6.1x |
| liquid | tool_toggle | 6.1x |

## Fix

The per-area Glass ceiling goes from 7x back to 10x, about 1.3x the
highest reading. The Settings scroll ceilings go from 12-15x to 18x:
staging for unslothai#16865 (which does not touch Settings or Glass) read
`frosted makes area settings_scroll cost 1,903 ms CPU against 141 ... =
13.5x (limit 12.0x)` on a GitHub runner, above the 9.7-12.2x seen
locally. A new appearance mode still has no allowance and is held to the
plain 4x limit, so a new slow material is still caught.

## Testing

- `test_area_matrix.py`: 28 passed.
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