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
Fix shell selection for remote Agents commands (#8844)
Lee Jackson2a5c942d6ddc
diff --git a/studio/frontend/src/features/settings/components/agent-command.ts b/studio/frontend/src/features/settings/components/agent-command.tsindex 38b2d73c3b8..7b3df8c2c0f 100644--- a/studio/frontend/src/features/settings/components/agent-command.ts+++ b/studio/frontend/src/features/settings/components/agent-command.ts@@ -9,6 +9,20 @@const DEFAULT_STUDIO_PORT = "8888";const DEFAULT_AGENT = "claude";+const SAFE_SHELL_ARG_PATTERN = /^[A-Za-z0-9_./:@%+=,-]+$/;++export type AgentCommandOs = "unix" | "windows";++export const shSingle = (value: string): string =>+ value.replace(/'/g, "'\\''");+export const psSingle = (value: string): string => value.replace(/'/g, "''");++export function quoteShellArg(value: string, os: AgentCommandOs): string {+ if (SAFE_SHELL_ARG_PATTERN.test(value)) {+ return value;+ }+ return os === "windows" ? `'${psSingle(value)}'` : `'${shSingle(value)}'`;+}// URL.hostname brackets IPv6 literals (`new URL("http://[::1]:8888").hostname` is// "[::1]"), so strip the brackets before matching the bare "::1" loopback rules below.@@ -39,7 +53,7 @@ export function isLoopbackHost(host: string): boolean {export function buildAgentCommand(base: string | null | undefined,key: string | null | undefined,- os: "unix" | "windows",+ os: AgentCommandOs,agent: string = DEFAULT_AGENT,): string {const bare = `unsloth start ${agent}`;@@ -71,3 +85,46 @@ export function buildAgentCommand(? `$env:UNSLOTH_STUDIO_URL="${studioUrl}"; ${cmd}`: `UNSLOTH_STUDIO_URL=${studioUrl} ${cmd}`;}++export interface AgentShellCommands {+ primary: string;+ subagent: string;+ remoteSetup: string;+ passThrough: string[];+ dryRun: string;+}++const REMOTE_SETUP_COMMANDS: Record<AgentCommandOs, string> = {+ unix: `export UNSLOTH_STUDIO_URL=https://studio.example.com+export UNSLOTH_API_KEY=sk-unsloth-...+unsloth start claude`,+ windows: `$env:UNSLOTH_STUDIO_URL = "https://studio.example.com"+$env:UNSLOTH_API_KEY = "sk-unsloth-..."+unsloth start claude`,+};++function appendCommand(command: string, args: string): string {+ return args ? `${command} ${args}` : command;+}++export function buildAgentShellCommands(+ base: string | null | undefined,+ os: AgentCommandOs,+ agent: string,+ modelArgs: string,+): AgentShellCommands {+ const primaryBase = buildAgentCommand(base, null, os, agent);+ return {+ primary: appendCommand(primaryBase, modelArgs),+ subagent: appendCommand(+ `${primaryBase} --as-subagent`,+ modelArgs,+ ),+ remoteSetup: REMOTE_SETUP_COMMANDS[os],+ passThrough: [+ `${buildAgentCommand(base, null, os, "claude")} --continue`,+ `${buildAgentCommand(base, null, os, "codex")} --persist resume --last`,+ ],+ dryRun: `${buildAgentCommand(base, null, os, "claude")} --no-launch`,+ };+}diff --git a/studio/frontend/src/features/settings/components/usage-examples.tsx b/studio/frontend/src/features/settings/components/usage-examples.tsxindex b9e77c67fcf..06ddb4a84ca 100644--- a/studio/frontend/src/features/settings/components/usage-examples.tsx+++ b/studio/frontend/src/features/settings/components/usage-examples.tsx@@ -40,6 +40,8 @@ import {buildAgentCommand,isLoopbackHost,normalizeHost,+ psSingle,+ shSingle,} from "./agent-command";import { keylessBaseEligible } from "./keyless-example-eligibility";@@ -139,9 +141,6 @@ const AGENT_LABELS: Record<string, string> = {};const j = (s: string): string => JSON.stringify(s);-// Inner escaping for a single-quoted argument (POSIX '\'' , PowerShell '').-export const shSingle = (s: string): string => s.replace(/'/g, "'\\''");-export const psSingle = (s: string): string => s.replace(/'/g, "''");const toolsJson = TOOLS.map(j).join(", ");function bodyExtraLines(variant: Variant, indent: string): string[] {diff --git a/studio/frontend/src/features/settings/stores/settings-panel-prefs-store.ts b/studio/frontend/src/features/settings/stores/settings-panel-prefs-store.tsindex 1727829625e..8cde7a0bae3 100644--- a/studio/frontend/src/features/settings/stores/settings-panel-prefs-store.ts+++ b/studio/frontend/src/features/settings/stores/settings-panel-prefs-store.ts@@ -14,12 +14,15 @@ export interface SettingsPanelPrefsState {// null model means "follow whichever model the server has resident".agentsAgent: string | null;agentsModel: string | null;+ // null means "follow the shell inferred from the client / Studio host".+ agentsOs: ExampleOs | null;// the quant carries the model it was picked for, so remembering a quant alone// never pins a model the tab would otherwise keep following.agentsVariant: string | null;agentsVariantModel: string | null;setAgentsAgent: (agent: string | null) => void;setAgentsModel: (model: string | null, variant: string | null) => void;+ setAgentsOs: (os: ExampleOs) => void;setAgentsVariant: (model: string, variant: string) => void;// null os means "follow the detected device type".@@ -67,6 +70,11 @@ function sanitize(...current,agentsAgent: text(raw.agentsAgent),agentsModel,+ agentsOs:+ typeof raw.agentsOs === "string" &&+ (EXAMPLE_OS_VALUES as string[]).includes(raw.agentsOs)+ ? (raw.agentsOs as ExampleOs)+ : null,// A quant with no model to scope it to can never be applied.agentsVariant: agentsVariantModel ? agentsVariant : null,agentsVariantModel: agentsVariant ? agentsVariantModel : null,@@ -90,12 +98,14 @@ export const useSettingsPanelPrefsStore = create<SettingsPanelPrefsState>()((set) => ({agentsAgent: null,agentsModel: null,+ agentsOs: null,agentsVariant: null,agentsVariantModel: null,setAgentsAgent: (agentsAgent) => set({ agentsAgent }),// picking a model carries its quant, and clearing it clears that quant.setAgentsModel: (agentsModel, agentsVariant) =>set({ agentsModel, agentsVariant, agentsVariantModel: agentsModel }),+ setAgentsOs: (agentsOs) => set({ agentsOs }),setAgentsVariant: (agentsVariantModel, agentsVariant) =>set({ agentsVariant, agentsVariantModel }),diff --git a/studio/frontend/src/features/settings/tabs/agents-tab.tsx b/studio/frontend/src/features/settings/tabs/agents-tab.tsxindex c9f726d8d38..a85c1eb8f6b 100644--- a/studio/frontend/src/features/settings/tabs/agents-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/agents-tab.tsx@@ -55,18 +55,21 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { ApiProviderLogo } from "../../chat/api-provider-logo";import { loadCodingAgents } from "../api/coding-agents";import {- buildAgentCommand,+ buildAgentShellCommands,isLoopbackHost,normalizeHost,+ quoteShellArg,} from "../components/agent-command";import { SettingsSection } from "../components/settings-section";-import { psSingle, shSingle } from "../components/usage-examples";import {isChatGenerativeHubModel,isClassifierOrRerankerHubModel,isSpeechOnlyHubModel,} from "../lib/agent-hub-model.ts";-import { useSettingsPanelPrefsStore } from "../stores/settings-panel-prefs-store";+import {+ type ExampleOs,+ useSettingsPanelPrefsStore,+} from "../stores/settings-panel-prefs-store";const DOCS_URL = "https://unsloth.ai/docs/integrations/unsloth-start";const FLAGS_DOCS_URL = `${DOCS_URL}#flags--options`;@@ -77,7 +80,6 @@ const MODEL_RESULT_LIMIT = 7;const STATUS_POLL_MS = 5000;const HUGGING_FACE_REPO_PATTERN = /^[^/\\:\s]+\/[^/\\:\s]+$/;const SEARCH_TOKEN_PATTERN = /\s+/;-const SAFE_SHELL_ARG_PATTERN = /^[A-Za-z0-9_./:@%+=,-]+$/;const SUBAGENT_AGENT_IDS = new Set(["claude", "codex", "opencode"]);function isLoopbackBase(base: string): boolean {@@ -93,24 +95,30 @@ function canUseLocalAgentDetection(base: string): boolean {return isTauri && isLoopbackBase(base);}-// One timeout, reset on re-click and cleared on unmount, so the tick never leaks.+// bind feedback to the copied text so command changes cannot retain a stale tick.function useCopyButton(text: string) {- const [copied, setCopied] = useState(false);+ const textVersion = useMemo(() => Symbol(text), [text]);+ const [copiedVersion, setCopiedVersion] = useState<symbol | null>(null);const timeoutRef = useRef<number | null>(null);+ const currentVersionRef = useRef(textVersion);- useEffect(- () => () => {+ useEffect(() => {+ currentVersionRef.current = textVersion;+ return () => {if (timeoutRef.current !== null) window.clearTimeout(timeoutRef.current);- },- [],- );+ timeoutRef.current = null;+ };+ }, [textVersion]);const copy = async () => {- if (!(await copyToClipboard(text))) return;- setCopied(true);+ const requestedText = text;+ const requestedVersion = textVersion;+ if (!(await copyToClipboard(requestedText))) return;+ if (currentVersionRef.current !== requestedVersion) return;+ setCopiedVersion(requestedVersion);if (timeoutRef.current !== null) window.clearTimeout(timeoutRef.current);timeoutRef.current = window.setTimeout(() => {- setCopied(false);+ setCopiedVersion(null);timeoutRef.current = null;}, 1600);};@@ -120,10 +128,10 @@ function useCopyButton(text: string) {window.clearTimeout(timeoutRef.current);timeoutRef.current = null;}- setCopied(false);+ setCopiedVersion(null);};- return { copied, copy, reset };+ return { copied: copiedVersion === textVersion, copy, reset };}type AgentDetails = {@@ -492,23 +500,6 @@ const OPTION_ROWS: { flag: string; descKey: TranslationKey }[] = [{ flag: "--yolo", descKey: "settings.agents.options.yolo" },];-const REMOTE_CMD_UNIX = `export UNSLOTH_STUDIO_URL=https://studio.example.com-export UNSLOTH_API_KEY=sk-unsloth-...-unsloth start claude`;--// PowerShell uses $env: assignments; export is POSIX-only.-const REMOTE_CMD_WINDOWS = `$env:UNSLOTH_STUDIO_URL = "https://studio.example.com"-$env:UNSLOTH_API_KEY = "sk-unsloth-..."-unsloth start claude`;--// Independent alternatives, each with its own copy button (not one script).-const PASSTHROUGH_EXAMPLES = [- { agent: "claude", flags: "--continue" },- { agent: "codex", flags: "--persist resume --last" },-];--const DRY_RUN_FLAGS = "--no-launch";-/** Code box with the copy control inside it, top-right. Presentational: the* copy state stays with the caller so existing resets still apply. */function CopyableCode({@@ -585,26 +576,14 @@ function CommandBlock({ command }: { command: string }) {);}-// Quote only values with shell metacharacters, e.g. a local path with spaces.-function quoteShellArg(value: string, windows: boolean): string {- if (SAFE_SHELL_ARG_PATTERN.test(value)) {- return value;- }- return windows ? `'${psSingle(value)}'` : `'${shSingle(value)}'`;-}-function SubagentSection({agent,- baseCommand,- modelArgs,+ command,}: {agent: AgentDetails;- baseCommand: string;- modelArgs: string;+ command: string;}) {const t = useT();- // modelArgs is empty when attaching to a resident model that has no id to name.- const command = `${baseCommand} --as-subagent${modelArgs ? ` ${modelArgs}` : ""}`;const prompt =agent.id === "opencode"? t("settings.agents.subagent.opencodePrompt")@@ -673,7 +652,8 @@ export function AgentsTab() {keepUnsupportedTags: false,enabled: online,});- // The remote snippet runs on the client, so use the client platform, not deviceType.+ // Seed a remote command from the client platform; the shell picker below can+ // override it for SSH, WSL, containers, or any other paste destination.// Anchor the match: a bare includes("win") would also match "darwin".const [isWindowsClient] = useState(() => {const p = getClientPlatform();@@ -684,20 +664,30 @@ export function AgentsTab() {// the CLI cannot reach, so use the backend URL from /api/health (getApiBase until it// lands). The command then runs wherever that CLI is: a loopback base is this Unsloth's// own host, so deviceType decides, and it reports wsl where the browser would claim- // Windows; any other base is reached from the viewer's machine, so only the client- // platform describes that shell.+ // Windows. For any other base the client platform is only the initial guess.const studioBase = isTauri ? (serverUrl ?? getApiBase()) : origin;- const isWindowsShell = isLoopbackBase(studioBase)- ? deviceType === "windows"- : isWindowsClient;+ const inferredCommandOs: ExampleOs = (+ isLoopbackBase(studioBase)+ ? deviceType === "windows"+ : isWindowsClient+ )+ ? "windows"+ : "unix";const localDetection = canUseLocalAgentDetection(serverUrl ?? origin);const setStoredAgent = useSettingsPanelPrefsStore((s) => s.setAgentsAgent);const setStoredModel = useSettingsPanelPrefsStore((s) => s.setAgentsModel);+ const setStoredOs = useSettingsPanelPrefsStore((s) => s.setAgentsOs);const setStoredVariant = useSettingsPanelPrefsStore((s) => s.setAgentsVariant,);// read once: these seed the controls, which write back through the handlers.const [storedPrefs] = useState(() => useSettingsPanelPrefsStore.getState());+ // Detection is only a default: a remote Studio cannot know whether its command+ // will be pasted into the viewer's local shell, SSH, WSL, or a container.+ const [commandOsOverride, setCommandOsOverride] = useState<ExampleOs | null>(+ storedPrefs.agentsOs,+ );+ const commandOs = commandOsOverride ?? inferredCommandOs;const [agents, setAgents] = useState<string[]>(SUPPORTED_AGENTS.map((agent) => agent.id),);@@ -842,13 +832,13 @@ export function AgentsTab() {selectedVariant && suffixVariant? `${modelId}:${selectedVariant}`: modelId;- const commandModelArg = quoteShellArg(commandModel, isWindowsShell);+ const commandModelArg = quoteShellArg(commandModel, commandOs);// A bare `unsloth start` attaches to whatever is loaded, which is the only way// to reach a native-grant GGUF: naming it would switch the server to another model.const attachOnly = selectedModel === attachOnlyModel;const selectedModelArgs =selectedVariant && !suffixVariant- ? `--model ${commandModelArg} --gguf-variant ${quoteShellArg(selectedVariant, isWindowsShell)}`+ ? `--model ${commandModelArg} --gguf-variant ${quoteShellArg(selectedVariant, commandOs)}`: `--model ${commandModelArg}`;const selectedModelFlags =modelKey(selectedModel) === modelKey(EXAMPLE_MODEL_REPO)@@ -859,23 +849,18 @@ export function AgentsTab() {: [selectedModelArgs, selectedModelFlags].filter(Boolean).join(" ");// No key is passed: the CLI caches an explicit one per base, overwriting a working// saved key. Omitting it replays the saved key; the remote section covers first setup.- const commandOs = isWindowsShell ? "windows" : "unix";- const commandBase = buildAgentCommand(+ const shellCommands = buildAgentShellCommands(studioBase,- null,commandOs,selectedAgent,+ modelArgs,);- const command = attachOnly ? commandBase : `${commandBase} ${modelArgs}`;- // The fixed examples below target the same Unsloth, not a bare 127.0.0.1:8888.- const example = (agentId: string, flags: string) =>- `${buildAgentCommand(studioBase, null, commandOs, agentId)} ${flags}`;+ const command = shellCommands.primary;const {copied,copy: handleCopy,reset: resetCopied,} = useCopyButton(command);- const remoteCommand = isWindowsClient ? REMOTE_CMD_WINDOWS : REMOTE_CMD_UNIX;useEffect(() => {void fetchDeviceType({ force: true });@@ -1611,9 +1596,50 @@ export function AgentsTab() {) : null}<div className="flex min-w-0 flex-col gap-2.5">- <span className="text-xs font-medium text-foreground">- {t("settings.agents.generatedCommand")}- </span>+ <div className="flex flex-wrap items-center justify-between gap-2">+ <span className="text-xs font-medium text-foreground">+ {t("settings.agents.generatedCommand")}+ </span>+ <fieldset className="flex min-w-0 items-center gap-0.5">+ <legend className="sr-only">+ {t("settings.agents.generatedCommand")}+ </legend>+ <button+ type="button"+ onClick={() => {+ setCommandOsOverride("unix");+ setStoredOs("unix");+ resetCopied();+ }}+ aria-pressed={commandOs === "unix"}+ className={cn(+ "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ commandOs === "unix"+ ? "hub-tab-toggle-pill text-foreground"+ : "text-muted-foreground hover:text-foreground",+ )}+ >+ {t("settings.apiKeys.osUnix")}+ </button>+ <button+ type="button"+ onClick={() => {+ setCommandOsOverride("windows");+ setStoredOs("windows");+ resetCopied();+ }}+ aria-pressed={commandOs === "windows"}+ className={cn(+ "rounded-full px-2.5 py-1 text-ui-11 font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ commandOs === "windows"+ ? "hub-tab-toggle-pill text-foreground"+ : "text-muted-foreground hover:text-foreground",+ )}+ >+ {t("settings.apiKeys.osWindows")}+ </button>+ </fieldset>+ </div><p className="text-ui-11 leading-relaxed text-muted-foreground">{t("settings.agents.automaticSettingsNote")}</p>@@ -1639,8 +1665,7 @@ export function AgentsTab() {<SubagentSectionkey={`${selectedAgent}:${commandModel}`}- baseCommand={commandBase}- modelArgs={modelArgs}+ command={shellCommands.subagent}agent={selectedAgentDetails}/>@@ -1675,7 +1700,7 @@ export function AgentsTab() {description={t("settings.agents.remote.description")}><div className="pt-3">- <CommandBlock command={remoteCommand} />+ <CommandBlock command={shellCommands.remoteSetup} /></div></SettingsSection>@@ -1684,8 +1709,11 @@ export function AgentsTab() {description={t("settings.agents.passthrough.description")}><div className="flex flex-col gap-3 pt-3">- {PASSTHROUGH_EXAMPLES.map(({ agent, flags }) => (- <CommandBlock key={flags} command={example(agent, flags)} />+ {shellCommands.passThrough.map((passThroughCommand) => (+ <CommandBlock+ key={passThroughCommand}+ command={passThroughCommand}+ />))}</div></SettingsSection>@@ -1695,7 +1723,7 @@ export function AgentsTab() {description={t("settings.agents.dryRun.description")}><div className="pt-3">- <CommandBlock command={example("claude", DRY_RUN_FLAGS)} />+ <CommandBlock command={shellCommands.dryRun} /></div></SettingsSection></div>diff --git a/studio/frontend/tests/agent-command.test.ts b/studio/frontend/tests/agent-command.test.tsnew file mode 100644index 00000000000..b6ab89e9c61--- /dev/null+++ b/studio/frontend/tests/agent-command.test.ts@@ -0,0 +1,96 @@+// 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 {+ buildAgentCommand,+ buildAgentShellCommands,+ quoteShellArg,+} from "../src/features/settings/components/agent-command.ts";++const REMOTE_STUDIO = "https://shed-topic-remark-arguments.trycloudflare.com/";++test("the Windows variant reproduces the reported PowerShell command", () => {+ assert.equal(+ buildAgentCommand(REMOTE_STUDIO, null, "windows", "claude"),+ '$env:UNSLOTH_STUDIO_URL="https://shed-topic-remark-arguments.trycloudflare.com"; unsloth start claude',+ );+});++test("the Unix override emits a Bash-compatible remote command", () => {+ assert.equal(+ buildAgentCommand(REMOTE_STUDIO, null, "unix", "claude"),+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start claude",+ );+});++test("safe model IDs do not get unnecessary quotes", () => {+ assert.equal(+ quoteShellArg("unsloth/Qwen3.8:UD-Q4_K_XL", "unix"),+ "unsloth/Qwen3.8:UD-Q4_K_XL",+ );+ assert.equal(+ quoteShellArg("unsloth/Qwen3.8:UD-Q4_K_XL", "windows"),+ "unsloth/Qwen3.8:UD-Q4_K_XL",+ );+});++test("model paths use the selected shell's single-quote escaping", () => {+ assert.equal(+ quoteShellArg("/tmp/Lee's model.gguf", "unix"),+ "'/tmp/Lee'\\''s model.gguf'",+ );+ assert.equal(+ quoteShellArg("C:\\Models\\Lee's model.gguf", "windows"),+ "'C:\\Models\\Lee''s model.gguf'",+ );+});++test("the Unix selection reaches every generated command", () => {+ const commands = buildAgentShellCommands(+ REMOTE_STUDIO,+ "unix",+ "codex",+ "--model '/tmp/My model.gguf'",+ );+ assert.equal(+ commands.primary,+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start codex --model '/tmp/My model.gguf'",+ );+ assert.equal(+ commands.subagent,+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start codex --as-subagent --model '/tmp/My model.gguf'",+ );+ assert.deepEqual(commands.passThrough, [+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start claude --continue",+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start codex --persist resume --last",+ ]);+ assert.equal(+ commands.dryRun,+ "UNSLOTH_STUDIO_URL=https://shed-topic-remark-arguments.trycloudflare.com unsloth start claude --no-launch",+ );+ assert.match(commands.remoteSetup, /^export UNSLOTH_STUDIO_URL=/);+});++test("the Windows selection reaches every generated command", () => {+ const commands = buildAgentShellCommands(+ REMOTE_STUDIO,+ "windows",+ "claude",+ "--model 'C:\\Models\\My model.gguf'",+ );+ for (const command of [+ commands.primary,+ commands.subagent,+ ...commands.passThrough,+ commands.dryRun,+ ]) {+ assert.match(command, /^\$env:UNSLOTH_STUDIO_URL=/);+ }+ assert.equal(+ commands.subagent,+ '$env:UNSLOTH_STUDIO_URL="https://shed-topic-remark-arguments.trycloudflare.com"; unsloth start claude --as-subagent --model \'C:\\Models\\My model.gguf\'',+ );+ assert.match(commands.remoteSetup, /^\$env:UNSLOTH_STUDIO_URL =/);+});diff --git a/studio/frontend/tests/settings-panel-prefs.test.ts b/studio/frontend/tests/settings-panel-prefs.test.tsindex 26edbad8a3e..094198c0f9e 100644--- a/studio/frontend/tests/settings-panel-prefs.test.ts+++ b/studio/frontend/tests/settings-panel-prefs.test.ts@@ -4,7 +4,10 @@import assert from "node:assert/strict";import { readFile } from "node:fs/promises";import test from "node:test";-import { installLocalStorageFake, registerBundlerResolver } from "./helpers/kit.ts";+import {+ installLocalStorageFake,+ registerBundlerResolver,+} from "./helpers/kit.ts";registerBundlerResolver();const { store } = installLocalStorageFake();@@ -37,6 +40,7 @@ test("a version 0 record hydrates every field", () => {const s = useSettingsPanelPrefsStore.getState();assert.equal(s.agentsAgent, "codex");assert.equal(s.agentsModel, "unsloth/Foo-GGUF");+ assert.equal(s.agentsOs, null);assert.equal(s.agentsVariant, "UD-Q4_K_XL");assert.equal(s.apiExampleOs, "windows");assert.equal(s.resourcesLiveUpdates, false);@@ -72,6 +76,22 @@ test("a setter write round-trips through localStorage", () => {assert.equal(JSON.parse(raw as string).state.fineTuneAction, "export");});+test("the Agents command shell override persists and rejects unknown values", () => {+ useSettingsPanelPrefsStore.getState().setAgentsOs("unix");+ assert.equal(useSettingsPanelPrefsStore.getState().agentsOs, "unix");+ const raw = store.get(KEY);+ assert.ok(raw);+ assert.equal(JSON.parse(raw as string).state.agentsOs, "unix");++ const merged = useSettingsPanelPrefsStore.persist.getOptions().merge;+ assert.ok(merged);+ const out = merged(+ { agentsOs: "fish" },+ useSettingsPanelPrefsStore.getState(),+ ) as { agentsOs: unknown };+ assert.equal(out.agentsOs, null);+});+// The reason the sanitiser exists: agentsModel reaches `.toLowerCase()` and the// path checks in agents-tab, so a non-string takes the whole app down.test("a non-string model is refused rather than handed to the tab", () => {