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: keep the view_image picture visible when its tool card is collapsed (#17174)
Keyi Yub335310b0961
diff --git a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx b/studio/frontend/src/components/assistant-ui/tool-fallback.tsxindex 3de4b923524..4c1e395f826 100644--- a/studio/frontend/src/components/assistant-ui/tool-fallback.tsx+++ b/studio/frontend/src/components/assistant-ui/tool-fallback.tsx@@ -390,6 +390,28 @@ function ToolFallbackMcpApp({);}+function ToolFallbackImages({+ images,+ className,+}: {+ images: McpImageResult["images"];+ className?: string;+}) {+ return (+ <div className={cn("flex flex-col gap-2", className)}>+ {images.map((img, i) => (+ <img+ key={i}+ src={`data:${img.mimeType};base64,${img.data}`}+ alt={`Tool result ${i + 1}`}+ loading="lazy"+ className="max-w-full rounded-lg border border-border"+ />+ ))}+ </div>+ );+}+function ToolFallbackResult({result,className,@@ -419,17 +441,7 @@ function ToolFallbackResult({{stripAnsi(imageResult.text)}</pre>)}- <div className="mt-2 flex flex-col gap-2">- {imageResult.images.map((img, i) => (- <img- key={i}- src={`data:${img.mimeType};base64,${img.data}`}- alt={`Tool result ${i + 1}`}- loading="lazy"- className="max-w-full rounded-lg border border-border"- />- ))}- </div>+ <ToolFallbackImages images={imageResult.images} className="mt-2" /></>) : (<pre className="aui-tool-fallback-result-content whitespace-pre-wrap text-xs">@@ -507,6 +519,9 @@ const ToolFallbackImpl: ToolCallMessagePartComponent = ({? plainBrowserResult(result): (widget?.text ?? result);+ const picture =+ !isCancelled && toolName === "view_image" && isMcpImageResult(shown) ? shown : null;+// Open while it waits on Allow / Deny, so what is being approved is readable.const awaitingApproval = useToolAwaitingApproval(toolCallId);@@ -535,8 +550,9 @@ const ToolFallbackImpl: ToolCallMessagePartComponent = ({argsText={argsText}className={cn(isCancelled && "opacity-60")}/>- {!isCancelled && <ToolFallbackResult result={shown} />}+ {!isCancelled && <ToolFallbackResult result={picture ? picture.text : shown} />}</ToolFallbackContent>+ {picture && <ToolFallbackImages className="ml-5 mt-2" images={picture.images} />}{/* Files stay outside even when the card is collapsed (#10425) */}{created && (<SandboxFilesdiff --git a/studio/frontend/tests/tool-fallback-view-image.test.ts b/studio/frontend/tests/tool-fallback-view-image.test.tsnew file mode 100644index 00000000000..72330199742--- /dev/null+++ b/studio/frontend/tests/tool-fallback-view-image.test.ts@@ -0,0 +1,67 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";+import ts from "@typescript/typescript6";++import { readSrc } from "./helpers/kit.ts";+import { openingTag } from "./helpers/tsx-ast.ts";++const PATH = "components/assistant-ui/tool-fallback.tsx";+const source = ts.createSourceFile(+ PATH,+ readSrc(PATH),+ ts.ScriptTarget.Latest,+ true,+ ts.ScriptKind.TSX,+);++function findDeclaration(name: string): ts.VariableDeclaration {+ let found: ts.VariableDeclaration | undefined;+ (function visit(node: ts.Node) {+ if (ts.isVariableDeclaration(node) && node.name.getText(source) === name)+ found = node;+ if (!found) ts.forEachChild(node, visit);+ })(source);+ assert.ok(found, `${PATH}: no ${name}`);+ return found;+}++function insideContent(node: ts.Node): boolean {+ for (let parent = node.parent; parent; parent = parent.parent) {+ if (+ ts.isJsxElement(parent) &&+ parent.openingElement.tagName.getText(source) === "ToolFallbackContent"+ ) {+ return true;+ }+ }+ return false;+}++test("the view_image picture renders outside the collapsible pane", () => {+ const impl = findDeclaration("ToolFallbackImpl");+ const images: ts.Node[] = [];+ (function visit(node: ts.Node) {+ if (openingTag(node)?.tagName.getText(source) === "ToolFallbackImages")+ images.push(node);+ ts.forEachChild(node, visit);+ })(impl);+ assert.equal(images.length, 1, "the card renders the picture once");+ assert.equal(insideContent(images[0]), false);+});++test("only a finished view_image result moves out of the pane", () => {+ const picture = findDeclaration("picture").initializer?.getText(source) ?? "";+ assert.match(picture, /!isCancelled/);+ assert.match(picture, /toolName === "view_image"/);+ assert.match(picture, /isMcpImageResult\(shown\)/);+});++test("the pane shows only the text of a picture that moved out", () => {+ assert.match(+ source.text,+ /<ToolFallbackResult result=\{picture \? picture\.text : shown\} \/>/,+ );+});