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: say why Sandbox High is unavailable when there is nothing to install (#13732)
Daniel Han047fededc30b
diff --git a/studio/frontend/src/features/chat/sandbox-setup-dialog.tsx b/studio/frontend/src/features/chat/sandbox-setup-dialog.tsxindex 25f8e1fabc9..7ded9df4770 100644--- a/studio/frontend/src/features/chat/sandbox-setup-dialog.tsx+++ b/studio/frontend/src/features/chat/sandbox-setup-dialog.tsx@@ -47,29 +47,22 @@ const NOTE_CLASS = "text-xs leading-relaxed";export function SandboxSetupDialog({open,onOpenChange,- onLearnMore,}: {open: boolean;onOpenChange: (open: boolean) => void;- /** Defaults to opening Settings > Sandbox at Permissions. */- onLearnMore?: () => void;}) {return (<AlertDialog open={open} onOpenChange={onOpenChange}>{/* Mounted per opening, so every opening starts from a fresh check. */}- {open ? (- <SandboxSetupContent onOpenChange={onOpenChange} onLearnMore={onLearnMore} />- ) : null}+ {open ? <SandboxSetupContent onOpenChange={onOpenChange} /> : null}</AlertDialog>);}function SandboxSetupContent({onOpenChange,- onLearnMore,}: {onOpenChange: (open: boolean) => void;- onLearnMore?: () => void;}) {const t = useT();const setSandboxLevel = useChatRuntimeStore((s) => s.setSandboxLevel);@@ -276,6 +269,9 @@ function SandboxSetupContent({{actionError ? (<p className={`${NOTE_CLASS} text-destructive`}>{actionError}</p>) : null}+ {view.reason ? (+ <p className={`${NOTE_CLASS} text-muted-foreground`}>{view.reason}</p>+ ) : null}{view.showOwnerOnly ? (<p className={`${NOTE_CLASS} text-muted-foreground`}>{t("sandboxSetup.ownerOnly")}@@ -317,15 +313,11 @@ function SandboxSetupContent({onClick={() => {// Closing does not stop a running setup; its result shows in Settings > Sandbox.onOpenChange(false);- if (onLearnMore) {- onLearnMore();- } else {- // Deferred past the dialog's focus restore.- setTimeout(- () => openSettings("sandbox", { scrollTarget: "sandbox-permissions" }),- 0,- );- }+ // Deferred past the dialog's focus restore; inside Settings it only scrolls.+ setTimeout(+ () => openSettings("sandbox", { scrollTarget: "sandbox-os" }),+ 0,+ );}}>{t("settings.sandbox.learnMore")}diff --git a/studio/frontend/src/features/chat/sandbox-setup-state.ts b/studio/frontend/src/features/chat/sandbox-setup-state.tsindex b67ec7eb983..bd78e5b4b05 100644--- a/studio/frontend/src/features/chat/sandbox-setup-state.ts+++ b/studio/frontend/src/features/chat/sandbox-setup-state.ts@@ -22,6 +22,8 @@ export type SandboxSetupView = {result: JobResult;outputLines: string[];note: string;+ /** Why High is unavailable, shown only when the popup has nothing else to offer. */+ reason: string;};export function sandboxSetupView({@@ -53,6 +55,7 @@ export function sandboxSetupView({result,outputLines: jobOutputLines(job),note,+ reason: "",};}const action = capability.canRunSetup ? capability.setupAction : null;@@ -67,6 +70,21 @@ export function sandboxSetupView({(result === "failed" || result === "declined") && job?.manualCommand? job.manualCommand: capability.manualCommand;+ // Windows commands name this install's paths: owner only.+ const showOwnerOnly =+ install === null &&+ (command !== "" ||+ capability.setupBlocked === "not_owner" ||+ capability.setupBlocked === "not_local") &&+ capability.setupBlocked !== "no_elevation";+ // A check that now passes (set up from another window) is not a reason to show here.+ const deadEnd =+ !(capability.pythonOsIsolated && capability.terminalOsIsolated) &&+ install === null &&+ command === "" &&+ !showOwnerOnly &&+ !running &&+ result === null;return {checking: false,loadFailed: false,@@ -74,13 +92,7 @@ export function sandboxSetupView({showConsent,installDisabled: running || (showConsent && !consent),command,- // Windows commands name this install's paths: owner only.- showOwnerOnly:- install === null &&- (command !== "" ||- capability.setupBlocked === "not_owner" ||- capability.setupBlocked === "not_local") &&- capability.setupBlocked !== "no_elevation",+ showOwnerOnly,showRunInTerminal:install === null &&command !== "" &&@@ -89,5 +101,6 @@ export function sandboxSetupView({result,outputLines: jobOutputLines(job),note,+ reason: deadEnd ? capability.reason : "",};}diff --git a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts b/studio/frontend/src/features/settings/stores/settings-dialog-store.tsindex 8227c148995..f561b0a9be2 100644--- a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts+++ b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts@@ -42,6 +42,7 @@ export type SettingsScrollTarget =| "general-permissions"| "library-storage"| "resources-caches"+ | "sandbox-os"| "sandbox-permissions";/** Which archive the Data tab should open straight into. */@@ -150,6 +151,7 @@ const SCROLL_TARGET_TAB: Record<SettingsScrollTarget, SettingsTab> = {"general-permissions": "sandbox","library-storage": "library","resources-caches": "resources",+ "sandbox-os": "sandbox","sandbox-permissions": "sandbox",};diff --git a/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx b/studio/frontend/src/features/settings/tabs/sandbox-tab.tsxindex 880eaaa6edf..3ca88767201 100644--- a/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/sandbox-tab.tsx@@ -314,13 +314,7 @@ function PermissionsSection() {</div></SettingsRow>{/* Its own instance: the chat-page root dialog is not mounted on every page. */}- <SandboxSetupDialog- open={setupOpen}- onOpenChange={setSetupOpen}- onLearnMore={() =>- permissionsRef.current?.scrollIntoView({ block: "start", behavior: "smooth" })- }- />+ <SandboxSetupDialog open={setupOpen} onOpenChange={setSetupOpen} /></SettingsSection>);}@@ -372,6 +366,9 @@ export function SandboxTab() {function OsSandboxSections() {const t = useT();+ const sectionRef = useRef<HTMLElement | null>(null);+ const scrollTarget = useSettingsDialogStore((s) => s.scrollTarget);+ const consumeScrollTarget = useSettingsDialogStore((s) => s.consumeScrollTarget);const [status, setStatus] = useState<SandboxStatus | null>(null);const [job, setJob] = useState<HostPrepJob | null>(null);const [error, setError] = useState<string | null>(null);@@ -395,6 +392,17 @@ function OsSandboxSections() {};}, []);+ // Waits for the first status read: before it the section is too short to scroll to.+ const settled = status !== null || error !== null || absent;+ useEffect(() => {+ if (scrollTarget !== "sandbox-os" || !settled) return;+ const frame = window.requestAnimationFrame(() => {+ sectionRef.current?.scrollIntoView({ block: "start", behavior: "smooth" });+ consumeScrollTarget("sandbox-os");+ });+ return () => window.cancelAnimationFrame(frame);+ }, [consumeScrollTarget, scrollTarget, settled]);+// Callers set `loading`: a synchronous setState from the mount effect would cascade a render.const refresh = useCallback((force: boolean) => {@@ -613,6 +621,7 @@ function OsSandboxSections() {) : (<><SettingsSection+ ref={sectionRef}title={t("settings.sandbox.toolsSection")}action={<Buttondiff --git a/studio/frontend/tests/sandbox-setup.test.ts b/studio/frontend/tests/sandbox-setup.test.tsindex 4149b169c55..0c8b82da182 100644--- a/studio/frontend/tests/sandbox-setup.test.ts+++ b/studio/frontend/tests/sandbox-setup.test.ts@@ -706,7 +706,6 @@ function sandboxPopup(capabilityNow: SandboxCapability | null) {SandboxSetupDialog: (props: {open: boolean;onOpenChange: (open: boolean) => void;- onLearnMore?: () => void;}) => StubElement;}>(new URL("../src/features/chat/sandbox-setup-dialog.tsx", import.meta.url), {"react/jsx-runtime": stubJsxRuntime(),@@ -757,12 +756,11 @@ function sandboxPopup(capabilityNow: SandboxCapability | null) {"./sandbox-setup-state": setupState,"./stores/chat-runtime-store": { useChatRuntimeStore: store },});- const render = (props: { onLearnMore?: () => void } = {}) => {+ const render = () => {const closes: boolean[] = [];const root = dialog.SandboxSetupDialog({open: true,onOpenChange: (open) => closes.push(open),- ...props,});const inner = root.props.children as StubElement;const content = (inner.type as (p: unknown) => StubElement)(inner.props);@@ -804,14 +802,8 @@ test("the High popup names the missing OS sandbox and offers Install, Learn moreother.button("settings.sandbox.learnMore")();await new Promise((resolve) => setTimeout(resolve, 5));assert.deepEqual(other.closes, [false]);- assert.deepEqual(popup.opened, [["sandbox", "sandbox-permissions"]]);-- let learned = 0;- const inSettings = popup.render({ onLearnMore: () => learned++ });- inSettings.button("settings.sandbox.learnMore")();- await new Promise((resolve) => setTimeout(resolve, 5));- assert.equal(learned, 1);- assert.equal(popup.opened.length, 1, "Settings scrolls itself; it opens nothing");+ // #13656: the OS sandbox status and setup, not Permissions, where High was just picked.+ assert.deepEqual(popup.opened, [["sandbox", "sandbox-os"]]);});test("the High popup stays short: no probe reason, no command block, a one-line Windows note", () => {@@ -831,6 +823,47 @@ test("the High popup stays short: no probe reason, no command block, a one-lineassert.ok(!windows.texts.includes("settings.sandbox.disclosure"));});+test("with nothing to install, the High popup says why instead of showing nothing", () => {+ // #13656: Windows with MXC allowed and prepared but failing its check, ARM64, or a pre-24H2 build.+ const reason = "MXC probe failed: the container did not start";+ const deadEnd = capability({+ platform: "win32",+ backend: "mxc-processcontainer",+ reason,+ setupAction: null,+ manualCommand: "",+ canRunSetup: false,+ });+ const view = setupState.sandboxSetupView({ capability: deadEnd, job: null, consent: false });+ assert.equal(view.install, null);+ assert.equal(view.command, "");+ assert.equal(view.showOwnerOnly, false);+ assert.equal(view.reason, reason);+ assert.ok(sandboxPopup(deadEnd).render().texts.includes(reason));++ for (const offers of [+ capability(),+ capability({ canRunSetup: false, setupAction: null, setupBlocked: "no_elevation" }),+ capability({ platform: "win32", setupAction: null, canRunSetup: false, manualCommand: "", setupBlocked: "not_owner" }),+ ]) {+ assert.equal(+ setupState.sandboxSetupView({ capability: offers, job: null, consent: false }).reason,+ "",+ );+ }+ const readyNow = { ...deadEnd, pythonOsIsolated: true, terminalOsIsolated: true, reason: "passed" };+ assert.equal(+ setupState.sandboxSetupView({ capability: readyNow, job: null, consent: false }).reason,+ "",+ );+ for (const state of ["running", "failed"] as const) {+ assert.equal(+ setupState.sandboxSetupView({ capability: deadEnd, job: setupJob({ state }), consent: false }).reason,+ "",+ );+ }+});+test("an install that makes the OS sandbox pass turns High on", () => {const source = readFileSync(new URL("../src/features/chat/sandbox-setup-dialog.tsx", import.meta.url),