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
// 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 { readFileSync } from "node:fs";
import test from "node:test";
import { registerBundlerResolver } from "./helpers/kit.ts";
registerBundlerResolver();
const { AiSpeechIcon, TextToSpeechIcon } = await import("../src/lib/hugeicons-derived.ts");
const { ATTACHMENT_KIND_ICONS } = await import("../src/features/chat/lib/attachment-file-kind.ts");
const { audioWorkflowTab } = await import("../src/features/audio/workflows.ts");
const read = (file: string) => readFileSync(new URL(`../src/${file}`, import.meta.url), "utf8");
test("audio reads as the bars-only icon everywhere and Text to Speech as ai-speech with its sparkle", () => {
assert.equal(ATTACHMENT_KIND_ICONS.audio, AiSpeechIcon);
assert.equal(audioWorkflowTab("speak").icon, TextToSpeechIcon);
const paths = (icon: unknown) => (icon as [string, { d: string }][]).map(([, attrs]) => attrs.d);
const sparkle = (d: string) => d.startsWith("M18.5 3.9375");
assert.ok(!paths(AiSpeechIcon).some(sparkle), "audio carries no sparkle");
assert.ok(paths(TextToSpeechIcon).some(sparkle), "Text to Speech keeps ai-speech's sparkle");
for (const file of ["components/app-sidebar.tsx", "components/command-palette.tsx", "features/library/file-kind.ts"]) {
assert.doesNotMatch(read(file), /AudioWave01Icon/, file);
}
// Chat's audio chips and Upload audio used lucide's headphones.
for (const file of ["features/chat/shared-composer.tsx", "components/assistant-ui/thread.tsx"]) {
assert.doesNotMatch(read(file), /HeadphonesIcon/, file);
}
});
test("a picture sits where fit puts it before it is measured, so opening it never jumps", () => {
const zoom = read("components/media-zoom.tsx");
assert.doesNotMatch(zoom, /\{ inset: 0 \}/);
assert.match(zoom, /left: inset\.left,\s*top: inset\.top,\s*width: `calc\(100% - \$\{inset\.left \+ inset\.right\}px\)`/);
});
test("the lightbox backdrop is a faint grey in light mode and near black in dark", () => {
const css = read("index.css");
assert.match(css, /\.media-lightbox-overlay \{\s*background: color-mix\(in oklab, color-mix\(in oklab, var\(--background\), black 7%\) 64%, transparent\);/);
assert.match(css, /\.dark \.media-lightbox-overlay \{\s*background: color-mix\(in oklab, color-mix\(in oklab, var\(--background\), black 45%\) 78%, transparent\);/);
assert.match(read("components/media-viewer.tsx"), /"media-lightbox-overlay bg-transparent /);
});
test("the video player uses Studio's icons and full screen turns into exit full screen", () => {
const video = read("features/browser/video-file.tsx");
// Studio's play glyph is lucide's; full screen uses Studio's shared expand and contract pair.
assert.match(video, /import \{ PlayIcon \} from "lucide-react";/);
assert.match(video, /import \{ ContractArrowsIcon, ExpandArrowsIcon \} from "@\/lib\/expand-icons";/);
assert.match(video, /addEventListener\("fullscreenchange", sync\)/);
assert.match(
video,
/\{fullscreened \? \(\s*<HugeiconsIcon icon=\{ContractArrowsIcon\}[^>]*\/>\s*\) : \(\s*<HugeiconsIcon icon=\{ExpandArrowsIcon\}[^>]*\/>\s*\)\}/,
);
assert.doesNotMatch(video, /ArrowShrink01Icon|ArrowExpand01Icon|Maximize2|Minimize2/);
assert.match(video, /fullscreened \? t\("browser\.video\.exitFullscreen"\) : t\("browser\.video\.fullscreen"\)/);
});
test("a full screen video drops the floating toolbar inset", () => {
const css = read("index.css");
assert.match(css, /\.browser-file-page \.browser-video \{\s*padding-top: var\(--browser-file-toolbar-inset\);/);
assert.match(css, /\.browser-file-page \.browser-video:fullscreen \{\s*padding-top: 0;\s*\}/);
});
test("video tabs share the document bar: Copy and Open splits and a download icon, no Save as", () => {
const panel = read("features/browser/browser-panel.tsx");
assert.doesNotMatch(panel, /VideoFileToolbar|isVideoEntry|browser\.video\.saveAs|browser\.video\.copyName/);
assert.match(panel, /return kind === "html" \|\| kind === "code";\n\}/);
assert.match(panel, /<CopySplit tab=\{tab\} entry=\{entry\} blob=\{blob\}/);
assert.match(panel, /<OpenSplit key=\{entry\.fileId\} entry=\{entry\} blob=\{blob\} \/>/);
assert.match(panel, /const timed = media === "video" \|\| media === "audio";/);
assert.match(panel, /\{timed \? null : \(\s*<ScaleMenu/);
});
test("the desktop Open lists apps, opens a local copy, and never opens programs", () => {
const openWith = read("features/browser/open-with.ts");
assert.match(openWith, /const copies = new WeakMap<Blob, Map<string, Promise<LocalCopy>>>\(\);/);
assert.match(openWith, /"browser_file_local_copy"/);
const panel = read("features/browser/browser-panel.tsx");
assert.match(panel, /const runsCode = isDangerousDownload\(entry\.name\);/);
assert.match(panel, /withLocalCopy\(blob, entry\.name, \(copy\) => localCopyPath\(copy\.id\)\)/);
const rust = readFileSync(new URL("../../src-tauri/src/browser_open_with.rs", import.meta.url), "utf8");
assert.match(rust, /if crate::browser_downloads::runs_code\(&path\) \{\s*return Err/);
assert.match(rust, /if !app_paths\(path\)\.0\.iter\(\)\.any\(\|app\| app == with\)/);
const main = readFileSync(new URL("../../src-tauri/src/main.rs", import.meta.url), "utf8");
for (const command of ["browser_file_local_copy", "browser_file_apps", "browser_file_open", "browser_file_path", "browser_file_reveal"]) {
assert.match(main, new RegExp(`browser_open_with::${command},`), command);
}
});
test("file bars show no menu or button that only repeats one beside it", () => {
const panel = read("features/browser/browser-panel.tsx");
const between = (start: string, end: string) =>
panel.slice(panel.indexOf(start), panel.indexOf(end, panel.indexOf(start)));
assert.match(panel, /const hasMenu = isTauri \|\| tabType !== null;/);
assert.match(panel, /\{hasMenu \? \(\s*<DropdownMenu onOpenChange/);
const floating = between("function FloatingFileToolbar(", "const SPLIT_PILL");
const nameMenu = between("function FloatingFileToolbar(", "</DropdownMenuContent>");
assert.doesNotMatch(nameMenu, /browser\.file\.openIn|saveBrowserDownload/);
assert.match(floating, /\{kind \? \(\s*<DropdownMenu>/);
assert.match(floating, /title=\{entry\.name\}/);
assert.doesNotMatch(floating, /kind === "html"|runAgain|toggleConsole/);
const chromeMenu = between("function BrowserFileToolbar(", "function FloatingFileToolbar(");
const menu = chromeMenu.slice(chromeMenu.indexOf("<PanelMenu"));
assert.doesNotMatch(menu, /onSelect=\{runAgain\}|onSelect=\{toggleConsole\}/);
assert.match(menu, /\{isTauri \|\| !tabType \? \(\s*<DropdownMenuItem disabled=\{!blob\} onSelect=\{openInNewChat\}>/);
});