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: simpler API usage examples, and no Pi / Mistral Vibe outbound links (#14914)
Michael Han4be98d13e294
diff --git a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsxindex 2ce722374f8..e5e18050514 100644--- a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx+++ b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx@@ -473,7 +473,9 @@ export function ApiModelLoadControls({placeholder="Load model"open={selectorOpen && !unloading}onOpenChange={setSelectorOpen}- className="h-9 max-w-full rounded-full sm:max-w-[calc(28rem*var(--ui-space-scale,1))]"+ // Select trigger spacing (px-3.5) and a clear gap before the chevron, not the chat+ // header's tucked-in one.+ className="h-9 max-w-full rounded-full px-3.5 sm:max-w-[calc(28rem*var(--ui-space-scale,1))] [&>span:last-child]:ml-1"contentClassName="max-sm:max-w-[calc(100vw-3rem)]"/><ToolbarTooltip label={reloadTitle(lastLoadLabel, Boolean(activeModel))}>diff --git a/studio/frontend/src/features/settings/components/api-example-parts.tsx b/studio/frontend/src/features/settings/components/api-example-parts.tsxnew file mode 100644index 00000000000..516bfc201cc--- /dev/null+++ b/studio/frontend/src/features/settings/components/api-example-parts.tsx@@ -0,0 +1,340 @@+// 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 pieces the API tab's example sections (usage, audio, images and video) share.++import { createCodePlugin } from "@/components/assistant-ui/code-plugin";+import {+ unslothDarkTheme,+ unslothLightTheme,+} from "@/components/assistant-ui/code-themes";+import { SegmentedPill } from "@/components/segmented-control";+import { getClientPlatform } from "@/components/tauri/window-titlebar";+import { usePlatformStore } from "@/config/env";+import { useT } from "@/i18n";+import type { TranslationKey } from "@/i18n";+import { copyToClipboard } from "@/lib/copy-to-clipboard";+import { Tick02Icon } from "@/lib/tick-icon";+import { cn } from "@/lib/utils";+import { Copy01Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import {+ type CSSProperties,+ type PointerEvent as ReactPointerEvent,+ type ReactNode,+ useId,+ useMemo,+ useRef,+ useState,+} from "react";+import { Streamdown } from "streamdown";+import { useSettingsPanelPrefsStore } from "../stores/settings-panel-prefs-store";+import { isLoopbackHost, normalizeHost } from "./agent-command";++export type ExampleOs = "unix" | "windows";++const OS_OPTIONS: { id: ExampleOs; labelKey: TranslationKey }[] = [+ { id: "unix", labelKey: "settings.apiKeys.osUnix" },+ { id: "windows", labelKey: "settings.apiKeys.osWindows" },+];++// Lines that fit the example box's starting height (h-46); longer ones start there and scroll.+const START_LINES = 8;++export function isLoopbackUrl(url: string | null | undefined): boolean {+ if (!url) return false;+ try {+ return isLoopbackHost(normalizeHost(new URL(url).hostname));+ } catch {+ return false;+ }+}++/** The platform an example's shell commands target. An explicit pick wins (the snippet may+ * run on another machine). Otherwise a loopback base is this machine, where deviceType tells+ * WSL from Windows, and any other base is pasted where the user is: the client platform. */+export function useExampleOs(+ base: string,+): [ExampleOs, (os: ExampleOs) => void] {+ const deviceType = usePlatformStore((s) => s.deviceType);+ const setStoredOs = useSettingsPanelPrefsStore((s) => s.setApiExampleOs);+ const [override, setOverride] = useState<ExampleOs | null>(() => {+ const stored = useSettingsPanelPrefsStore.getState().apiExampleOs;+ return stored === "windows" || stored === "unix" ? stored : null;+ });+ // Anchor the match: a bare includes("win") would also match "darwin".+ const [isWindowsClient] = useState(() => {+ const p = getClientPlatform();+ return p.startsWith("win") || p.includes("windows");+ });+ const os: ExampleOs =+ override ??+ ((isLoopbackUrl(base) ? deviceType === "windows" : isWindowsClient)+ ? "windows"+ : "unix");+ const pick = (next: ExampleOs) => {+ setOverride(next);+ setStoredOs(next);+ };+ return [os, pick];+}++/** A labelled control in the Agents tab's style: fixed-height header, then the control. */+export function ExampleField({+ label,+ children,+}: {+ label: string;+ children: ReactNode;+}) {+ return (+ <div className="flex min-w-0 flex-col gap-1.5">+ <div className="flex h-5 items-center">+ <span className="truncate text-xs font-medium text-foreground">+ {label}+ </span>+ </div>+ {children}+ </div>+ );+}++/** A code box header's choice: "toggle" (the Agents tab's) for what the example does,+ * "pills" (as the usage examples' were) for the language and platform it is written for. */+export function ExampleToggle<T extends string>({+ label,+ value,+ options,+ onChange,+ variant = "pills",+}: {+ label: string;+ value: T;+ options: { id: T; label: string }[];+ onChange: (next: T) => void;+ variant?: "toggle" | "pills";+}) {+ const pillId = useId();+ const toggle = variant === "toggle";+ return (+ <fieldset className="flex min-w-0">+ <legend className="sr-only">{label}</legend>+ <div+ className={+ toggle+ ? "hub-tab-toggle flex h-9 w-fit max-w-full min-w-0 items-center rounded-full"+ : "isolate flex min-w-0 flex-wrap items-center gap-0.5"+ }+ >+ {options.map((option) => (+ <button+ key={option.id}+ type="button"+ onClick={() => onChange(option.id)}+ aria-pressed={value === option.id}+ className={cn(+ "relative whitespace-nowrap rounded-full font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ toggle+ ? "inline-flex h-9 items-center px-3 text-ui-12"+ : "px-2.5 py-1 text-ui-11",+ value === option.id+ ? "text-foreground"+ : "text-muted-foreground hover:text-foreground",+ )}+ >+ {value === option.id && <SegmentedPill group={pillId} />}+ <span className="relative truncate">{option.label}</span>+ </button>+ ))}+ </div>+ </fieldset>+ );+}++export function PlatformToggle({+ value,+ onChange,+}: {+ value: ExampleOs;+ onChange: (os: ExampleOs) => void;+}) {+ const t = useT();+ return (+ <ExampleToggle+ label={t("settings.apiKeys.examplePlatform")}+ value={value}+ options={OS_OPTIONS.map((o) => ({ id: o.id, label: t(o.labelKey) }))}+ onChange={onChange}+ />+ );+}++const SHIKI_THEMES = [unslothLightTheme, unslothDarkTheme] as [+ typeof unslothLightTheme,+ typeof unslothDarkTheme,+];+const codePlugin = createCodePlugin({ themes: SHIKI_THEMES });++export function HighlightedCode({+ code,+ language,+ label,+ redactFromReload,+}: {+ code: string;+ language: string;+ label: string;+ redactFromReload: boolean;+}) {+ const markdown = useMemo(+ () => `\`\`\`${language}\n${code}\n\`\`\``,+ [code, language],+ );+ return (+ // Intrinsic code width keeps scrolling on the focusable section.+ <section+ // Safari never focuses a scroller on its own, so long examples need a tab stop.+ // biome-ignore lint/a11y/noNoninteractiveTabindex: keyboard-scrollable region+ tabIndex={0}+ aria-label={label}+ className="max-h-96 max-w-full hover-scrollbar overflow-auto [mask-image:linear-gradient(to_bottom,transparent,#000_0.75rem)] p-3 pr-16 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset text-ui-11 leading-relaxed [&_pre]:!m-0 [&_pre]:!whitespace-pre [&_pre]:!break-normal [&_pre]:!border-0 [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:!text-ui-11 [&_pre]:!leading-relaxed [&_code]:!text-ui-11 [&_[data-streamdown=code-block]]:!min-w-max [&_[data-streamdown=code-block]]:!my-0 [&_[data-streamdown=code-block]]:!border-0 [&_[data-streamdown=code-block]]:!bg-transparent [&_[data-streamdown=code-block]]:!p-0 [&_[data-streamdown=code-block]]:!text-ui-11"+ data-reload-snapshot-sensitive={redactFromReload ? "" : undefined}+ >+ <Streamdown+ mode="static"+ plugins={{ code: codePlugin }}+ controls={{ code: false }}+ shikiTheme={SHIKI_THEMES}+ >+ {markdown}+ </Streamdown>+ </section>+ );+}++/** An example's code under one header row of its choices and, at the end, the Platform pills,+ * with an icon copy on the first code line. No language label (the Language pills say it); starts about eight lines tall+ * and drags taller from its grip. */+export function ExampleCodeBox({+ code,+ language,+ label,+ redactFromReload,+ pills,+ os,+ onOsChange,+}: {+ code: string;+ language: string;+ label: string;+ redactFromReload: boolean;+ pills: ReactNode;+ os: ExampleOs;+ onOsChange: (os: ExampleOs) => void;+}) {+ const t = useT();+ const [copied, setCopied] = useState(false);+ const boxRef = useRef<HTMLDivElement>(null);+ const [height, setHeight] = useState<number | null>(null);+ const tall = code.split("\n").length > START_LINES;++ const handleCopy = async () => {+ if (await copyToClipboard(code)) {+ setCopied(true);+ setTimeout(() => setCopied(false), 1800);+ }+ };++ const startResize = (event: ReactPointerEvent<HTMLSpanElement>) => {+ const scroller = boxRef.current?.querySelector("section");+ if (!scroller || event.button !== 0) {+ return;+ }+ event.preventDefault();+ const handle = event.currentTarget;+ handle.setPointerCapture(event.pointerId);+ const startY = event.clientY;+ const startHeight = scroller.getBoundingClientRect().height;+ const move = (e: PointerEvent) => {+ // 96px floor matches min-h-24.+ setHeight(Math.max(96, Math.round(startHeight + e.clientY - startY)));+ };+ const stop = () => {+ handle.removeEventListener("pointermove", move);+ handle.removeEventListener("pointerup", stop);+ handle.removeEventListener("pointercancel", stop);+ };+ handle.addEventListener("pointermove", move);+ handle.addEventListener("pointerup", stop);+ handle.addEventListener("pointercancel", stop);+ };++ return (+ <div className="relative min-w-0 overflow-hidden rounded-xl border border-border bg-background/70 dark:border-transparent dark:bg-[rgb(255_255_255_/_calc(0.05*var(--contrast-wash-gain,1)))]">+ {/* Square scroller: this overflow-hidden rounds its scrollbars off at the corners. */}+ <div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-2 pt-1.5">+ {pills}+ <div className="ml-auto">+ <PlatformToggle value={os} onChange={onOsChange} />+ </div>+ </div>+ {/* HighlightedCode's max-h-96 is lifted so a drag can grow the box past it. */}+ <div+ ref={boxRef}+ style={+ height === null+ ? undefined+ : ({ "--example-h": `${height}px` } as CSSProperties)+ }+ className={cn(+ "relative [&>section]:max-h-none [&>section]:min-h-24 [&>section]:pr-8 [&_[data-streamdown=code-block-header]]:hidden",+ height === null+ ? tall && "[&>section]:h-46"+ : "[&>section]:h-(--example-h)",+ )}+ >+ {/* On the first code line, clear of the vertical scrollbar. */}+ <button+ type="button"+ onClick={handleCopy}+ className="absolute top-2.5 right-3 z-10 flex size-6 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ aria-label={+ copied+ ? t("settings.apiKeys.copied")+ : t("settings.apiKeys.copySnippet")+ }+ >+ <HugeiconsIcon+ icon={copied ? Tick02Icon : Copy01Icon}+ className={cn("size-3.5", copied && "text-control-accent")}+ />+ </button>+ <HighlightedCode+ key={code}+ code={code}+ language={language}+ label={label}+ redactFromReload={redactFromReload}+ />+ </div>+ {/* Our own handle, not CSS resize: the native grabber can't be hidden without custom+ scrollbars and the rounded corner clips it into a stray arc. Inset past the curve.+ Mouse-only, like the native one; the keyboard still scrolls the region. */}+ <span+ aria-hidden="true"+ onPointerDown={startResize}+ className="absolute right-1 bottom-1 flex size-5 cursor-ns-resize touch-none items-center justify-center text-muted-foreground/60 transition-colors hover:text-muted-foreground"+ >+ <svg aria-hidden="true" viewBox="0 0 10 10" className="size-2.5">+ <path+ d="M9 3 3 9M9 6.5 6.5 9"+ stroke="currentColor"+ strokeWidth="1.25"+ strokeLinecap="round"+ fill="none"+ />+ </svg>+ </span>+ </div>+ );+}diff --git a/studio/frontend/src/features/settings/components/audio-api-examples.tsx b/studio/frontend/src/features/settings/components/audio-api-examples.tsxindex 5660dcabde0..bac33469bc8 100644--- a/studio/frontend/src/features/settings/components/audio-api-examples.tsx+++ b/studio/frontend/src/features/settings/components/audio-api-examples.tsx@@ -1,24 +1,20 @@// 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 { SegmentedPill } from "@/components/segmented-control";+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { usePlatformStore } from "@/config/env";import { useT } from "@/i18n";import type { TranslationKey } from "@/i18n";import { isTauri } from "@/lib/api-base";-import { copyToClipboard } from "@/lib/copy-to-clipboard";-import { Tick02Icon } from "@/lib/tick-icon";-import { cn } from "@/lib/utils";-import { Copy01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import {- type ReactNode,- useEffect,- useId,- useMemo,- useRef,- useState,-} from "react";+import { useEffect, useMemo, useRef, useState } from "react";import type {KeylessApiAccessExposure,KeylessApiAccessScope,@@ -40,7 +36,6 @@ import {AUDIO_RUN_WORKFLOWS,type AudioApiExample,type AudioApiLang,- type AudioApiOs,type AudioApiTab,type AudioRunWorkflow,audioApiExampleFor,@@ -51,7 +46,12 @@ import {langFromStored,pickAudioApiModel,} from "./audio-api-snippets";-import { HighlightedCode } from "./usage-examples";+import {+ ExampleCodeBox,+ ExampleField,+ ExampleToggle,+ useExampleOs,+} from "./api-example-parts";const LANGS: { id: AudioApiLang; label: string }[] = [{ id: "curl", label: "curl" },@@ -73,35 +73,6 @@ const RUN_LABEL: Record<AudioRunWorkflow, TranslationKey> = {edit: "settings.apiKeys.audioApi.edit",};-export function Pill({- active,- pillGroup,- onClick,- children,-}: {- active: boolean;- pillGroup: string;- onClick: () => void;- children: ReactNode;-}) {- return (- <button- type="button"- onClick={onClick}- aria-pressed={active}- className={cn(- "relative 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",- active- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",- )}- >- {active && <SegmentedPill group={pillGroup} />}- {children}- </button>- );-}-export function AudioApiExamples({apiKey,useTunnel,@@ -114,13 +85,10 @@ export function AudioApiExamples({keylessExposure?: KeylessApiAccessExposure | null;}) {const t = useT();- const pillId = useId();- const deviceType = usePlatformStore((s) => s.deviceType);const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);const serverUrl = usePlatformStore((s) => s.serverUrl);const setStoredTab = useSettingsPanelPrefsStore((s) => s.setApiAudioExample);const setStoredLang = useSettingsPanelPrefsStore((s) => s.setApiExampleLang);- const setStoredOs = useSettingsPanelPrefsStore((s) => s.setApiExampleOs);const [storedPrefs] = useState(() => useSettingsPanelPrefsStore.getState());const [tab, setTab] = useState<AudioApiTab>(AUDIO_API_TABS.find((id) => id === storedPrefs.apiAudioExample) ?? "speak",@@ -129,13 +97,9 @@ export function AudioApiExamples({const [lang, setLang] = useState<AudioApiLang>(langFromStored(storedPrefs.apiExampleLang),);- const [os, setOs] = useState<AudioApiOs>(- storedPrefs.apiExampleOs ?? (deviceType === "windows" ? "windows" : "unix"),- );// null until /v1/models answers, so a slow or failed listing never claims nothing is downloaded.const [models, setModels] = useState<AudioApiModel[] | null>(null);const [autoSwitch, setAutoSwitch] = useState<boolean | null>(null);- const [copied, setCopied] = useState(false);const [pageModel, setPageModel] = useState<{example: AudioApiExample;model: string;@@ -212,6 +176,7 @@ export function AudioApiExamples({: isTauri? (serverUrl ?? origin): origin;+ const [os, setOs] = useExampleOs(base);const key = audioApiKey(apiKey, {base,tunnel: useTunnel && !!cloudflareUrl,@@ -249,132 +214,105 @@ export function AudioApiExamples({const shikiLang =lang === "curl" ? (os === "windows" ? "powershell" : "bash") : lang;- const handleCopy = async () => {- if (await copyToClipboard(snippet)) {- setCopied(true);- setTimeout(() => setCopied(false), 1800);+ const pickExample = (next: string) => {+ const workflow = AUDIO_RUN_WORKFLOWS.find((id) => id === next);+ if (workflow) {+ setRun(workflow);+ setTab("workflows");+ setStoredTab("workflows");+ return;}+ const nextTab = AUDIO_API_TABS.find((id) => id === next);+ if (nextTab) {+ setTab(nextTab);+ setStoredTab(nextTab);+ }+ };++ const pickLang = (next: AudioApiLang) => {+ setLang(next);+ const stored = audioLangToStore(+ useSettingsPanelPrefsStore.getState().apiExampleLang,+ next,+ );+ if (stored) setStoredLang(stored);};return (<sectionref={sectionRef}data-settings-label={t("settings.apiKeys.audioApi.title")}- className="flex min-w-0 max-w-full scroll-mt-6 flex-col"+ className="flex min-w-0 max-w-full scroll-mt-6 flex-col gap-4">- <h2 className="settings-heading mb-1 text-sm font-semibold">- {t("settings.apiKeys.audioApi.title")}- </h2>- <p className="mb-2 text-xs leading-relaxed text-muted-foreground">- {t("settings.apiKeys.audioApi.description")}- </p>- <div className="min-w-0 max-w-full overflow-hidden rounded-xl border border-border bg-muted/20">- <div className="flex min-w-0 flex-wrap items-center justify-between gap-x-2 gap-y-1 border-b border-border px-2 py-1.5">- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">- {AUDIO_API_TABS.map((id) => (- <Pill- key={id}- active={tab === id}- pillGroup={`${pillId}-tab`}- onClick={() => {- setTab(id);- setStoredTab(id);- }}- >- {t(TAB_LABEL[id])}- </Pill>- ))}- </div>- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">- {LANGS.map((item) => (- <Pill- key={item.id}- active={lang === item.id}- pillGroup={`${pillId}-lang`}- onClick={() => {- setLang(item.id);- const stored = audioLangToStore(- useSettingsPanelPrefsStore.getState().apiExampleLang,- item.id,- );- if (stored) setStoredLang(stored);- }}- >- {item.label}- </Pill>- ))}- </div>- </div>- {tab === "workflows" ? (- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5 border-b border-border px-2 py-1.5">- {AUDIO_RUN_WORKFLOWS.map((id) => (- <Pill- key={id}- active={run === id}- pillGroup={`${pillId}-run`}- onClick={() => setRun(id)}+ <div className="flex flex-col gap-1">+ <h2 className="settings-heading text-sm font-semibold">+ {t("settings.apiKeys.audioApi.title")}+ </h2>+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("settings.apiKeys.audioApi.description")}+ </p>+ </div>+ <div className="@container">+ <div className="grid grid-cols-1 items-start gap-3 @[34rem]:grid-cols-3">+ <ExampleField label={t("settings.apiKeys.exampleKind")}>+ {/* One picker for the tabs and the workflows that used to sit in a second row. */}+ <Select value={example} onValueChange={pickExample}>+ <SelectTrigger+ aria-label={t("settings.apiKeys.exampleKind")}+ className="w-full rounded-lg">- {t(RUN_LABEL[id])}- </Pill>- ))}- </div>- ) : null}- {lang === "curl" ? (- <div className="isolate flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">- <Pill- active={os === "unix"}- pillGroup={`${pillId}-os`}- onClick={() => {- setOs("unix");- setStoredOs("unix");- }}- >- {t("settings.apiKeys.osUnix")}- </Pill>- <Pill- active={os === "windows"}- pillGroup={`${pillId}-os`}- onClick={() => {- setOs("windows");- setStoredOs("windows");- }}- >- {t("settings.apiKeys.osWindows")}- </Pill>- </div>- ) : null}- <div className="relative min-w-0">- <button- type="button"- onClick={handleCopy}- className="btn-fill absolute right-2 top-2 z-10 flex items-center gap-1 rounded-full px-1.5 py-1 text-ui-11 text-muted-foreground backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- aria-label={t("settings.apiKeys.copySnippet")}- >- <HugeiconsIcon- icon={copied ? Tick02Icon : Copy01Icon}- className={cn("size-3.5", copied && "text-emerald-600")}- />- {copied ? t("settings.apiKeys.copied") : t("settings.apiKeys.copy")}- </button>- <HighlightedCode- key={snippet}- code={snippet}- language={shikiLang}- label={t("settings.apiKeys.audioApi.title")}- redactFromReload={Boolean(apiKey)}- />+ <SelectValue />+ </SelectTrigger>+ <SelectContent align="start">+ {/* Grouped too, so these line up with the workflow items. */}+ <SelectGroup>+ {AUDIO_API_TABS.filter((id) => id !== "workflows").map(+ (id) => (+ <SelectItem key={id} value={id}>+ {t(TAB_LABEL[id])}+ </SelectItem>+ ),+ )}+ </SelectGroup>+ <SelectGroup>+ <SelectLabel>{t(TAB_LABEL.workflows)}</SelectLabel>+ {AUDIO_RUN_WORKFLOWS.map((id) => (+ <SelectItem key={id} value={id}>+ {t(RUN_LABEL[id])}+ </SelectItem>+ ))}+ </SelectGroup>+ </SelectContent>+ </Select>+ </ExampleField></div>- {placeholder || needsLoad ? (- <div className="flex min-w-0 flex-col gap-1 border-t border-border px-3 py-2.5 text-ui-11 leading-snug text-muted-foreground">- {placeholder ? (- <span>{t("settings.apiKeys.audioApi.placeholderModel")}</span>- ) : null}- {needsLoad ? (- <span>{t("settings.apiKeys.audioApi.autoSwitchOff")}</span>- ) : null}- </div>- ) : null}</div>+ {placeholder || needsLoad ? (+ <div className="flex min-w-0 flex-col gap-1 text-ui-11 leading-relaxed text-muted-foreground">+ {placeholder ? (+ <p>{t("settings.apiKeys.audioApi.placeholderModel")}</p>+ ) : null}+ {needsLoad ? (+ <p>{t("settings.apiKeys.audioApi.autoSwitchOff")}</p>+ ) : null}+ </div>+ ) : null}+ <ExampleCodeBox+ code={snippet}+ language={shikiLang}+ label={t("settings.apiKeys.audioApi.title")}+ redactFromReload={Boolean(apiKey)}+ pills={+ <ExampleToggle+ label={t("settings.apiKeys.exampleLanguage")}+ value={lang}+ options={LANGS}+ onChange={pickLang}+ />+ }+ os={os}+ onOsChange={setOs}+ /></section>);}diff --git a/studio/frontend/src/features/settings/components/coding-agent-list.ts b/studio/frontend/src/features/settings/components/coding-agent-list.tsindex ed425443719..6b674f3bc65 100644--- a/studio/frontend/src/features/settings/components/coding-agent-list.ts+++ b/studio/frontend/src/features/settings/components/coding-agent-list.ts@@ -72,7 +72,8 @@ export const SUPPORTED_AGENTS: AgentDetails[] = [{id: "pi",name: "Pi",- docsUrl: "https://pi.dev",+ // Pi and Vibe have no page of their own: they share the unsloth start one.+ docsUrl: UNSLOTH_START_DOCS_URL,// The monochrome mark from https://pi.dev/favicon.svg, in its light and dark fills.icon: "pi-light.svg",darkIcon: "pi-dark.svg",@@ -81,7 +82,7 @@ export const SUPPORTED_AGENTS: AgentDetails[] = [{id: "vibe",name: "Mistral Vibe",- docsUrl: "https://github.com/mistralai/mistral-vibe",+ docsUrl: UNSLOTH_START_DOCS_URL,logo: "mistral",compact: true,},diff --git a/studio/frontend/src/features/settings/components/lan-access-section.tsx b/studio/frontend/src/features/settings/components/lan-access-section.tsxindex 54d29a5f32b..2c1361983b9 100644--- a/studio/frontend/src/features/settings/components/lan-access-section.tsx+++ b/studio/frontend/src/features/settings/components/lan-access-section.tsx@@ -473,7 +473,7 @@ export function LanAccessSection() {<AccessStatus status={status} /></div><p className="text-xs text-muted-foreground leading-relaxed">- Use Unsloth and its APIs from other devices on your Wi-Fi or wired+ Use Unsloth and its APIs from devices on your Wi-Fi or wirednetwork.</p></div>@@ -482,7 +482,7 @@ export function LanAccessSection() {type="button"size="sm"variant={stopAction ? "outline" : "default"}- className="min-w-20 shrink-0"+ className="shrink-0"onClick={stopAction ? stop : start}disabled={actionDisabled}>@@ -500,7 +500,7 @@ export function LanAccessSection() {{status?.portConfigurationSupported ? (<SettingsRowlabel="Port"- description="Automatic tries 8888, then 8889–8908. Custom uses only the selected port. Stop LAN access before changing it."+ description="Automatic tries 8888, then 8889–8908. Custom uses only that port. Stop LAN access to change it."// Always mounted, even when empty: a live region has to exist before its// text changes for the change to be announced.below={@@ -529,7 +529,7 @@ export function LanAccessSection() {><SelectTriggersize="sm"- className="w-28"+ className="w-32"aria-label="LAN port mode"><SelectValue />@@ -576,7 +576,7 @@ export function LanAccessSection() {<><SettingsRowlabel="Addresses"- description="Automatic uses every address this machine has, public ones included. Choose uses only the addresses you tick, such as a Tailscale address. Stop LAN access before changing it, and save before starting."+ description="Automatic uses every address this machine has, public ones included. Choose limits it to the ones you tick, like a Tailscale address. Stop LAN access to change it; save before starting."below={<spanid={addressErrorId}@@ -607,7 +607,7 @@ export function LanAccessSection() {><SelectTriggersize="sm"- className="w-28"+ className="w-32"aria-label="LAN address mode"><SelectValue />@@ -693,7 +693,7 @@ export function LanAccessSection() {</SettingsRow><SettingsRowlabel="Start automatically"- description="Put Unsloth on the network each time it starts. Stopping LAN access now won’t turn this off."+ description="Put Unsloth on the network each time it starts. Stopping now won’t turn this off."><Switchchecked={status?.autoStart ?? false}diff --git a/studio/frontend/src/features/settings/components/media-api-examples.tsx b/studio/frontend/src/features/settings/components/media-api-examples.tsxindex cffa75f7027..d337cfd9949 100644--- a/studio/frontend/src/features/settings/components/media-api-examples.tsx+++ b/studio/frontend/src/features/settings/components/media-api-examples.tsx@@ -4,12 +4,7 @@import { usePlatformStore } from "@/config/env";import { useT } from "@/i18n";import { isTauri } from "@/lib/api-base";-import { copyToClipboard } from "@/lib/copy-to-clipboard";-import { Tick02Icon } from "@/lib/tick-icon";-import { cn } from "@/lib/utils";-import { Copy01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import { useEffect, useId, useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import type {KeylessApiAccessExposure,KeylessApiAccessScope,@@ -20,10 +15,13 @@ import {} from "../api/openai-auto-switch";import { useSettingsDialogStore } from "../stores/settings-dialog-store";import { useSettingsPanelPrefsStore } from "../stores/settings-panel-prefs-store";-import { Pill } from "./audio-api-examples";+import {+ ExampleCodeBox,+ ExampleToggle,+ useExampleOs,+} from "./api-example-parts";import {type AudioApiLang,- type AudioApiOs,audioApiKey,audioLangToStore,langFromStored,@@ -34,7 +32,6 @@ import {type MediaApiKind,buildMediaApiSnippet,} from "./media-api-snippets";-import { HighlightedCode } from "./usage-examples";const LANGS: { id: AudioApiLang; label: string }[] = [{ id: "curl", label: "curl" },@@ -54,25 +51,18 @@ export function MediaApiExamples({keylessExposure?: KeylessApiAccessExposure | null;}) {const t = useT();- const pillId = useId();- const deviceType = usePlatformStore((s) => s.deviceType);const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);const serverUrl = usePlatformStore((s) => s.serverUrl);const setStoredLang = useSettingsPanelPrefsStore((s) => s.setApiExampleLang);- const setStoredOs = useSettingsPanelPrefsStore((s) => s.setApiExampleOs);const [storedPrefs] = useState(() => useSettingsPanelPrefsStore.getState());const [kind, setKind] = useState<MediaApiKind>("images");const [lang, setLang] = useState<AudioApiLang>(langFromStored(storedPrefs.apiExampleLang),);- const [os, setOs] = useState<AudioApiOs>(- storedPrefs.apiExampleOs ?? (deviceType === "windows" ? "windows" : "unix"),- );const [pageModels, setPageModels] = useState<Partial<Record<MediaApiKind, string>>>({});const [autoSwitch, setAutoSwitch] = useState<boolean | null>(null);- const [copied, setCopied] = useState(false);const sectionRef = useRef<HTMLElement | null>(null);const mediaApiRequested = useSettingsDialogStore((s) => s.mediaApiRequested);const scrollTarget = useSettingsDialogStore((s) => s.scrollTarget);@@ -134,6 +124,7 @@ export function MediaApiExamples({: isTauri? (serverUrl ?? origin): origin;+ const [os, setOs] = useExampleOs(base);const key = audioApiKey(apiKey, {base,tunnel: useTunnel && !!cloudflareUrl,@@ -149,119 +140,69 @@ export function MediaApiExamples({const shikiLang =lang === "curl" ? (os === "windows" ? "powershell" : "bash") : lang;- const handleCopy = async () => {- if (await copyToClipboard(snippet)) {- setCopied(true);- setTimeout(() => setCopied(false), 1800);- }+ const pickLang = (next: AudioApiLang) => {+ setLang(next);+ const stored = audioLangToStore(+ useSettingsPanelPrefsStore.getState().apiExampleLang,+ next,+ );+ if (stored) setStoredLang(stored);};return (<sectionref={sectionRef}data-settings-label={t("settings.apiKeys.mediaApi.title")}- className="flex min-w-0 max-w-full scroll-mt-6 flex-col"+ className="flex min-w-0 max-w-full scroll-mt-6 flex-col gap-4">- <h2 className="settings-heading mb-1 text-sm font-semibold">- {t("settings.apiKeys.mediaApi.title")}- </h2>- <p className="mb-2 text-xs leading-relaxed text-muted-foreground">- {t("settings.apiKeys.mediaApi.description")}- </p>- <div className="min-w-0 max-w-full overflow-hidden rounded-xl border border-border bg-muted/20">- <div className="flex min-w-0 flex-wrap items-center justify-between gap-x-2 gap-y-1 border-b border-border px-2 py-1.5">- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">- {MEDIA_API_KINDS.map((id) => (- <Pill- key={id}- active={kind === id}- pillGroup={`${pillId}-kind`}- onClick={() => setKind(id)}- >- {t(- id === "images"- ? "settings.apiKeys.mediaApi.images"- : "settings.apiKeys.mediaApi.video",- )}- </Pill>- ))}- </div>- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">- {LANGS.map((item) => (- <Pill- key={item.id}- active={lang === item.id}- pillGroup={`${pillId}-lang`}- onClick={() => {- setLang(item.id);- const stored = audioLangToStore(- useSettingsPanelPrefsStore.getState().apiExampleLang,- item.id,- );- if (stored) setStoredLang(stored);- }}- >- {item.label}- </Pill>- ))}- </div>+ <div className="flex flex-col gap-1">+ <h2 className="settings-heading text-sm font-semibold">+ {t("settings.apiKeys.mediaApi.title")}+ </h2>+ <p className="text-xs leading-relaxed text-muted-foreground">+ {t("settings.apiKeys.mediaApi.description")}+ </p>+ </div>+ <ExampleToggle+ label={t("settings.apiKeys.exampleKind")}+ variant="toggle"+ value={kind}+ options={MEDIA_API_KINDS.map((id) => ({+ id,+ label: t(+ id === "images"+ ? "settings.apiKeys.mediaApi.images"+ : "settings.apiKeys.mediaApi.video",+ ),+ }))}+ onChange={setKind}+ />+ {pageModel == null || autoSwitch === false ? (+ <div className="flex min-w-0 flex-col gap-1 text-ui-11 leading-relaxed text-muted-foreground">+ {pageModel == null ? (+ <p>{t("settings.apiKeys.mediaApi.placeholderModel")}</p>+ ) : null}+ {autoSwitch === false ? (+ <p>{t("settings.apiKeys.mediaApi.autoSwitchOff")}</p>+ ) : null}</div>- {lang === "curl" ? (- <div className="isolate flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">- <Pill- active={os === "unix"}- pillGroup={`${pillId}-os`}- onClick={() => {- setOs("unix");- setStoredOs("unix");- }}- >- {t("settings.apiKeys.osUnix")}- </Pill>- <Pill- active={os === "windows"}- pillGroup={`${pillId}-os`}- onClick={() => {- setOs("windows");- setStoredOs("windows");- }}- >- {t("settings.apiKeys.osWindows")}- </Pill>- </div>- ) : null}- <div className="relative min-w-0">- <button- type="button"- onClick={handleCopy}- className="btn-fill absolute right-2 top-2 z-10 flex items-center gap-1 rounded-full px-1.5 py-1 text-ui-11 text-muted-foreground backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- aria-label={t("settings.apiKeys.copySnippet")}- >- <HugeiconsIcon- icon={copied ? Tick02Icon : Copy01Icon}- className={cn("size-3.5", copied && "text-emerald-600")}- />- {copied ? t("settings.apiKeys.copied") : t("settings.apiKeys.copy")}- </button>- <HighlightedCode- key={snippet}- code={snippet}- language={shikiLang}- label={t("settings.apiKeys.mediaApi.title")}- redactFromReload={Boolean(apiKey)}+ ) : null}+ <ExampleCodeBox+ code={snippet}+ language={shikiLang}+ label={t("settings.apiKeys.mediaApi.title")}+ redactFromReload={Boolean(apiKey)}+ pills={+ <ExampleToggle+ label={t("settings.apiKeys.exampleLanguage")}+ value={lang}+ options={LANGS}+ onChange={pickLang}/>- </div>- {pageModel == null || autoSwitch === false ? (- <div className="flex min-w-0 flex-col gap-1 border-t border-border px-3 py-2.5 text-ui-11 leading-snug text-muted-foreground">- {pageModel == null ? (- <span>{t("settings.apiKeys.mediaApi.placeholderModel")}</span>- ) : null}- {autoSwitch === false ? (- <span>{t("settings.apiKeys.mediaApi.autoSwitchOff")}</span>- ) : null}- </div>- ) : null}- </div>+ }+ os={os}+ onOsChange={setOs}+ /></section>);}diff --git a/studio/frontend/src/features/settings/components/remote-access-section.tsx b/studio/frontend/src/features/settings/components/remote-access-section.tsxindex 91e13bdebd4..d7a9e08398e 100644--- a/studio/frontend/src/features/settings/components/remote-access-section.tsx+++ b/studio/frontend/src/features/settings/components/remote-access-section.tsx@@ -393,8 +393,8 @@ export function RemoteAccessSection() {<AccessStatus status={status} /></div><p className="text-xs text-muted-foreground leading-relaxed">- Use Unsloth and its APIs from other devices through a secure,- temporary public Cloudflare URL.+ Use Unsloth and its APIs from other devices over a secure,+ temporary Cloudflare URL.</p></div></div>@@ -402,7 +402,7 @@ export function RemoteAccessSection() {type="button"size="sm"variant={stopAction ? "outline" : "default"}- className="min-w-20 shrink-0"+ className="shrink-0"onClick={stopAction ? stop : start}disabled={actionDisabled}>@@ -422,7 +422,7 @@ export function RemoteAccessSection() {<SettingsRowlabel="Start automatically"- description="Create a new remote URL each time Unsloth starts. Stopping remote access now won’t turn this off."+ description="Create a new remote URL each time Unsloth starts. Stopping now won’t turn this off."><Switchchecked={status?.autoStart ?? false}diff --git a/studio/frontend/src/features/settings/components/remote-lan-summary.tsx b/studio/frontend/src/features/settings/components/remote-lan-summary.tsxdeleted file mode 100644index f8083a5a72c..00000000000--- a/studio/frontend/src/features/settings/components/remote-lan-summary.tsx+++ /dev/null@@ -1,174 +0,0 @@-// 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 { Button } from "@/components/ui/button";-import { usePlatformStore } from "@/config/env";-import { useT } from "@/i18n";-import { cn } from "@/lib/utils";-import { ArrowRight01Icon, HomeWifiIcon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";-import { useEffect, useState } from "react";-import {- type LanAccessStatus,- loadLanAccess,- publishLanUrls,-} from "../api/lan-access";-import {- type RemoteAccessStatus,- loadRemoteAccess,-} from "../api/remote-access";-import { remoteAccessPollDelay } from "../api/remote-access-state";-import { useSettingsDialogStore } from "../stores/settings-dialog-store";--type AccessState = "off" | "starting" | "online" | "stopping" | "error";--const STATE_LABEL: Record<AccessState, string> = {- off: "Off",- starting: "Starting",- online: "Online",- stopping: "Stopping",- error: "Error",-};--function stateDotClass(state?: AccessState): string {- if (state === "online") return "bg-emerald-500";- if (state === "starting" || state === "stopping") {- return "animate-pulse bg-blue-500";- }- return state === "error" ? "bg-red-500" : "bg-muted-foreground";-}--function AccessLine({- label,- state,- url,-}: {- label: string;- state: AccessState | "unavailable" | null;- url: string | null;-}) {- const known = state !== null && state !== "unavailable" ? state : undefined;- return (- <div className="flex min-w-0 items-center gap-3 px-4 py-2.5">- <span className="w-28 shrink-0 text-sm text-foreground">{label}</span>- <span className="flex shrink-0 items-center gap-1.5 text-xs text-muted-foreground">- <span- className={cn("size-2 rounded-full", stateDotClass(known))}- aria-hidden={true}- />- {known- ? STATE_LABEL[known]- : state === "unavailable"- ? "Unavailable"- : "Checking…"}- </span>- {url ? (- <span className="min-w-0 truncate font-mono text-xs text-muted-foreground">- {url}- </span>- ) : null}- </div>- );-}--/**- * Reads each once instead of mounting both panels and their five-second polls here.- */-export function RemoteLanSummary() {- const t = useT();- const [remote, setRemote] = useState<RemoteAccessStatus | null>(null);- const [lan, setLan] = useState<LanAccessStatus | null>(null);- const [remoteFailed, setRemoteFailed] = useState(false);- const [lanFailed, setLanFailed] = useState(false);-- useEffect(() => {- let cancelled = false;- let timer: number | undefined;- let settling = false;- // Re-read only mid-transition: a Start left on another tab would otherwise read "Starting" forever.- // A failed read while settling retries too, or the last transitional state would stick.- const readRemote = () => {- loadRemoteAccess()- .then((next) => {- if (cancelled) return;- setRemote(next);- usePlatformStore.setState({ cloudflareUrl: next.url });- settling = next.state === "starting" || next.state === "stopping";- if (settling) {- timer = window.setTimeout(readRemote, remoteAccessPollDelay(next));- }- })- .catch(() => {- if (cancelled) return;- setRemoteFailed(true);- if (settling) {- timer = window.setTimeout(readRemote, remoteAccessPollDelay(null));- }- });- };- readRemote();- loadLanAccess()- .then((next) => {- if (cancelled) return;- setLan(next);- publishLanUrls(next);- })- .catch(() => {- if (!cancelled) setLanFailed(true);- });- return () => {- cancelled = true;- window.clearTimeout(timer);- };- }, []);-- return (- <section- data-settings-label={t("settings.remoteLan.title")}- className="overflow-hidden rounded-xl border border-border/70"- >- <div className="flex items-center justify-between gap-4 bg-muted/30 p-4">- <div className="flex min-w-0 items-start gap-3">- <div className="flex size-8 shrink-0 items-center justify-center rounded-md border border-border/70 bg-muted/40">- <HugeiconsIcon- icon={HomeWifiIcon}- className="size-4 text-foreground"- />- </div>- <div className="flex min-w-0 flex-col gap-0.5">- <h2 className="settings-heading text-base font-semibold font-heading">- {t("settings.remoteLan.title")}- </h2>- <p className="text-xs text-muted-foreground leading-relaxed">- {t("settings.remoteLan.description")}- </p>- </div>- </div>- <Button- type="button"- size="sm"- variant="outline"- className="shrink-0 gap-1.5"- onClick={() =>- useSettingsDialogStore.getState().setActiveTab("remote-lan")- }- >- Manage- <HugeiconsIcon icon={ArrowRight01Icon} className="size-3.5" />- </Button>- </div>- <div className="flex flex-col py-1">- <AccessLine- label="Remote access"- state={remote?.state ?? (remoteFailed ? "unavailable" : null)}- url={remote?.state === "online" ? remote.url : null}- />- <AccessLine- label="LAN access"- state={lan?.state ?? (lanFailed ? "unavailable" : null)}- url={lan?.state === "online" ? (lan.urls[0] ?? null) : null}- />- </div>- </section>- );-}diff --git a/studio/frontend/src/features/settings/components/usage-examples.tsx b/studio/frontend/src/features/settings/components/usage-examples.tsxindex 345a40c8f9f..03d06b04180 100644--- a/studio/frontend/src/features/settings/components/usage-examples.tsx+++ b/studio/frontend/src/features/settings/components/usage-examples.tsx@@ -1,12 +1,13 @@// 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 { createCodePlugin } from "@/components/assistant-ui/code-plugin";import {- unslothDarkTheme,- unslothLightTheme,-} from "@/components/assistant-ui/code-themes";-import { SegmentedPill } from "@/components/segmented-control";+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { Switch } from "@/components/ui/switch";import {Tooltip,@@ -14,6 +15,7 @@ import {TooltipTrigger,} from "@/components/ui/tooltip";import { fetchDeviceType, usePlatformStore } from "@/config/env";+import { useIsAccountOwner } from "@/features/auth";import {getInferenceStatus,isExternalModelId,@@ -28,20 +30,20 @@ import { copyToClipboard } from "@/lib/copy-to-clipboard";import { Tick02Icon } from "@/lib/tick-icon";import { cn } from "@/lib/utils";import {+ ArrowRight01Icon,ArrowUpRight01Icon,+ BotIcon,Copy01Icon,InformationCircleIcon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import {useEffect,- useId,useMemo,useRef,useState,useSyncExternalStore,} from "react";-import { Streamdown } from "streamdown";import { loadCodingAgents } from "../api/coding-agents";import type {KeylessApiAccessExposure,@@ -49,6 +51,7 @@ import type {} from "../api/keyless-api-access";import { loadOpenAIAutoSwitchSettings } from "../api/openai-auto-switch";import { type OpenAIModel, listOpenAIModels } from "../api/openai-models";+import { useSettingsDialogStore } from "../stores/settings-dialog-store";import { useSettingsPanelPrefsStore } from "../stores/settings-panel-prefs-store";import {agentRunsOnActiveModel,@@ -63,6 +66,15 @@ import {shSingle,statusGgufVerdict,} from "./agent-command";+import { AgentIcon } from "./agent-command-block";+import {+ ExampleCodeBox,+ ExampleToggle,+ type ExampleOs,+ isLoopbackUrl,+ useExampleOs,+} from "./api-example-parts";+import { detailsFor } from "./coding-agent-list";import { keylessBaseEligible } from "./keyless-example-eligibility";import {readUseTunnelPref,@@ -80,44 +92,55 @@ type ExampleType =| "curlAdvanced"| "pythonAdvanced"| "javascriptAdvanced";-type Os = "unix" | "windows";+type Os = ExampleOs;type Variant = "plain" | "tools" | "advanced";+type Language = "curl" | "python" | "javascript";-const TYPE_TABS: { id: ExampleType; label: string }[] = [+const LANGUAGES: { id: Language; label: string }[] = [{ id: "curl", label: "curl" },{ id: "python", label: "Python" },{ id: "javascript", label: "JavaScript" },- { id: "curlTools", label: "curl + tools" },- { id: "pythonTools", label: "Python + tools" },- { id: "javascriptTools", label: "JavaScript + tools" },- { id: "curlAdvanced", label: "curl + advanced" },- { id: "pythonAdvanced", label: "Python + advanced" },- { id: "javascriptAdvanced", label: "JavaScript + advanced" },];-// guards a restored tab against a snippet type dropped in a later release.-const EXAMPLE_TYPE_IDS = new Set<string>(TYPE_TABS.map((tab) => tab.id));+const VARIANTS: { id: Variant; labelKey: TranslationKey }[] = [+ { id: "plain", labelKey: "settings.apiKeys.requestPlain" },+ { id: "tools", labelKey: "settings.apiKeys.requestTools" },+ { id: "advanced", labelKey: "settings.apiKeys.requestAdvanced" },+];++// guards a restored pick against a snippet type dropped in a later release.+const EXAMPLE_TYPE_IDS = new Set<string>([+ "curl",+ "python",+ "javascript",+ "curlTools",+ "pythonTools",+ "javascriptTools",+ "curlAdvanced",+ "pythonAdvanced",+ "javascriptAdvanced",+] satisfies ExampleType[]);-const TYPE_LABEL_KEY: Partial<Record<ExampleType, TranslationKey>> = {- curlTools: "settings.apiKeys.exampleCurlTools",- pythonTools: "settings.apiKeys.examplePythonTools",- javascriptTools: "settings.apiKeys.exampleJavaScriptTools",- curlAdvanced: "settings.apiKeys.exampleCurlAdvanced",- pythonAdvanced: "settings.apiKeys.examplePythonAdvanced",- javascriptAdvanced: "settings.apiKeys.exampleJavaScriptAdvanced",-};+function exampleType(language: Language, variant: Variant): ExampleType {+ if (variant === "plain") {+ return language;+ }+ return `${language}${variant === "tools" ? "Tools" : "Advanced"}`;+}-const OS_AWARE: Record<ExampleType, boolean> = {- curl: true,- python: false,- javascript: false,- curlTools: true,- pythonTools: false,- javascriptTools: false,- curlAdvanced: true,- pythonAdvanced: false,- javascriptAdvanced: false,-};+function exampleParts(type: ExampleType): [Language, Variant] {+ const language: Language = type.startsWith("curl")+ ? "curl"+ : type.startsWith("python")+ ? "python"+ : "javascript";+ const variant: Variant = type.endsWith("Tools")+ ? "tools"+ : type.endsWith("Advanced")+ ? "advanced"+ : "plain";+ return [language, variant];+}const CURL_TYPES = new Set<ExampleType>(["curl", "curlTools", "curlAdvanced"]);const JAVASCRIPT_TYPES = new Set<ExampleType>([@@ -138,27 +161,6 @@ const ADV = {max_tokens: 1024,} as const;-const DOC_LINKS = [- { label: "Claude Code", href: "https://unsloth.ai/docs/basics/claude-code" },- { label: "Codex", href: "https://unsloth.ai/docs/basics/codex" },- {- label: "VS Code",- href: "https://code.visualstudio.com/docs/copilot/customization/language-models",- },- {- label: "DeepSeek Harness",- href: "https://github.com/deepseek-ai/deepseek-harness",- },- { label: "OpenCode", href: "https://unsloth.ai/docs/integrations/opencode" },- {- label: "Hermes Agent",- href: "https://unsloth.ai/docs/integrations/hermes-agent",- },- { label: "OpenClaw", href: "https://unsloth.ai/docs/integrations/openclaw" },- { label: "Pi", href: "https://pi.dev" },- { label: "Mistral Vibe", href: "https://github.com/mistralai/mistral-vibe" },-];-// Fallback until the backend's installed-CLI check resolves. Mirrors CODING_AGENTS in// studio/backend/utils/coding_agents.py.const DEFAULT_AGENTS = [@@ -176,17 +178,6 @@ const DEFAULT_AGENTS = [// trustworthy (leaving loopback, or the only compatible detected agent// stops being compatible) rather than lingering on a stale choice.const DEFAULT_AGENT = "claude";-const AGENT_LABELS: Record<string, string> = {- claude: "Claude Code",- codex: "Codex",- vscode: "VS Code",- dsh: "DeepSeek Harness",- opencode: "OpenCode",- hermes: "Hermes",- openclaw: "OpenClaw",- pi: "Pi",- vibe: "Mistral Vibe",-};const j = (s: string): string => JSON.stringify(s);const toolsJson = TOOLS.map(j).join(", ");@@ -398,6 +389,7 @@ function buildSnippets(}const KEY_PLACEHOLDER = "sk-unsloth-YOUR_KEY";+const MODEL_PLACEHOLDER = "YOUR_MODEL";// OpenAI SDKs require an api_key value even for keyless access.const KEYLESS_KEY_PLACEHOLDER = "not-needed";// retry while /v1 has no model because downloads and loads do not update the store.@@ -535,58 +527,6 @@ function canUseLocalAgentDetection(base: string): boolean {}}-function isLoopbackUrl(url: string | null | undefined): boolean {- if (!url) return false;- try {- return isLoopbackHost(normalizeHost(new URL(url).hostname));- } catch {- return false;- }-}--const SHIKI_THEMES = [unslothLightTheme, unslothDarkTheme] as [- typeof unslothLightTheme,- typeof unslothDarkTheme,-];-const codePlugin = createCodePlugin({ themes: SHIKI_THEMES });--export function HighlightedCode({- code,- language,- label,- redactFromReload,-}: {- code: string;- language: string;- label: string;- redactFromReload: boolean;-}) {- const markdown = useMemo(- () => `\`\`\`${language}\n${code}\n\`\`\``,- [code, language],- );- return (- // Intrinsic code width keeps scrolling on the focusable section.- <section- // Safari never focuses a scroller on its own, so long examples need a tab stop.- // biome-ignore lint/a11y/noNoninteractiveTabindex: keyboard-scrollable region- tabIndex={0}- aria-label={label}- className="max-h-96 max-w-full overflow-auto scroll-rounded rounded-lg p-3 pr-16 outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset text-ui-11 leading-relaxed [&_pre]:!m-0 [&_pre]:!whitespace-pre [&_pre]:!break-normal [&_pre]:!border-0 [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:!text-ui-11 [&_pre]:!leading-relaxed [&_code]:!text-ui-11 [&_[data-streamdown=code-block]]:!min-w-max [&_[data-streamdown=code-block]]:!my-0 [&_[data-streamdown=code-block]]:!border-0 [&_[data-streamdown=code-block]]:!bg-transparent [&_[data-streamdown=code-block]]:!p-0 [&_[data-streamdown=code-block]]:!text-ui-11"- data-reload-snapshot-sensitive={redactFromReload ? "" : undefined}- >- <Streamdown- mode="static"- plugins={{ code: codePlugin }}- controls={{ code: false }}- shikiTheme={SHIKI_THEMES}- >- {markdown}- </Streamdown>- </section>- );-}-export function UsageExamples({apiKey,useTunnel,@@ -606,16 +546,15 @@ export function UsageExamples({keylessExposure?: KeylessApiAccessExposure | null;}) {const t = useT();- const pillId = useId();- const deviceType = usePlatformStore((s) => s.deviceType);+ const isOwner = useIsAccountOwner();const cloudflareUrl = usePlatformStore((s) => s.cloudflareUrl);const serverUrl = usePlatformStore((s) => s.serverUrl);const secure = usePlatformStore((s) => s.secure);const setStoredLang = useSettingsPanelPrefsStore((s) => s.setApiExampleLang);- const setStoredOs = useSettingsPanelPrefsStore((s) => s.setApiExampleOs);const setStoredAgent = useSettingsPanelPrefsStore((s) => s.setApiExampleAgent,);+ const setAgentsTabAgent = useSettingsPanelPrefsStore((s) => s.setAgentsAgent);// read once: these seed the controls, which write back through the handlers.const [storedPrefs] = useState(() => useSettingsPanelPrefsStore.getState());const [lang, setLang] = useState<ExampleType>(@@ -624,16 +563,6 @@ export function UsageExamples({? (storedPrefs.apiExampleLang as ExampleType): "curl",);- // an explicit pick wins, since the snippet may target another machine.- const [os, setOs] = useState<Os>(- storedPrefs.apiExampleOs === "windows" ||- storedPrefs.apiExampleOs === "unix"- ? storedPrefs.apiExampleOs- : deviceType === "windows"- ? "windows"- : "unix",- );- const [copied, setCopied] = useState(false);const [copiedUrl, setCopiedUrl] = useState(false);const [copiedAgent, setCopiedAgent] = useState(false);const [agent, setAgent] = useState<string>(@@ -658,6 +587,7 @@ export function UsageExamples({: isTauri? (serverUrl ?? origin): origin;+ const [os, setOs] = useExampleOs(base);const localAgentDetection = canUseLocalAgentDetection(base);const loopbackBind = isLoopbackUrl(serverUrl);// isServedByLlamaCpp owns which store fields count; a context length is not among them,@@ -860,9 +790,10 @@ export function UsageExamples({const agentKey =apiKey || (keylessBase ? KEYLESS_KEY_PLACEHOLDER : KEY_PLACEHOLDER);- // Null model: nothing is servable, so there is no snippet worth copying.+ // Null model: nothing is servable yet, so the example names a placeholder (and the note+ // above it says so) rather than vanishing, which left the pickers looking dead.const snippets = useMemo(- () => (model ? buildSnippets(base, key, toolsKey, model, os) : null),+ () => buildSnippets(base, key, toolsKey, model ?? MODEL_PLACEHOLDER, os),[base, key, toolsKey, model, os],);// Agent command must target the server the panel shows, not the :8888 default.@@ -871,7 +802,6 @@ export function UsageExamples({[base, agentKey, os, agent],);- const osAware = OS_AWARE[lang];const shikiLang = CURL_TYPES.has(lang)? os === "windows"? "powershell"@@ -880,14 +810,6 @@ export function UsageExamples({? "javascript": "python";- const handleCopy = async () => {- if (!snippets) return;- if (await copyToClipboard(snippets[lang])) {- setCopied(true);- setTimeout(() => setCopied(false), 1800);- }- };-const handleCopyUrl = async () => {if (cloudflareUrl && (await copyToClipboard(cloudflareUrl))) {setCopiedUrl(true);@@ -902,261 +824,220 @@ export function UsageExamples({}};+ const [language, variant] = exampleParts(lang);+ const pickExample = (next: ExampleType) => {+ setLang(next);+ setStoredLang(next);+ };+ const agentDetails = detailsFor(agent);+return (- <section className="flex min-w-0 max-w-full flex-col">- <h2 className="settings-heading mb-2 text-sm font-semibold">+ <section className="flex min-w-0 max-w-full flex-col gap-4">+ <h2 className="settings-heading text-sm font-semibold">{t("settings.apiKeys.usageExamples")}</h2>- <div className="min-w-0 max-w-full overflow-hidden rounded-xl border border-border bg-muted/20">- {/* No model-auto-switch row: ModelAutoSwitchSection renders that setting just below. */}- {cloudflareUrl ? (- <div className="flex min-w-0 items-center justify-between gap-2 border-b border-border px-2 py-1.5">- <div className="flex shrink-0 items-center gap-1.5">- <Switch- size="sm"- checked={useTunnel}- onCheckedChange={onUseTunnelChange}- aria-label={t("settings.apiKeys.secureHttps")}- />- <span className="text-ui-11 font-medium text-foreground">- {t("settings.apiKeys.secureHttps")}- {/* Only for a network bind not launched with --secure: its raw port stays- reachable. A loopback bind (the default, and Desktop) exposes nothing. */}- {secure || loopbackBind ? null : (- <Tooltip>- <TooltipTrigger asChild={true}>- {/* Inline on the baseline, like a glyph after the label. */}- <button- type="button"- className="ml-1.5 inline-flex align-baseline rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- aria-label={t("settings.apiKeys.secureHttpsHint")}- >- {/* Follows the UI font size, like the SettingsRow hint- this matches. */}- <HugeiconsIcon- icon={InformationCircleIcon}- className="size-[var(--ui-icon-size-hint)]"- />- </button>- </TooltipTrigger>- <TooltipContent className="max-w-[calc(260px*var(--ui-space-scale,1))] text-ui-11 leading-snug">- {t("settings.apiKeys.secureHttpsHint")}- </TooltipContent>- </Tooltip>- )}- </span>- </div>- <button- type="button"- onClick={handleCopyUrl}- className={cn(- "flex min-w-0 items-center gap-1 rounded-full px-1.5 py-1 text-ui-11 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",- !useTunnel && "opacity-50",+ {/* No model-auto-switch row: ModelAutoSwitchSection renders that setting just below. */}+ {cloudflareUrl ? (+ <div className="flex min-w-0 items-center justify-between gap-2 rounded-lg border border-border px-3 py-2">+ <div className="flex shrink-0 items-center gap-1.5">+ <Switch+ size="sm"+ checked={useTunnel}+ onCheckedChange={onUseTunnelChange}+ aria-label={t("settings.apiKeys.secureHttps")}+ />+ <span className="text-ui-11 font-medium text-foreground">+ {t("settings.apiKeys.secureHttps")}+ {/* Only for a network bind not launched with --secure: its raw port stays+ reachable. A loopback bind (the default, and Desktop) exposes nothing. */}+ {secure || loopbackBind ? null : (+ <Tooltip>+ <TooltipTrigger asChild={true}>+ {/* Inline on the baseline, like a glyph after the label. */}+ <button+ type="button"+ className="ml-1.5 inline-flex align-baseline rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ aria-label={t("settings.apiKeys.secureHttpsHint")}+ >+ {/* Follows the UI font size, like the SettingsRow hint+ this matches. */}+ <HugeiconsIcon+ icon={InformationCircleIcon}+ className="size-[var(--ui-icon-size-hint)]"+ />+ </button>+ </TooltipTrigger>+ <TooltipContent className="max-w-[calc(260px*var(--ui-space-scale,1))] text-ui-11 leading-snug">+ {t("settings.apiKeys.secureHttpsHint")}+ </TooltipContent>+ </Tooltip>)}- title={cloudflareUrl}- aria-label={t("settings.apiKeys.copyTunnelUrl")}- >- <span className="truncate font-mono">{cloudflareUrl}</span>- <HugeiconsIcon- icon={copiedUrl ? Tick02Icon : Copy01Icon}- className={cn(- "size-3.5 shrink-0",- copiedUrl && "text-emerald-600",- )}- />- </button>- </div>- ) : null}- <div className="flex min-w-0 items-center justify-between gap-2 border-b border-border px-2 py-1.5">- <div className="isolate flex min-w-0 flex-wrap items-center gap-0.5">- {TYPE_TABS.map((tab) => {- const active = lang === tab.id;- const labelKey = TYPE_LABEL_KEY[tab.id];- return (- <button- key={tab.id}- type="button"- onClick={() => {- setLang(tab.id);- setStoredLang(tab.id);- }}- aria-pressed={active}- className={cn(- "relative 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",- active- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",- )}- >- {active && <SegmentedPill group={`${pillId}-lang`} />}- {labelKey ? t(labelKey) : tab.label}- </button>- );- })}+ </span></div>- </div>- {osAware ? (- <div className="isolate flex min-w-0 items-center gap-0.5 border-b border-border px-2 py-1.5">- <button- type="button"- onClick={() => {- setOs("unix");- setStoredOs("unix");- }}- aria-pressed={os === "unix"}- className={cn(- "relative 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",- os === "unix"- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",- )}- >- {os === "unix" && <SegmentedPill group={`${pillId}-os`} />}- {t("settings.apiKeys.osUnix")}- </button>- <button- type="button"- onClick={() => {- setOs("windows");- setStoredOs("windows");- }}- aria-pressed={os === "windows"}+ <button+ type="button"+ onClick={handleCopyUrl}+ className={cn(+ "flex min-w-0 items-center gap-1 rounded-full px-1.5 py-1 text-ui-11 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",+ !useTunnel && "opacity-50",+ )}+ title={cloudflareUrl}+ aria-label={t("settings.apiKeys.copyTunnelUrl")}+ >+ <span className="truncate font-mono">{cloudflareUrl}</span>+ <HugeiconsIcon+ icon={copiedUrl ? Tick02Icon : Copy01Icon}className={cn(- "relative 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",- os === "windows"- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",+ "size-3.5 shrink-0",+ copiedUrl && "text-emerald-600",)}- >- {os === "windows" && <SegmentedPill group={`${pillId}-os`} />}- {t("settings.apiKeys.osWindows")}- </button>- </div>- ) : null}- {snippets ? (- <div className="relative min-w-0">- <button- type="button"- onClick={handleCopy}- className="btn-fill absolute right-2 top-2 z-10 flex items-center gap-1 rounded-full px-1.5 py-1 text-ui-11 text-muted-foreground backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- aria-label={t("settings.apiKeys.copySnippet")}- >- <HugeiconsIcon- icon={copied ? Tick02Icon : Copy01Icon}- className={cn("size-3.5", copied && "text-emerald-600")}- />- {copied- ? t("settings.apiKeys.copied")- : t("settings.apiKeys.copy")}- </button>- <HighlightedCode- key={snippets[lang]}- code={snippets[lang]}- language={shikiLang}- label={t("settings.apiKeys.usageExamples")}- redactFromReload={Boolean(apiKey)}/>- </div>- ) : (- <div className="min-w-0 px-3 py-2.5 text-ui-11 leading-snug text-muted-foreground">- {t("settings.apiKeys.usageNoModel")}- </div>- )}- <div className="flex min-w-0 flex-col gap-1.5 border-t border-border px-3 py-2.5">- <span className="text-ui-11 font-semibold text-foreground">+ </button>+ </div>+ ) : null}+ <ExampleToggle+ label={t("settings.apiKeys.exampleRequest")}+ variant="toggle"+ value={variant}+ options={VARIANTS.map((option) => ({+ id: option.id,+ label: t(option.labelKey),+ }))}+ onChange={(next) => pickExample(exampleType(language, next))}+ />+ {model ? null : (+ <p className="text-ui-11 leading-relaxed text-muted-foreground">+ {t("settings.apiKeys.usageNoModel")}+ </p>+ )}+ <ExampleCodeBox+ code={snippets[lang]}+ language={shikiLang}+ label={t("settings.apiKeys.usageExamples")}+ redactFromReload={Boolean(apiKey)}+ pills={+ <ExampleToggle+ label={t("settings.apiKeys.exampleLanguage")}+ value={language}+ options={LANGUAGES}+ onChange={(next) => pickExample(exampleType(next, variant))}+ />+ }+ os={os}+ onOsChange={setOs}+ />+ <div className="flex min-w-0 flex-col gap-2.5 pt-2">+ <div className="flex h-5 items-center justify-between gap-3">+ <span className="text-xs font-medium text-foreground">{t("settings.apiKeys.codingAgents")}</span>- <span className="text-ui-11 leading-snug text-muted-foreground">- {t("settings.apiKeys.codingAgentsHint")}- </span>- <div className="isolate flex min-w-0 flex-wrap items-center gap-1">- {availableAgents.map((id) => {- const installed = detectedAgents.includes(id);- const active = agent === id;- return (- <button- key={id}- type="button"- onClick={() => {- agentPickedByUserRef.current = true;- clickedUnderGgufRef.current = isGguf;- setAgent(id);- setStoredAgent(id);- }}- aria-pressed={active}- title={- installed- ? t("settings.apiKeys.codingAgentDetected")- : undefined- }- className={cn(- "relative flex items-center gap-1 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",- active- ? "text-foreground"- : "text-muted-foreground hover:text-foreground",- )}- >- {active && <SegmentedPill group={`${pillId}-agent`} />}- {AGENT_LABELS[id] ?? id}- {installed ? (- <span- aria-hidden="true"- className="size-1.5 rounded-full bg-emerald-500"- />- ) : null}- </button>- );- })}- </div>- <div className="relative mt-0.5 min-w-0">- <code- className="block min-w-0 overflow-x-auto rounded-full border border-border bg-muted/30 px-2 py-1.5 pr-14 font-mono text-ui-11 text-foreground"- data-reload-snapshot-sensitive={apiKey ? "" : undefined}- >- {agentCommand}- </code>+ {/* Agents is owner-only (settings-tab-visibility.ts): other accounts would land+ on General, so they get the agent's docs instead. The tab restores its agent+ from this pref when it mounts. */}+ {isOwner ? (<buttontype="button"- onClick={handleCopyAgent}- className="btn-fill absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-1 rounded-full px-1.5 py-0.5 text-ui-11 text-muted-foreground backdrop-blur transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"- aria-label={t("settings.apiKeys.copySnippet")}+ onClick={() => {+ setAgentsTabAgent(agent);+ useSettingsDialogStore.getState().setActiveTab("agents");+ }}+ className="inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-ui-11 font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">- <HugeiconsIcon- icon={copiedAgent ? Tick02Icon : Copy01Icon}- className={cn("size-3.5", copiedAgent && "text-emerald-600")}- />+ <HugeiconsIcon icon={BotIcon} className="size-3.5" />+ {t("settings.apiKeys.openAgentsTab")}+ <HugeiconsIcon icon={ArrowRight01Icon} className="size-3" /></button>- </div>- {agent === "vscode" && (- <span className="text-ui-11 leading-snug text-muted-foreground">- {t("settings.agents.vscodeNote")}- </span>- )}- {detectedAgents.length > 0 ? (- <span className="text-ui-11 leading-snug text-muted-foreground">- {t("settings.apiKeys.codingAgentsDetectedHint", {- agents: detectedAgents- .map((id) => AGENT_LABELS[id] ?? id)- .join(", "),- })}- </span>- ) : null}- </div>- <div className="flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-border px-3 py-2 text-ui-11 text-muted-foreground">- <span>{t("settings.apiKeys.setupDocs")}</span>- {DOC_LINKS.map((link) => (+ ) : (<a- key={link.href}- href={link.href}+ href={agentDetails.docsUrl}target="_blank"rel="noreferrer"- className="inline-flex items-center gap-0.5 rounded-full font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ aria-label={t("settings.agents.agentDocs", {+ agent: agentDetails.name,+ })}+ className="inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-ui-11 font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">- {link.label}+ {t("settings.agents.docs")}<HugeiconsIcon icon={ArrowUpRight01Icon} className="size-3" /></a>- ))}+ )}</div>+ <p className="text-ui-11 leading-relaxed text-muted-foreground">+ {t("settings.apiKeys.codingAgentsHint")}+ </p>+ <div className="@container">+ <div className="grid grid-cols-1 items-start gap-3 @[34rem]:grid-cols-3">+ <div className="min-w-0">+ <Select+ value={agent}+ onValueChange={(id) => {+ agentPickedByUserRef.current = true;+ clickedUnderGgufRef.current = isGguf;+ setAgent(id);+ setStoredAgent(id);+ }}+ >+ <SelectTrigger+ aria-label={t("settings.agents.agent")}+ className="w-full rounded-lg"+ >+ <SelectValue>+ <span className="flex min-w-0 items-center gap-2">+ <AgentIcon {...agentDetails} />+ <span className="truncate">{agentDetails.name}</span>+ </span>+ </SelectValue>+ </SelectTrigger>+ {/* Seven 36px rows, as on the Agents tab; the rest scroll. */}+ <SelectContent+ align="start"+ className="max-h-[min(var(--radix-select-content-available-height),calc(7*2.25rem+0.5rem))] [&_[data-slot=select-scroll-down-button]]:hidden [&_[data-slot=select-scroll-up-button]]:hidden"+ >+ {availableAgents.map((id) => {+ const details = detailsFor(id);+ return (+ <SelectItem key={id} value={id}>+ <span className="flex min-w-0 items-center gap-2">+ <AgentIcon {...details} />+ <span className="truncate">{details.name}</span>+ {detectedAgents.includes(id) ? (+ <span className="shrink-0 rounded-full bg-control-accent/10 px-2 py-1 text-ui-10 leading-none font-semibold text-control-accent">+ {t("settings.agents.quickstart.installed")}+ </span>+ ) : null}+ </span>+ </SelectItem>+ );+ })}+ </SelectContent>+ </Select>+ </div>+ </div>+ </div>+ <div className="relative min-w-0">+ <code+ className="block min-w-0 whitespace-pre-wrap break-all rounded-lg border border-border bg-background/70 py-2.5 pr-9 pl-4 font-mono text-ui-11 leading-relaxed text-foreground dark:border-transparent dark:bg-[rgb(255_255_255_/_calc(0.05*var(--contrast-wash-gain,1)))]"+ data-reload-snapshot-sensitive={apiKey ? "" : undefined}+ >+ {agentCommand}+ </code>+ <button+ type="button"+ onClick={handleCopyAgent}+ className="absolute top-1.5 right-1.5 flex size-6 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"+ aria-label={t("settings.apiKeys.copySnippet")}+ >+ <HugeiconsIcon+ icon={copiedAgent ? Tick02Icon : Copy01Icon}+ className={cn("size-3.5", copiedAgent && "text-control-accent")}+ />+ </button>+ </div>+ {agent === "vscode" && (+ <p className="text-ui-11 leading-relaxed text-muted-foreground">+ {t("settings.agents.vscodeNote")}+ </p>+ )}</div></section>);diff --git a/studio/frontend/src/features/settings/hooks/use-publish-access-urls.ts b/studio/frontend/src/features/settings/hooks/use-publish-access-urls.tsnew file mode 100644index 00000000000..b149b7b830a--- /dev/null+++ b/studio/frontend/src/features/settings/hooks/use-publish-access-urls.ts@@ -0,0 +1,48 @@+// 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 { usePlatformStore } from "@/config/env";+import { useEffect } from "react";+import { loadLanAccess, publishLanUrls } from "../api/lan-access";+import { loadRemoteAccess } from "../api/remote-access";+import { remoteAccessPollDelay } from "../api/remote-access-state";++/**+ * Publishes the tunnel and LAN URLs the API examples build on, without the Remote & LAN panels.+ */+export function usePublishAccessUrls(enabled: boolean) {+ useEffect(() => {+ if (!enabled) return;+ let cancelled = false;+ let timer: number | undefined;+ let settling = false;+ // Re-read only mid-transition: a Start left on another tab publishes its URL once the tunnel is up.+ // A failed read while settling retries too, or the last transitional state would stick.+ const readRemote = () => {+ loadRemoteAccess()+ .then((next) => {+ if (cancelled) return;+ usePlatformStore.setState({ cloudflareUrl: next.url });+ settling = next.state === "starting" || next.state === "stopping";+ if (settling) {+ timer = window.setTimeout(readRemote, remoteAccessPollDelay(next));+ }+ })+ .catch(() => {+ if (!cancelled && settling) {+ timer = window.setTimeout(readRemote, remoteAccessPollDelay(null));+ }+ });+ };+ readRemote();+ loadLanAccess()+ .then((next) => {+ if (!cancelled) publishLanUrls(next);+ })+ .catch(() => undefined);+ return () => {+ cancelled = true;+ window.clearTimeout(timer);+ };+ }, [enabled]);+}diff --git a/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx b/studio/frontend/src/features/settings/tabs/api-keys-tab.tsxindex 19acdc51310..72661184ffe 100644--- a/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx@@ -31,8 +31,8 @@ import { McpAccessSection } from "../components/mcp-access-section";import { ModelAliasesSection } from "../components/model-aliases-section";import { ModelAutoSwitchSection } from "../components/model-auto-switch-section";import { MonitorLink } from "../components/monitor-link";-import { RemoteLanSummary } from "../components/remote-lan-summary";import { UsageExamples, useApiTunnelPref } from "../components/usage-examples";+import { usePublishAccessUrls } from "../hooks/use-publish-access-urls";export function ApiKeysTab() {const t = useT();@@ -45,6 +45,8 @@ export function ApiKeysTab() {const [revoking, setRevoking] = useState(false);const [revealed, setRevealed] = useState<string | null>(null);const [useTunnel, setUseTunnel] = useApiTunnelPref();+ // Owner-only routes, as the Remote & LAN tab is.+ usePublishAccessUrls(isOwner);const [keyless, setKeyless] = useState<{scope: KeylessApiAccessScope;tools: boolean;@@ -213,8 +215,6 @@ export function ApiKeysTab() {<><KeylessApiAccessSection onSettingsChange={setKeyless} />- <RemoteLanSummary />-<ModelAutoSwitchSection /><ModelAliasesSection />diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex dc6bfe07eb2..d55134d29a7 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -3114,12 +3114,13 @@ export const ar = {copyNow: "انسخه الآن - لن يُعرض مرة أخرى.",usageExamples: "أمثلة الاستخدام",usageTools: "الأدوات",- exampleCurlTools: "curl + أدوات",- examplePythonTools: "Python + أدوات",- exampleJavaScriptTools: "JavaScript + أدوات",- exampleCurlAdvanced: "curl + متقدم",- examplePythonAdvanced: "Python + متقدم",- exampleJavaScriptAdvanced: "JavaScript + متقدم",+ exampleLanguage: "اللغة",+ exampleRequest: "الطلب",+ examplePlatform: "المنصة",+ requestPlain: "أساسي",+ requestTools: "مع الأدوات",+ requestAdvanced: "أخذ عينات متقدم",+ exampleKind: "المثال",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS آمن",@@ -3129,13 +3130,11 @@ export const ar = {copySnippet: "نسخ المقتطف",copy: "نسخ",copied: "تم النسخ",- setupDocs: "وثائق الإعداد:",codingAgents: "وكلاء البرمجة",codingAgentsHint:"شغّل وكيل برمجة متصلًا بهذا الخادم. يستخدم الوكيل النموذج المُحمَّل؛ وينشئ الخادم المحلي مفتاح API تلقائيًا، بينما يضمّنه الخادم البعيد في الأمر.",+ openAgentsTab: "فتح في الوكلاء",codingAgentsSwap: "استبدل claude بـ codex أو openclaw أو opencode أو hermes.",- codingAgentDetected: "مثبّت على هذا الجهاز",- codingAgentsDetectedHint: "وكلاء البرمجة المكتشفون على هذا الجهاز: {agents}.",relativeNever: "لا يوجد",relativeJustNow: "للتوّ",expired: "منتهي الصلاحية",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 6dbfe165b50..6d417c3bba4 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -3160,12 +3160,13 @@ export const de = {copyNow: "Jetzt kopieren - es wird nicht erneut angezeigt.",usageExamples: "Nutzungsbeispiele",usageTools: "Tools",- exampleCurlTools: "curl + Tools",- examplePythonTools: "Python + Tools",- exampleJavaScriptTools: "JavaScript + Tools",- exampleCurlAdvanced: "curl + erweitert",- examplePythonAdvanced: "Python + erweitert",- exampleJavaScriptAdvanced: "JavaScript + erweitert",+ exampleLanguage: "Sprache",+ exampleRequest: "Anfrage",+ examplePlatform: "Plattform",+ requestPlain: "Einfach",+ requestTools: "Mit Tools",+ requestAdvanced: "Erweitertes Sampling",+ exampleKind: "Beispiel",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "Sicheres HTTPS",@@ -3175,14 +3176,12 @@ export const de = {copySnippet: "Snippet kopieren",copy: "Kopieren",copied: "Kopiert",- setupDocs: "Einrichtungsdokumentation:",codingAgents: "Coding-Agents",codingAgentsHint:"Starten Sie einen Coding-Agenten für diesen Server. Er verwendet das geladene Modell; ein lokaler Server erstellt automatisch einen API-Schlüssel, ein Remote-Server fügt ihn dem Befehl hinzu.",+ openAgentsTab: "In Agenten öffnen",codingAgentsSwap:"Ersetzen Sie claude durch codex, openclaw, opencode oder hermes.",- codingAgentDetected: "Auf diesem Gerät installiert",- codingAgentsDetectedHint: "Auf diesem Gerät erkannt: {agents}.",relativeNever: "nie",relativeJustNow: "gerade eben",expired: "abgelaufen",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 56d4d1d8e20..6b5c43fa939 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -3172,12 +3172,13 @@ export const en = {usageNoModel:"Load or download a model to see runnable examples. This server has no model to name yet.",usageTools: "Tools",- exampleCurlTools: "curl + tools",- examplePythonTools: "Python + tools",- exampleJavaScriptTools: "JavaScript + tools",- exampleCurlAdvanced: "curl + advanced",- examplePythonAdvanced: "Python + advanced",- exampleJavaScriptAdvanced: "JavaScript + advanced",+ exampleLanguage: "Language",+ exampleRequest: "Request",+ examplePlatform: "Platform",+ requestPlain: "Basic",+ requestTools: "With tools",+ requestAdvanced: "Advanced sampling",+ exampleKind: "Example",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "Secure HTTPS",@@ -3187,13 +3188,11 @@ export const en = {copySnippet: "Copy snippet",copy: "Copy",copied: "Copied",- setupDocs: "Setup docs:",codingAgents: "Coding agents",codingAgentsHint:"Launch a coding agent against this server. It uses the loaded model; a local server mints an API key automatically, a remote one includes it in the command.",+ openAgentsTab: "Open in Agents",codingAgentsSwap: "Swap claude for codex, openclaw, opencode, or hermes.",- codingAgentDetected: "Installed on this machine",- codingAgentsDetectedHint: "Detected on this machine: {agents}.",relativeNever: "never",relativeJustNow: "just now",expired: "expired",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex c30047a278b..8c7897dfc6d 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -3153,12 +3153,13 @@ export const es = {copyNow: "Cópialo ahora: no se volverá a mostrar.",usageExamples: "Ejemplos de uso",usageTools: "Herramientas",- exampleCurlTools: "curl + herramientas",- examplePythonTools: "Python + herramientas",- exampleJavaScriptTools: "JavaScript + herramientas",- exampleCurlAdvanced: "curl + avanzado",- examplePythonAdvanced: "Python + avanzado",- exampleJavaScriptAdvanced: "JavaScript + avanzado",+ exampleLanguage: "Lenguaje",+ exampleRequest: "Solicitud",+ examplePlatform: "Plataforma",+ requestPlain: "Básica",+ requestTools: "Con herramientas",+ requestAdvanced: "Muestreo avanzado",+ exampleKind: "Ejemplo",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS seguro",@@ -3168,14 +3169,12 @@ export const es = {copySnippet: "Copiar fragmento",copy: "Copiar",copied: "Copiado",- setupDocs: "Documentación de configuración:",codingAgents: "Agentes de programación",codingAgentsHint:"Inicia un agente de programación conectado a este servidor. Usa el modelo cargado; un servidor local genera una clave de API automáticamente y uno remoto la incluye en el comando.",+ openAgentsTab: "Abrir en Agentes",codingAgentsSwap:"Reemplaza claude por codex, openclaw, opencode o hermes.",- codingAgentDetected: "Instalado en esta máquina",- codingAgentsDetectedHint: "Detectados en esta máquina: {agents}.",relativeNever: "nunca",relativeJustNow: "justo ahora",expired: "caducado",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex dff569d56b9..27a335c8943 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -3161,12 +3161,13 @@ export const fr = {copyNow: "Copiez le jeton maintenant : il ne sera plus affiché.",usageExamples: "Exemples d'utilisation",usageTools: "Outils",- exampleCurlTools: "curl + outils",- examplePythonTools: "Python + outils",- exampleJavaScriptTools: "JavaScript + outils",- exampleCurlAdvanced: "curl + avancé",- examplePythonAdvanced: "Python + avancé",- exampleJavaScriptAdvanced: "JavaScript + avancé",+ exampleLanguage: "Langage",+ exampleRequest: "Requête",+ examplePlatform: "Plateforme",+ requestPlain: "Simple",+ requestTools: "Avec outils",+ requestAdvanced: "Échantillonnage avancé",+ exampleKind: "Exemple",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS sécurisé",@@ -3176,14 +3177,12 @@ export const fr = {copySnippet: "Copier l'extrait",copy: "Copier",copied: "Copié",- setupDocs: "Documentation de configuration :",codingAgents: "Agents de codage",codingAgentsHint:"Lancez un agent de codage sur ce serveur. Il utilise le modèle chargé ; un serveur local génère automatiquement une clé API, un serveur distant l'inclut dans la commande.",+ openAgentsTab: "Ouvrir dans Agents",codingAgentsSwap:"Remplacez claude par codex, openclaw, opencode ou hermes.",- codingAgentDetected: "Installé sur cette machine",- codingAgentsDetectedHint: "Détecté sur cette machine : {agents}.",relativeNever: "jamais",relativeJustNow: "à l'instant",expired: "expiré",diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.tsindex 028f41de2c4..164261f1b0f 100644--- a/studio/frontend/src/i18n/locales/he.ts+++ b/studio/frontend/src/i18n/locales/he.ts@@ -3234,12 +3234,13 @@ export const he = {usageNoModel:"טען או הורד מודל כדי לראות דוגמאות הניתנות להרצה. בשרת זה עדיין אין מודל זמין.",usageTools: "כלים",- exampleCurlTools: "curl + כלים",- examplePythonTools: "Python + כלים",- exampleJavaScriptTools: "JavaScript + כלים",- exampleCurlAdvanced: "curl + מתקדם",- examplePythonAdvanced: "Python + מתקדם",- exampleJavaScriptAdvanced: "JavaScript + מתקדם",+ exampleLanguage: "שפה",+ exampleRequest: "בקשה",+ examplePlatform: "פלטפורמה",+ requestPlain: "בסיסי",+ requestTools: "עם כלים",+ requestAdvanced: "דגימה מתקדמת",+ exampleKind: "דוגמה",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS מאובטח",@@ -3249,13 +3250,11 @@ export const he = {copySnippet: "העתק קטע קוד",copy: "העתק",copied: "הועתק",- setupDocs: "תיעוד הגדרה:",codingAgents: "סוכני תכנות",codingAgentsHint:"הפעל סוכן תכנות מול שרת זה. הוא משתמש במודל הנטען; שרת מקומי מנפיק מפתח API אוטומטית, ושרת מרוחק כולל אותו בפקודה.",+ openAgentsTab: "פתח בסוכנים",codingAgentsSwap: "החלף את claude ב-codex, openclaw, opencode או hermes.",- codingAgentDetected: "מותקן במחשב זה",- codingAgentsDetectedHint: "זוהו במחשב זה: {agents}.",relativeNever: "אף פעם",relativeJustNow: "זה עתה",expired: "פג תוקף",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex 76c1018de7f..ceec6ca410b 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -3123,12 +3123,13 @@ export const hi = {copyNow: "अभी कॉपी करें। यह दोबारा नहीं दिखाया जाएगा।",usageExamples: "उपयोग उदाहरण",usageTools: "टूल",- exampleCurlTools: "curl + टूल",- examplePythonTools: "Python + टूल",- exampleJavaScriptTools: "JavaScript + टूल",- exampleCurlAdvanced: "curl + उन्नत",- examplePythonAdvanced: "Python + उन्नत",- exampleJavaScriptAdvanced: "JavaScript + उन्नत",+ exampleLanguage: "भाषा",+ exampleRequest: "अनुरोध",+ examplePlatform: "प्लेटफ़ॉर्म",+ requestPlain: "बुनियादी",+ requestTools: "टूल के साथ",+ requestAdvanced: "उन्नत सैंपलिंग",+ exampleKind: "उदाहरण",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "सुरक्षित HTTPS",@@ -3138,13 +3139,11 @@ export const hi = {copySnippet: "स्निपेट कॉपी करें",copy: "कॉपी करें",copied: "कॉपी किया गया",- setupDocs: "सेटअप दस्तावेज़:",codingAgents: "कोडिंग एजेंट",codingAgentsHint:"इस सर्वर से कनेक्ट करके कोडिंग एजेंट चलाएँ। यह लोड किए गए मॉडल का उपयोग करता है। स्थानीय सर्वर अपने-आप API कुंजी बनाता है, जबकि रिमोट सर्वर उसे कमांड में शामिल करता है।",+ openAgentsTab: "एजेंट में खोलें",codingAgentsSwap: "claude को codex, openclaw, opencode, या hermes से बदलें।",- codingAgentDetected: "इस मशीन पर इंस्टॉल है",- codingAgentsDetectedHint: "इस मशीन पर मिले एजेंट: {agents}।",relativeNever: "कभी नहीं",relativeJustNow: "अभी",expired: "समाप्त",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex bfc8892a80b..e8f3e02d707 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -3064,12 +3064,13 @@ export const it = {usageNoModel:"Carica o scarica un modello per vedere esempi eseguibili. Su questo server non è ancora disponibile alcun modello da usare negli esempi.",usageTools: "Strumenti",- exampleCurlTools: "curl + strumenti",- examplePythonTools: "Python + strumenti",- exampleJavaScriptTools: "JavaScript + strumenti",- exampleCurlAdvanced: "curl + avanzato",- examplePythonAdvanced: "Python + avanzato",- exampleJavaScriptAdvanced: "JavaScript + avanzato",+ exampleLanguage: "Linguaggio",+ exampleRequest: "Richiesta",+ examplePlatform: "Piattaforma",+ requestPlain: "Base",+ requestTools: "Con strumenti",+ requestAdvanced: "Campionamento avanzato",+ exampleKind: "Esempio",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS sicuro",@@ -3079,14 +3080,12 @@ export const it = {copySnippet: "Copia lo snippet",copy: "Copia",copied: "Copiato",- setupDocs: "Documentazione di configurazione:",codingAgents: "Agenti di programmazione",codingAgentsHint:"Avvia un agente di programmazione configurato per usare questo server. Usa il modello caricato; un server locale genera automaticamente una chiave API, mentre uno remoto la include nel comando.",+ openAgentsTab: "Apri in Agenti",codingAgentsSwap:"Sostituisci claude con codex, openclaw, opencode o hermes.",- codingAgentDetected: "Installato su questo computer",- codingAgentsDetectedHint: "Rilevati su questo computer: {agents}.",relativeNever: "mai",relativeJustNow: "proprio ora",expired: "scaduta",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex e698fbd55c1..ed5ac5826a0 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -3089,12 +3089,13 @@ export const ja = {copyNow: "今すぐコピーしてください - これは二度と表示されません。",usageExamples: "使用例",usageTools: "ツール",- exampleCurlTools: "curl + ツール",- examplePythonTools: "Python + ツール",- exampleJavaScriptTools: "JavaScript + ツール",- exampleCurlAdvanced: "curl + 高度な設定",- examplePythonAdvanced: "Python + 高度な設定",- exampleJavaScriptAdvanced: "JavaScript + 高度な設定",+ exampleLanguage: "言語",+ exampleRequest: "リクエスト",+ examplePlatform: "プラットフォーム",+ requestPlain: "基本",+ requestTools: "ツールあり",+ requestAdvanced: "詳細なサンプリング",+ exampleKind: "例",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "セキュア HTTPS",@@ -3103,12 +3104,10 @@ export const ja = {copySnippet: "スニペットをコピー",copy: "コピー",copied: "コピーしました",- setupDocs: "セットアップドキュメント:",codingAgents: "コーディングエージェント",codingAgentsHint: "このサーバーに対してコーディングエージェントを起動します。読み込み済みのモデルを使用します。ローカルサーバーでは API キーが自動的に発行され、リモートサーバーではコマンドに含まれます。",+ openAgentsTab: "エージェントで開く",codingAgentsSwap: "claude を codex、openclaw、opencode、hermes に置き換えられます。",- codingAgentDetected: "このマシンにインストール済み",- codingAgentsDetectedHint: "このマシンで検出されました: {agents}。",relativeNever: "なし",relativeJustNow: "たった今",expired: "期限切れ",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex db04298e50c..068ac7debc1 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -3102,12 +3102,13 @@ export const ko = {copyNow: "지금 복사하세요. 이 토큰은 다시 표시되지 않습니다.",usageExamples: "사용 예시",usageTools: "도구",- exampleCurlTools: "curl + 도구",- examplePythonTools: "Python + 도구",- exampleJavaScriptTools: "JavaScript + 도구",- exampleCurlAdvanced: "curl + 고급",- examplePythonAdvanced: "Python + 고급",- exampleJavaScriptAdvanced: "JavaScript + 고급",+ exampleLanguage: "언어",+ exampleRequest: "요청",+ examplePlatform: "플랫폼",+ requestPlain: "기본",+ requestTools: "도구 사용",+ requestAdvanced: "고급 샘플링",+ exampleKind: "예제",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "보안 HTTPS",@@ -3117,13 +3118,11 @@ export const ko = {copySnippet: "스니펫 복사",copy: "복사",copied: "복사됨",- setupDocs: "설정 문서:",codingAgents: "코딩 에이전트",codingAgentsHint:"이 서버에 연결된 코딩 에이전트를 실행합니다. 로드된 모델을 사용하며, 로컬 서버에서는 API 키를 자동으로 발급하고 원격 서버에서는 명령에 API 키를 포함합니다.",+ openAgentsTab: "에이전트에서 열기",codingAgentsSwap: "claude를 codex, openclaw, opencode 또는 hermes로 바꾸세요.",- codingAgentDetected: "이 컴퓨터에 설치됨",- codingAgentsDetectedHint: "이 컴퓨터에서 감지됨: {agents}.",relativeNever: "없음",relativeJustNow: "방금",expired: "만료됨",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 96385655fcb..bebb2937286 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -3133,12 +3133,13 @@ export const ptBR = {copyNow: "Copie agora. O token não será exibido novamente.",usageExamples: "Exemplos de uso",usageTools: "Ferramentas",- exampleCurlTools: "curl + ferramentas",- examplePythonTools: "Python + ferramentas",- exampleJavaScriptTools: "JavaScript + ferramentas",- exampleCurlAdvanced: "curl + avançado",- examplePythonAdvanced: "Python + avançado",- exampleJavaScriptAdvanced: "JavaScript + avançado",+ exampleLanguage: "Linguagem",+ exampleRequest: "Requisição",+ examplePlatform: "Plataforma",+ requestPlain: "Básica",+ requestTools: "Com ferramentas",+ requestAdvanced: "Amostragem avançada",+ exampleKind: "Exemplo",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "HTTPS seguro",@@ -3148,13 +3149,11 @@ export const ptBR = {copySnippet: "Copiar trecho de código",copy: "Copiar",copied: "Copiado",- setupDocs: "Docs de configuração:",codingAgents: "Agentes de código",codingAgentsHint:"Inicie um agente de código conectado a este servidor. Ele usa o modelo carregado; um servidor local gera uma chave de API automaticamente, um remoto a inclui no comando.",+ openAgentsTab: "Abrir em Agentes",codingAgentsSwap: "Troque claude por codex, openclaw, opencode ou hermes.",- codingAgentDetected: "Instalado nesta máquina",- codingAgentsDetectedHint: "Detectados nesta máquina: {agents}.",relativeNever: "nunca",relativeJustNow: "agora mesmo",expired: "expirado",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex f3d36815364..499cd2ed3f9 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -3130,12 +3130,13 @@ export const ru = {copyNow: "Скопируйте сейчас: он больше не будет показан.",usageExamples: "Примеры использования",usageTools: "Инструменты",- exampleCurlTools: "curl + инструменты",- examplePythonTools: "Python + инструменты",- exampleJavaScriptTools: "JavaScript + инструменты",- exampleCurlAdvanced: "curl + расширенное",- examplePythonAdvanced: "Python + расширенное",- exampleJavaScriptAdvanced: "JavaScript + расширенное",+ exampleLanguage: "Язык",+ exampleRequest: "Запрос",+ examplePlatform: "Платформа",+ requestPlain: "Простой",+ requestTools: "С инструментами",+ requestAdvanced: "Расширенная выборка",+ exampleKind: "Пример",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "Защищённый HTTPS",@@ -3145,13 +3146,11 @@ export const ru = {copySnippet: "Копировать фрагмент",copy: "Копировать",copied: "Скопировано",- setupDocs: "Документация по настройке:",codingAgents: "Кодинг-агенты",codingAgentsHint:"Запустите кодинг-агента, подключив его к этому серверу. Он будет использовать загруженную модель; локальный сервер автоматически создаст ключ API, а удалённый добавит его в команду.",+ openAgentsTab: "Открыть в разделе «Агенты»",codingAgentsSwap: "Замените claude на codex, openclaw, opencode или hermes.",- codingAgentDetected: "Установлен на этой машине",- codingAgentsDetectedHint: "Обнаружены на этой машине: {agents}.",relativeNever: "никогда",relativeJustNow: "только что",expired: "истёк",diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.tsindex 0efa6ab6aa7..87441148e0f 100644--- a/studio/frontend/src/i18n/locales/sv.ts+++ b/studio/frontend/src/i18n/locales/sv.ts@@ -3333,12 +3333,13 @@ export const sv = {usageNoModel:"Läs in eller hämta en modell för att se exempel som går att köra. Den här servern har ännu ingen modell att ange.",usageTools: "Verktyg",- exampleCurlTools: "curl + verktyg",- examplePythonTools: "Python + verktyg",- exampleJavaScriptTools: "JavaScript + verktyg",- exampleCurlAdvanced: "curl + avancerat",- examplePythonAdvanced: "Python + avancerat",- exampleJavaScriptAdvanced: "JavaScript + avancerat",+ exampleLanguage: "Språk",+ exampleRequest: "Förfrågan",+ examplePlatform: "Plattform",+ requestPlain: "Grundläggande",+ requestTools: "Med verktyg",+ requestAdvanced: "Avancerad sampling",+ exampleKind: "Exempel",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "Säker HTTPS",@@ -3348,14 +3349,12 @@ export const sv = {copySnippet: "Kopiera kodstycke",copy: "Kopiera",copied: "Kopierat",- setupDocs: "Installationsdokumentation:",codingAgents: "Kodagenter",codingAgentsHint:"Starta en kodagent mot den här servern. Den använder den inlästa modellen; en lokal server skapar automatiskt en API-nyckel, medan en fjärrserver inkluderar den i kommandot.",+ openAgentsTab: "Öppna i Agenter",codingAgentsSwap:"Byt ut claude mot codex, openclaw, opencode eller hermes.",- codingAgentDetected: "Installerad på den här datorn",- codingAgentsDetectedHint: "Identifierade på den här datorn: {agents}.",relativeNever: "aldrig",relativeJustNow: "just nu",expired: "har löpt ut",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex a1c73ef8f85..fdbe19b328f 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -3060,12 +3060,13 @@ export const zhCN = {copyNow: "请立即复制,此 token 不会再次显示。",usageExamples: "使用示例",usageTools: "工具",- exampleCurlTools: "curl + 工具",- examplePythonTools: "Python + 工具",- exampleJavaScriptTools: "JavaScript + 工具",- exampleCurlAdvanced: "curl + 高级",- examplePythonAdvanced: "Python + 高级",- exampleJavaScriptAdvanced: "JavaScript + 高级",+ exampleLanguage: "语言",+ exampleRequest: "请求",+ examplePlatform: "平台",+ requestPlain: "基础",+ requestTools: "使用工具",+ requestAdvanced: "高级采样",+ exampleKind: "示例",osUnix: "Linux / macOS / WSL",osWindows: "Windows",secureHttps: "安全 HTTPS",@@ -3075,13 +3076,11 @@ export const zhCN = {copySnippet: "复制代码片段",copy: "复制",copied: "已复制",- setupDocs: "配置文档:",codingAgents: "编程智能体",codingAgentsHint:"针对此服务器启动编程智能体。它会使用已加载的模型;本地服务器会自动生成 API 密钥,远程服务器则会将其包含在命令中。",+ openAgentsTab: "在智能体中打开",codingAgentsSwap: "可将 claude 替换为 codex、openclaw、opencode 或 hermes。",- codingAgentDetected: "已安装在本机",- codingAgentsDetectedHint: "本机检测到:{agents}。",relativeNever: "从未",relativeJustNow: "刚刚",expired: "已过期",diff --git a/studio/frontend/tests/agent-docs-links.test.ts b/studio/frontend/tests/agent-docs-links.test.tsnew file mode 100644index 00000000000..edf2bb3cb47--- /dev/null+++ b/studio/frontend/tests/agent-docs-links.test.ts@@ -0,0 +1,150 @@+// 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 {+ SUPPORTED_AGENTS,+ UNSLOTH_START_DOCS_URL,+} from "../src/features/settings/components/coding-agent-list.ts";+import { readSrc } from "./helpers/kit.ts";++test("Pi and Mistral Vibe docs open the unsloth start page", () => {+ for (const id of ["pi", "vibe"]) {+ const agent = SUPPORTED_AGENTS.find((a) => a.id === id);+ assert.equal(agent?.docsUrl, UNSLOTH_START_DOCS_URL, id);+ }+});++test("the API tab hands owners to the Agents tab and gives other accounts the agent's docs", () => {+ const src = readSrc("features/settings/components/usage-examples.tsx");+ assert.match(+ src,+ /\{isOwner \? \([\s\S]*?setAgentsTabAgent\(agent\);\s*useSettingsDialogStore\.getState\(\)\.setActiveTab\("agents"\);[\s\S]*?\) : \([\s\S]*?href=\{agentDetails\.docsUrl\}/,+ );+ const visibility = readSrc("features/settings/settings-tab-visibility.ts");+ assert.match(visibility, /OWNER_ONLY_SETTINGS_TABS[\s\S]*?"agents"/);+ assert.doesNotMatch(src, /const DOC_LINKS/);+ assert.doesNotMatch(src, /href: "https?:\/\//);+});++test("every API example section has a platform toggle that follows the user's machine", () => {+ const parts = readSrc("features/settings/components/api-example-parts.tsx");+ assert.match(+ parts,+ /const os: ExampleOs =\s*override \?\?\s*\(\(isLoopbackUrl\(base\) \? deviceType === "windows" : isWindowsClient\)/,+ );+ assert.match(parts, /p\.startsWith\("win"\) \|\| p\.includes\("windows"\)/);+ for (const name of [+ "usage-examples",+ "audio-api-examples",+ "media-api-examples",+ ]) {+ const src = readSrc(`features/settings/components/${name}.tsx`);+ assert.match(src, /const \[os, setOs\] = useExampleOs\(base\);/, name);+ // the code box draws the Platform row, under the Language pills+ assert.match(src, /os=\{os\}\s*onOsChange=\{setOs\}/, name);+ // no section hides the toggle behind its curl pick any more+ assert.doesNotMatch(src, /lang === "curl" \? \(\s*<div/, name);+ assert.match(+ src,+ /pills=\{[\s\S]*?<ExampleToggle\s*label=\{t\("settings\.apiKeys\.exampleLanguage"\)\}/,+ name,+ );+ assert.equal(+ src.match(/<ExampleToggle\b/g)?.length,+ name === "audio-api-examples" ? 1 : 2,+ name,+ );+ }+ // one header row, no divider: the choices, then Platform pushed to its end+ assert.match(+ parts,+ /<div className="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-2 pt-1\.5">\s*\{pills\}\s*<div className="ml-auto">\s*<PlatformToggle value=\{os\} onChange=\{onOsChange\} \/>\s*<\/div>\s*<\/div>/,+ );+ // copy stays put over the code area, on its first line+ assert.match(+ parts,+ /<button\s*type="button"\s*onClick=\{handleCopy\}\s*className="absolute top-2\.5 right-3 [^"]*"[\s\S]*?<\/button>\s*<HighlightedCode/,+ );+ // code scrolling up fades out under the header row+ assert.match(+ parts,+ /\[mask-image:linear-gradient\(to_bottom,transparent,#000_0\.75rem\)\]/,+ );+ // Language and Platform keep the old usage-example pills; what the example does is a toggle+ assert.match(parts, /variant = "pills"/);+ assert.match(+ parts,+ /toggle\s*\? "inline-flex h-9 items-center px-3 text-ui-12"\s*: "px-2\.5 py-1 text-ui-11"/,+ );+});++test("Request and Image or video are toggles above the code box; Audio keeps its grouped Example dropdown", () => {+ const usage = readSrc("features/settings/components/usage-examples.tsx");+ const media = readSrc("features/settings/components/media-api-examples.tsx");+ const audio = readSrc("features/settings/components/audio-api-examples.tsx");+ for (const [src, key] of [+ [usage, "exampleRequest"],+ [media, "exampleKind"],+ ]) {+ const toggle = src.search(+ new RegExp(+ `<ExampleToggle\\s*label=\\{t\\("settings\\.apiKeys\\.${key}"\\)\\}\\s*variant="toggle"`,+ ),+ );+ assert.ok(toggle > 0, key);+ assert.ok(toggle < src.indexOf("<ExampleCodeBox"), key);+ // the box header holds only the Language pills (and its own Platform pills)+ assert.match(+ src,+ /pills=\{\s*<ExampleToggle\s*label=\{t\("settings\.apiKeys\.exampleLanguage"\)\}[^/]*\/>\s*\}/,+ key,+ );+ }+ assert.doesNotMatch(media, /@\/components\/ui\/select/);+ assert.match(+ audio,+ /<Select value=\{example\} onValueChange=\{pickExample\}>/,+ );+});++test("with no model loaded the example still renders, naming a placeholder", () => {+ const src = readSrc("features/settings/components/usage-examples.tsx");+ assert.match(src, /const MODEL_PLACEHOLDER = "YOUR_MODEL";/);+ assert.match(+ src,+ /buildSnippets\(base, key, toolsKey, model \?\? MODEL_PLACEHOLDER, os\)/,+ );+ assert.doesNotMatch(src, /\{snippets \? \(/);+});++test("the example code box starts short, drags taller, and its copy button is icon-only", () => {+ const src = readSrc("features/settings/components/api-example-parts.tsx");+ assert.match(src, /const START_LINES = 8;/);+ assert.match(src, /code\.split\("\\n"\)\.length > START_LINES/);+ // the cap is lifted so a drag can grow it; a height is set, from the drag once there is one+ assert.match(+ src,+ /"relative \[&>section\]:max-h-none \[&>section\]:min-h-24 \[&>section\]:pr-8 \[&_\[data-streamdown=code-block-header\]\]:hidden",\s*height === null\s*\? tall && "\[&>section\]:h-46"\s*: "\[&>section\]:h-\(--example-h\)"/,+ );+ // our own handle: CSS resize draws a native grabber the rounded corner clips into an arc+ assert.doesNotMatch(src, /resize-y|webkit-resizer/);+ assert.match(src, /onPointerDown=\{startResize\}/);+ assert.match(src, /setPointerCapture\(event\.pointerId\)/);+ for (const name of [+ "usage-examples",+ "audio-api-examples",+ "media-api-examples",+ "api-example-parts",+ ]) {+ const file = readSrc(`features/settings/components/${name}.tsx`);+ assert.doesNotMatch(file, /t\("settings\.apiKeys\.copy"\)/, name);+ assert.doesNotMatch(+ file,+ /SegmentedPill group=\{`\$\{pillId\}-(lang|tab|kind|run)`\}/,+ name,+ );+ }+});diff --git a/studio/frontend/tests/api-settings-tab.test.ts b/studio/frontend/tests/api-settings-tab.test.tsindex d50db3266a8..64f50fadcf8 100644--- a/studio/frontend/tests/api-settings-tab.test.ts+++ b/studio/frontend/tests/api-settings-tab.test.ts@@ -7,18 +7,31 @@ import test from "node:test";import { readSrc } from "./helpers/kit.ts";const TAB = readSrc("features/settings/tabs/api-keys-tab.tsx");-const SUMMARY = readSrc("features/settings/components/remote-lan-summary.tsx");const LAN_API = readSrc("features/settings/api/lan-access.ts");-test("the API tab shows Remote & LAN as a status line, not a second set of polling panels", () => {- assert.doesNotMatch(TAB, /<RemoteAccessSection|<LanAccessSection/);- assert.match(TAB, /<RemoteLanSummary \/>/);- assert.doesNotMatch(SUMMARY, /setInterval/);+test("the API tab leaves Remote & LAN to its own tab, the next one down", () => {+ assert.doesNotMatch(+ TAB,+ /<RemoteAccessSection|<LanAccessSection|<RemoteLanSummary/,+ );+});++test("the API tab still publishes a tunnel URL that comes up after it opens", () => {+ const hook = readSrc("features/settings/hooks/use-publish-access-urls.ts");+ assert.match(TAB, /usePublishAccessUrls\(isOwner\);/);+ assert.match(+ hook,+ /usePlatformStore\.setState\(\{ cloudflareUrl: next\.url \}\)/,+ );+ assert.match(+ hook,+ /next\.state === "starting" \|\| next\.state === "stopping"/,+ );assert.match(- SUMMARY,- /settling = next\.state === "starting" \|\| next\.state === "stopping";\s*if \(settling\) \{\s*timer = window\.setTimeout/,+ hook,+ /window\.setTimeout\(readRemote, remoteAccessPollDelay\(next\)\)/,);- assert.match(SUMMARY, /setActiveTab\("remote-lan"\)/);+ assert.match(hook, /publishLanUrls\(next\)/);});test("usage examples sit right under the keys, where a new key lands", () => {@@ -66,15 +79,11 @@ test("the API page marks one served row as the primary, found by checkpoint firsassert.match(page, /\(model\.active && !canEditSettings\)/);});-test("a failed read while remote access is settling retries instead of sticking", () => {- assert.match(- SUMMARY,- /\.catch\(\(\) => \{[\s\S]*?if \(settling\) \{\s*timer = window\.setTimeout\(readRemote/,- );-});-test("the keyless note shows beside a public address too, since LAN callers stay keyless", () => {const lan = readSrc("features/settings/components/lan-access-section.tsx");- assert.doesNotMatch(lan, /keylessLanEligible &&\s*status\.publicUrls\.length === 0/);+ assert.doesNotMatch(+ lan,+ /keylessLanEligible &&\s*status\.publicUrls\.length === 0/,+ );assert.equal(lan.match(/\{keylessNote\}/g)?.length, 2);});diff --git a/studio/frontend/tests/settings-code-boxes.test.ts b/studio/frontend/tests/settings-code-boxes.test.tsindex 3e4c9595885..114debed97a 100644--- a/studio/frontend/tests/settings-code-boxes.test.ts+++ b/studio/frontend/tests/settings-code-boxes.test.ts@@ -11,13 +11,15 @@ const COMMAND_BLOCK = readSrc();const USAGE = readSrc("features/settings/components/usage-examples.tsx");const AUDIO = readSrc("features/settings/components/audio-api-examples.tsx");+const MEDIA = readSrc("features/settings/components/media-api-examples.tsx");+const PARTS = readSrc("features/settings/components/api-example-parts.tsx");const commandBlock = COMMAND_BLOCK.slice(COMMAND_BLOCK.indexOf("export function CommandBlock"),);-const highlightedCode = USAGE.slice(- USAGE.indexOf("export function HighlightedCode"),- USAGE.indexOf("export function UsageExamples"),+const highlightedCode = PARTS.slice(+ PARTS.indexOf("export function HighlightedCode"),+ PARTS.indexOf("export function ExampleCodeBox"),);test("command boxes wrap long commands instead of scrolling under the copy button", () => {@@ -35,8 +37,11 @@ test("long API examples are capped and scroll inside a keyboard-reachable regionassert.match(highlightedCode, /aria-label=\{label\}/);assert.match(highlightedCode,- /className="max-h-96 [^"]*\boverflow-auto\b[^"]*\bscroll-rounded rounded-lg\b[^"]*\bfocus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset\b/,+ /className="max-h-96 [^"]*\bhover-scrollbar overflow-auto\b[^"]*\bfocus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-inset\b/,);+ // square under the header: a rounded scroller cut its scrollbar's top off; the box clips the ends+ assert.doesNotMatch(highlightedCode, /scroll-rounded|rounded-lg/);+ assert.match(PARTS, /"relative min-w-0 overflow-hidden rounded-xl border/);// redaction must stay on the scroller that holds the snippet textassert.match(highlightedCode,@@ -48,10 +53,12 @@ test("long API examples are capped and scroll inside a keyboard-reachable regionassert.match(cls, /\[&_pre\]:!whitespace-pre(?!-)/);assert.doesNotMatch(cls, /break-words|break-all|whitespace-pre-wrap/);assert.match(cls, /\[&_\[data-streamdown=code-block\]\]:!min-w-max\b/);- for (const caller of [USAGE, AUDIO]) {+ // all three example sections share one code box+ for (const caller of [USAGE, AUDIO, MEDIA]) {assert.match(caller,- /<HighlightedCode[\s\S]*?label=\{t\("settings\.apiKeys\./,+ /<ExampleCodeBox[\s\S]*?label=\{t\("settings\.apiKeys\./,);+ assert.doesNotMatch(caller, /<HighlightedCode\b/);}});