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: set thinking traces apart from the answer and give tool rows kind icons (#13545)
Michael Hanfa168bbf4de9
diff --git a/studio/frontend/src/components/assistant-ui/reasoning-transcript.tsx b/studio/frontend/src/components/assistant-ui/reasoning-transcript.tsxindex 0130be08c22..14334249c99 100644--- a/studio/frontend/src/components/assistant-ui/reasoning-transcript.tsx+++ b/studio/frontend/src/components/assistant-ui/reasoning-transcript.tsx@@ -762,7 +762,8 @@ export function ReasoningTranscript({}, []);useLayoutEffect(() => {- if (!bounded || covered) return;+ // A finished box shows its start, which mounts first anyway.+ if (!bounded || !streaming || covered) return;let start = fragments.length;for (let height = 0; start > 0 && height < BOUNDED_TAIL_PX; )height += estimates[--start];@@ -774,7 +775,7 @@ export function ReasoningTranscript({if (next === islandsRef.current) return;islandsRef.current = next;setIslands(next);- }, [bounded, covered, fragments.length, estimates, grid, setIslands]);+ }, [bounded, streaming, covered, fragments.length, estimates, grid, setIslands]);useLayoutEffect(() => {recapture.current(true);diff --git a/studio/frontend/src/components/assistant-ui/reasoning.tsx b/studio/frontend/src/components/assistant-ui/reasoning.tsxindex f12f848e411..8602c9a68bc 100644--- a/studio/frontend/src/components/assistant-ui/reasoning.tsx+++ b/studio/frontend/src/components/assistant-ui/reasoning.tsx@@ -212,7 +212,7 @@ function ReasoningTrigger({data-slot="reasoning-trigger"data-active={active ? "" : undefined}className={cn(- "aui-reasoning-trigger group/trigger flex min-h-5 min-w-0 cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",+ "aui-reasoning-trigger group/trigger flex min-h-5 min-w-0 cursor-pointer items-center gap-2 text-trace-foreground text-sm transition-colors hover:text-foreground",className,)}{...props}@@ -240,7 +240,7 @@ function ReasoningTrigger({</span>{/* Outside the label so it reads while the block is still working and closed. */}{foldedSummary ? (- <span className="whitespace-nowrap leading-none text-muted-foreground/70">+ <span className="whitespace-nowrap leading-none">{"\u00b7 "}{foldedSummary}</span>@@ -330,10 +330,7 @@ function ReasoningText({data-slot="reasoning-text"data-streaming={streaming ? "" : undefined}className={cn(- // Same muted colour and size as the header above it, so only the answer is at full- // foreground. Flush with the header, no cap and no fade; the thread's own- // follow-scroll tracks it while it streams.- "aui-reasoning-text relative z-0 pt-4 pb-0 text-sm text-muted-foreground leading-relaxed",+ "aui-reasoning-text relative z-0 pt-4 pb-0 text-sm text-trace-foreground leading-relaxed","[&_p]:my-0 [&_p+p]:mt-4 [&_ul]:my-4 [&_ol]:my-4 [&_pre]:my-4",!virtualized &&cn(@@ -526,33 +523,40 @@ function ReasoningBody({);}-// The newest lines of a live trace in a fixed box (#11703), clipped at the top rather than an inner-// scroller, which split the reading anchor across two containers and wrote its own scroll (#11704).+// 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({- capped,- onShowFull,+ cappable,+ expanded,+ streaming,+ onExpandedChange,children,}: {- capped: boolean;- onShowFull: () => void;+ streaming: boolean;+ cappable: boolean;+ expanded: boolean;+ onExpandedChange: (expanded: boolean) => void;children: ReactNode;}) {const boxRef = useRef<HTMLDivElement>(null);+ const capped = cappable && !expanded;+ // Sticky while expanded: an unbounded box cannot measure its cap, and a trace only grows.const [overflowing, setOverflowing] = useState(false);useLayoutEffect(() => {const box = boxRef.current;const content = box?.firstElementChild as HTMLElement | null | undefined;- if (!capped || !box || !content) {+ if (!cappable) {setOverflowing(false);return;}+ if (!capped || !box || !content) return;const check = () => setOverflowing(content.offsetHeight > box.clientHeight);const observer = new ResizeObserver(check);observer.observe(content);observer.observe(box);check();return () => observer.disconnect();- }, [capped]);+ }, [cappable, capped]);const clipped = capped && overflowing;return (<>@@ -562,39 +566,43 @@ function ReasoningTail({data-capped={capped ? "" : undefined}data-overflowing={clipped ? "" : undefined}onFocus={(event) => {- // Clipped lines cannot scroll into view: a link focused up there shows the full trace.+ // Clipped lines cannot scroll into view: a link focused in them expands the trace.+ const target = event.target.getBoundingClientRect();+ const box = event.currentTarget.getBoundingClientRect();if (clipped &&- event.target.getBoundingClientRect().top <- event.currentTarget.getBoundingClientRect().top+ (streaming ? target.top < box.top : target.bottom > box.bottom))- onShowFull();+ onExpandedChange(true);}}className={cn(capped &&- "flex max-h-[min(18rem,40vh)] flex-col justify-end overflow-hidden [&>*]:shrink-0",+ "flex max-h-[min(18rem,40vh)] flex-col overflow-hidden [&>*]:shrink-0",+ capped && (streaming ? "justify-end" : "justify-start"),clipped &&- "[mask-image:linear-gradient(to_bottom,transparent,black_3rem)]",+ (streaming+ ? "[mask-image:linear-gradient(to_bottom,transparent,black_3rem)]"+ : "[mask-image:linear-gradient(to_top,transparent,black_3rem)]"),)}>{children}</div>- {clipped && (+ {cappable && overflowing && (<buttontype="button"data-slot="reasoning-show-full"- onClick={(event) => {- // The button unmounts with the cap: keep keyboard focus on this block's header.- if (event.currentTarget === document.activeElement)- boxRef.current- ?.closest('[data-slot="reasoning-root"]')- ?.querySelector<HTMLElement>('[data-slot="reasoning-trigger"]')- ?.focus({ preventScroll: true });- onShowFull();- }}- className="mt-2 cursor-pointer font-medium text-muted-foreground text-xs transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ aria-expanded={expanded}+ onClick={() => onExpandedChange(!expanded)}+ className="mt-2 inline-flex cursor-pointer items-center gap-1.5 font-medium text-muted-foreground text-xs transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">- Show full thinking+ {expanded ? "Collapse thinking" : "Expand thinking"}+ <ChevronDownIcon+ aria-hidden={true}+ className={cn(+ "size-3.5 shrink-0 transition-transform duration-200 ease-out",+ !expanded && "-rotate-90",+ )}+ /></button>)}</>@@ -792,6 +800,7 @@ const ReasoningGroupBlock = ({// null until toggled by hand, then it outranks the setting for the round.const [override, setOverride] = useState<boolean | null>(null);+ const [tailExpanded, setTailExpanded] = useState(false);const [duration, setDuration] = useState<number>(0);const startTimeRef = useRef<number | null>(null);@@ -814,6 +823,7 @@ const ReasoningGroupBlock = ({setWasStreaming(isReasoningStreaming);if (startsNewReasoningRound(isReasoningStreaming, wasStreaming)) {setOverride(null);+ setTailExpanded(false);}}@@ -833,7 +843,7 @@ const ReasoningGroupBlock = ({// Fold mode keeps its rounds inline: the lead's box could not hold the rounds folded after it.// A closing block keeps the cap it had while open: a hand close must not re-cap a full trace.- const cappedNow = !foldLead && reasoningTailCapped({ visibility, override });+ const cappedNow = !foldLead && reasoningTailCapped({ visibility });const [closingCapped, setClosingCapped] = useState(cappedNow);if (isOpen && closingCapped !== cappedNow) {setClosingCapped(cappedNow);@@ -914,8 +924,13 @@ const ReasoningGroupBlock = ({ref={reasoningContentRef}><ReasoningTail- capped={capped}- onShowFull={() => handleOpenChange(true)}+ cappable={capped}+ expanded={tailExpanded}+ streaming={isReasoningStreaming}+ onExpandedChange={(expanded) => {+ setTailExpanded(expanded);+ if (expanded) handleOpenChange(true);+ }}><ReasoningBodytranscript={transcript}@@ -925,7 +940,7 @@ const ReasoningGroupBlock = ({messageHasRenderableRenderHtmlTool}isStreaming={isReasoningStreaming}- bounded={capped}+ bounded={capped && !tailExpanded}>{children}</ReasoningBody>diff --git a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx b/studio/frontend/src/components/assistant-ui/tool-fallback.tsxindex 7c5054ba516..b4cb9c5cbe4 100644--- a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx+++ b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx@@ -43,10 +43,10 @@ import {AlertCircleIcon,ChevronDownIcon,LoaderIcon,+ WrenchIcon,XCircleIcon,} from "lucide-react";-import { Tick02Icon } from "@/lib/tick-icon";-import { HugeiconsIcon } from "@hugeicons/react";+import { InternetGlyph } from "@/lib/internet-icon";import {type CSSProperties,type ComponentProps,@@ -166,15 +166,13 @@ function ToolFallbackRoot({type ToolStatus = ToolCallMessagePartStatus["type"];-// The shared app tick is icon data, not a component; wrap it to slot into the-// status map alongside the lucide icons.-function CompleteTickIcon(props: Omit<ComponentProps<typeof HugeiconsIcon>, "icon">) {- return <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} {...props} />;+// Not a tick: "Used tool" already says it finished.+function completeToolIcon(name: string): ElementType {+ return name.startsWith("browser_") ? InternetGlyph : WrenchIcon;}-const statusIconMap: Record<ToolStatus, ElementType> = {+const statusIconMap: Record<Exclude<ToolStatus, "complete">, ElementType> = {running: LoaderIcon,- complete: CompleteTickIcon,incomplete: XCircleIcon,"requires-action": AlertCircleIcon,};@@ -201,9 +199,12 @@ function ToolFallbackTrigger({const isRunning = isToolCallRunning(status);const isCancelled = isToolCallCancelled(status);- const StatusIcon = statusIconMap[statusType];const label = toolFallbackLabel(status);const name = toolArgText(toolName);+ const StatusIcon =+ statusType === "complete"+ ? completeToolIcon(name)+ : statusIconMap[statusType];const displayName = formatMcpToolName(name, mcpServer, mcpTool) ?? name;return (@@ -212,7 +213,7 @@ function ToolFallbackTrigger({className={cn(// Brightens on hover like the Thinking trigger. The icon inherits this; the label// sets its own colour and picks it up through the group below.- "aui-tool-fallback-trigger group/trigger flex w-full cursor-pointer items-center gap-2 text-sm transition-colors hover:text-foreground",+ "aui-tool-fallback-trigger group/trigger flex w-full cursor-pointer items-center gap-2 text-trace-foreground text-sm transition-colors hover:text-foreground",className,)}{...props}@@ -222,28 +223,20 @@ function ToolFallbackTrigger({) : ToolIcon ? (<ToolIcondata-slot="tool-fallback-trigger-icon"- className={cn(- "aui-tool-fallback-trigger-icon size-4 shrink-0",- isCancelled && "text-muted-foreground",- )}+ className="aui-tool-fallback-trigger-icon size-4 shrink-0"/>) : (<StatusIcondata-slot="tool-fallback-trigger-icon"- className={cn(- "aui-tool-fallback-trigger-icon size-4 shrink-0",- isCancelled && "text-muted-foreground",- )}+ className="aui-tool-fallback-trigger-icon size-4 shrink-0"/>)}<spandata-slot="tool-fallback-trigger-label"className={cn(- "aui-tool-fallback-trigger-label-wrapper relative min-w-0 text-left leading-none text-muted-foreground transition-colors",+ "aui-tool-fallback-trigger-label-wrapper relative min-w-0 text-left leading-none text-trace-foreground transition-colors",// A cancelled row stays muted: the strikethrough is the point, not the name.- isCancelled- ? "text-muted-foreground line-through"- : "group-hover/trigger:text-foreground",+ isCancelled ? "line-through" : "group-hover/trigger:text-foreground",)}><span@@ -291,7 +284,7 @@ function ToolFallbackContent({<CollapsibleContentdata-slot="tool-fallback-content"className={cn(- "aui-tool-fallback-content relative overflow-hidden text-sm outline-none",+ "aui-tool-fallback-content relative overflow-hidden text-trace-foreground text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down",@@ -325,7 +318,7 @@ function ToolFallbackArgs({className={cn("aui-tool-fallback-args", className)}{...props}>- <pre className="aui-tool-fallback-args-value whitespace-pre-wrap">+ <pre className="aui-tool-fallback-args-value whitespace-pre-wrap text-xs">{argsText}</pre></div>@@ -410,7 +403,7 @@ function ToolFallbackResult({{imageResult ? (<>{imageResult.text && (- <pre className="aui-tool-fallback-result-content whitespace-pre-wrap">+ <pre className="aui-tool-fallback-result-content whitespace-pre-wrap text-xs">{stripAnsi(imageResult.text)}</pre>)}@@ -427,7 +420,7 @@ function ToolFallbackResult({</div></>) : (- <pre className="aui-tool-fallback-result-content whitespace-pre-wrap">+ <pre className="aui-tool-fallback-result-content whitespace-pre-wrap text-xs">{resultText}</pre>)}diff --git a/studio/frontend/src/components/assistant-ui/tool-group.tsx b/studio/frontend/src/components/assistant-ui/tool-group.tsxindex fa2cd00021f..d8ca3d02aa7 100644--- a/studio/frontend/src/components/assistant-ui/tool-group.tsx+++ b/studio/frontend/src/components/assistant-ui/tool-group.tsx@@ -171,7 +171,7 @@ function ToolGroupTrigger({className={cn(// Muted like the tool rows it summarises, so only the answer is at full foreground,// and it brightens on hover like the Thinking trigger above it.- "aui-tool-group-trigger group/trigger flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",+ "aui-tool-group-trigger group/trigger flex w-full cursor-pointer items-center gap-2 text-trace-foreground text-sm transition-colors hover:text-foreground","group-data-[variant=outline]/tool-group-root:px-4","group-data-[variant=muted]/tool-group-root:px-4","group-data-[variant=ghost]/tool-group-root:px-0",diff --git a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts b/studio/frontend/src/features/chat/utils/reasoning-visibility.tsindex cbfe8eb458d..0f6b4cafcd5 100644--- a/studio/frontend/src/features/chat/utils/reasoning-visibility.ts+++ b/studio/frontend/src/features/chat/utils/reasoning-visibility.ts@@ -27,13 +27,11 @@ export function resolveReasoningOpen({return resolveOpen(visibility, isStreaming, override);}-/** `auto` opens a block only for its stream, so it shows the newest lines in a bounded box- * instead of growing the thread (#11703). Opening it by hand, or `expanded`, shows it all. */+/** Under `auto` a block shows a bounded box (#11703) until its Expand toggle lifts it. */export function reasoningTailCapped({visibility,- override,-}: Omit<ReasoningOpenStateInput, "isStreaming">): boolean {- return visibility === "auto" && override !== true;+}: Pick<ReasoningOpenStateInput, "visibility">): boolean {+ return visibility === "auto";}/** Whether the block sits where the setting alone would put it. */diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex ad8d89039df..9ecae59e1ba 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -248,6 +248,8 @@--secondary-foreground-base: oklch(0.2868 0.0649 159.9823);--muted-base: oklch(0.9702 0 0);--muted-foreground: oklch(0.5486 0 0);+ /* Trace ink: muted, pulled toward the page so the answer stands apart. */+ --trace-fade: 20%;/* Hover/active washes are neutral grey (matches the sidebar), not thebrand green; green stays on primary controls only. */--accent-base: #ececec;@@ -465,6 +467,7 @@/* Secondary text: settings descriptions, empty states, captions.Under the ink, still ~7:1 on the dialog surface. */--muted-foreground: #b0b0b0;+ --trace-fade: 30%;/* Shared hover tone: one step over --popover. */--accent-base: #3a3a3a;--accent-foreground-base: #dfdfdf;@@ -2050,6 +2053,7 @@ html[data-chat-font] .aui-root {--color-accent-foreground: var(--accent-foreground);--color-accent: var(--accent);--color-muted-foreground: var(--muted-foreground);+ --color-trace-foreground: color-mix(in oklab, var(--muted-foreground), var(--background) var(--trace-fade, 0%));--color-muted: var(--muted);--color-secondary-foreground: var(--secondary-foreground);--color-secondary: var(--secondary);diff --git a/studio/frontend/tests/reasoning-live-tail.test.ts b/studio/frontend/tests/reasoning-live-tail.test.tsindex 919c7e7ce83..13ee55e4525 100644--- a/studio/frontend/tests/reasoning-live-tail.test.ts+++ b/studio/frontend/tests/reasoning-live-tail.test.ts@@ -1,8 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0-// The live Thinking box (#11703): bounded only while the `auto` setting holds a block open for-// its stream, lifted by a hand open, and never an inner scroller (#11704 review).+// The Thinking box (#11703): bounded under `auto`, lifted by its Expand toggle, never a scroller (#11704).import assert from "node:assert/strict";import test from "node:test";@@ -21,58 +20,36 @@ const { reasoningTailCapped, resolveReasoningOpen } = await import(const reasoning = readSrc("components/assistant-ui/reasoning.tsx");const transcript = readSrc("components/assistant-ui/reasoning-transcript.tsx");-test("only a block the auto setting opened for its stream is bounded", () => {+test("only the auto setting bounds a block, whether the stream or a hand opened it", () => {for (const visibility of DISPLAY_VISIBILITIES) {- for (const override of [null, false, true]) {- for (const isStreaming of [false, true]) {- const open = resolveReasoningOpen({- isStreaming,- visibility,- override,- });- const capped = reasoningTailCapped({ visibility, override });- const shown = open && capped;- assert.equal(- shown,- visibility === "auto" && override === null && isStreaming,- `${visibility} override=${override} streaming=${isStreaming}`,- );- }- }+ assert.equal(+ reasoningTailCapped({ visibility }),+ visibility === "auto",+ visibility,+ );}});-test("the box clips at the top instead of scrolling, and Show full is a hand open", () => {+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("),reasoning.indexOf("// With the fold preference on"),);assert.match(tail,- /flex max-h-\[[^\]]+\] flex-col justify-end overflow-hidden/,+ /flex max-h-\[[^\]]+\] flex-col overflow-hidden/,);assert.doesNotMatch(tail, /overflow-(y-)?(auto|scroll)|scrollTop|scrollTo\(/);assert.match(reasoning,- /const cappedNow = !foldLead && reasoningTailCapped\(\{ visibility, override \}\);/,+ /const cappedNow = !foldLead && reasoningTailCapped\(\{ visibility \}\);/,);- assert.match(- reasoning,- /<ReasoningTail\s+capped=\{capped\}\s+onShowFull=\{\(\) => handleOpenChange\(true\)\}/,- );- assert.match(reasoning, /bounded=\{capped\}/);-});--test("Show full hands keyboard focus to the block header before its button unmounts", () => {- const tail = reasoning.slice(- reasoning.indexOf("function ReasoningTail("),- reasoning.indexOf("// With the fold preference on"),- );- assert.match(- tail,- /event\.currentTarget === document\.activeElement\)[\s\S]*?closest\('\[data-slot="reasoning-root"\]'\)[\s\S]*?querySelector<HTMLElement>\('\[data-slot="reasoning-trigger"\]'\)[\s\S]*?\.focus\(\{ preventScroll: true \}\);\s*onShowFull\(\);/,- );- assert.match(tail, /focus-visible:ring-1 focus-visible:ring-ring/);+ assert.match(tail, /\{cappable && overflowing && \(/);+ assert.match(tail, /onClick=\{\(\) => onExpandedChange\(!expanded\)\}/);+ assert.match(tail, /aria-expanded=\{expanded\}/);+ assert.match(tail, /\{expanded \? "Collapse thinking" : "Expand thinking"\}/);+ assert.match(reasoning, /bounded=\{capped && !tailExpanded\}/);+ assert.match(reasoning, /setOverride\(null\);\s*setTailExpanded\(false\);/);});test("focus landing in the clipped lines lifts the cap instead of staying invisible", () => {@@ -82,7 +59,7 @@ test("focus landing in the clipped lines lifts the cap instead of staying invisi);assert.match(tail,- /onFocus=\{\(event\) => \{[\s\S]*?clipped &&[\s\S]*?event\.target\.getBoundingClientRect\(\)\.top <\s*event\.currentTarget\.getBoundingClientRect\(\)\.top[\s\S]*?onShowFull\(\);/,+ /onFocus=\{\(event\) => \{[\s\S]*?clipped &&\s*\(streaming \? target\.top < box\.top : target\.bottom > box\.bottom\)[\s\S]*?onExpandedChange\(true\);/,);});@@ -100,7 +77,7 @@ test("a bounded transcript corrects nothing through the thread and mounts the taassert.match(transcript, /boundedRef\.current = bounded;/);assert.match(transcript,- /if \(!bounded \|\| covered\) return;[\s\S]*?BOUNDED_TAIL_PX[\s\S]*?end: fragments\.length[\s\S]*?setIslands\(next\);/,+ /if \(!bounded \|\| !streaming \|\| covered\) return;[\s\S]*?BOUNDED_TAIL_PX[\s\S]*?end: fragments\.length[\s\S]*?setIslands\(next\);/,"the newest rows are not mounted while the prefix catches up",);assert.match(transcript, /recapture\.current\(true\);\s*\}, \[bounded\]\);/);@@ -115,3 +92,24 @@ test("a closing block keeps the cap it had while open", () => {const open = reasoning.indexOf("const isOpen = resolveReasoningOpen(");assert.ok(open !== -1 && open < reasoning.indexOf("const cappedNow ="));});++test("Expand thinking ends in the header's chevron: right while bounded, down once expanded", () => {+ const tail = reasoning.slice(+ reasoning.indexOf("function ReasoningTail("),+ reasoning.indexOf("// With the fold preference on"),+ );+ assert.match(+ tail,+ /\{expanded \? "Collapse thinking" : "Expand thinking"\}\s*<ChevronDownIcon[\s\S]*?!expanded && "-rotate-90"/,+ );+});++test("a streaming box shows the newest lines, a finished one shows the start", () => {+ const tail = reasoning.slice(+ reasoning.indexOf("function ReasoningTail("),+ reasoning.indexOf("// With the fold preference on"),+ );+ assert.match(tail, /capped && \(streaming \? "justify-end" : "justify-start"\)/);+ assert.match(tail, /to_bottom,transparent[\s\S]*?to_top,transparent/);+ assert.match(reasoning, /streaming=\{isReasoningStreaming\}\s*onExpandedChange=/);+});