Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: stop Expand thinking from restyling the whole trace (#13665)
oobabooga90586ae0aa1f
diff --git a/studio/frontend/src/components/assistant-ui/reasoning.tsx b/studio/frontend/src/components/assistant-ui/reasoning.tsxindex f0524452857..9d4a08fb5fa 100644--- a/studio/frontend/src/components/assistant-ui/reasoning.tsx+++ b/studio/frontend/src/components/assistant-ui/reasoning.tsx@@ -32,6 +32,7 @@ import {clearReasoningRound,foldIsActive,reasoningTailCapped,+ reasoningTailFlexBox,resolveReasoningGroupDuration,resolveReasoningOpen,setReasoningRoundOpen,@@ -523,6 +524,15 @@ function ReasoningBody({);}+function useTailFlexBox(capped: boolean, streaming: boolean): boolean {+ const [flexBox, setFlexBox] = useState(capped);+ const next = reasoningTailFlexBox({ capped, streaming, previous: flexBox });+ if (next !== flexBox) {+ setFlexBox(next);+ }+ return next;+}+// A fixed box (#11703): the newest lines while streaming, the start once finished. Clipped, not an inner// scroller, which split the reading anchor across two containers (#11704).function ReasoningTail({@@ -558,6 +568,7 @@ function ReasoningTail({return () => observer.disconnect();}, [cappable, capped]);const clipped = capped && overflowing;+ const flexBox = useTailFlexBox(capped, streaming);return (<><div@@ -576,9 +587,12 @@ function ReasoningTail({onExpandedChange(true);}}className={cn(+ // The child rule stays on too: it is inert outside a flex box and toggling it restyles every row.+ cappable && "[&>*]:shrink-0",+ cappable && flexBox && "flex flex-col",// 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))] flex min-w-0 max-h-[min(18rem,40vh)] flex-col overflow-hidden px-[calc(1.25rem*var(--ui-space-scale,1))] supports-[overflow:clip]:overflow-x-visible supports-[overflow:clip]:overflow-y-clip [&>*]:shrink-0",+ "-mx-[calc(1.25rem*var(--ui-space-scale,1))] min-w-0 max-h-[min(18rem,40vh)] overflow-hidden px-[calc(1.25rem*var(--ui-space-scale,1))] supports-[overflow:clip]:overflow-x-visible supports-[overflow:clip]:overflow-y-clip",capped && (streaming ? "justify-end" : "justify-start"),clipped &&(streamingdiff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.tsindex cd416dceb1e..07c41292bfc 100644--- a/studio/frontend/src/features/chat/index.ts+++ b/studio/frontend/src/features/chat/index.ts@@ -471,6 +471,7 @@ export { resolveReasoningGroupDuration } from "./utils/reasoning-duration";export {reasoningFollowsPreference,reasoningTailCapped,+ reasoningTailFlexBox,resolveReasoningOpen,startsNewReasoningRound,} from "./utils/reasoning-visibility";diff --git a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts b/studio/frontend/src/features/chat/utils/reasoning-visibility.tsindex 0f6b4cafcd5..bb91b45f097 100644--- a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts+++ b/studio/frontend/src/features/chat/utils/reasoning-visibility.ts@@ -34,6 +34,20 @@ export function reasoningTailCapped({return visibility === "auto";}+/** Whether a bounded box keeps its flex layout. Toggling it restyles the whole trace, so it drops+ * only for an Expand while streaming and returns only with the next cap, not when the stream ends. */+export function reasoningTailFlexBox({+ capped,+ streaming,+ previous,+}: {+ capped: boolean;+ streaming: boolean;+ previous: boolean;+}): boolean {+ return capped || (!streaming && previous);+}+/** Whether the block sits where the setting alone would put it. */export function reasoningFollowsPreference(open: boolean,diff --git a/studio/frontend/tests/reasoning-live-tail.test.ts b/studio/frontend/tests/reasoning-live-tail.test.tsindex a30df554621..6dc76cd423d 100644--- a/studio/frontend/tests/reasoning-live-tail.test.ts+++ b/studio/frontend/tests/reasoning-live-tail.test.ts@@ -13,7 +13,7 @@ registerBundlerResolver();const { DISPLAY_VISIBILITIES } = await import("../src/features/chat/utils/display-visibility.ts");-const { reasoningTailCapped, resolveReasoningOpen } = await import(+const { reasoningTailCapped, reasoningTailFlexBox, resolveReasoningOpen } = await import("../src/features/chat/utils/reasoning-visibility.ts");@@ -30,6 +30,31 @@ test("only the auto setting bounds a block, whether the stream or a hand opened}});+// Mirrors useTailFlexBox: the first state is `capped`, then each render feeds the last result back.+function flexBoxTrace(steps: readonly { capped: boolean; streaming: boolean }[]): boolean[] {+ let previous = steps[0]?.capped ?? false;+ return steps.map((step) => {+ previous = reasoningTailFlexBox({ ...step, previous });+ return previous;+ });+}++test("the flex box survives Expand/Collapse once finished and never flips when a stream ends", () => {+ const capped = { capped: true, streaming: false };+ const expanded = { capped: false, streaming: false };+ const live = { capped: true, streaming: true };+ const liveExpanded = { capped: false, streaming: true };++ assert.deepEqual(flexBoxTrace([capped, expanded, capped, expanded]), [true, true, true, true]);+ assert.deepEqual(+ flexBoxTrace([live, liveExpanded, expanded, capped, expanded]),+ [true, false, false, true, true],+ );+ assert.deepEqual(flexBoxTrace([live, capped, expanded]), [true, true, true]);+ assert.deepEqual(flexBoxTrace([expanded, expanded]), [false, false]);+ assert.deepEqual(flexBoxTrace([live, liveExpanded, live]), [true, false, true]);+});+test("the box clips at the top instead of scrolling, and Expand toggles without a permanent open", () => {const tail = reasoning.slice(reasoning.indexOf("function ReasoningTail("),@@ -37,8 +62,15 @@ test("the box clips at the top instead of scrolling, and Expand toggles without);assert.match(tail,- /flex min-w-0 max-h-\[[^\]]+\] flex-col overflow-hidden px-\[[^\]]+\] supports-\[overflow:clip\]:overflow-x-visible supports-\[overflow:clip\]:overflow-y-clip/,+ /capped &&\s*"-mx-\[[^\]]+\] min-w-0 max-h-\[[^\]]+\] overflow-hidden px-\[[^\]]+\] supports-\[overflow:clip\]:overflow-x-visible supports-\[overflow:clip\]:overflow-y-clip"/,+ );+ // Toggling the flex box or the child rule on a finished box restyles every row.+ assert.match(tail, /cappable && "\[&>\*\]:shrink-0"/);+ assert.match(+ reasoning,+ /const next = reasoningTailFlexBox\(\{ capped, streaming, previous: flexBox \}\);/,);+ assert.match(tail, /cappable && flexBox && "flex flex-col"/);assert.doesNotMatch(tail, /overflow-(y-)?(auto|scroll)|scrollTop|scrollTo\(/);assert.match(reasoning,