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/frontend: make toast and inline error text selectable and copyable (#5506)
Michael Han84d9d56062f1
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsxindex 8433ae9dafd..aac5f8f8a81 100644--- a/studio/frontend/src/components/app-sidebar.tsx+++ b/studio/frontend/src/components/app-sidebar.tsx@@ -91,7 +91,7 @@ import {} from "@/features/training";import type { TrainingRunSummary } from "@/features/training";import { useEffect, useRef, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { ShutdownDialog } from "@/components/shutdown-dialog";function getTourId(pathname: string): string | null {diff --git a/studio/frontend/src/components/assistant-ui/model-selector/model-delete-action.tsx b/studio/frontend/src/components/assistant-ui/model-selector/model-delete-action.tsxindex 58a62354545..4a9b22e1034 100644--- a/studio/frontend/src/components/assistant-ui/model-selector/model-delete-action.tsx+++ b/studio/frontend/src/components/assistant-ui/model-selector/model-delete-action.tsx@@ -14,7 +14,7 @@ import {import { cn } from "@/lib/utils";import { Trash2Icon } from "lucide-react";import { useCallback, useState, type ReactNode } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";interface ModelDeleteActionProps {ariaLabel: string;diff --git a/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx b/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsxindex a0f97967eff..ea40c260c56 100644--- a/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx+++ b/studio/frontend/src/components/assistant-ui/model-selector/pickers.tsx@@ -50,7 +50,7 @@ import {useMemo,useState,} from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import type {DeletedModelRef,LoraModelOption,diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex e42696d06da..ff800995051 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -85,7 +85,7 @@ import {useRef,useState,} from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";export const Thread: FC<{hideComposer?: boolean;diff --git a/studio/frontend/src/components/ui/copyable-error-chip.tsx b/studio/frontend/src/components/ui/copyable-error-chip.tsxnew file mode 100644index 00000000000..1d956a23fc3--- /dev/null+++ b/studio/frontend/src/components/ui/copyable-error-chip.tsx@@ -0,0 +1,91 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"use client";++import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { copyToClipboard } from "@/lib/copy-to-clipboard";+import { cn } from "@/lib/utils";+import { Copy01Icon, Tick02Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { useEffect, useRef, useState } from "react";++interface CopyableErrorChipProps {+ message: string;+ className?: string;+}++export function CopyableErrorChip({+ message,+ className,+}: CopyableErrorChipProps) {+ const [copied, setCopied] = useState(false);+ const resetTimer = useRef<ReturnType<typeof setTimeout> | null>(null);++ // Clear any pending reset on unmount to avoid a setState on an+ // unmounted component.+ useEffect(() => () => {+ if (resetTimer.current) clearTimeout(resetTimer.current);+ }, []);++ const handleCopy = async () => {+ if (await copyToClipboard(message)) {+ setCopied(true);+ if (resetTimer.current) clearTimeout(resetTimer.current);+ resetTimer.current = setTimeout(() => {+ setCopied(false);+ resetTimer.current = null;+ }, 1800);+ }+ };++ return (+ <Popover>+ <PopoverTrigger asChild={true}>+ {/* No aria-label override: the visible message text is the+ button's accessible name, so screen readers announce the+ full (untruncated) error. Truncation here is purely visual. */}+ <button+ type="button"+ className={cn(+ "flex max-w-[28rem] min-w-0 cursor-pointer items-center rounded-md text-left text-xs text-destructive transition-colors hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ className,+ )}+ >+ <span className="min-w-0 flex-1 truncate">{message}</span>+ </button>+ </PopoverTrigger>+ <PopoverContent+ align="start"+ side="bottom"+ className="w-[min(36rem,calc(100vw-1rem))] gap-2"+ >+ <div className="flex items-start justify-between gap-2">+ <span className="text-xs font-medium text-destructive">Error</span>+ <button+ type="button"+ onClick={handleCopy}+ aria-label={copied ? "Copied" : "Copy error message"}+ className={cn(+ "inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",+ copied && "border-emerald-500/40 text-emerald-600 dark:text-emerald-500",+ )}+ >+ <HugeiconsIcon+ icon={copied ? Tick02Icon : Copy01Icon}+ className="size-3.5"+ />+ {copied ? "Copied" : "Copy"}+ </button>+ </div>+ <p className="max-h-64 overflow-y-auto select-text whitespace-pre-wrap break-words text-xs text-destructive">+ {message}+ </p>+ </PopoverContent>+ </Popover>+ );+}diff --git a/studio/frontend/src/components/ui/sonner.tsx b/studio/frontend/src/components/ui/sonner.tsxindex dff9e09cb56..80319f10db7 100644--- a/studio/frontend/src/components/ui/sonner.tsx+++ b/studio/frontend/src/components/ui/sonner.tsx@@ -65,6 +65,8 @@ const Toaster = ({ ...props }: ToasterProps) => {"--border-radius": "var(--radius)",} as React.CSSProperties}+ // No swipe gestures; keeps toast text selectable.+ swipeDirections={[]}toastOptions={{classNames: {toast: "cn-toast",diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 42a9ddc29b8..bbe299199cd 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -3,7 +3,7 @@import type { ChatModelAdapter } from "@assistant-ui/react";import type { MessageTiming, ToolCallMessagePart } from "@assistant-ui/core";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { getAuthToken } from "@/features/auth/session";import { apiUrl } from "@/lib/api-base";import {diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsxindex d08bee1f8ff..9744b0b0173 100644--- a/studio/frontend/src/features/chat/chat-page.tsx+++ b/studio/frontend/src/features/chat/chat-page.tsx@@ -34,10 +34,11 @@ import {useRef,useState,} from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import type { ChatSearch } from "@/app/routes/chat";import { listLocalModels } from "./api/chat-api";import { ChatSettingsPanel } from "./chat-settings-sheet";+import { CopyableErrorChip } from "@/components/ui/copyable-error-chip";import { ContextUsageBar } from "./components/context-usage-bar";import { ModelLoadInlineStatus } from "./components/model-load-status";import { db } from "./db";@@ -1375,12 +1376,11 @@ export function ChatPage(): ReactElement {) : null}{!loadingModel && modelsError ? (<div- className="relative top-0.5 max-w-[28rem] truncate pl-0.5 text-xs text-destructive"- title={modelsError}+ className="relative top-0.5 pl-0.5"role="status"aria-live="polite">- {modelsError}+ <CopyableErrorChip message={modelsError} /></div>) : null}</div>diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsxindex 394601f07b4..9705beea629 100644--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx@@ -62,7 +62,7 @@ import { Tooltip as TooltipPrimitive } from "radix-ui";import { ChevronDown } from "lucide-react";import { Fragment, type ReactNode } from "react";import { useEffect, useMemo, useRef, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { useChatRuntimeStore } from "./stores/chat-runtime-store";import {type ExternalProviderConfig,diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.tsindex 3e0ead88d31..c0982a05c01 100644--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { createElement, useCallback, useRef, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { consumeNativePathToken } from "@/features/native-intents/api";import {notifyNative,diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsxindex ac23356180e..c320f6d86b3 100644--- a/studio/frontend/src/features/chat/shared-composer.tsx+++ b/studio/frontend/src/features/chat/shared-composer.tsx@@ -18,7 +18,7 @@ import { isMultimodalResponse } from "./types/api";import { getImageInputUnavailableReason } from "./utils/image-input-support";import { useAui } from "@assistant-ui/react";import { ArrowUpIcon, GlobeIcon, HeadphonesIcon, LightbulbIcon, LightbulbOffIcon, MicIcon, PlusIcon, SquareIcon, XIcon } from "lucide-react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { loadModel, validateModel } from "./api/chat-api";import { parseExternalModelId, providerTypeSupportsVision } from "./external-providers";import { useExternalProvidersStore } from "./stores/external-providers-store";diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.tsindex 9a80d12da49..13d3cb533fa 100644--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { create } from "zustand";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import {DEFAULT_INFERENCE_PARAMS,type ChatLoraSummary,diff --git a/studio/frontend/src/features/native-intents/components/native-model-chip.tsx b/studio/frontend/src/features/native-intents/components/native-model-chip.tsxindex 22ae36c503b..40a6362ce01 100644--- a/studio/frontend/src/features/native-intents/components/native-model-chip.tsx+++ b/studio/frontend/src/features/native-intents/components/native-model-chip.tsx@@ -3,7 +3,7 @@ import { useNativeIntentStore } from "../store";import type { NativeIntent } from "../types";import { XIcon } from "lucide-react";import { useEffect, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";interface NativeModelChipProps {intent: NativeIntent;diff --git a/studio/frontend/src/features/native-intents/use-native-dialogs.ts b/studio/frontend/src/features/native-intents/use-native-dialogs.tsindex 45ca81343a7..7f242eadf72 100644--- a/studio/frontend/src/features/native-intents/use-native-dialogs.ts+++ b/studio/frontend/src/features/native-intents/use-native-dialogs.ts@@ -1,5 +1,5 @@import { useCallback, useRef } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { pickNativeModel } from "./api";import { useNativeIntentStore } from "./store";import type { NativeIntent } from "./types";diff --git a/studio/frontend/src/features/native-intents/use-native-drop.ts b/studio/frontend/src/features/native-intents/use-native-drop.tsindex 5d35511c106..708c8324070 100644--- a/studio/frontend/src/features/native-intents/use-native-drop.ts+++ b/studio/frontend/src/features/native-intents/use-native-drop.ts@@ -1,6 +1,6 @@import { isTauri } from "@/lib/api-base";import { useEffect, useRef, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { registerNativeModelPath } from "./api";import { useNativeIntentStore } from "./store";import type { NativeIntent } from "./types";diff --git a/studio/frontend/src/features/recipe-studio/hooks/use-recipe-executions.ts b/studio/frontend/src/features/recipe-studio/hooks/use-recipe-executions.tsindex 1040025a5de..c3da5b19994 100644--- a/studio/frontend/src/features/recipe-studio/hooks/use-recipe-executions.ts+++ b/studio/frontend/src/features/recipe-studio/hooks/use-recipe-executions.ts@@ -3,7 +3,7 @@import { useCallback, useEffect, useState } from "react";import { useShallow } from "zustand/react/shallow";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { toastError } from "@/shared/toast";import {getInferenceStatus,diff --git a/studio/frontend/src/features/studio/sections/dataset-section.tsx b/studio/frontend/src/features/studio/sections/dataset-section.tsxindex 80f0a06c3f8..fafd1eadf6a 100644--- a/studio/frontend/src/features/studio/sections/dataset-section.tsx+++ b/studio/frontend/src/features/studio/sections/dataset-section.tsx@@ -67,7 +67,7 @@ import {useRef,useState,} from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { useShallow } from "zustand/react/shallow";import { DocumentUploadRedirectDialog } from "./document-upload-redirect-dialog";diff --git a/studio/frontend/src/features/studio/sections/training-section.tsx b/studio/frontend/src/features/studio/sections/training-section.tsxindex c30b4cbd773..46f97c358f2 100644--- a/studio/frontend/src/features/studio/sections/training-section.tsx+++ b/studio/frontend/src/features/studio/sections/training-section.tsx@@ -26,7 +26,7 @@ import {} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { useRef } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";const chartConfig = {diff --git a/studio/frontend/src/features/training/hooks/use-training-actions.ts b/studio/frontend/src/features/training/hooks/use-training-actions.tsindex 104724d9730..3d2cb64022f 100644--- a/studio/frontend/src/features/training/hooks/use-training-actions.ts+++ b/studio/frontend/src/features/training/hooks/use-training-actions.ts@@ -3,7 +3,7 @@import { primeNativeNotificationPermission } from "@/lib/native-notifications";import { useCallback } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { checkDatasetFormat } from "../api/datasets-api";import { emitTrainingRunsChanged } from "../events";import { getTrainingRun } from "../api/history-api";diff --git a/studio/frontend/src/features/training/hooks/use-training-history-sidebar.ts b/studio/frontend/src/features/training/hooks/use-training-history-sidebar.tsindex 82e2e7a2c05..92ffd684667 100644--- a/studio/frontend/src/features/training/hooks/use-training-history-sidebar.ts+++ b/studio/frontend/src/features/training/hooks/use-training-history-sidebar.ts@@ -2,7 +2,7 @@// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0import { useCallback, useEffect, useRef, useState } from "react";-import { toast } from "sonner";+import { toast } from "@/lib/toast";import { listTrainingRuns } from "../api/history-api";import {onTrainingRunDeleted,diff --git a/studio/frontend/src/hooks/use-tauri-update.ts b/studio/frontend/src/hooks/use-tauri-update.tsindex adfe64e8db8..8ebb4d29801 100644--- a/studio/frontend/src/hooks/use-tauri-update.ts+++ b/studio/frontend/src/hooks/use-tauri-update.ts@@ -7,7 +7,7 @@ import {copySupportDiagnostics,type CopySupportDiagnosticsResult,} from "@/lib/tauri-diagnostics";-import { toast } from "sonner";+import { toast } from "@/lib/toast";export type UpdateStatus =| "idle"diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.cssindex 43f244d9ba5..237370df1f2 100644--- a/studio/frontend/src/index.css+++ b/studio/frontend/src/index.css@@ -996,6 +996,35 @@}}+/* Selectable toast text; non-selectable toast buttons. */+[data-sonner-toast],+[data-sonner-toast] [data-content],+[data-sonner-toast] [data-title],+[data-sonner-toast] [data-description],+[data-sonner-toast] p,+[data-sonner-toast] span {+ -webkit-user-select: text;+ user-select: text;+}++/* Text cursor only on actual text nodes, so the toast container does+ not pretend to be an input. */+[data-sonner-toast] [data-title],+[data-sonner-toast] [data-description],+[data-sonner-toast] p,+[data-sonner-toast] span {+ cursor: text;+}++[data-sonner-toast] button,+[data-sonner-toast] [data-button],+[data-sonner-toast] [data-cancel],+[data-sonner-toast] [data-close-button] {+ -webkit-user-select: none;+ user-select: none;+ cursor: pointer;+}+/* Flat scrollbar chrome */* {scrollbar-width: thin;diff --git a/studio/frontend/src/lib/toast.ts b/studio/frontend/src/lib/toast.tsnew file mode 100644index 00000000000..138ceb4c4da--- /dev/null+++ b/studio/frontend/src/lib/toast.ts@@ -0,0 +1,59 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// sonner `toast` wrapper that defaults `dismissible: false` so swipe+// capture doesn't block text selection. Drop-in for `from "sonner"`.++import { toast as sonnerToast, type ExternalToast } from "sonner";++type AnyFn = (...args: unknown[]) => unknown;++function withDismissibleFalse<F extends AnyFn>(fn: F): F {+ return ((...args: unknown[]) => {+ // Branch by arity: React-element messages are objects too.+ if (args.length <= 1) {+ args.push({ dismissible: false } satisfies ExternalToast);+ } else {+ const lastIdx = args.length - 1;+ const last = args[lastIdx];+ if (last && typeof last === "object" && !Array.isArray(last)) {+ const opts = last as ExternalToast;+ if (!("dismissible" in opts)) {+ args[lastIdx] = { dismissible: false, ...opts };+ }+ }+ }+ return fn(...args);+ }) as F;+}++const wrappedCallable = withDismissibleFalse(+ sonnerToast as unknown as AnyFn,+) as typeof sonnerToast;++// `promise(p, data?)` carries `dismissible` at the top of `data`,+// covering loading / success / error states. `dismiss`, `getHistory`,+// `getToasts` take no options.+const wrappedPromise: typeof sonnerToast.promise = ((promise, data) => {+ const merged =+ data && typeof data === "object" && !("dismissible" in data)+ ? { dismissible: false, ...data }+ : (data ?? { dismissible: false });+ return sonnerToast.promise(promise, merged);+}) as typeof sonnerToast.promise;++export const toast: typeof sonnerToast = Object.assign(wrappedCallable, {+ success: withDismissibleFalse(sonnerToast.success.bind(sonnerToast) as AnyFn) as typeof sonnerToast.success,+ info: withDismissibleFalse(sonnerToast.info.bind(sonnerToast) as AnyFn) as typeof sonnerToast.info,+ warning: withDismissibleFalse(sonnerToast.warning.bind(sonnerToast) as AnyFn) as typeof sonnerToast.warning,+ error: withDismissibleFalse(sonnerToast.error.bind(sonnerToast) as AnyFn) as typeof sonnerToast.error,+ message: withDismissibleFalse(sonnerToast.message.bind(sonnerToast) as AnyFn) as typeof sonnerToast.message,+ loading: withDismissibleFalse(sonnerToast.loading.bind(sonnerToast) as AnyFn) as typeof sonnerToast.loading,+ custom: withDismissibleFalse(sonnerToast.custom.bind(sonnerToast) as AnyFn) as typeof sonnerToast.custom,+ promise: wrappedPromise,+ dismiss: sonnerToast.dismiss.bind(sonnerToast) as typeof sonnerToast.dismiss,+ getHistory: sonnerToast.getHistory.bind(sonnerToast) as typeof sonnerToast.getHistory,+ getToasts: sonnerToast.getToasts.bind(sonnerToast) as typeof sonnerToast.getToasts,+});++export type { ExternalToast } from "sonner";diff --git a/studio/frontend/src/shared/toast.ts b/studio/frontend/src/shared/toast.tsindex 2468ca76337..bfea60543e6 100644--- a/studio/frontend/src/shared/toast.ts+++ b/studio/frontend/src/shared/toast.ts@@ -1,7 +1,7 @@// 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 { toast } from "sonner";+import { toast } from "@/lib/toast";export function toastSuccess(message: string): void {toast.success(message);