Skip to content

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.

feat(studio): replace navbar with collapsible sidebar (#4936)

Wasim Yousef Saidb01e9af1240d
diff --git a/studio/frontend/package.json b/studio/frontend/package.json
index ffb3c657199..a2eebd5cb59 100644
--- a/studio/frontend/package.json
+++ b/studio/frontend/package.json
@@ -87,6 +87,7 @@
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
+ "playwright": "^1.59.1",
"typescript": "~5.9.3",
"typescript-eslint": "^8.55.0",
"vite": "^8.0.1"
diff --git a/studio/frontend/public/blacklogo-c.png b/studio/frontend/public/blacklogo-c.png
new file mode 100644
index 00000000000..7ab9959536d
Binary files /dev/null and b/studio/frontend/public/blacklogo-c.png differ
diff --git a/studio/frontend/public/sticker.png b/studio/frontend/public/sticker.png
new file mode 100644
index 00000000000..d04573c080e
Binary files /dev/null and b/studio/frontend/public/sticker.png differ
diff --git a/studio/frontend/public/whitelogo-c.png b/studio/frontend/public/whitelogo-c.png
new file mode 100644
index 00000000000..ee159550921
Binary files /dev/null and b/studio/frontend/public/whitelogo-c.png differ
diff --git a/studio/frontend/src/app/router.tsx b/studio/frontend/src/app/router.tsx
index d5079297584..13ff8a5cbe0 100644
--- a/studio/frontend/src/app/router.tsx
+++ b/studio/frontend/src/app/router.tsx
@@ -13,7 +13,6 @@ import { Route as loginRoute } from "./routes/login";
import { Route as onboardingRoute } from "./routes/onboarding";
import { Route as changePasswordRoute } from "./routes/change-password";
import { Route as studioRoute } from "./routes/studio";
-import { Route as apiKeysRoute } from "./routes/api-keys";
const routeTree = rootRoute.addChildren([
indexRoute,
@@ -26,7 +25,6 @@ const routeTree = rootRoute.addChildren([
exportRoute,
dataRecipesRoute,
dataRecipeRoute,
- apiKeysRoute,
]);
export const router = createRouter({ routeTree });
diff --git a/studio/frontend/src/app/routes/__root.tsx b/studio/frontend/src/app/routes/__root.tsx
index e1bbdc03f74..69aeb117484 100644
--- a/studio/frontend/src/app/routes/__root.tsx
+++ b/studio/frontend/src/app/routes/__root.tsx
@@ -1,8 +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 { AppSidebar } from "@/components/app-sidebar";
import { Navbar } from "@/components/navbar";
+import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import { usePlatformStore } from "@/config/env";
+import { SettingsDialog, useSettingsDialogStore } from "@/features/settings";
+import { useTrainingUnloadGuard } from "@/features/training/hooks/use-training-unload-guard";
+import { useSidebarPin } from "@/hooks/use-sidebar-pin";
import {
Outlet,
createRootRoute,
@@ -10,7 +15,7 @@ import {
useRouterState,
} from "@tanstack/react-router";
import { AnimatePresence, motion } from "motion/react";
-import { Suspense } from "react";
+import { Suspense, useEffect } from "react";
import { AppProvider } from "../provider";
const CHAT_ONLY_ALLOWED = new Set([
@@ -19,7 +24,6 @@ const CHAT_ONLY_ALLOWED = new Set([
"/login",
"/signup",
"/change-password",
- "/api-keys",
]);
function isChatOnlyAllowed(pathname: string): boolean {
@@ -43,24 +47,63 @@ const HIDDEN_NAVBAR_ROUTES = ["/onboarding", "/login", "/change-password"];
function RootLayout() {
const pathname = useRouterState({ select: (s) => s.location.pathname });
const hideNavbar = HIDDEN_NAVBAR_ROUTES.includes(pathname);
+ const isChatRoute = pathname.startsWith("/chat");
+ const { pinned, setPinned, togglePinned } = useSidebarPin();
+
+ useTrainingUnloadGuard();
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (e.defaultPrevented) return;
+ if ((e.metaKey || e.ctrlKey) && e.key === ",") {
+ e.preventDefault();
+ useSettingsDialogStore.getState().openDialog();
+ }
+ };
+ window.addEventListener("keydown", handler);
+ return () => window.removeEventListener("keydown", handler);
+ }, []);
return (
<AppProvider>
- {!hideNavbar && <Navbar />}
- <AnimatePresence initial={false} mode="wait">
- <motion.div
- key={pathname}
- initial={{ opacity: 0 }}
- animate={{ opacity: 1 }}
- exit={{ opacity: 0 }}
- transition={{ duration: 0.15 }}
- className="flex-1"
- >
+ <SettingsDialog />
+ {hideNavbar ? (
+ <main className="flex-1">
<Suspense fallback={null}>
<Outlet />
</Suspense>
- </motion.div>
- </AnimatePresence>
+ </main>
+ ) : (
+ <SidebarProvider
+ pinned={pinned}
+ setPinned={setPinned}
+ togglePinned={togglePinned}
+ className="!min-h-0 h-dvh overflow-hidden"
+ >
+ <AppSidebar />
+ <SidebarInset className={isChatRoute ? "overflow-hidden" : "overflow-y-auto"}>
+ <Navbar />
+ <div
+ className={`flex min-h-0 min-w-0 flex-1 basis-0 flex-col ${isChatRoute ? "overflow-hidden" : "overflow-visible"} ${isChatRoute ? "" : "pt-14 md:pt-0"}`}
+ >
+ <AnimatePresence initial={false} mode="wait">
+ <motion.div
+ key={pathname}
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ transition={{ duration: 0.15 }}
+ className={`flex min-h-0 min-w-0 flex-1 basis-0 flex-col ${isChatRoute ? "overflow-hidden" : "overflow-visible"}`}
+ >
+ <Suspense fallback={null}>
+ <Outlet />
+ </Suspense>
+ </motion.div>
+ </AnimatePresence>
+ </div>
+ </SidebarInset>
+ </SidebarProvider>
+ )}
</AppProvider>
);
}
diff --git a/studio/frontend/src/app/routes/api-keys.tsx b/studio/frontend/src/app/routes/api-keys.tsx
deleted file mode 100644
index 5846690d7be..00000000000
--- a/studio/frontend/src/app/routes/api-keys.tsx
+++ /dev/null
@@ -1,18 +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 { createRoute } from "@tanstack/react-router";
-import { lazy } from "react";
-import { requireAuth } from "../auth-guards";
-import { Route as rootRoute } from "./__root";
-
-const ApiKeysPage = lazy(() =>
- import("@/features/auth/api-keys-page").then((m) => ({ default: m.ApiKeysPage })),
-);
-
-export const Route = createRoute({
- getParentRoute: () => rootRoute,
- path: "/api-keys",
- beforeLoad: () => requireAuth(),
- component: ApiKeysPage,
-});
diff --git a/studio/frontend/src/app/routes/chat.tsx b/studio/frontend/src/app/routes/chat.tsx
index e435f090bde..49c05ce2190 100644
--- a/studio/frontend/src/app/routes/chat.tsx
+++ b/studio/frontend/src/app/routes/chat.tsx
@@ -1,18 +1,25 @@
// 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 { ChatPage } from "@/features/chat/chat-page";
import { createRoute } from "@tanstack/react-router";
-import { lazy } from "react";
import { requireAuth } from "../auth-guards";
import { Route as rootRoute } from "./__root";
-const ChatPage = lazy(() =>
- import("@/features/chat/chat-page").then((m) => ({ default: m.ChatPage })),
-);
+export type ChatSearch = {
+ thread?: string;
+ compare?: string;
+ new?: string;
+};
export const Route = createRoute({
getParentRoute: () => rootRoute,
path: "/chat",
beforeLoad: () => requireAuth(),
+ validateSearch: (search: Record<string, unknown>): ChatSearch => ({
+ thread: typeof search.thread === "string" ? search.thread : undefined,
+ compare: typeof search.compare === "string" ? search.compare : undefined,
+ new: typeof search.new === "string" ? search.new : undefined,
+ }),
component: ChatPage,
});
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
new file mode 100644
index 00000000000..8264f329a3b
--- /dev/null
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -0,0 +1,607 @@
+// 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 {
+ Sidebar,
+ SidebarContent,
+ SidebarFooter,
+ SidebarGroup,
+ SidebarGroupContent,
+ SidebarGroupLabel,
+ SidebarHeader,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ useSidebar,
+} from "@/components/ui/sidebar";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { useAnimatedThemeToggle } from "@/components/ui/animated-theme-toggler";
+import { cn } from "@/lib/utils";
+import {
+ Book03Icon,
+ ChefHatIcon,
+ ColumnInsertIcon,
+ CursorInfo02Icon,
+ Delete02Icon,
+ MessageSearch01Icon,
+ Search01Icon,
+ NewReleasesIcon,
+ PackageIcon,
+ PencilEdit02Icon,
+ Settings02Icon,
+ ZapIcon,
+} from "@hugeicons/core-free-icons";
+import {
+ Tooltip,
+ TooltipContent,
+} from "@/components/ui/tooltip";
+import { Tooltip as TooltipPrimitive } from "radix-ui";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { ChevronDown, ChevronsUpDown, Moon, PanelLeft, Sun } from "lucide-react";
+import { Link, useNavigate, useRouterState } from "@tanstack/react-router";
+import { motion } from "motion/react";
+import { useTrainingRuntimeStore } from "@/features/training";
+import { useSettingsDialogStore } from "@/features/settings";
+import { usePlatformStore } from "@/config/env";
+import { TOUR_OPEN_EVENT } from "@/features/tour";
+import {
+ useChatSidebarItems,
+ deleteChatItem,
+} from "@/features/chat/hooks/use-chat-sidebar-items";
+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";
+import { useChatSearchStore } from "@/features/chat/stores/chat-search-store";
+import { ChatSearchDialog } from "@/features/chat/components/chat-search-dialog";
+import { useTrainingHistorySidebarItems, deleteTrainingRun } from "@/features/training";
+import type { TrainingRunSummary } from "@/features/training";
+import { useState } from "react";
+
+function getTourId(pathname: string): string | null {
+ if (pathname.startsWith("/studio")) return "studio";
+ if (pathname.startsWith("/export")) return "export";
+ if (pathname.startsWith("/chat")) return "chat";
+ return null;
+}
+
+const NAV_SPRING = { type: "spring", stiffness: 500, damping: 35, mass: 0.5 } as const;
+
+function runStatusDotClass(status: TrainingRunSummary["status"]): string {
+ switch (status) {
+ case "running":
+ return "bg-blue-500 animate-pulse";
+ case "completed":
+ return "bg-emerald-500";
+ case "stopped":
+ return "bg-amber-500";
+ case "error":
+ return "bg-red-500";
+ default:
+ return "bg-muted-foreground";
+ }
+}
+
+function formatRelativeShort(iso: string): string {
+ const then = new Date(iso).getTime();
+ if (Number.isNaN(then)) return "";
+ const diffMs = Date.now() - then;
+ const s = Math.max(0, Math.floor(diffMs / 1000));
+ if (s < 60) return `${s}s`;
+ const m = Math.floor(s / 60);
+ if (m < 60) return `${m}m`;
+ const h = Math.floor(m / 60);
+ if (h < 24) return `${h}h`;
+ const d = Math.floor(h / 24);
+ return `${d}d`;
+}
+
+function NavItem({
+ icon,
+ label,
+ active,
+ disabled,
+ onClick,
+ children,
+ variant = "nav",
+ dataTour,
+}: {
+ icon: typeof ZapIcon;
+ label: string;
+ active: boolean;
+ disabled?: boolean;
+ onClick: () => void;
+ children?: React.ReactNode;
+ variant?: "nav" | "menu";
+ dataTour?: string;
+}) {
+ const isNav = variant === "nav";
+ return (
+ <SidebarMenuItem>
+ <div className="relative">
+ {isNav && active && (
+ <motion.div
+ layoutId="sidebar-active-indicator"
+ className="absolute left-0 top-0 bottom-0 w-[3px] rounded-full bg-primary"
+ transition={NAV_SPRING}
+ />
+ )}
+ <SidebarMenuButton
+ tooltip={label}
+ disabled={disabled}
+ onClick={onClick}
+ isActive={active}
+ data-tour={dataTour}
+ className={
+ isNav
+ ? "rounded-none pr-0 pl-4 text-[#475569] dark:text-[#94a3b8] data-active:text-foreground!"
+ : "rounded-none pr-0 pl-4 text-[#475569] dark:text-[#94a3b8] hover:bg-muted! hover:text-foreground! data-active:bg-[oklch(0.94_0_0)]! data-active:text-foreground! dark:data-active:bg-[oklch(0.3_0_0)]!"
+ }
+ >
+ <HugeiconsIcon icon={icon} strokeWidth={2} className="size-[18px]" />
+ <span className="text-[13px] font-medium">{label}</span>
+ </SidebarMenuButton>
+ </div>
+ {children}
+ </SidebarMenuItem>
+ );
+}
+
+export function AppSidebar() {
+ const { isDark, toggleTheme, anchorRef } = useAnimatedThemeToggle();
+ const { pathname, search } = useRouterState({
+ select: (s) => ({
+ pathname: s.location.pathname,
+ search: s.location.search as Record<string, string | undefined>,
+ }),
+ });
+ const { togglePinned, isMobile, setOpenMobile } = useSidebar();
+ const navigate = useNavigate();
+
+ // Auto-close mobile Sheet after navigation
+ const closeMobileIfOpen = () => {
+ if (isMobile) setOpenMobile(false);
+ };
+
+ const isTrainingRunning = useTrainingRuntimeStore((s) => s.isTrainingRunning);
+ const chatOnly = usePlatformStore((s) => s.isChatOnly());
+
+ // Chat collapsible state — open by default, syncs with route
+ const isChatRoute = pathname.startsWith("/chat");
+ const isStudioRoute = pathname === "/studio" || pathname.startsWith("/studio/");
+ const [chatOpen, setChatOpen] = useState(true);
+ const [runsOpen, setRunsOpen] = useState(true);
+ const effectiveChatOpen = isChatRoute || chatOpen;
+ const effectiveRunsOpen = isStudioRoute || runsOpen;
+
+ const isRecipesRoute = pathname.startsWith("/data-recipes");
+
+ const { items: chatItems } = useChatSidebarItems();
+ const storeThreadId = useChatRuntimeStore((s) => s.activeThreadId);
+ const setActiveThreadId = useChatRuntimeStore((s) => s.setActiveThreadId);
+ const activeThreadId = isChatRoute
+ ? (search.thread as string | undefined) ??
+ (search.compare as string | undefined) ??
+ storeThreadId ??
+ undefined
+ : undefined;
+
+ // Training runs
+ const { items: runItems, refresh: refreshRuns } = useTrainingHistorySidebarItems(
+ !chatOnly && isStudioRoute,
+ );
+ const activeJobId = useTrainingRuntimeStore((s) => s.jobId);
+ const selectedHistoryRunId = useTrainingRuntimeStore((s) => s.selectedHistoryRunId);
+ const setSelectedHistoryRunId = useTrainingRuntimeStore((s) => s.setSelectedHistoryRunId);
+
+ const chatDisabled = isTrainingRunning;
+
+ async function handleDeleteThread(item: Parameters<typeof deleteChatItem>[0]) {
+ await deleteChatItem(item, activeThreadId, (view) => {
+ navigate({
+ to: "/chat",
+ search: { new: view.newThreadNonce },
+ });
+ });
+ }
+
+ return (
+ <>
+ <Sidebar collapsible="icon" variant="sidebar">
+ <SidebarHeader className="group-data-[collapsible=icon]:px-0">
+ {/* Expanded: compact logo + close toggle */}
+ <div className="flex items-center justify-between gap-2 px-1 py-1 group-data-[collapsible=icon]:hidden">
+ <Link
+ to={chatOnly ? "/chat" : "/studio"}
+ onClick={closeMobileIfOpen}
+ className="flex items-center select-none"
+ aria-label="Unsloth home"
+ >
+ <img
+ src="/blacklogo-c.png"
+ alt="Unsloth"
+ className="h-7 w-auto dark:hidden"
+ />
+ <img
+ src="/whitelogo-c.png"
+ alt="Unsloth"
+ className="hidden h-7 w-auto dark:block"
+ />
+ </Link>
+ {!isMobile && (
+ <Tooltip>
+ <TooltipPrimitive.Trigger asChild>
+ <button
+ type="button"
+ onClick={togglePinned}
+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ aria-label="Close sidebar"
+ >
+ <PanelLeft strokeWidth={1.5} className="size-4" />
+ </button>
+ </TooltipPrimitive.Trigger>
+ <TooltipContent side="bottom" sideOffset={6}>
+ Close sidebar
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+
+ {/* Collapsed: sticker with hover-swap to open toggle */}
+ {!isMobile && (
+ <div className="hidden group-data-[collapsible=icon]:flex items-center justify-center h-9 w-full">
+ <Tooltip>
+ <TooltipPrimitive.Trigger asChild>
+ <button
+ type="button"
+ onClick={togglePinned}
+ className="inline-flex h-7 w-7 items-center justify-center rounded-md text-sidebar-foreground/70 transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ aria-label="Open sidebar"
+ >
+ <PanelLeft strokeWidth={1.5} className="size-4" />
+ </button>
+ </TooltipPrimitive.Trigger>
+ <TooltipContent side="right" sideOffset={8}>
+ Open sidebar
+ </TooltipContent>
+ </Tooltip>
+ </div>
+ )}
+ </SidebarHeader>
+
+ <SidebarGroup className="group-data-[collapsible=icon]:p-0 p-0 pt-1 shrink-0">
+ <SidebarGroupContent>
+ <SidebarMenu>
+ <NavItem
+ icon={PencilEdit02Icon}
+ label="New Chat"
+ active={false}
+ disabled={chatDisabled}
+ onClick={() => {
+ if (chatDisabled) return;
+ setActiveThreadId(null);
+ navigate({ to: "/chat", search: { new: crypto.randomUUID() } });
+ closeMobileIfOpen();
+ }}
+ />
+ <NavItem
+ icon={ColumnInsertIcon}
+ label="Compare"
+ active={!!search.compare}
+ disabled={chatDisabled}
+ dataTour="chat-compare"
+ onClick={() => {
+ if (chatDisabled) return;
+ setActiveThreadId(null);
+ navigate({ to: "/chat", search: { compare: crypto.randomUUID() } });
+ closeMobileIfOpen();
+ }}
+ />
+ <NavItem
+ icon={Search01Icon}
+ label="Search"
+ active={false}
+ disabled={chatDisabled}
+ onClick={() => {
+ if (chatDisabled) return;
+ useChatSearchStore.getState().open();
+ closeMobileIfOpen();
+ }}
+ />
+ </SidebarMenu>
+ </SidebarGroupContent>
+ <div className="my-2" />
+ </SidebarGroup>
+
+ <SidebarContent className="gap-0 overflow-y-auto overscroll-contain min-h-0">
+ {/* Navigate (no header) */}
+ <SidebarGroup data-tour="navbar" className="group-data-[collapsible=icon]:p-0 p-0">
+ <SidebarGroupContent>
+ <SidebarMenu>
+ <NavItem
+ icon={ZapIcon}
+ label="Studio"
+ active={pathname === "/studio" || pathname.startsWith("/studio/")}
+ disabled={chatOnly}
+ onClick={() => {
+ if (chatOnly) return;
+ navigate({ to: "/studio" });
+ closeMobileIfOpen();
+ }}
+ />
+
+ <NavItem
+ icon={ChefHatIcon}
+ label="Recipes"
+ active={isRecipesRoute}
+ onClick={() => {
+ navigate({ to: "/data-recipes" });
+ closeMobileIfOpen();
+ }}
+ />
+
+ <NavItem
+ icon={PackageIcon}
+ label="Export"
+ active={pathname === "/export" || pathname.startsWith("/export/")}
+ disabled={chatOnly}
+ onClick={() => {
+ if (chatOnly) return;
+ navigate({ to: "/export" });
+ closeMobileIfOpen();
+ }}
+ />
+ </SidebarMenu>
+ </SidebarGroupContent>
+ <div className="my-2" />
+ </SidebarGroup>
+
+ {/* Recent Chats */}
+ {chatItems.length > 0 && (
+ <Collapsible open={effectiveChatOpen} onOpenChange={setChatOpen} asChild>
+ <SidebarGroup className="group-data-[collapsible=icon]:hidden overflow-hidden p-0">
+ <SidebarGroupLabel asChild>
+ <CollapsibleTrigger className="cursor-pointer flex w-full items-center justify-between">
+ Recent Chats
+ <ChevronDown className="size-3.5 transition-transform duration-200 data-[state=open]:rotate-0 [[data-state=closed]_&]:rotate-[-90deg]" />
+ </CollapsibleTrigger>
+ </SidebarGroupLabel>
+ <CollapsibleContent>
+ <SidebarGroupContent>
+ <SidebarMenu>
+ {chatItems.map((item) => (
+ <SidebarMenuItem key={item.id} className="group/recent-item relative">
+ <SidebarMenuButton
+ isActive={activeThreadId === item.id}
+ className="rounded-none pl-4 pr-7 text-[13px] font-medium text-[#475569] dark:text-[#94a3b8] hover:bg-muted! hover:text-foreground! data-active:bg-[oklch(0.94_0_0)]! data-active:text-foreground! dark:data-active:bg-[oklch(0.3_0_0)]!"
+ onClick={() => {
+ navigate({
+ to: "/chat",
+ search:
+ item.type === "single"
+ ? { thread: item.id }
+ : { compare: item.id },
+ });
+ closeMobileIfOpen();
+ }}
+ >
+ <span className="truncate">{item.title}</span>
+ </SidebarMenuButton>
+ <button
+ type="button"
+ onClick={(e) => {
+ e.stopPropagation();
+ handleDeleteThread(item);
+ }}
+ title="Delete"
+ className="absolute right-1 top-1/2 -translate-y-1/2 flex size-5 scale-90 items-center justify-center rounded-md text-sidebar-foreground/55 opacity-0 transition-all duration-150 hover:bg-destructive/12 hover:text-destructive group-hover/recent-item:scale-100 group-hover/recent-item:opacity-100"
+ >
+ <HugeiconsIcon icon={Delete02Icon} strokeWidth={2} className="size-3.5" />
+ </button>
+ </SidebarMenuItem>
+ ))}
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </CollapsibleContent>
+ </SidebarGroup>
+ </Collapsible>
+ )}
+
+ {/* Recent Runs */}
+ {isStudioRoute && runItems.length > 0 && !chatOnly && (
+ <Collapsible open={effectiveRunsOpen} onOpenChange={setRunsOpen} asChild>
+ <SidebarGroup className="group-data-[collapsible=icon]:hidden overflow-hidden p-0">
+ <SidebarGroupLabel asChild>
+ <CollapsibleTrigger className="cursor-pointer flex w-full items-center justify-between">
+ Recent Runs
+ <ChevronDown className="size-3.5 transition-transform duration-200 data-[state=open]:rotate-0 [[data-state=closed]_&]:rotate-[-90deg]" />
+ </CollapsibleTrigger>
+ </SidebarGroupLabel>
+ <CollapsibleContent>
+ <SidebarGroupContent>
+ <SidebarMenu>
+ {runItems.map((run) => {
+ const isActiveRun =
+ selectedHistoryRunId === run.id || activeJobId === run.id;
+ return (
+ <SidebarMenuItem
+ key={run.id}
+ className="group/run-item relative"
+ >
+ <SidebarMenuButton
+ isActive={isActiveRun}
+ className="h-auto flex-col items-start gap-0.5 py-2 rounded-none pl-4 pr-7 text-[13px] font-medium text-[#475569] dark:text-[#94a3b8] hover:bg-muted! hover:text-foreground! data-active:bg-[oklch(0.94_0_0)]! data-active:text-foreground! dark:data-active:bg-[oklch(0.3_0_0)]!"
+ onClick={() => {
+ setSelectedHistoryRunId(run.id);
+ closeMobileIfOpen();
+ }}
+ >
+ <div className="flex w-full items-center gap-2">
+ <span
+ className={cn(
+ "size-1.5 shrink-0 rounded-full",
+ runStatusDotClass(run.status),
+ )}
+ aria-hidden
+ />
+ <span className="truncate text-sm font-medium">
+ {run.model_name}
+ </span>
+ <span className="ml-auto shrink-0 text-[10px] text-muted-foreground">
+ {formatRelativeShort(run.started_at)}
+ </span>
+ </div>
+ <span className="w-full truncate pl-3.5 text-xs text-muted-foreground">
+ {run.dataset_name}
+ </span>
+ </SidebarMenuButton>
+ <button
+ type="button"
+ onClick={async (e) => {
+ e.stopPropagation();
+ try {
+ await deleteTrainingRun(run.id);
+ if (selectedHistoryRunId === run.id) {
+ setSelectedHistoryRunId(null);
+ }
+ await refreshRuns();
+ } catch {
+ // ignore — next refresh will reconcile
+ }
+ }}
+ title="Delete"
+ className="absolute right-1 top-1/2 -translate-y-1/2 flex size-5 scale-90 items-center justify-center rounded-md text-sidebar-foreground/55 opacity-0 transition-all duration-150 hover:bg-destructive/12 hover:text-destructive group-hover/run-item:scale-100 group-hover/run-item:opacity-100"
+ >
+ <HugeiconsIcon icon={Delete02Icon} strokeWidth={2} className="size-3.5" />
+ </button>
+ </SidebarMenuItem>
+ );
+ })}
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </CollapsibleContent>
+ </SidebarGroup>
+ </Collapsible>
+ )}
+ </SidebarContent>
+
+ <SidebarFooter className="border-t border-sidebar-border">
+ <SidebarMenu>
+ <SidebarMenuItem>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <SidebarMenuButton
+ size="lg"
+ className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
+ >
+ <img
+ src="/Sloth emojis/sloth rounded.png"
+ alt="Unsloth"
+ className="size-8 rounded-lg shrink-0"
+ />
+ <div className="flex flex-col gap-0.5 leading-none group-data-[collapsible=icon]:hidden">
+ <span className="truncate text-sm font-semibold">Unsloth</span>
+ <span className="truncate text-[11px] text-muted-foreground">Studio</span>
+ </div>
+ <ChevronsUpDown strokeWidth={1.25} className="ml-auto size-4 text-muted-foreground group-data-[collapsible=icon]:hidden" />
+ </SidebarMenuButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ side="top"
+ align="start"
+ className="w-56"
+ >
+ <DropdownMenuGroup>
+ <DropdownMenuItem
+ onSelect={() => useSettingsDialogStore.getState().openDialog()}
+ >
+ <HugeiconsIcon icon={Settings02Icon} className="size-4" />
+ <span>Settings</span>
+ <DropdownMenuShortcut>⌘,</DropdownMenuShortcut>
+ </DropdownMenuItem>
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuGroup>
+ <DropdownMenuItem
+ ref={anchorRef as React.Ref<HTMLDivElement>}
+ onSelect={(e) => { e.preventDefault(); toggleTheme(); }}
+ >
+ {isDark ? <Sun className="size-4" /> : <Moon className="size-4" />}
+ <span>{isDark ? "Light Mode" : "Dark Mode"}</span>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ disabled={!getTourId(pathname)}
+ onSelect={() => {
+ const tourId = getTourId(pathname);
+ if (!tourId) return;
+ window.dispatchEvent(
+ new CustomEvent(TOUR_OPEN_EVENT, {
+ detail: { id: tourId },
+ }),
+ );
+ }}
+ >
+ <HugeiconsIcon icon={CursorInfo02Icon} className="size-4" />
+ <span>Guided Tour</span>
+ </DropdownMenuItem>
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuGroup>
+ <DropdownMenuItem asChild>
+ <a
+ href="https://unsloth.ai/docs"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <HugeiconsIcon icon={Book03Icon} className="size-4" />
+ <span>Learn More</span>
+ </a>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <a
+ href="https://unsloth.ai/docs/new/changelog"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <HugeiconsIcon
+ icon={NewReleasesIcon}
+ className="size-4"
+ />
+ <span>What's New</span>
+ </a>
+ </DropdownMenuItem>
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem asChild>
+ <a
+ href="https://github.com/unslothai/unsloth/issues"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <HugeiconsIcon
+ icon={MessageSearch01Icon}
+ className="size-4"
+ />
+ <span>Feedback</span>
+ </a>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </SidebarMenuItem>
+ </SidebarMenu>
+ </SidebarFooter>
+ </Sidebar>
+ <ChatSearchDialog />
+ </>
+ );
+}
diff --git a/studio/frontend/src/components/assistant-ui/reasoning.tsx b/studio/frontend/src/components/assistant-ui/reasoning.tsx
index 6b2c7a05e7b..e4306df4b9c 100644
--- a/studio/frontend/src/components/assistant-ui/reasoning.tsx
+++ b/studio/frontend/src/components/assistant-ui/reasoning.tsx
@@ -6,7 +6,6 @@
/* eslint-disable react-refresh/only-export-components */
import { MarkdownText } from "@/components/assistant-ui/markdown-text";
-import { AnimatedShinyText } from "@/components/ui/animated-shiny-text";
import {
Collapsible,
CollapsibleContent,
@@ -151,34 +150,6 @@ function ReasoningRoot({
);
}
-function ReasoningFade({ className, ...props }: ComponentProps<"div">) {
- return (
- <div
- data-slot="reasoning-fade"
- className={cn(
- "aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8",
- "bg-gradient-to-t from-background to-transparent",
- className,
- )}
- {...props}
- />
- );
-}
-
-function ReasoningFadeTop({ className, ...props }: ComponentProps<"div">) {
- return (
- <div
- data-slot="reasoning-fade-top"
- className={cn(
- "aui-reasoning-fade-top pointer-events-none absolute inset-x-0 top-0 z-10 h-8",
- "bg-gradient-to-b from-background to-transparent",
- className,
- )}
- {...props}
- />
- );
-}
-
function ReasoningTrigger({
active,
duration,
@@ -206,7 +177,7 @@ function ReasoningTrigger({
className="aui-reasoning-trigger-label-wrapper relative inline-block leading-none"
>
{active ? (
- <AnimatedShinyText className="text-sm">Thinking...</AnimatedShinyText>
+ <span className="text-sm">Thinking...</span>
) : (
<span>Thought for {duration ?? 0} seconds</span>
)}
@@ -234,7 +205,7 @@ function ReasoningContent({
<CollapsibleContent
data-slot="reasoning-content"
className={cn(
- "aui-reasoning-content relative overflow-hidden text-muted-foreground text-sm outline-none",
+ "aui-reasoning-content relative overflow-hidden text-foreground/85 text-[13.5px] outline-none",
"group/collapsible-content ease-out",
"data-[state=closed]:animate-collapsible-up",
"data-[state=open]:animate-collapsible-down",
@@ -246,9 +217,7 @@ function ReasoningContent({
)}
{...props}
>
- {streaming && <ReasoningFadeTop />}
{children}
- <ReasoningFade />
</CollapsibleContent>
);
}
@@ -481,8 +450,6 @@ const Reasoning = memo(
Trigger: typeof ReasoningTrigger;
Content: typeof ReasoningContent;
Text: typeof ReasoningText;
- Fade: typeof ReasoningFade;
- FadeTop: typeof ReasoningFadeTop;
};
Reasoning.displayName = "Reasoning";
@@ -490,8 +457,6 @@ Reasoning.Root = ReasoningRoot;
Reasoning.Trigger = ReasoningTrigger;
Reasoning.Content = ReasoningContent;
Reasoning.Text = ReasoningText;
-Reasoning.Fade = ReasoningFade;
-Reasoning.FadeTop = ReasoningFadeTop;
const ReasoningGroup = memo(ReasoningGroupImpl);
ReasoningGroup.displayName = "ReasoningGroup";
@@ -503,6 +468,4 @@ export {
ReasoningTrigger,
ReasoningContent,
ReasoningText,
- ReasoningFade,
- ReasoningFadeTop,
};
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 8f41987fbfb..77fdf28736e 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -16,7 +16,6 @@ import { WebSearchToolUI } from "@/components/assistant-ui/tool-ui-web-search";
import { PythonToolUI } from "@/components/assistant-ui/tool-ui-python";
import { TerminalToolUI } from "@/components/assistant-ui/tool-ui-terminal";
import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
-import { AnimatedShinyText } from "@/components/ui/animated-shiny-text";
import { Button } from "@/components/ui/button";
import { sentAudioNames } from "@/features/chat/api/chat-adapter";
import { AUDIO_ACCEPT, MAX_AUDIO_SIZE, fileToBase64 } from "@/lib/audio-utils";
@@ -70,13 +69,25 @@ export const Thread: FC<{ hideComposer?: boolean; hideWelcome?: boolean }> = ({
}) => {
return (
<ThreadPrimitive.Root
- className="aui-root aui-thread-root @container flex h-full flex-col "
+ className={cn(
+ "aui-root aui-thread-root @container flex flex-col",
+ hideComposer
+ ? "h-full"
+ : "relative min-h-0 min-w-0 flex-1 basis-0 overflow-hidden",
+ )}
style={{
["--thread-max-width" as string]: "44rem",
+ ["--thread-content-max-width" as string]:
+ "calc(var(--thread-max-width) - 2.5rem)",
}}
>
<ThreadPrimitive.Viewport
- className="aui-thread-viewport relative flex min-w-0 flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-4 pt-4"
+ className={cn(
+ "aui-thread-viewport relative flex min-w-0 flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth px-5",
+ hideComposer
+ ? "pt-4"
+ : "h-0 min-h-0 basis-0 pt-[56px]",
+ )}
>
{!hideWelcome && (
<AuiIf condition={({ thread }) => thread.isEmpty}>
@@ -92,19 +103,21 @@ export const Thread: FC<{ hideComposer?: boolean; hideWelcome?: boolean }> = ({
}}
/>
+ {/* Small overlap and extra slack so the last lines can scroll under the composer cleanly */}
+ {!hideComposer && <div className="h-40 shrink-0" aria-hidden />}
+
<ThreadPrimitive.ViewportFooter
className={cn(
- "aui-thread-viewport-footer sticky bottom-0 z-20 mt-auto flex w-full flex-col overflow-visible bg-transparent",
- hideComposer ? "gap-2" : "gap-4",
+ "aui-thread-viewport-footer sticky z-20 mt-auto flex w-full flex-col overflow-visible bg-transparent",
+ hideComposer
+ ? "bottom-0 gap-2"
+ : "bottom-[140px] shrink-0 gap-3",
// Compare: pointer-events pass-through so messages behind footer stay clickable
hideComposer
? "pointer-events-none pb-3"
- : "relative pb-4",
+ : "pb-2",
)}
>
- {!hideComposer && (
- <div className="pointer-events-none absolute inset-x-0 bottom-0 h-4 bg-background" aria-hidden />
- )}
<div
className={cn(
"flex justify-center",
@@ -113,11 +126,26 @@ export const Thread: FC<{ hideComposer?: boolean; hideWelcome?: boolean }> = ({
>
<ThreadScrollToBottom />
</div>
- <AuiIf condition={({ thread }) => !thread.isEmpty}>
- {!hideComposer && <ComposerAnimated />}
- </AuiIf>
</ThreadPrimitive.ViewportFooter>
</ThreadPrimitive.Viewport>
+ {!hideComposer && (
+ <AuiIf condition={({ thread }) => !thread.isEmpty}>
+ <div className="aui-thread-composer-dock pointer-events-none absolute bottom-0 left-0 right-0 md:right-2 z-20">
+ <div
+ aria-hidden
+ className="absolute inset-x-0 bottom-0 top-[10px] bg-background"
+ />
+ <div className="relative px-5 pb-2">
+ <div className="pointer-events-auto mx-auto w-full max-w-(--thread-max-width)">
+ <ComposerAnimated />
+ </div>
+ <p className="mt-1.5 text-center text-[11px] text-muted-foreground">
+ LLM's can make mistakes. Double-check all responses.
+ </p>
+ </div>
+ </div>
+ </AuiIf>
+ )}
</ThreadPrimitive.Root>
);
};
@@ -207,18 +235,13 @@ const ThreadWelcome: FC<{ hideComposer?: boolean }> = ({ hideComposer }) => {
alt="Sloth mascot"
className="size-20"
/>
- <h1 className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in font-semibold text-2xl duration-200">
+ <h1 className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in font-bold text-2xl tracking-[-0.02em] duration-200">
Chat with your model
</h1>
- <p className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in text-muted-foreground text-base delay-75 duration-200">
- Run GGUFs, safetensors, vision and audio models!
+ <p className="aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in text-muted-foreground text-sm delay-75 duration-200">
+ Run GGUFs, safetensors, vision and audio models
</p>
</div>
- <div className="grid grid-cols-2 gap-2">
- <ThreadPrimitive.Suggestions
- components={{ Suggestion: SuggestionItem }}
- />
- </div>
<GeneratingSpinner />
{!hideComposer && <ComposerAnimated />}
</div>
@@ -243,10 +266,6 @@ const GeneratingSpinner: FC = () => {
const ComposerAnimated: FC = () => {
return (
<div className="relative mx-auto min-w-0 w-full max-w-(--thread-max-width)">
- <div
- className="pointer-events-none absolute inset-x-0 top-1/2 bottom-0 z-0 bg-background"
- aria-hidden
- />
<motion.div
layout={true}
layoutId="composer"
@@ -284,14 +303,15 @@ const PendingAudioChip: FC = () => {
const Composer: FC = () => {
return (
<ComposerPrimitive.Root className="aui-composer-root relative flex w-full flex-col">
- <ComposerPrimitive.AttachmentDropzone className="aui-composer-attachment-dropzone shadow-border ring-1 ring-border flex w-full flex-col rounded-2xl bg-background px-1 pt-2 outline-none transition-shadow data-[dragging=true]:ring-ring data-[dragging=true]:bg-accent/50">
+ <ComposerPrimitive.AttachmentDropzone className="aui-composer-attachment-dropzone chat-composer-surface flex w-full flex-col rounded-3xl bg-background px-1 pt-2 outline-none transition-shadow data-[dragging=true]:border-ring data-[dragging=true]:bg-accent/50">
<ComposerAttachments />
<PendingAudioChip />
<ToolStatusDisplay />
<ComposerPrimitive.Input
placeholder="Send a message..."
- className="aui-composer-input mb-1 max-h-32 min-h-12 w-full resize-none bg-transparent pl-5 pr-4 pt-2 pb-3 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-0"
- rows={1}
+ className="aui-composer-input mb-1 min-h-12 w-full resize-none overflow-y-auto bg-transparent pl-5 pr-4 pt-2 pb-3 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-0"
+ minRows={1}
+ maxRows={6}
autoFocus={true}
aria-label="Message input"
/>
@@ -457,12 +477,30 @@ const CodeToolsToggle: FC = () => {
)}
aria-label={codeToolsEnabled ? "Disable code execution" : "Enable code execution"}
>
- <TerminalIcon className="size-3.5" />
+ <CodeToggleIcon className="size-3.5" />
<span>Code</span>
</button>
);
};
+const CodeToggleIcon: FC<{ className?: string }> = ({ className }) => {
+ return (
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ className={className}
+ aria-hidden="true"
+ >
+ <polyline points="16 18 22 12 16 6" />
+ <polyline points="8 6 2 12 8 18" />
+ </svg>
+ );
+};
+
const ToolStatusDisplay: FC = () => {
const toolStatus = useChatRuntimeStore((s) => s.toolStatus);
const isThreadRunning = useAuiState(({ thread }) => thread.isRunning);
@@ -594,15 +632,13 @@ const GeneratingIndicator: FC = () => {
message.content.length === 0 && message.status?.type === "running",
);
if (!show) return null;
- return (
- <AnimatedShinyText className="text-sm">Generating...</AnimatedShinyText>
- );
+ return <span className="text-sm text-muted-foreground">Generating...</span>;
};
const AssistantMessage: FC = () => {
return (
<MessagePrimitive.Root
- className="aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto min-w-0 w-full max-w-(--thread-max-width) animate-in py-3 duration-150"
+ className="aui-assistant-message-root fade-in slide-in-from-bottom-1 relative mx-auto min-w-0 w-full max-w-(--thread-content-max-width) animate-in py-0.5 text-[15.5px] duration-150"
data-role="assistant"
>
<div className="aui-assistant-message-content wrap-break-word min-w-0 text-foreground leading-relaxed">
@@ -701,9 +737,9 @@ const AssistantActionBar: FC = () => {
return (
<ActionBarPrimitive.Root
hideWhenRunning={true}
- autohide="not-last"
+ autohide="always"
autohideFloat="single-branch"
- className="aui-assistant-action-bar-root col-start-3 row-start-2 -ml-1 flex gap-1 text-muted-foreground data-floating:absolute data-floating:rounded-md data-floating:border data-floating:bg-background data-floating:p-1 data-floating:shadow-sm"
+ className="aui-assistant-action-bar-root col-start-3 row-start-2 -ml-1 flex gap-1 text-muted-foreground data-floating:absolute"
>
<CopyButton />
<ActionBarPrimitive.Reload asChild={true}>
@@ -755,22 +791,22 @@ const UserMessageAudio: FC = () => {
const UserMessage: FC = () => {
return (
<MessagePrimitive.Root
- className="aui-user-message-root fade-in slide-in-from-bottom-1 mx-auto grid w-full max-w-(--thread-max-width) animate-in auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 py-3 duration-150 [&:where(>*)]:col-start-2"
+ className="aui-user-message-root fade-in slide-in-from-bottom-1 mx-auto flex w-full max-w-(--thread-content-max-width) animate-in flex-col items-end gap-y-2 pt-6 pb-0.5 text-[15.5px] duration-150"
data-role="user"
>
<UserMessageAttachments />
<UserMessageAudio />
- <div className="aui-user-message-content-wrapper relative col-start-2 min-w-0">
- <div className="aui-user-message-content wrap-break-word rounded-2xl bg-muted px-4 py-2.5 text-foreground">
+ <div className="aui-user-message-content-wrapper flex max-w-[80%] min-w-0 flex-col items-end">
+ <div className="aui-user-message-content wrap-break-word w-fit rounded-2xl bg-muted px-4 py-2.5 text-foreground">
<MessagePrimitive.Parts />
</div>
- <div className="aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2">
+ <div className="mt-1 flex min-h-6">
<UserActionBar />
</div>
</div>
- <BranchPicker className="aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end" />
+ <BranchPicker className="aui-user-branch-picker -mr-1 justify-end" />
</MessagePrimitive.Root>
);
};
@@ -778,8 +814,8 @@ const UserMessage: FC = () => {
const UserActionBar: FC = () => {
return (
<ActionBarPrimitive.Root
- autohide="not-last"
- className="aui-user-action-bar-root flex items-center"
+ autohide="always"
+ className="aui-user-action-bar-root -mr-1 flex gap-1 text-muted-foreground"
>
<CopyButton />
<ActionBarPrimitive.Edit asChild={true}>
@@ -805,7 +841,7 @@ const EditComposer: FC = () => {
});
return (
- <MessagePrimitive.Root className="aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-max-width) flex-col px-2 py-3">
+ <MessagePrimitive.Root className="aui-edit-composer-wrapper mx-auto flex w-full max-w-(--thread-content-max-width) flex-col py-3">
<ComposerPrimitive.Root className="aui-edit-composer-root ml-auto flex w-full max-w-[85%] flex-col rounded-2xl bg-muted">
<ComposerPrimitive.Input
className="aui-edit-composer-input min-h-14 w-full resize-none bg-transparent p-4 text-foreground text-sm outline-none"
diff --git a/studio/frontend/src/components/navbar.tsx b/studio/frontend/src/components/navbar.tsx
index 2d310a81c3e..56b1e0346d0 100644
--- a/studio/frontend/src/components/navbar.tsx
+++ b/studio/frontend/src/components/navbar.tsx
@@ -1,647 +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 {
- HoverCard,
- HoverCardContent,
- HoverCardTrigger,
-} from "@/components/ui/hover-card";
-import {
- Collapsible,
- CollapsibleContent,
- CollapsibleTrigger,
-} from "@/components/ui/collapsible";
-import { AnimatedThemeToggler } from "@/components/ui/animated-theme-toggler";
-import {
- Sheet,
- SheetContent,
- SheetHeader,
- SheetTitle,
- SheetTrigger,
-} from "@/components/ui/sheet";
-import { cn } from "@/lib/utils";
-import {
- ArrowReloadHorizontalIcon,
- ArrowRight01Icon,
- Cancel01Icon,
- Book03Icon,
- BubbleChatIcon,
- ChefHatIcon,
- Copy01Icon,
- CursorInfo02Icon,
- Key01Icon,
- PackageIcon,
- Tick02Icon,
- ZapIcon,
-} from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import { copyToClipboard } from "@/lib/copy-to-clipboard";
-import { useTrainingRuntimeStore } from "@/features/training";
-import { usePlatformStore } from "@/config/env";
-import { Link, useRouterState } from "@tanstack/react-router";
-import { AnimatePresence, motion, useReducedMotion } from "motion/react";
-import type { ReactElement } from "react";
-import { useEffect, useRef, useState } from "react";
-import { TOUR_OPEN_EVENT } from "@/features/tour";
-import { ShutdownDialog } from "@/components/shutdown-dialog";
-
-const NAV_ITEMS = [
- { label: "Studio", href: "/studio", icon: ZapIcon, enabled: true },
- { label: "Recipes", href: "/data-recipes", icon: ChefHatIcon, enabled: true },
- { label: "Export", href: "/export", icon: PackageIcon, enabled: true },
- { label: "Chat", href: "/chat", icon: BubbleChatIcon, enabled: true },
-];
-
-const STUDIO_UPDATE_CMD = "unsloth studio update";
-const STUDIO_UPDATE_FALLBACK_UNIX_CMD =
- "curl -fsSL https://unsloth.ai/install.sh | sh";
-const STUDIO_UPDATE_FALLBACK_WINDOWS_CMD =
- "irm https://unsloth.ai/install.ps1 | iex";
-
-type UpdateShell = "windows" | "unix";
-
-function getDefaultUpdateShell(deviceType: string): UpdateShell {
- return deviceType === "windows" ? "windows" : "unix";
-}
-
-function getStudioUpdateInstructionLine(shell: UpdateShell): string {
- return shell === "windows" ? "Open PowerShell and run:" : "Open Terminal and run:";
-}
-
-function CopyableCommand({
- command,
- copyLabel,
-}: {
- command: string;
- copyLabel: string;
-}): ReactElement {
- const [copied, setCopied] = useState(false);
- const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
-
- useEffect(() => {
- return () => {
- if (timerRef.current) {
- clearTimeout(timerRef.current);
- }
- };
- }, []);
-
- const handleCopy = () => {
- if (!copyToClipboard(command)) {
- return;
- }
- setCopied(true);
- if (timerRef.current) {
- clearTimeout(timerRef.current);
- }
- timerRef.current = setTimeout(() => setCopied(false), 2000);
- };
-
- return (
- <div className="flex min-w-0 items-stretch overflow-hidden rounded-md border border-border bg-muted/40">
- <input
- type="text"
- readOnly
- value={command}
- className="min-w-0 flex-1 bg-transparent px-2 py-1.5 font-mono text-[11px] text-foreground outline-none"
- title={command}
- aria-label={`${copyLabel} text`}
- />
- <button
- type="button"
- onClick={handleCopy}
- className="flex shrink-0 items-center justify-center border-l border-border px-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
- title={copied ? "Copied" : "Copy command"}
- aria-label={copied ? `${copyLabel} copied` : `Copy ${copyLabel}`}
- >
- {copied ? (
- <HugeiconsIcon icon={Tick02Icon} className="size-4 text-emerald-600" />
- ) : (
- <HugeiconsIcon icon={Copy01Icon} className="size-4" />
- )}
- </button>
- </div>
- );
-}
-
-function UpdateStudioInstructions({
- className,
- defaultShell,
- showTitle = true,
-}: {
- className?: string;
- defaultShell: UpdateShell;
- showTitle?: boolean;
-}): ReactElement {
- const [shell, setShell] = useState<UpdateShell>(defaultShell);
- const prefersReducedMotion = useReducedMotion();
- const windows = shell === "windows";
- const fadeTransition = prefersReducedMotion
- ? { duration: 0 }
- : { duration: 0.16, ease: [0.165, 0.84, 0.44, 1] as const };
- const fadeInitial = prefersReducedMotion ? { opacity: 1 } : { opacity: 0, y: 2 };
- const fadeAnimate = { opacity: 1, y: 0 };
- const fadeExit = prefersReducedMotion ? { opacity: 1 } : { opacity: 0, y: -2 };
-
- useEffect(() => {
- setShell(defaultShell);
- }, [defaultShell]);
-
- return (
- <div className={cn("flex flex-col gap-3", className)}>
- <div
- className={cn(
- "flex items-center gap-3",
- showTitle ? "justify-between" : "justify-start",
- )}
- >
- {showTitle ? (
- <p className="shrink-0 whitespace-nowrap text-sm font-semibold font-heading">
- Update Unsloth Studio
- </p>
- ) : null}
- <div className="flex shrink-0 items-center gap-0.5 text-[11px]">
- <button
- type="button"
- onClick={() => setShell("windows")}
- className={cn(
- "px-0.5 py-0.5 font-medium transition-colors",
- windows
- ? "text-foreground"
- : "text-muted-foreground hover:text-emerald-600",
- )}
- aria-pressed={windows}
- >
- Windows
- </button>
- <span className="text-border">/</span>
- <button
- type="button"
- onClick={() => setShell("unix")}
- className={cn(
- "px-0.5 py-0.5 font-medium transition-colors",
- !windows
- ? "text-foreground"
- : "text-muted-foreground hover:text-emerald-600",
- )}
- aria-pressed={!windows}
- >
- macOS/Linux
- </button>
- </div>
- </div>
- <AnimatePresence mode="wait" initial={false}>
- <motion.p
- key={`instruction-${shell}`}
- initial={fadeInitial}
- animate={fadeAnimate}
- exit={fadeExit}
- transition={fadeTransition}
- className="text-xs text-muted-foreground leading-relaxed"
- >
- {getStudioUpdateInstructionLine(shell)}
- </motion.p>
- </AnimatePresence>
- <CopyableCommand command={STUDIO_UPDATE_CMD} copyLabel="update command" />
- <p className="text-xs text-muted-foreground leading-relaxed">
- If that fails or unsloth studio update is unavailable, run:
- </p>
- <AnimatePresence mode="wait" initial={false}>
- <motion.div
- key={`fallback-${shell}`}
- initial={fadeInitial}
- animate={fadeAnimate}
- exit={fadeExit}
- transition={fadeTransition}
- >
- <CopyableCommand
- command={
- windows
- ? STUDIO_UPDATE_FALLBACK_WINDOWS_CMD
- : STUDIO_UPDATE_FALLBACK_UNIX_CMD
- }
- copyLabel="fallback command"
- />
- </motion.div>
- </AnimatePresence>
- <p className="text-xs text-muted-foreground leading-relaxed">
- Restart Studio after updating for changes to take effect.
- </p>
- </div>
- );
-}
-
-function getTourId(pathname: string): "studio" | "chat" | "export" | null {
- if (pathname === "/studio") return "studio";
- if (pathname === "/chat") return "chat";
- if (pathname === "/export") return "export";
- return null;
-}
+import { SidebarTrigger, useSidebar } from "@/components/ui/sidebar";
export function Navbar() {
- const pathname = useRouterState({ select: (s) => s.location.pathname });
- const isTrainingRunning = useTrainingRuntimeStore((s) => s.isTrainingRunning);
- const [mobileOpen, setMobileOpen] = useState(false);
- const [mobileUpdateOpen, setMobileUpdateOpen] = useState(false);
- const [shutdownOpen, setShutdownOpen] = useState(false);
-
- const deviceType = usePlatformStore((s) => s.deviceType);
- const chatOnly = usePlatformStore((s) => s.isChatOnly());
- const defaultUpdateShell = getDefaultUpdateShell(deviceType);
-
- // Warn before closing the tab only when training is running (data loss risk).
- // We store the handler in a ref so removeUnloadHandler() can clean it up
- // before the "Server stopped" page renders.
- const unloadHandlerRef = useRef<((e: BeforeUnloadEvent) => void) | null>(null);
-
- useEffect(() => {
- const handler = (e: BeforeUnloadEvent) => {
- if (!useTrainingRuntimeStore.getState().isTrainingRunning) return;
- e.preventDefault();
- e.returnValue = "";
- };
- unloadHandlerRef.current = handler;
- window.addEventListener("beforeunload", handler);
- return () => {
- window.removeEventListener("beforeunload", handler);
- };
- }, []);
-
- const removeUnloadHandler = () => {
- if (unloadHandlerRef.current) {
- window.removeEventListener("beforeunload", unloadHandlerRef.current);
- unloadHandlerRef.current = null;
- }
- };
-
- const tourId = getTourId(pathname);
-
- const openTour = () => {
- if (!tourId) return;
- window.dispatchEvent(
- new CustomEvent(TOUR_OPEN_EVENT, { detail: { id: tourId } }),
+ const { isMobile } = useSidebar();
+ if (!isMobile) {
+ return (
+ <header className="absolute top-0 inset-x-0 z-40 h-11 pointer-events-none" />
);
- };
-
+ }
return (
- <>
- <header className="relative top-0 z-40 h-16 w-full">
- <div className="mx-auto grid h-full max-w-7xl grid-cols-[1fr_auto_1fr] items-center px-4 sm:px-6">
- {/* Left: logo */}
- <Link to={chatOnly ? "/chat" : "/studio"} className="flex items-center gap-1.5 justify-self-start select-none">
- <img
- src="/blacklogo.png"
- alt="Unsloth"
- className="h-9 w-auto dark:hidden"
- />
- <img
- src="/whitelogo.png"
- alt="Unsloth"
- className="hidden h-9 w-auto dark:block"
- />
- <span className="relative -top-[1px] inline-flex items-center text-[10px] font-extrabold leading-none tracking-[0.12em] text-primary">
- BETA
- </span>
- </Link>
-
- {/* Center: pill nav */}
- <nav
- data-tour="navbar"
- className="hidden items-center rounded-full border border-border bg-card p-1 ring-1 ring-foreground/5 md:flex"
- >
- {NAV_ITEMS.map((item) => {
- const active =
- pathname === item.href || pathname.startsWith(`${item.href}/`);
- const disabledByTraining =
- isTrainingRunning && item.href !== "/studio";
- const disabledByDevice =
- chatOnly && item.href !== "/chat" && item.href !== "/data-recipes";
- if (!item.enabled || disabledByTraining || disabledByDevice) {
- return (
- <span
- key={item.href}
- className="relative rounded-full px-3 py-1.5 text-sm font-medium text-muted-foreground/40 cursor-not-allowed"
- >
- {item.label}
- </span>
- );
- }
- return (
- <Link
- key={item.href}
- to={item.href}
- className={cn(
- "relative rounded-full px-3 py-1.5 text-sm font-medium transition-colors",
- active
- ? "text-background"
- : "text-muted-foreground hover:text-foreground",
- )}
- >
- {active && (
- <motion.span
- layoutId="nav-pill"
- className="absolute inset-0 rounded-full bg-foreground"
- transition={{
- type: "spring",
- stiffness: 500,
- damping: 35,
- mass: 0.5,
- }}
- />
- )}
- <span className="relative z-10 flex items-center">
- <motion.span
- initial={false}
- animate={{
- width: active ? 14 : 0,
- marginLeft: active ? -4 : 0,
- marginRight: active ? 4 : 0,
- opacity: active ? 1 : 0,
- }}
- transition={{ duration: 0.2, ease: [0.165, 0.84, 0.44, 1] }}
- className="inline-flex shrink-0 items-center justify-center overflow-hidden"
- >
- <HugeiconsIcon
- icon={item.icon}
- className="size-3.5 -mt-px shrink-0"
- />
- </motion.span>
- {item.label}
- </span>
- </Link>
- );
- })}
- </nav>
-
- {/* Right: docs/tour desktop — one wrapper per control so flex gap is even (HoverCard roots can confuse flex spacing). */}
- <div className="hidden items-center justify-self-end gap-0 md:flex">
- <div className="flex shrink-0 items-center">
- <AnimatedThemeToggler
- className="flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground [&_svg]:size-4"
- title="Toggle theme"
- aria-label="Toggle theme"
- />
- </div>
- <div className="flex shrink-0 items-center">
- <HoverCard openDelay={200} closeDelay={100}>
- <HoverCardTrigger asChild={true}>
- <a
- href="https://unsloth.ai/docs"
- target="_blank"
- rel="noopener noreferrer"
- className="inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium text-emerald-600 transition-colors hover:bg-accent hover:text-emerald-700 dark:hover:text-emerald-400"
- >
- <HugeiconsIcon icon={Book03Icon} className="size-4" />
- Learn more
- </a>
- </HoverCardTrigger>
- <HoverCardContent align="end" className="w-80 p-0">
- <a
- href="https://unsloth.ai/docs"
- target="_blank"
- rel="noopener noreferrer"
- className="group/card flex flex-col gap-1 p-4 no-underline"
- >
- <p className="text-sm font-semibold font-heading">
- Unsloth Documentation
- </p>
- <p className="text-xs text-muted-foreground leading-relaxed">
- Guides on fine-tuning LLMs 2x faster with 70% less memory.
- Covers LoRA, QLoRA, data formatting, and deployment.
- </p>
- <span className="mt-1 flex items-center gap-1 text-xs font-medium text-emerald-600 group-hover/card:underline">
- Visit docs
- <HugeiconsIcon icon={ArrowRight01Icon} className="size-3" />
- </span>
- </a>
- </HoverCardContent>
- </HoverCard>
- </div>
- <div className="flex shrink-0 items-center">
- <Link
- to="/api-keys"
- className={cn(
- "flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium transition-colors hover:bg-accent",
- pathname === "/api-keys"
- ? "text-foreground"
- : "text-muted-foreground hover:text-foreground",
- )}
- >
- <HugeiconsIcon icon={Key01Icon} className="size-4" />
- API Keys
- </Link>
- </div>
- {tourId ? (
- <div className="flex shrink-0 items-center">
- <button
- type="button"
- onClick={openTour}
- className="flex h-9 items-center gap-1.5 rounded-md px-3 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- title="Tour"
- >
- <HugeiconsIcon icon={CursorInfo02Icon} className="size-4" />
- <span className="text-sm font-medium">Tour</span>
- </button>
- </div>
- ) : null}
- <div className="flex shrink-0 items-center">
- <HoverCard openDelay={200} closeDelay={100}>
- <HoverCardTrigger asChild={true}>
- <button
- type="button"
- className="flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- aria-label="How to update Unsloth Studio"
- >
- <HugeiconsIcon icon={ArrowReloadHorizontalIcon} className="size-4" />
- Update
- </button>
- </HoverCardTrigger>
- <HoverCardContent align="end" className="w-[22.5rem] p-0">
- <UpdateStudioInstructions
- className="p-4"
- defaultShell={defaultUpdateShell}
- />
- </HoverCardContent>
- </HoverCard>
- </div>
- <div className="flex shrink-0 items-center">
- <button
- type="button"
- onClick={() => setShutdownOpen(true)}
- className="flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- title="Shut down Unsloth Studio server"
- aria-label="Shut down Unsloth Studio server"
- >
- <HugeiconsIcon icon={Cancel01Icon} className="size-5" />
- </button>
- </div>
- </div>
-
- {/* Right: mobile */}
- <div className="col-start-3 flex items-center gap-2 justify-self-end md:hidden">
- {tourId ? (
- <button
- type="button"
- onClick={openTour}
- className="flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- title="Tour"
- >
- <HugeiconsIcon icon={CursorInfo02Icon} className="size-4" />
- </button>
- ) : null}
- <Sheet
- open={mobileOpen}
- onOpenChange={(open) => {
- setMobileOpen(open);
- if (!open) setMobileUpdateOpen(false);
- }}
- >
- <SheetTrigger asChild={true}>
- <button
- type="button"
- className="rounded-md border border-border px-3 py-1.5 text-sm font-medium text-foreground"
- aria-label="Open navigation menu"
- >
- Menu
- </button>
- </SheetTrigger>
- <SheetContent side="right" className="w-[300px] p-4">
- <SheetHeader>
- <SheetTitle>Navigate</SheetTitle>
- </SheetHeader>
- <div className="mt-6 flex max-h-[calc(100dvh-8rem)] flex-col gap-2 overflow-y-auto pr-1">
- {NAV_ITEMS.filter((item) => item.enabled).map((item) => {
- const active = pathname === item.href;
- const disabledByTraining =
- isTrainingRunning && item.href !== "/studio";
- const disabledByDevice =
- chatOnly && item.href !== "/chat" && item.href !== "/data-recipes";
- if (disabledByTraining || disabledByDevice) {
- return (
- <span
- key={item.href}
- className="flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-medium text-muted-foreground/40 cursor-not-allowed"
- >
- <HugeiconsIcon icon={item.icon} className="size-4" />
- {item.label}
- </span>
- );
- }
- return (
- <Link
- key={item.href}
- to={item.href}
- onClick={() => setMobileOpen(false)}
- className={cn(
- "flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",
- active
- ? "border-foreground bg-foreground text-background"
- : "border-border text-foreground hover:bg-accent",
- )}
- >
- <HugeiconsIcon icon={item.icon} className="size-4" />
- {item.label}
- </Link>
- );
- })}
- <Link
- to="/api-keys"
- onClick={() => setMobileOpen(false)}
- className={cn(
- "mt-3 flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",
- pathname === "/api-keys"
- ? "border-foreground bg-foreground text-background"
- : "border-border text-foreground hover:bg-accent",
- )}
- >
- <HugeiconsIcon icon={Key01Icon} className="size-4" />
- API Keys
- </Link>
- <a
- href="https://unsloth.ai/docs"
- target="_blank"
- rel="noopener noreferrer"
- className="flex items-center gap-2 rounded-md border border-border px-3 py-2 text-sm font-medium text-foreground hover:bg-accent"
- onClick={() => setMobileOpen(false)}
- >
- <HugeiconsIcon icon={Book03Icon} className="size-4" />
- Learn more (Docs)
- </a>
- {tourId ? (
- <button
- type="button"
- className="flex items-center gap-2 rounded-md border border-border px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent"
- onClick={() => {
- openTour();
- setMobileOpen(false);
- }}
- >
- <HugeiconsIcon icon={CursorInfo02Icon} className="size-4" />
- Start tour
- </button>
- ) : null}
- <Collapsible
- open={mobileUpdateOpen}
- onOpenChange={setMobileUpdateOpen}
- className="rounded-md border border-border"
- >
- <CollapsibleTrigger asChild={true}>
- <button
- type="button"
- className="flex w-full items-center justify-between rounded-md px-3 py-2 text-left text-sm font-medium text-foreground transition-colors hover:bg-accent"
- aria-label="Toggle update instructions"
- >
- <span className="flex items-center gap-2">
- <HugeiconsIcon icon={ArrowReloadHorizontalIcon} className="size-4" />
- Update Unsloth Studio
- </span>
- <HugeiconsIcon
- icon={ArrowRight01Icon}
- className={cn(
- "size-4 text-muted-foreground transition-transform",
- mobileUpdateOpen && "rotate-90",
- )}
- />
- </button>
- </CollapsibleTrigger>
- <CollapsibleContent className="border-t border-border p-3 pt-2">
- <UpdateStudioInstructions
- defaultShell={defaultUpdateShell}
- showTitle={false}
- />
- </CollapsibleContent>
- </Collapsible>
- <button
- type="button"
- className="mt-3 flex items-center gap-2 rounded-md border border-border px-3 py-2 text-left text-sm font-medium text-foreground hover:bg-accent"
- onClick={() => {
- setMobileOpen(false);
- setShutdownOpen(true);
- }}
- >
- <HugeiconsIcon icon={Cancel01Icon} className="size-5" />
- Quit Unsloth Studio
- </button>
- <div className="mt-2 flex items-center justify-between rounded-md border border-border px-3 py-2">
- <span className="text-sm font-medium text-foreground">Theme</span>
- <AnimatedThemeToggler
- className="flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground [&_svg]:size-4"
- title="Toggle theme"
- aria-label="Toggle theme"
- />
- </div>
- </div>
- </SheetContent>
- </Sheet>
- </div>
+ <header className="absolute top-0 inset-x-0 z-40 h-11 pointer-events-none">
+ <div className="flex h-full items-center pl-2">
+ <SidebarTrigger className="pointer-events-auto" />
</div>
</header>
-
- <ShutdownDialog
- open={shutdownOpen}
- onOpenChange={setShutdownOpen}
- onBeforeShutdown={removeUnloadHandler}
- />
- </>
);
}
diff --git a/studio/frontend/src/components/shutdown-dialog.tsx b/studio/frontend/src/components/shutdown-dialog.tsx
index dea738bf6bb..dfeafb33eb7 100644
--- a/studio/frontend/src/components/shutdown-dialog.tsx
+++ b/studio/frontend/src/components/shutdown-dialog.tsx
@@ -18,16 +18,17 @@ import {
interface ShutdownDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
- /** Called right before the shutdown API request so callers can remove the
- * beforeunload listener — otherwise the "Server stopped" page would still
- * trigger a "Leave site?" prompt when the user tries to close it. */
- onBeforeShutdown?: () => void;
+ /** Called after the shutdown API returns success, right before we replace
+ * document.body with the "Server stopped" page. Callers use this to remove
+ * their beforeunload listener — otherwise the browser would prompt
+ * "Leave site?" when the user tries to close the final tab. */
+ onAfterShutdown?: () => void;
}
export function ShutdownDialog({
open,
onOpenChange,
- onBeforeShutdown,
+ onAfterShutdown,
}: ShutdownDialogProps) {
const [stopping, setStopping] = useState(false);
@@ -49,7 +50,7 @@ export function ShutdownDialog({
return;
}
- onBeforeShutdown?.();
+ onAfterShutdown?.();
document.body.innerHTML = `
<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;font-family:sans-serif;gap:12px">
<p style="font-size:1.1rem;font-weight:600;margin:0">Unsloth Studio has stopped.</p>
diff --git a/studio/frontend/src/components/ui/animated-theme-toggler.tsx b/studio/frontend/src/components/ui/animated-theme-toggler.tsx
index 24f3c68ec9f..d83e278401f 100644
--- a/studio/frontend/src/components/ui/animated-theme-toggler.tsx
+++ b/studio/frontend/src/components/ui/animated-theme-toggler.tsx
@@ -6,11 +6,73 @@ import { Moon, Sun } from "lucide-react"
import { flushSync } from "react-dom"
import { cn } from "@/lib/utils"
+import { setTheme } from "@/features/settings/stores/theme-store"
interface AnimatedThemeTogglerProps extends React.ComponentPropsWithoutRef<"button"> {
duration?: number
}
+export function useAnimatedThemeToggle(duration = 400) {
+ const [isDark, setIsDark] = useState(false)
+ const anchorRef = useRef<HTMLElement | null>(null)
+
+ useEffect(() => {
+ const updateTheme = () => {
+ setIsDark(document.documentElement.classList.contains("dark"))
+ }
+ updateTheme()
+ const observer = new MutationObserver(updateTheme)
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ["class"],
+ })
+ return () => observer.disconnect()
+ }, [])
+
+ const toggleTheme = useCallback(async () => {
+ const anchor = anchorRef.current
+ const applyTheme = () => {
+ flushSync(() => {
+ const newTheme = !isDark
+ setIsDark(newTheme)
+ setTheme(newTheme ? "dark" : "light")
+ })
+ }
+
+ if (!document.startViewTransition) {
+ applyTheme()
+ return
+ }
+
+ await document.startViewTransition(applyTheme).ready
+
+ if (anchor) {
+ const { top, left, width, height } = anchor.getBoundingClientRect()
+ const x = left + width / 2
+ const y = top + height / 2
+ const maxRadius = Math.hypot(
+ Math.max(left, window.innerWidth - left),
+ Math.max(top, window.innerHeight - top)
+ )
+ document.documentElement.animate(
+ {
+ clipPath: [
+ `circle(0px at ${x}px ${y}px)`,
+ `circle(${maxRadius}px at ${x}px ${y}px)`,
+ ],
+ },
+ {
+ duration,
+ easing: "ease-in-out",
+ pseudoElement: "::view-transition-new(root)",
+ }
+ )
+ }
+ }, [isDark, duration])
+
+ return { isDark, toggleTheme, anchorRef }
+}
+
export const AnimatedThemeToggler = ({
className,
duration = 400,
@@ -38,14 +100,20 @@ export const AnimatedThemeToggler = ({
const toggleTheme = useCallback(async () => {
if (!buttonRef.current) return
- await document.startViewTransition(() => {
+ const apply = () => {
flushSync(() => {
const newTheme = !isDark
setIsDark(newTheme)
- document.documentElement.classList.toggle("dark")
- localStorage.setItem("theme", newTheme ? "dark" : "light")
+ setTheme(newTheme ? "dark" : "light")
})
- }).ready
+ }
+
+ if (!document.startViewTransition) {
+ apply()
+ return
+ }
+
+ await document.startViewTransition(apply).ready
const { top, left, width, height } =
buttonRef.current.getBoundingClientRect()
diff --git a/studio/frontend/src/components/ui/command.tsx b/studio/frontend/src/components/ui/command.tsx
index 6181d55ea16..a2340b62ede 100644
--- a/studio/frontend/src/components/ui/command.tsx
+++ b/studio/frontend/src/components/ui/command.tsx
@@ -1,6 +1,6 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.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
+
"use client";
import { Command as CommandPrimitive } from "cmdk";
@@ -39,12 +39,14 @@ function CommandDialog({
description = "Search for a command to run...",
children,
className,
+ overlayClassName,
showCloseButton = false,
...props
}: React.ComponentProps<typeof Dialog> & {
title?: string;
description?: string;
className?: string;
+ overlayClassName?: string;
showCloseButton?: boolean;
}) {
return (
@@ -55,9 +57,10 @@ function CommandDialog({
</DialogHeader>
<DialogContent
className={cn(
- "rounded-4xl! p-0 top-1/3 translate-y-0 overflow-hidden p-0",
+ "rounded-4xl! top-1/3 translate-y-0 overflow-hidden p-0",
className,
)}
+ overlayClassName={overlayClassName}
showCloseButton={showCloseButton}
>
{children}
diff --git a/studio/frontend/src/components/ui/sidebar.tsx b/studio/frontend/src/components/ui/sidebar.tsx
index 898972f1ee3..6d9016f8e21 100644
--- a/studio/frontend/src/components/ui/sidebar.tsx
+++ b/studio/frontend/src/components/ui/sidebar.tsx
@@ -1,6 +1,6 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.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
+
"use client"
import * as React from "react"
@@ -28,10 +28,9 @@ import { useIsMobile } from "@/hooks/use-mobile"
import { HugeiconsIcon } from "@hugeicons/react"
import { SidebarLeftIcon } from "@hugeicons/core-free-icons"
-const SIDEBAR_COOKIE_NAME = "sidebar_state"
-const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
+const noop = () => {}
+
const SIDEBAR_WIDTH = "16rem"
-const SIDEBAR_WIDTH_MOBILE = "18rem"
const SIDEBAR_WIDTH_ICON = "3rem"
const SIDEBAR_KEYBOARD_SHORTCUT = "b"
@@ -43,6 +42,10 @@ type SidebarContextProps = {
setOpenMobile: (open: boolean) => void
isMobile: boolean
toggleSidebar: () => void
+ hasPinMode: boolean
+ pinned: boolean
+ setPinned: (value: boolean) => void
+ togglePinned: () => void
}
const SidebarContext = React.createContext<SidebarContextProps | null>(null)
@@ -60,6 +63,9 @@ function SidebarProvider({
defaultOpen = true,
open: openProp,
onOpenChange: setOpenProp,
+ pinned: pinnedProp,
+ setPinned: setPinnedProp,
+ togglePinned: togglePinnedProp,
className,
style,
children,
@@ -68,33 +74,57 @@ function SidebarProvider({
defaultOpen?: boolean
open?: boolean
onOpenChange?: (open: boolean) => void
+ pinned?: boolean
+ setPinned?: (value: boolean) => void
+ togglePinned?: () => void
}) {
const isMobile = useIsMobile()
const [openMobile, setOpenMobile] = React.useState(false)
+ const prevIsMobileRef = React.useRef(isMobile)
+ React.useEffect(() => {
+ if (prevIsMobileRef.current && !isMobile) {
+ setOpenMobile(false)
+ }
+ prevIsMobileRef.current = isMobile
+ }, [isMobile])
+
+ // Whether pin mode is active (caller provides pinned + setPinned + togglePinned).
+ const hasPinMode = pinnedProp !== undefined && setPinnedProp !== undefined && togglePinnedProp !== undefined
+
// This is the internal state of the sidebar.
// We use openProp and setOpenProp for control from outside the component.
const [_open, _setOpen] = React.useState(defaultOpen)
- const open = openProp ?? _open
+
+ // When pin mode is active, open is driven entirely by `pinned` (explicit
+ // user toggle). Otherwise fall back to the controlled/uncontrolled pattern.
+ const open = hasPinMode ? !!pinnedProp : (openProp ?? _open)
+
const setOpen = React.useCallback(
(value: boolean | ((value: boolean) => boolean)) => {
const openState = typeof value === "function" ? value(open) : value
+
+ if (hasPinMode) {
+ // In pin mode, setOpen controls pinned state.
+ setPinnedProp?.(openState)
+ return
+ }
+
if (setOpenProp) {
setOpenProp(openState)
} else {
_setOpen(openState)
}
-
- // This sets the cookie to keep the sidebar state.
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`
},
- [setOpenProp, open]
+ [setOpenProp, open, hasPinMode, setPinnedProp]
)
// Helper to toggle the sidebar.
const toggleSidebar = React.useCallback(() => {
- return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
- }, [isMobile, setOpen, setOpenMobile])
+ if (isMobile) return setOpenMobile((open) => !open)
+ if (hasPinMode && togglePinnedProp) return togglePinnedProp()
+ return setOpen((open) => !open)
+ }, [isMobile, setOpen, setOpenMobile, hasPinMode, togglePinnedProp])
// Adds a keyboard shortcut to toggle the sidebar.
React.useEffect(() => {
@@ -116,6 +146,10 @@ function SidebarProvider({
// This makes it easier to style the sidebar with Tailwind classes.
const state = open ? "expanded" : "collapsed"
+ const pinned = pinnedProp ?? false
+ const setPinned = setPinnedProp ?? noop
+ const togglePinned = togglePinnedProp ?? noop
+
const contextValue = React.useMemo<SidebarContextProps>(
() => ({
state,
@@ -125,8 +159,12 @@ function SidebarProvider({
openMobile,
setOpenMobile,
toggleSidebar,
+ hasPinMode,
+ pinned,
+ setPinned,
+ togglePinned,
}),
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar, hasPinMode, pinned, setPinned, togglePinned]
)
return (
@@ -165,7 +203,7 @@ function Sidebar({
variant?: "sidebar" | "floating" | "inset"
collapsible?: "offcanvas" | "icon" | "none"
}) {
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
+ const { isMobile, state, openMobile, setOpenMobile, hasPinMode, pinned } = useSidebar()
if (collapsible === "none") {
return (
@@ -190,12 +228,7 @@ function Sidebar({
data-sidebar="sidebar"
data-slot="sidebar"
data-mobile="true"
- className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
- style={
- {
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
- } as React.CSSProperties
- }
+ className="bg-sidebar text-sidebar-foreground w-2/3 max-w-[18rem] p-0 [&>button]:hidden"
side={side}
>
<SheetHeader className="sr-only">
@@ -210,7 +243,11 @@ function Sidebar({
return (
<div
- className="group peer text-sidebar-foreground hidden md:block"
+ className={cn(
+ "group peer text-sidebar-foreground relative shrink-0",
+ hasPinMode && pinned && "w-(--sidebar-width)",
+ hasPinMode && !pinned && "w-(--sidebar-width-icon)",
+ )}
data-state={state}
data-collapsible={state === "collapsed" ? collapsible : ""}
data-variant={variant}
@@ -221,23 +258,45 @@ function Sidebar({
<div
data-slot="sidebar-gap"
className={cn(
- "transition-[width] duration-200 ease-linear relative w-(--sidebar-width) bg-transparent",
- "group-data-[collapsible=offcanvas]:w-0",
+ "relative bg-transparent shrink-0",
"group-data-[side=right]:rotate-180",
- variant === "floating" || variant === "inset"
- ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
+ hasPinMode
+ ? cn(
+ // Pin mode: always push content. Expanded when pinned.
+ pinned
+ ? "w-(--sidebar-width)"
+ : (variant === "floating" || variant === "inset"
+ ? "w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
+ : "w-(--sidebar-width-icon)"),
+ )
+ : cn(
+ // Legacy mode: original shadcn behavior.
+ "w-(--sidebar-width)",
+ "group-data-[collapsible=offcanvas]:w-0",
+ variant === "floating" || variant === "inset"
+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]"
+ : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
+ ),
)}
/>
<div
data-slot="sidebar-container"
data-side={side}
className={cn(
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
+ hasPinMode
+ ? cn(
+ // Pin mode: always push content, full height.
+ "absolute top-0 bottom-0 flex w-(--sidebar-width) data-[side=left]:left-0",
+ "group-data-[collapsible=icon]:w-(--sidebar-width-icon)",
+ )
+ : cn(
+ // Legacy mode: fixed to viewport (original shadcn behavior).
+ "fixed inset-y-0 z-10 flex h-svh w-(--sidebar-width) data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
+ ),
// Adjust the padding for floating and inset variants.
variant === "floating" || variant === "inset"
? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]"
- : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
+ : !hasPinMode && "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
className
)}
{...props}
@@ -245,7 +304,11 @@ function Sidebar({
<div
data-sidebar="sidebar"
data-slot="sidebar-inner"
- className="bg-sidebar group-data-[variant=floating]:ring-sidebar-border group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 flex size-full flex-col"
+ className={cn(
+ "bg-sidebar flex size-full flex-col overflow-hidden border-r border-sidebar-border",
+ "group-data-[variant=floating]:ring-sidebar-border group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1",
+ hasPinMode && "ring-1 ring-sidebar-border/60",
+ )}
>
{children}
</div>
@@ -310,7 +373,7 @@ function SidebarInset({ className, ...props }: React.ComponentProps<"main">) {
<main
data-slot="sidebar-inset"
className={cn(
- "bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2 relative flex w-full flex-1 flex-col",
+ "bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2 relative flex min-h-0 w-full flex-1 flex-col",
className
)}
{...props}
@@ -374,7 +437,7 @@ function SidebarContent({ className, ...props }: React.ComponentProps<"div">) {
data-slot="sidebar-content"
data-sidebar="content"
className={cn(
- "no-scrollbar gap-2 flex min-h-0 flex-1 flex-col overflow-auto group-data-[collapsible=icon]:overflow-hidden",
+ "gap-2 flex min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden group-data-[collapsible=icon]:overflow-hidden [&>*]:shrink-0",
className
)}
{...props}
@@ -408,7 +471,7 @@ function SidebarGroupLabel({
data-slot="sidebar-group-label"
data-sidebar="group-label"
className={cn(
- "text-sidebar-foreground/70 ring-sidebar-ring h-8 rounded-md px-2 text-xs font-medium transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 flex shrink-0 items-center outline-hidden [&>svg]:shrink-0",
+ "text-[#94a3b8] dark:text-[#64748b] ring-sidebar-ring h-auto pt-3 pb-2 px-4 rounded-md text-[10px] font-semibold uppercase tracking-[0.08em] group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-3 flex shrink-0 items-center outline-hidden [&>svg]:shrink-0",
className
)}
{...props}
@@ -455,7 +518,7 @@ function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">) {
<ul
data-slot="sidebar-menu"
data-sidebar="menu"
- className={cn("gap-1 flex w-full min-w-0 flex-col", className)}
+ className={cn("gap-0.5 flex w-full min-w-0 flex-col", className)}
{...props}
/>
)
@@ -473,7 +536,7 @@ function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">) {
}
const sidebarMenuButtonVariants = cva(
- "ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-lg corner-squircle p-2 text-left text-sm transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&_svg]:size-4 [&_svg]:shrink-0",
+ "ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground gap-2 rounded-md p-2 text-left text-sm cursor-pointer transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:w-full! group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:p-2! focus-visible:ring-2 data-active:font-medium peer/menu-button flex w-full items-center overflow-hidden outline-hidden group/menu-button disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate group-data-[collapsible=icon]:[&>span]:hidden [&_svg]:size-4 [&_svg]:shrink-0 group-data-[collapsible=icon]:[&_svg]:size-5",
{
variants: {
variant: {
diff --git a/studio/frontend/src/features/auth/api-keys-page.tsx b/studio/frontend/src/features/auth/api-keys-page.tsx
deleted file mode 100644
index 2065384a7dd..00000000000
--- a/studio/frontend/src/features/auth/api-keys-page.tsx
+++ /dev/null
@@ -1,426 +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 { DashboardLayout } from "@/components/layout/dashboard-layout";
-import { Button } from "@/components/ui/button";
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
-import { Input } from "@/components/ui/input";
-import { Label } from "@/components/ui/label";
-import { cn } from "@/lib/utils";
-import { copyToClipboardAsync } from "@/lib/copy-to-clipboard";
-import {
- AlertCircleIcon,
- Copy01Icon,
- Delete02Icon,
- Key01Icon,
- Tick02Icon,
-} from "@hugeicons/core-free-icons";
-import { HugeiconsIcon } from "@hugeicons/react";
-import { useCallback, useEffect, useRef, useState } from "react";
-import { authFetch } from "./api";
-
-// ---------------------------------------------------------------------------
-// Types
-// ---------------------------------------------------------------------------
-
-interface ApiKey {
- id: number;
- name: string;
- key_prefix: string;
- created_at: string;
- last_used_at: string | null;
- expires_at: string | null;
- is_active: boolean;
-}
-
-// ---------------------------------------------------------------------------
-// API helpers
-// ---------------------------------------------------------------------------
-
-async function fetchApiKeys(): Promise<ApiKey[]> {
- const res = await authFetch("/api/auth/api-keys");
- if (!res.ok) throw new Error("Failed to load API keys");
- const data = (await res.json()) as { api_keys: ApiKey[] };
- return data.api_keys;
-}
-
-async function createApiKey(
- name: string,
- expiresInDays: number | null,
-): Promise<{ key: string; api_key: ApiKey }> {
- const res = await authFetch("/api/auth/api-keys", {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({
- name,
- expires_in_days: expiresInDays,
- }),
- });
- if (!res.ok) throw new Error("Failed to create API key");
- return res.json();
-}
-
-async function revokeApiKey(keyId: number): Promise<void> {
- const res = await authFetch(`/api/auth/api-keys/${keyId}`, {
- method: "DELETE",
- });
- if (!res.ok) throw new Error("Failed to revoke API key");
-}
-
-// ---------------------------------------------------------------------------
-// Helpers
-// ---------------------------------------------------------------------------
-
-function formatDate(iso: string | null): string {
- if (!iso) return "--";
- const d = new Date(iso);
- return d.toLocaleDateString(undefined, {
- year: "numeric",
- month: "short",
- day: "numeric",
- hour: "2-digit",
- minute: "2-digit",
- });
-}
-
-// ---------------------------------------------------------------------------
-// Components
-// ---------------------------------------------------------------------------
-
-function CopyButton({ text }: { text: string }) {
- const [copied, setCopied] = useState(false);
- const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
-
- useEffect(() => {
- return () => {
- if (timerRef.current) clearTimeout(timerRef.current);
- };
- }, []);
-
- const handleCopy = async () => {
- if (!(await copyToClipboardAsync(text))) return;
- setCopied(true);
- if (timerRef.current) clearTimeout(timerRef.current);
- timerRef.current = setTimeout(() => setCopied(false), 2000);
- };
-
- return (
- <Button
- variant="ghost"
- size="icon-sm"
- onClick={handleCopy}
- className={cn(
- "shrink-0 rounded-md text-muted-foreground hover:text-foreground",
- copied && "text-emerald-600 hover:text-emerald-600",
- )}
- aria-label={copied ? "Copied API key" : "Copy API key"}
- title={copied ? "Copied" : "Copy"}
- >
- <HugeiconsIcon
- icon={copied ? Tick02Icon : Copy01Icon}
- className="size-4"
- />
- </Button>
- );
-}
-
-function RevealKeyDialog({
- open,
- rawKey,
- onClose,
-}: {
- open: boolean;
- rawKey: string;
- onClose: () => void;
-}) {
- return (
- <Dialog open={open} onOpenChange={(o) => !o && onClose()}>
- <DialogContent className="max-w-lg">
- <DialogHeader>
- <DialogTitle>API Key Created</DialogTitle>
- <DialogDescription>
- Copy this key now. It will not be shown again.
- </DialogDescription>
- </DialogHeader>
- <div className="flex items-center gap-2 rounded-md border border-border bg-muted/40 p-3">
- <code className="min-w-0 flex-1 break-all font-mono text-sm">
- {rawKey}
- </code>
- <CopyButton text={rawKey} />
- </div>
- <div className="flex items-start gap-2 rounded-md border border-amber-500/20 bg-amber-50 p-3 text-amber-800 dark:border-amber-400/20 dark:bg-amber-950/30 dark:text-amber-300">
- <HugeiconsIcon icon={AlertCircleIcon} className="mt-0.5 size-4 shrink-0" />
- <p className="text-xs leading-relaxed">
- Store this key securely. You will not be able to see it again after closing this dialog.
- </p>
- </div>
- <DialogFooter>
- <Button onClick={onClose}>Done</Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-}
-
-function CreateKeyForm({ onCreated }: { onCreated: (rawKey: string) => void }) {
- const [name, setName] = useState("");
- const [expiresInDays, setExpiresInDays] = useState("");
- const [loading, setLoading] = useState(false);
-
- const handleSubmit = async (e: React.FormEvent) => {
- e.preventDefault();
- if (!name.trim()) return;
- setLoading(true);
- try {
- const days = expiresInDays ? parseInt(expiresInDays, 10) : null;
- const result = await createApiKey(name.trim(), days);
- onCreated(result.key);
- setName("");
- setExpiresInDays("");
- } finally {
- setLoading(false);
- }
- };
-
- return (
- <form onSubmit={handleSubmit} className="flex flex-col gap-4 rounded-lg border border-border p-4">
- <div className="flex flex-col gap-1.5">
- <Label htmlFor="key-name">Key name</Label>
- <Input
- id="key-name"
- placeholder="e.g. My application"
- value={name}
- onChange={(e) => setName(e.target.value)}
- required
- />
- </div>
- <div className="flex flex-col gap-1.5">
- <Label htmlFor="key-expiry">Expires in (days)</Label>
- <Input
- id="key-expiry"
- type="number"
- min={1}
- placeholder="Leave blank for no expiry"
- value={expiresInDays}
- onChange={(e) => setExpiresInDays(e.target.value)}
- />
- </div>
- <Button type="submit" disabled={loading || !name.trim()} className="self-start">
- {loading ? "Creating..." : "Create API key"}
- </Button>
- </form>
- );
-}
-
-function KeysTable({
- keys,
- onRevoke,
-}: {
- keys: ApiKey[];
- onRevoke: (id: number) => void;
-}) {
- if (keys.length === 0) {
- return (
- <p className="py-8 text-center text-sm text-muted-foreground">
- No API keys yet. Create one above.
- </p>
- );
- }
-
- return (
- <div className="overflow-x-auto rounded-lg border border-border">
- <table className="w-full text-sm">
- <thead>
- <tr className="border-b border-border bg-muted/40">
- <th className="px-4 py-2.5 text-left font-medium text-muted-foreground">Name</th>
- <th className="px-4 py-2.5 text-left font-medium text-muted-foreground">Key</th>
- <th className="px-4 py-2.5 text-left font-medium text-muted-foreground">Created</th>
- <th className="px-4 py-2.5 text-left font-medium text-muted-foreground">Last used</th>
- <th className="px-4 py-2.5 text-left font-medium text-muted-foreground">Expires</th>
- <th className="px-4 py-2.5 text-right font-medium text-muted-foreground" />
- </tr>
- </thead>
- <tbody>
- {keys.map((k) => (
- <tr
- key={k.id}
- className={cn(
- "border-b border-border last:border-b-0",
- !k.is_active && "opacity-50",
- )}
- >
- <td className="px-4 py-2.5 font-medium">{k.name}</td>
- <td className="px-4 py-2.5">
- <code className="rounded bg-muted px-1.5 py-0.5 font-mono text-xs">
- sk-unsloth-{k.key_prefix}...
- </code>
- </td>
- <td className="px-4 py-2.5 text-muted-foreground">{formatDate(k.created_at)}</td>
- <td className="px-4 py-2.5 text-muted-foreground">{formatDate(k.last_used_at)}</td>
- <td className="px-4 py-2.5 text-muted-foreground">{formatDate(k.expires_at)}</td>
- <td className="px-4 py-2.5 text-right">
- {k.is_active ? (
- <Button
- variant="ghost"
- size="sm"
- onClick={() => onRevoke(k.id)}
- className="text-destructive hover:text-destructive"
- >
- <HugeiconsIcon icon={Delete02Icon} className="size-3.5 mr-1" />
- Revoke
- </Button>
- ) : (
- <span className="text-xs text-muted-foreground">Revoked</span>
- )}
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- );
-}
-
-function UsageExamples() {
- const base = window.location.origin;
-
- const curlExample = `curl ${base}/v1/chat/completions \\
- -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\
- -H "Content-Type: application/json" \\
- -d '{
- "messages": [{"role": "user", "content": "Hello"}],
- "stream": true
- }'`;
-
- const pythonExample = `from openai import OpenAI
-
-client = OpenAI(
- base_url="${base}/v1",
- api_key="sk-unsloth-YOUR_KEY",
-)
-
-response = client.chat.completions.create(
- model="current",
- messages=[{"role": "user", "content": "Hello"}],
- stream=True,
-)
-for chunk in response:
- print(chunk.choices[0].delta.content or "", end="")`;
-
- const toolsExample = `curl ${base}/v1/chat/completions \\
- -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\
- -H "Content-Type: application/json" \\
- -d '{
- "messages": [{"role": "user", "content": "Search for Python 3.13 features"}],
- "stream": true,
- "enable_tools": true,
- "enabled_tools": ["web_search", "python"],
- "session_id": "my-session"
- }'`;
-
- return (
- <div className="flex flex-col gap-4">
- <h3 className="text-sm font-semibold">Usage examples</h3>
- <div className="flex flex-col gap-3">
- <div>
- <p className="mb-1.5 text-xs font-medium text-muted-foreground">curl</p>
- <pre className="overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-xs leading-relaxed">
- {curlExample}
- </pre>
- </div>
- <div>
- <p className="mb-1.5 text-xs font-medium text-muted-foreground">Python (OpenAI SDK)</p>
- <pre className="overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-xs leading-relaxed">
- {pythonExample}
- </pre>
- </div>
- <div>
- <p className="mb-1.5 text-xs font-medium text-muted-foreground">With tools (web search + code execution)</p>
- <pre className="overflow-x-auto rounded-md border border-border bg-muted/40 p-3 font-mono text-xs leading-relaxed">
- {toolsExample}
- </pre>
- </div>
- </div>
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// Page
-// ---------------------------------------------------------------------------
-
-export function ApiKeysPage() {
- const [keys, setKeys] = useState<ApiKey[]>([]);
- const [revealedKey, setRevealedKey] = useState<string | null>(null);
- const [error, setError] = useState<string | null>(null);
-
- const loadKeys = useCallback(async () => {
- try {
- setError(null);
- const loaded = await fetchApiKeys();
- setKeys(loaded);
- } catch (e) {
- setError(e instanceof Error ? e.message : "Failed to load API keys");
- }
- }, []);
-
- useEffect(() => {
- void loadKeys();
- }, [loadKeys]);
-
- const handleCreated = (rawKey: string) => {
- setRevealedKey(rawKey);
- void loadKeys();
- };
-
- const handleRevoke = async (keyId: number) => {
- try {
- await revokeApiKey(keyId);
- void loadKeys();
- } catch {
- setError("Failed to revoke key");
- }
- };
-
- return (
- <DashboardLayout>
- <div className="flex flex-col gap-8">
- <div className="flex items-center gap-3">
- <div className="flex h-10 w-10 items-center justify-center rounded-lg border border-border bg-muted/40">
- <HugeiconsIcon icon={Key01Icon} className="size-5" />
- </div>
- <div>
- <h1 className="text-xl font-bold font-heading">API Keys</h1>
- <p className="text-sm text-muted-foreground">
- Create keys to access Unsloth Studio programmatically via the OpenAI-compatible API.
- </p>
- </div>
- </div>
-
- {error && (
- <div className="flex items-center gap-2 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive">
- <HugeiconsIcon icon={AlertCircleIcon} className="size-4 shrink-0" />
- {error}
- </div>
- )}
-
- <CreateKeyForm onCreated={handleCreated} />
- <KeysTable keys={keys} onRevoke={handleRevoke} />
- <UsageExamples />
- </div>
-
- <RevealKeyDialog
- open={revealedKey !== null}
- rawKey={revealedKey ?? ""}
- onClose={() => setRevealedKey(null)}
- />
- </DashboardLayout>
- );
-}
diff --git a/studio/frontend/src/features/auth/index.ts b/studio/frontend/src/features/auth/index.ts
index 9962f6d431d..75db92432c7 100644
--- a/studio/frontend/src/features/auth/index.ts
+++ b/studio/frontend/src/features/auth/index.ts
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-export { ApiKeysPage } from "./api-keys-page";
export { LoginPage } from "./login-page";
export { ChangePasswordPage } from "./change-password-page";
export { authFetch, refreshSession } from "./api";
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index c3153cdec79..32c3b6cd16d 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -7,36 +7,16 @@ import {
ModelSelector,
} from "@/components/assistant-ui/model-selector";
import { Thread } from "@/components/assistant-ui/thread";
-import { Button } from "@/components/ui/button";
-import {
- Sheet,
- SheetContent,
- SheetDescription,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet";
-import {
- SidebarProvider,
- SidebarTrigger,
- useSidebar,
-} from "@/components/ui/sidebar";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { GuidedTour, useGuidedTourController } from "@/features/tour";
import { cn } from "@/lib/utils";
+import { GuidedTour, useGuidedTourController } from "@/features/tour";
+import { useSidebar } from "@/components/ui/sidebar";
import {
- ColumnInsertIcon,
- PencilEdit02Icon,
Settings04Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
+import { useNavigate, useSearch } from "@tanstack/react-router";
import {
- type CSSProperties,
type ReactElement,
- type ReactNode,
memo,
useCallback,
useEffect,
@@ -45,6 +25,7 @@ import {
useState,
} from "react";
import { toast } from "sonner";
+import type { ChatSearch } from "@/app/routes/chat";
import { listLocalModels } from "./api/chat-api";
import { ChatSettingsPanel } from "./chat-settings-sheet";
import { ContextUsageBar } from "./components/context-usage-bar";
@@ -63,7 +44,6 @@ import {
SharedComposer,
} from "./shared-composer";
import { useChatRuntimeStore } from "./stores/chat-runtime-store";
-import { ThreadSidebar } from "./thread-sidebar";
import { buildChatTourSteps } from "./tour";
import type { ChatView, MessageRecord } from "./types";
@@ -135,7 +115,7 @@ const SingleContent = memo(function SingleContent({
initialThreadId={threadId}
newThreadNonce={newThreadNonce}
>
- <div className="min-h-0 flex-1">
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
<Thread />
</div>
</ChatRuntimeProvider>
@@ -223,7 +203,7 @@ const LoraCompareContent = memo(function LoraCompareContent({
Base Model
</span>
</div>
- <div className="min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 flex-col">
<ChatRuntimeProvider
modelType="base"
pairId={pairId}
@@ -231,7 +211,9 @@ const LoraCompareContent = memo(function LoraCompareContent({
syncActiveThreadId={false}
>
<RegisterCompareHandle name="base" />
- <Thread hideComposer={true} hideWelcome={true} />
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
+ <Thread hideComposer={true} hideWelcome={true} />
+ </div>
</ChatRuntimeProvider>
</div>
</div>
@@ -241,7 +223,7 @@ const LoraCompareContent = memo(function LoraCompareContent({
Fine-tuned
</span>
</div>
- <div className="min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 flex-col">
<ChatRuntimeProvider
modelType="lora"
pairId={pairId}
@@ -249,12 +231,14 @@ const LoraCompareContent = memo(function LoraCompareContent({
syncActiveThreadId={false}
>
<RegisterCompareHandle name="lora" />
- <Thread hideComposer={true} hideWelcome={true} />
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
+ <Thread hideComposer={true} hideWelcome={true} />
+ </div>
</ChatRuntimeProvider>
</div>
</div>
</div>
- <div className="z-20 mx-auto w-full max-w-4xl shrink-0 border-t border-border/60 bg-background px-4 pt-2 pb-4">
+ <div className="z-20 mx-auto w-full max-w-4xl shrink-0 bg-background px-4 pt-2 pb-4">
<SharedComposer handlesRef={handlesRef} />
</div>
</div>
@@ -322,10 +306,7 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
className="grid min-h-0 flex-1 grid-cols-1 px-0 md:grid-cols-2"
>
<div className="flex min-h-0 flex-col">
- <div className="flex items-center gap-2 px-3 py-1.5">
- <span className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">
- Model 1
- </span>
+ <div className="flex h-11 shrink-0 items-center gap-2 px-3">
<ModelSelector
models={models}
loraModels={loraModels}
@@ -340,10 +321,10 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
onFoldersChange={onFoldersChange}
variant="ghost"
size="sm"
- className="max-w-[50%]"
+ className="max-w-[80%]"
/>
</div>
- <div className="min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 flex-col">
<ChatRuntimeProvider
modelType="model1"
pairId={pairId}
@@ -351,15 +332,14 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
syncActiveThreadId={false}
>
<RegisterCompareHandle name="model1" />
- <Thread hideComposer={true} hideWelcome={true} />
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
+ <Thread hideComposer={true} hideWelcome={true} />
+ </div>
</ChatRuntimeProvider>
</div>
</div>
- <div className="flex min-h-0 flex-col border-t border-border/60 md:border-t-0 md:border-l">
- <div className="flex items-center gap-2 px-3 py-1.5 md:justify-end">
- <span className="text-[10px] font-semibold uppercase tracking-wider text-primary">
- Model 2
- </span>
+ <div className="flex min-h-0 flex-col border-t border-sidebar-border md:border-t-0 md:border-l">
+ <div className="flex h-11 shrink-0 items-center gap-2 px-3">
<ModelSelector
models={models}
loraModels={loraModels}
@@ -374,10 +354,10 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
onFoldersChange={onFoldersChange}
variant="ghost"
size="sm"
- className="max-w-[50%]"
+ className="max-w-[80%]"
/>
</div>
- <div className="min-h-0 flex-1">
+ <div className="flex min-h-0 flex-1 flex-col">
<ChatRuntimeProvider
modelType="model2"
pairId={pairId}
@@ -385,12 +365,14 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
syncActiveThreadId={false}
>
<RegisterCompareHandle name="model2" />
- <Thread hideComposer={true} hideWelcome={true} />
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
+ <Thread hideComposer={true} hideWelcome={true} />
+ </div>
</ChatRuntimeProvider>
</div>
</div>
</div>
- <div className="z-20 mx-auto w-full max-w-4xl shrink-0 border-t border-border/60 bg-background px-4 pt-2 pb-4">
+ <div className="z-20 mx-auto w-full max-w-4xl shrink-0 bg-background px-4 pt-2 pb-4">
<SharedComposer
handlesRef={handlesRef}
model1={model1}
@@ -402,110 +384,19 @@ const GeneralCompareContent = memo(function GeneralCompareContent({
);
});
-function InlineSidebar({
- children,
- side = "left",
-}: {
- children: ReactNode;
- side?: "left" | "right";
-}) {
- const { state, isMobile, openMobile, setOpenMobile } = useSidebar();
- const collapsed = state === "collapsed";
-
- if (isMobile) {
- return (
- <Sheet open={openMobile} onOpenChange={setOpenMobile}>
- <SheetContent side={side} className="w-[18rem] p-0">
- <SheetHeader className="sr-only">
- <SheetTitle>Chat sidebar</SheetTitle>
- <SheetDescription>Chat threads and actions</SheetDescription>
- </SheetHeader>
- <div className="h-full overflow-auto">{children}</div>
- </SheetContent>
- </Sheet>
- );
- }
-
- return (
- <div
- className="group shrink-0 h-full pb-3.5"
- data-state={state}
- data-collapsible={collapsed ? "offcanvas" : ""}
- data-side={side}
- >
- <aside
- data-sidebar="sidebar"
- className={cn(
- "bg-muted/70 text-sidebar-foreground h-full overflow-hidden rounded-2xl corner-squircle transition-[width] duration-200 ease-linear",
- !collapsed && side === "right" && "border-l border-sidebar-border/70",
- collapsed ? "w-0" : "w-(--sidebar-width)",
- )}
- >
- <div className="flex h-full w-(--sidebar-width) flex-col">
- {children}
- </div>
- </aside>
- </div>
- );
-}
-
-function TopBarActions({
- onNewThread,
- onNewCompare,
- showCompare,
-}: {
- onNewThread: () => void;
- onNewCompare: () => void;
- showCompare: boolean;
-}) {
- const { state } = useSidebar();
- if (state !== "collapsed") {
- return null;
- }
- return (
- <>
- <Tooltip>
- <TooltipTrigger asChild={true}>
- <Button variant="ghost" size="icon-sm" onClick={onNewThread}>
- <HugeiconsIcon icon={PencilEdit02Icon} strokeWidth={2} />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="bottom">New Chat</TooltipContent>
- </Tooltip>
- {showCompare ? (
- <Tooltip>
- <TooltipTrigger asChild={true}>
- <Button variant="ghost" size="icon-sm" onClick={onNewCompare}>
- <HugeiconsIcon icon={ColumnInsertIcon} strokeWidth={2} />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="bottom">Compare</TooltipContent>
- </Tooltip>
- ) : null}
- </>
- );
-}
+export function ChatPage(): ReactElement {
+ const search = useSearch({ from: "/chat" });
+ const navigate = useNavigate();
-function getInitialSingleChatView(): ChatView {
- const id = useChatRuntimeStore.getState().activeThreadId;
- if (typeof id === "string" && id.length > 0 && !id.startsWith("__LOCALID_")) {
- return { mode: "single", threadId: id };
- }
- return { mode: "single" };
-}
+ const settingsOpen = useChatRuntimeStore((s) => s.settingsPanelOpen);
+ const setSettingsOpen = useChatRuntimeStore((s) => s.setSettingsPanelOpen);
-export function ChatPage(): ReactElement {
- // Do not set newThreadNonce here: each /chat mount would run ThreadNewChatSwitch
- // and create spurious threads when navigating (e.g. Recipes / Export). New Chat
- // explicitly sets a nonce in handleNewThread.
- const [view, setView] = useState<ChatView>(getInitialSingleChatView);
- const [settingsOpen, setSettingsOpen] = useState(false);
+ useEffect(() => {
+ return () => setSettingsOpen(false);
+ }, [setSettingsOpen]);
const [modelSelectorOpen, setModelSelectorOpen] = useState(false);
const [modelSelectorLocked, setModelSelectorLocked] = useState(false);
- const [sidebarOpen, setSidebarOpen] = useState(true);
- const [viewBeforeCompare, setViewBeforeCompare] = useState<ChatView | null>(
- null,
- );
+ const viewBeforeCompareRef = useRef<ChatSearch | null>(null);
const inferenceParams = useChatRuntimeStore((state) => state.params);
const setInferenceParams = useChatRuntimeStore((state) => state.setParams);
const activeGgufVariant = useChatRuntimeStore(
@@ -515,8 +406,6 @@ export function ChatPage(): ReactElement {
(state) => state.ggufContextLength,
);
const contextUsage = useChatRuntimeStore((state) => state.contextUsage);
- const autoTitle = useChatRuntimeStore((state) => state.autoTitle);
- const setAutoTitle = useChatRuntimeStore((state) => state.setAutoTitle);
const modelsFromStore = useChatRuntimeStore((state) => state.models);
const lorasFromStore = useChatRuntimeStore((state) => state.loras);
const modelsError = useChatRuntimeStore((state) => state.modelsError);
@@ -541,6 +430,27 @@ export function ChatPage(): ReactElement {
return Boolean(inferenceParams.checkpoint);
}, [inferenceParams.checkpoint]);
+ // Derive view from URL search params
+ const view = useMemo<ChatView>(() => {
+ if (search.compare) {
+ return {
+ mode: "compare",
+ pairId:
+ search.compare,
+ };
+ }
+ if (search.thread) {
+ return { mode: "single", threadId: search.thread };
+ }
+ if (activeThreadId && !activeThreadId.startsWith("__LOCALID_")) {
+ return { mode: "single", threadId: activeThreadId };
+ }
+ if (search.new) {
+ return { mode: "single", newThreadNonce: search.new };
+ }
+ return { mode: "single" };
+ }, [search.thread, search.compare, search.new, activeThreadId]);
+
const handleCheckpointChange = useCallback(
(
value: string,
@@ -601,28 +511,6 @@ export function ChatPage(): ReactElement {
const handleEject = useCallback(() => {
void ejectModel();
}, [ejectModel]);
- const handleNewThread = useCallback(() => {
- // Skip if we are already on a fresh unsaved draft with no messages sent.
- // Once the user sends a message, append() sets activeThreadId in the store,
- // so we check the store to know whether the current draft has been sent.
- if (
- view.mode === "single" &&
- !view.threadId &&
- !useChatRuntimeStore.getState().activeThreadId
- ) {
- return;
- }
-
- useChatRuntimeStore.getState().setActiveThreadId(null);
- setView({ mode: "single", newThreadNonce: crypto.randomUUID() });
- }, [view]);
- const handleNewCompare = useCallback(() => {
- setView({ mode: "compare", pairId: crypto.randomUUID() });
- // Clear activeThreadId so compare panes do not inherit the single-chat
- // thread ID as a fallback for session_id routing.
- useChatRuntimeStore.getState().setActiveThreadId(null);
- useChatRuntimeStore.getState().setContextUsage(null);
- }, []);
const openModelSelector = useCallback(() => {
setModelSelectorLocked(true);
@@ -641,30 +529,26 @@ export function ChatPage(): ReactElement {
},
[modelSelectorLocked],
);
- const openSettings = useCallback(() => setSettingsOpen(true), []);
- const closeSettings = useCallback(() => setSettingsOpen(false), []);
- const openSidebar = useCallback(() => setSidebarOpen(true), []);
+ const openSettings = useCallback(() => setSettingsOpen(true), [setSettingsOpen]);
+ const closeSettings = useCallback(() => setSettingsOpen(false), [setSettingsOpen]);
+ const { setPinned, isMobile } = useSidebar();
+ const openSidebar = useCallback(() => setPinned(true), [setPinned]);
const enterCompare = useCallback(() => {
- setViewBeforeCompare((prev) => prev ?? view);
- setView({ mode: "compare", pairId: crypto.randomUUID() });
- // Clear activeThreadId so compare panes do not inherit the single-chat
- // thread ID as a fallback for session_id routing.
+ viewBeforeCompareRef.current = { ...search };
useChatRuntimeStore.getState().setActiveThreadId(null);
useChatRuntimeStore.getState().setContextUsage(null);
- }, [view]);
+ navigate({ to: "/chat", search: { compare: crypto.randomUUID() } });
+ }, [navigate, search]);
const exitCompare = useCallback(() => {
- if (!viewBeforeCompare) return;
- setView(viewBeforeCompare);
- setViewBeforeCompare(null);
+ const saved = viewBeforeCompareRef.current;
+ if (!saved) return;
+ viewBeforeCompareRef.current = null;
+ navigate({ to: "/chat", search: saved });
// Restore context usage from the active thread's last assistant message.
- // Use the thread ID from the saved view rather than the store, because
- // activeThreadId may have been cleared on compare entry.
- const store = useChatRuntimeStore.getState();
const threadId =
- ("threadId" in viewBeforeCompare ? viewBeforeCompare.threadId : null) ??
- store.activeThreadId;
+ saved.thread ?? useChatRuntimeStore.getState().activeThreadId;
if (threadId) {
void db.messages
.where("threadId")
@@ -672,18 +556,12 @@ export function ChatPage(): ReactElement {
.reverse()
.first()
.then((msg) => {
- const saved = msg?.metadata as Record<string, unknown> | undefined;
- const usage = saved?.contextUsage as
- | typeof store.contextUsage
- | undefined;
- if (usage) store.setContextUsage(usage);
+ const metadata = msg?.metadata as Record<string, unknown> | undefined;
+ const usage = metadata?.contextUsage as ReturnType<typeof useChatRuntimeStore.getState>["contextUsage"];
+ if (usage) useChatRuntimeStore.getState().setContextUsage(usage);
});
}
- }, [viewBeforeCompare]);
-
- const handleThreadSelect = useCallback((nextView: ChatView) => {
- setView(nextView);
- }, []);
+ }, [navigate]);
const models = useMemo<ModelOption[]>(
() =>
@@ -727,7 +605,7 @@ export function ChatPage(): ReactElement {
);
})
.catch(() => {});
- }, []);
+ }, [navigate]);
const loraModels = useMemo<LoraModelOption[]>(() => {
const fromLoras = lorasFromStore.map((lora) => ({
@@ -771,9 +649,9 @@ export function ChatPage(): ReactElement {
});
await selectModelRef.current({ id: targetLora.id, isLora: true });
if (canceled) return;
- setView({ mode: "compare", pairId: crypto.randomUUID() });
useChatRuntimeStore.getState().setActiveThreadId(null);
useChatRuntimeStore.getState().setContextUsage(null);
+ navigate({ to: "/chat", search: { compare: crypto.randomUUID() } });
clearHandoff();
console.info("[chat-handoff] loaded lora + opened compare");
return;
@@ -851,39 +729,18 @@ export function ChatPage(): ReactElement {
}, [modelSelectorLocked, tour.open]);
return (
- <div className="h-[calc(100dvh-4rem)] bg-background overflow-hidden">
+ <div className="flex min-h-0 min-w-0 flex-1 basis-0 bg-background overflow-hidden">
<GuidedTour {...tour.tourProps} />
- <SidebarProvider
- defaultOpen={true}
- open={sidebarOpen}
- onOpenChange={setSidebarOpen}
- className="!min-h-0 h-full w-full max-w-7xl mx-auto px-2 sm:px-4"
- style={
- {
- "--sidebar-width": "14rem",
- "--sidebar-width-icon": "3rem",
- } as CSSProperties
- }
- >
- <InlineSidebar>
- <ThreadSidebar
- view={view}
- onSelect={handleThreadSelect}
- onNewThread={handleNewThread}
- onNewCompare={handleNewCompare}
- showCompare={canCompare}
- />
- </InlineSidebar>
-
- <div className="flex min-h-0 min-w-0 flex-1 flex-col">
- <div className="flex h-11 shrink-0 items-center px-1.5 sm:px-2">
- <div className="flex items-center gap-1">
- <SidebarTrigger />
- <TopBarActions
- onNewThread={handleNewThread}
- onNewCompare={handleNewCompare}
- showCompare={canCompare}
- />
+ <div className="relative flex min-h-0 min-w-0 flex-1 basis-0 flex-col overflow-hidden">
+ <div
+ className={cn(
+ "absolute top-0 left-0 right-2 z-30 flex h-11 shrink-0 items-center pr-2 bg-background",
+ isMobile ? "pl-12 pr-1.5" : "pl-2",
+ view.mode === "compare" && "right-2 left-auto w-auto bg-transparent pl-0 pr-2",
+ )}
+ >
+ <div className="flex items-center gap-1">
+ {view.mode !== "compare" && (
<ModelSelector
models={models}
loraModels={loraModels}
@@ -899,92 +756,90 @@ export function ChatPage(): ReactElement {
contentDataTour="chat-model-selector-popover"
className="max-w-[62vw] sm:max-w-none"
/>
- {loadingModel && loadToastDismissed ? (
- <ModelLoadInlineStatus
- label={
- loadProgress?.phase === "starting"
- ? "Starting model…"
- : loadingModel.isDownloaded || loadingModel.isCachedLora
- ? "Loading model…"
- : "Downloading model…"
- }
- title={
- loadingModel.isDownloaded
- ? `Loading ${loadingModel.displayName} from cache.`
- : loadingModel.isCachedLora
- ? `Loading ${loadingModel.displayName} into memory.`
- : `Loading ${loadingModel.displayName}. This may include downloading.`
- }
- progressPercent={loadProgress?.percent}
- progressLabel={loadProgress?.label}
- onStop={cancelLoading}
- />
- ) : null}
- </div>
- {modelsError && (
- <div className="ml-2 text-xs text-destructive truncate max-w-[28rem]">
- {modelsError}
- </div>
)}
- <div className="flex-1" />
- {view.mode === "single" && ggufContextLength && contextUsage ? (
- <ContextUsageBar
- used={contextUsage.totalTokens}
- total={ggufContextLength}
- cached={contextUsage.cachedTokens}
- promptTokens={contextUsage.promptTokens}
- completionTokens={contextUsage.completionTokens}
+ {loadingModel && loadToastDismissed ? (
+ <ModelLoadInlineStatus
+ label={
+ loadProgress?.phase === "starting"
+ ? "Starting model…"
+ : loadingModel.isDownloaded || loadingModel.isCachedLora
+ ? "Loading model…"
+ : "Downloading model…"
+ }
+ title={
+ loadingModel.isDownloaded
+ ? `Loading ${loadingModel.displayName} from cache.`
+ : loadingModel.isCachedLora
+ ? `Loading ${loadingModel.displayName} into memory.`
+ : `Loading ${loadingModel.displayName}. This may include downloading.`
+ }
+ progressPercent={loadProgress?.percent}
+ progressLabel={loadProgress?.label}
+ onStop={cancelLoading}
/>
) : null}
- <button
- type="button"
- onClick={() => setSettingsOpen((o) => !o)}
- className="flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
- title="Inference settings"
- data-tour="chat-settings"
- >
- <HugeiconsIcon icon={Settings04Icon} className="size-5" />
- </button>
</div>
-
- {view.mode === "single" ? (
- <SingleContent
- key={view.threadId ?? "single"}
- threadId={view.threadId}
- newThreadNonce={view.newThreadNonce}
- />
- ) : (
- <CompareContent
- key={view.pairId}
- pairId={view.pairId}
- models={models}
- loraModels={loraModels}
- onFoldersChange={refreshLocalModels}
- />
+ {modelsError && (
+ <div className="ml-2 text-xs text-destructive truncate max-w-[28rem]">
+ {modelsError}
+ </div>
)}
+ <div className="flex-1" />
+ {view.mode === "single" && ggufContextLength && contextUsage ? (
+ <ContextUsageBar
+ used={contextUsage.totalTokens}
+ total={ggufContextLength}
+ cached={contextUsage.cachedTokens}
+ promptTokens={contextUsage.promptTokens}
+ completionTokens={contextUsage.completionTokens}
+ />
+ ) : null}
+ <button
+ type="button"
+ onClick={() => setSettingsOpen(!settingsOpen)}
+ className="flex h-9 w-9 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
+ title="Inference settings"
+ data-tour="chat-settings"
+ >
+ <HugeiconsIcon icon={Settings04Icon} className="size-5" />
+ </button>
</div>
- <ChatSettingsPanel
- open={settingsOpen}
- onOpenChange={setSettingsOpen}
- params={inferenceParams}
- onParamsChange={setInferenceParams}
- autoTitle={autoTitle}
- onAutoTitleChange={setAutoTitle}
- onReloadModel={() => {
- const state = useChatRuntimeStore.getState();
- if (state.params.checkpoint) {
- selectModel({
- id: state.params.checkpoint,
- ggufVariant: state.activeGgufVariant ?? undefined,
- forceReload: true,
- isDownloaded: true,
- loadingDescription: "Reloading with updated chat template.",
- });
- }
- }}
- />
- </SidebarProvider>
+ {view.mode === "single" ? (
+ <SingleContent
+ key={view.threadId ?? "single"}
+ threadId={view.threadId}
+ newThreadNonce={view.newThreadNonce}
+ />
+ ) : (
+ <CompareContent
+ key={view.pairId}
+ pairId={view.pairId}
+ models={models}
+ loraModels={loraModels}
+ onFoldersChange={refreshLocalModels}
+ />
+ )}
+ </div>
+
+ <ChatSettingsPanel
+ open={settingsOpen}
+ onOpenChange={setSettingsOpen}
+ params={inferenceParams}
+ onParamsChange={setInferenceParams}
+ onReloadModel={() => {
+ const state = useChatRuntimeStore.getState();
+ if (state.params.checkpoint) {
+ selectModel({
+ id: state.params.checkpoint,
+ ggufVariant: state.activeGgufVariant ?? undefined,
+ forceReload: true,
+ isDownloaded: true,
+ loadingDescription: "Reloading with updated chat template.",
+ });
+ }
+ }}
+ />
</div>
);
}
diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
index bcfd5852144..2e03591a8e3 100644
--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx
+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx
@@ -55,7 +55,6 @@ import {
PencilEdit01Icon,
Settings02Icon,
SlidersHorizontalIcon,
- UserSettings01Icon,
Wrench01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -476,8 +475,6 @@ interface ChatSettingsPanelProps {
onOpenChange?: (open: boolean) => void;
params: InferenceParams;
onParamsChange: (params: InferenceParams) => void;
- autoTitle: boolean;
- onAutoTitleChange: (enabled: boolean) => void;
onReloadModel?: () => void;
}
@@ -486,8 +483,6 @@ export function ChatSettingsPanel({
onOpenChange,
params,
onParamsChange,
- autoTitle,
- onAutoTitleChange,
onReloadModel,
}: ChatSettingsPanelProps) {
const isMobile = useIsMobile();
@@ -743,7 +738,8 @@ export function ChatSettingsPanel({
const settingsContent = (
<>
- <div className="flex items-center gap-2 px-4 py-3">
+ <div className="aui-thread-viewport relative h-full overflow-y-auto bg-muted/70">
+ <div className="sticky top-0 z-10 flex items-center gap-2 bg-muted/70 px-4 py-3 backdrop-blur">
<HugeiconsIcon
icon={PencilEdit01Icon}
className="size-4 text-muted-foreground/70"
@@ -753,7 +749,7 @@ export function ChatSettingsPanel({
</span>
</div>
- <div className="flex-1 overflow-y-auto px-1.5">
+ <div className="px-1.5">
{/* mt-4 matches the Playground sidebar gap (SidebarHeader py-3 + SidebarGroup pt-1) */}
<div className="mt-4 px-2 pb-3">
<div className="space-y-1.5">
@@ -893,7 +889,7 @@ export function ChatSettingsPanel({
value={params.systemPrompt}
onChange={(e) => set("systemPrompt")(e.target.value)}
placeholder="You are a helpful assistant..."
- className="min-h-20 text-xs corner-squircle"
+ className="min-h-20 max-h-48 overflow-y-auto text-xs corner-squircle"
rows={3}
/>
</div>
@@ -1174,27 +1170,9 @@ export function ChatSettingsPanel({
</div>
</CollapsibleSection>
- <CollapsibleSection
- icon={UserSettings01Icon}
- label="Preferences"
- defaultOpen={true}
- >
- <div className="flex flex-col gap-3 py-1">
- <div className="flex items-center justify-between gap-3">
- <div className="min-w-0">
- <div className="text-xs font-medium">Auto title</div>
- <div className="text-[11px] text-muted-foreground">
- Generate short title after reply.
- </div>
- </div>
- <Switch checked={autoTitle} onCheckedChange={onAutoTitleChange} />
- </div>
- <HfTokenField />
- </div>
- </CollapsibleSection>
-
<ChatTemplateSection onReloadModel={onReloadModel} />
</div>
+ </div>
<Dialog
open={systemPromptEditorOpen}
onOpenChange={(nextOpen) => {
@@ -1224,7 +1202,7 @@ export function ChatSettingsPanel({
value={systemPromptDraft}
onChange={(event) => setSystemPromptDraft(event.target.value)}
placeholder="You are a helpful assistant..."
- className="min-h-[24rem] text-sm leading-6 corner-squircle"
+ className="min-h-[24rem] max-h-[50vh] overflow-y-auto text-sm leading-6 corner-squircle"
rows={14}
/>
</div>
@@ -1268,9 +1246,9 @@ export function ChatSettingsPanel({
return (
<aside
- className={`shrink-0 self-start h-[calc(100%-0.875rem)] overflow-hidden bg-muted/70 rounded-2xl corner-squircle transition-[width] duration-200 ease-linear ${open ? "w-[17rem] border-l border-sidebar-border/70" : "w-0"}`}
+ className={`relative z-50 shrink-0 h-full overflow-hidden bg-muted/70 transition-[width] duration-200 ease-linear ${open ? "w-[17rem]" : "w-0"}`}
>
- <div className="flex h-full w-[17rem] flex-col">{settingsContent}</div>
+ <div className="h-full w-[17rem]">{settingsContent}</div>
</aside>
);
}
@@ -1348,29 +1326,6 @@ function AutoHealToolCallsToggle() {
);
}
-function HfTokenField() {
- const hfToken = useChatRuntimeStore((s) => s.hfToken);
- const setHfToken = useChatRuntimeStore((s) => s.setHfToken);
-
- return (
- <div className="flex flex-col gap-1.5">
- <div className="min-w-0">
- <div className="text-xs font-medium">Hugging Face Token</div>
- <div className="text-[11px] text-muted-foreground">
- For downloading gated or private models.
- </div>
- </div>
- <Input
- type="password"
- value={hfToken}
- placeholder="hf_..."
- className="h-7 text-xs font-mono"
- onChange={(e) => setHfToken(e.target.value)}
- />
- </div>
- );
-}
-
function ChatTemplateSection({
onReloadModel,
}: {
@@ -1391,7 +1346,7 @@ function ChatTemplateSection({
<Textarea
value={displayValue}
onChange={(e) => setOverride(e.target.value)}
- className="min-h-32 font-mono text-[10px] leading-relaxed md:text-[10px] corner-squircle"
+ className="min-h-32 max-h-64 overflow-y-auto font-mono text-[10px] leading-relaxed md:text-[10px] corner-squircle"
rows={6}
spellCheck={false}
/>
diff --git a/studio/frontend/src/features/chat/components/chat-search-dialog.tsx b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
new file mode 100644
index 00000000000..eca3b4bd9ff
--- /dev/null
+++ b/studio/frontend/src/features/chat/components/chat-search-dialog.tsx
@@ -0,0 +1,120 @@
+// 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 {
+ Command,
+ CommandDialog,
+ CommandEmpty,
+ CommandGroup,
+ CommandList,
+} from "@/components/ui/command";
+import { useTrainingRuntimeStore } from "@/features/training";
+import { Cancel01Icon, Message01Icon, SearchIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { useNavigate } from "@tanstack/react-router";
+import { Command as CommandPrimitive } from "cmdk";
+import { useEffect } from "react";
+import { useChatSearchIndex } from "../hooks/use-chat-search-index";
+import { useChatSearchStore } from "../stores/chat-search-store";
+
+function formatRelative(createdAt: number): string {
+ const diff = Date.now() - createdAt;
+ const day = 86_400_000;
+ if (diff < day) return "Today";
+ if (diff < 7 * day) return "Past week";
+ if (diff < 30 * day) return "Past month";
+ return "Older";
+}
+
+export function ChatSearchDialog() {
+ const isOpen = useChatSearchStore((s) => s.isOpen);
+ const setOpen = useChatSearchStore((s) => s.setOpen);
+ const close = useChatSearchStore((s) => s.close);
+ const navigate = useNavigate();
+ const { items, loading } = useChatSearchIndex(isOpen);
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (!(e.metaKey || e.ctrlKey) || e.key.toLowerCase() !== "k") return;
+ if (useTrainingRuntimeStore.getState().isTrainingRunning) return;
+ const el = document.activeElement as HTMLElement | null;
+ const tag = el?.tagName;
+ if (tag === "INPUT" || tag === "TEXTAREA" || el?.isContentEditable) return;
+ e.preventDefault();
+ useChatSearchStore.getState().open();
+ };
+ window.addEventListener("keydown", handler);
+ return () => window.removeEventListener("keydown", handler);
+ }, []);
+
+ return (
+ <CommandDialog
+ open={isOpen}
+ onOpenChange={setOpen}
+ className="shadow-border corner-squircle w-[635px] max-w-[calc(100%-2rem)] gap-0 p-0 sm:max-w-[635px]"
+ overlayClassName="bg-transparent"
+ >
+ <Command className="rounded-none p-0">
+ <div className="flex items-center gap-3 border-b border-border/40 px-4 py-3">
+ <HugeiconsIcon
+ icon={SearchIcon}
+ strokeWidth={2}
+ className="size-4 shrink-0 text-muted-foreground"
+ />
+ <CommandPrimitive.Input
+ placeholder="Search chats..."
+ className="flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
+ />
+ <button
+ type="button"
+ onClick={close}
+ className="flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ aria-label="Close"
+ >
+ <HugeiconsIcon icon={Cancel01Icon} strokeWidth={2} className="size-4" />
+ </button>
+ </div>
+ <CommandList className="max-h-[420px] p-1">
+ <CommandEmpty className="py-6 text-center text-xs text-muted-foreground">
+ {loading
+ ? "Loading…"
+ : items.length === 0
+ ? "No chats yet."
+ : "No chats match."}
+ </CommandEmpty>
+ <CommandGroup className="p-0">
+ {items.map((item) => (
+ <CommandPrimitive.Item
+ key={item.id}
+ value={`${item.title} ${item.preview}`}
+ onSelect={() => {
+ navigate({
+ to: "/chat",
+ search:
+ item.type === "single"
+ ? { thread: item.id }
+ : { compare: item.id },
+ });
+ close();
+ }}
+ className="relative flex cursor-default select-none items-center gap-3 rounded-lg px-3 py-2.5 text-sm outline-hidden data-selected:bg-muted data-selected:text-foreground"
+ >
+ <HugeiconsIcon
+ icon={Message01Icon}
+ strokeWidth={2}
+ className="size-4 shrink-0 text-muted-foreground"
+ />
+ <span className="min-w-0 flex-1 truncate text-[13px] font-medium">
+ {item.title || "Untitled chat"}
+ </span>
+ <span className="shrink-0 text-[11px] text-muted-foreground">
+ {formatRelative(item.createdAt)}
+ </span>
+ </CommandPrimitive.Item>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </CommandDialog>
+ );
+}
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-search-index.ts b/studio/frontend/src/features/chat/hooks/use-chat-search-index.ts
new file mode 100644
index 00000000000..cab91da44f7
--- /dev/null
+++ b/studio/frontend/src/features/chat/hooks/use-chat-search-index.ts
@@ -0,0 +1,156 @@
+// 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 { useEffect, useState } from "react";
+import { db } from "../db";
+import type { MessageRecord, ThreadRecord } from "../types";
+
+export interface ChatSearchItem {
+ type: "single" | "compare";
+ id: string;
+ title: string;
+ preview: string;
+ createdAt: number;
+}
+
+const THREAD_LIMIT = 200;
+const PREVIEW_MAX = 120;
+
+function extractText(message: MessageRecord): string {
+ const content = message.content;
+ if (!Array.isArray(content)) return "";
+ const parts: string[] = [];
+ for (const part of content) {
+ if (!part || typeof part !== "object") continue;
+ const p = part as { type?: string; text?: unknown };
+ if ((p.type === "text" || p.type === "reasoning") && typeof p.text === "string") {
+ parts.push(p.text);
+ }
+ }
+ return parts.join(" ").replace(/\s+/g, " ").trim();
+}
+
+function truncate(text: string, max: number): string {
+ if (text.length <= max) return text;
+ return text.slice(0, max).trimEnd() + "…";
+}
+
+async function buildIndex(): Promise<ChatSearchItem[]> {
+ // Fetch all threads newest-first, filter archived in JS, then take top N.
+ // `archived` is a boolean which Dexie does not index reliably, so we filter
+ // after the sort instead of using `.where("archived")`.
+ const all = (await db.threads
+ .orderBy("createdAt")
+ .reverse()
+ .toArray()) as ThreadRecord[];
+ const active = all.filter((t) => !t.archived).slice(0, THREAD_LIMIT);
+
+ const itemThreadIds = new Map<
+ string,
+ { item: Omit<ChatSearchItem, "preview">; threadIds: string[] }
+ >();
+ const seenPairs = new Set<string>();
+
+ for (const t of active) {
+ if (t.pairId) {
+ if (seenPairs.has(t.pairId)) {
+ const existing = itemThreadIds.get(t.pairId);
+ if (existing) existing.threadIds.push(t.id);
+ continue;
+ }
+ seenPairs.add(t.pairId);
+ itemThreadIds.set(t.pairId, {
+ item: {
+ type: "compare",
+ id: t.pairId,
+ title: t.title,
+ createdAt: t.createdAt,
+ },
+ threadIds: [t.id],
+ });
+ } else {
+ itemThreadIds.set(t.id, {
+ item: {
+ type: "single",
+ id: t.id,
+ title: t.title,
+ createdAt: t.createdAt,
+ },
+ threadIds: [t.id],
+ });
+ }
+ }
+
+ // One query for all messages across all relevant threads, then group by
+ // threadId in memory. Avoids N sequential awaits.
+ const allThreadIds = Array.from(itemThreadIds.values()).flatMap(
+ (e) => e.threadIds,
+ );
+ const messages = (await db.messages
+ .where("threadId")
+ .anyOf(allThreadIds)
+ .toArray()) as MessageRecord[];
+
+ const byThreadId = new Map<string, MessageRecord[]>();
+ for (const m of messages) {
+ const arr = byThreadId.get(m.threadId);
+ if (arr) arr.push(m);
+ else byThreadId.set(m.threadId, [m]);
+ }
+
+ const results: ChatSearchItem[] = [];
+ for (const { item, threadIds } of itemThreadIds.values()) {
+ const merged: MessageRecord[] = [];
+ for (const tid of threadIds) {
+ const arr = byThreadId.get(tid);
+ if (arr) merged.push(...arr);
+ }
+ merged.sort((a, b) => b.createdAt - a.createdAt);
+
+ let preview = "";
+ for (const m of merged) {
+ const text = extractText(m);
+ if (text) {
+ preview = truncate(text, PREVIEW_MAX);
+ break;
+ }
+ }
+ results.push({ ...item, preview });
+ }
+
+ results.sort((a, b) => b.createdAt - a.createdAt);
+ return results;
+}
+
+export function useChatSearchIndex(enabled: boolean): {
+ items: ChatSearchItem[];
+ loading: boolean;
+} {
+ const [items, setItems] = useState<ChatSearchItem[]>([]);
+ const [loading, setLoading] = useState(false);
+
+ useEffect(() => {
+ if (!enabled) {
+ // Clear stale results so the next open doesn't flash old items.
+ setItems([]);
+ return;
+ }
+ let cancelled = false;
+ setLoading(true);
+ buildIndex()
+ .then((result) => {
+ if (!cancelled) setItems(result);
+ })
+ .catch(() => {
+ if (!cancelled) setItems([]);
+ })
+ .finally(() => {
+ if (!cancelled) setLoading(false);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [enabled]);
+
+ return { items, loading };
+}
diff --git a/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts b/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts
new file mode 100644
index 00000000000..fb27f990cf8
--- /dev/null
+++ b/studio/frontend/src/features/chat/hooks/use-chat-sidebar-items.ts
@@ -0,0 +1,82 @@
+// 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 { db, useLiveQuery } from "../db";
+import { useChatRuntimeStore } from "../stores/chat-runtime-store";
+import type { ThreadRecord } from "../types";
+
+export interface SidebarItem {
+ type: "single" | "compare";
+ id: string;
+ title: string;
+ createdAt: number;
+}
+
+export function groupThreads(threads: ThreadRecord[]): SidebarItem[] {
+ const items: SidebarItem[] = [];
+ const seenPairs = new Set<string>();
+
+ for (const t of threads) {
+ if (t.archived) {
+ continue;
+ }
+ if (t.pairId) {
+ if (seenPairs.has(t.pairId)) {
+ continue;
+ }
+ seenPairs.add(t.pairId);
+ items.push({
+ type: "compare",
+ id: t.pairId,
+ title: t.title,
+ createdAt: t.createdAt,
+ });
+ } else if (!t.pairId) {
+ items.push({
+ type: "single",
+ id: t.id,
+ title: t.title,
+ createdAt: t.createdAt,
+ });
+ }
+ }
+
+ return items.sort((a, b) => b.createdAt - a.createdAt);
+}
+
+export function useChatSidebarItems() {
+ const allThreads = useLiveQuery(async () => {
+ const threadIdsWithMessage = new Set(
+ (await db.messages.orderBy("threadId").uniqueKeys()) as string[],
+ );
+ const rows = await db.threads.orderBy("createdAt").reverse().toArray();
+ return rows.filter((t) => !t.archived && threadIdsWithMessage.has(t.id));
+ }, []);
+ const items = groupThreads(allThreads ?? []);
+ const canCompare = useChatRuntimeStore((s) => Boolean(s.params.checkpoint));
+
+ return { items, canCompare };
+}
+
+export async function deleteChatItem(
+ item: SidebarItem,
+ activeId: string | undefined,
+ onSelect: (view: { mode: "single"; newThreadNonce: string }) => void,
+) {
+ await db.transaction("rw", db.threads, db.messages, async () => {
+ if (item.type === "single") {
+ await db.messages.where("threadId").equals(item.id).delete();
+ await db.threads.delete(item.id);
+ } else {
+ const paired = await db.threads.where("pairId").equals(item.id).toArray();
+ for (const t of paired) {
+ await db.messages.where("threadId").equals(t.id).delete();
+ await db.threads.delete(t.id);
+ }
+ }
+ });
+ if (activeId === item.id) {
+ useChatRuntimeStore.getState().setActiveThreadId(null);
+ onSelect({ mode: "single", newThreadNonce: crypto.randomUUID() });
+ }
+}
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index d45004cd43e..f82355526fd 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -455,7 +455,7 @@ export function SharedComposer({
return (
<div
- className={`shadow-border ring-1 ring-border relative flex w-full flex-col rounded-2xl bg-background px-1 pt-2 transition-shadow outline-none ${dragging ? "ring-ring bg-accent/50" : ""}`}
+ className={`chat-composer-surface relative flex w-full flex-col rounded-3xl bg-background px-1 pt-2 transition-shadow outline-none ${dragging ? "border-ring bg-accent/50" : ""}`}
onDragOver={(e) => {
e.preventDefault();
setDragging(true);
diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
index a041452a48b..9ff7ded18fe 100644
--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts
@@ -173,6 +173,7 @@ type ChatRuntimeStore = {
defaultChatTemplate: string | null;
chatTemplateOverride: string | null;
activeThreadId: string | null;
+ settingsPanelOpen: boolean;
pendingAudioBase64: string | null;
pendingAudioName: string | null;
contextUsage: {
@@ -193,6 +194,7 @@ type ChatRuntimeStore = {
setModelsError: (error: string | null) => void;
setCheckpoint: (modelId: string, ggufVariant?: string | null) => void;
setActiveThreadId: (threadId: string | null) => void;
+ setSettingsPanelOpen: (open: boolean) => void;
clearCheckpoint: () => void;
setReasoningEnabled: (enabled: boolean) => void;
setToolsEnabled: (enabled: boolean) => void;
@@ -243,6 +245,7 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set) => ({
defaultChatTemplate: null,
chatTemplateOverride: null,
activeThreadId: null,
+ settingsPanelOpen: false,
pendingAudioBase64: null,
pendingAudioName: null,
contextUsage: null,
@@ -294,6 +297,7 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set) => ({
activeGgufVariant: ggufVariant ?? null,
})),
setActiveThreadId: (activeThreadId) => set({ activeThreadId, contextUsage: null }),
+ setSettingsPanelOpen: (settingsPanelOpen) => set({ settingsPanelOpen }),
clearCheckpoint: () =>
set((state) => ({
params: {
diff --git a/studio/frontend/src/features/chat/stores/chat-search-store.ts b/studio/frontend/src/features/chat/stores/chat-search-store.ts
new file mode 100644
index 00000000000..3719d4f10f3
--- /dev/null
+++ b/studio/frontend/src/features/chat/stores/chat-search-store.ts
@@ -0,0 +1,18 @@
+// 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 { create } from "zustand";
+
+interface ChatSearchStore {
+ isOpen: boolean;
+ open: () => void;
+ close: () => void;
+ setOpen: (open: boolean) => void;
+}
+
+export const useChatSearchStore = create<ChatSearchStore>((set) => ({
+ isOpen: false,
+ open: () => set({ isOpen: true }),
+ close: () => set({ isOpen: false }),
+ setOpen: (isOpen) => set({ isOpen }),
+}));
diff --git a/studio/frontend/src/features/chat/thread-sidebar.tsx b/studio/frontend/src/features/chat/thread-sidebar.tsx
index 62246cdad5f..b15c16297e7 100644
--- a/studio/frontend/src/features/chat/thread-sidebar.tsx
+++ b/studio/frontend/src/features/chat/thread-sidebar.tsx
@@ -21,48 +21,10 @@ import {
PencilEdit02Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { db, useLiveQuery } from "./db";
import { useChatRuntimeStore } from "./stores/chat-runtime-store";
-import type { ChatView, ThreadRecord } from "./types";
-
-interface SidebarItem {
- type: "single" | "compare";
- id: string;
- title: string;
- createdAt: number;
-}
-
-function groupThreads(threads: ThreadRecord[]): SidebarItem[] {
- const items: SidebarItem[] = [];
- const seenPairs = new Set<string>();
-
- for (const t of threads) {
- if (t.archived) {
- continue;
- }
- if (t.pairId) {
- if (seenPairs.has(t.pairId)) {
- continue;
- }
- seenPairs.add(t.pairId);
- items.push({
- type: "compare",
- id: t.pairId,
- title: t.title,
- createdAt: t.createdAt,
- });
- } else if (!t.pairId) {
- items.push({
- type: "single",
- id: t.id,
- title: t.title,
- createdAt: t.createdAt,
- });
- }
- }
-
- return items.sort((a, b) => b.createdAt - a.createdAt);
-}
+import type { ChatView } from "./types";
+import { deleteChatItem, useChatSidebarItems } from "./hooks/use-chat-sidebar-items";
+import type { SidebarItem } from "./hooks/use-chat-sidebar-items";
export function ThreadSidebar({
view,
@@ -77,14 +39,7 @@ export function ThreadSidebar({
onNewCompare: () => void;
showCompare: boolean;
}) {
- const allThreads = useLiveQuery(async () => {
- const threadIdsWithMessage = new Set(
- (await db.messages.orderBy("threadId").uniqueKeys()) as string[],
- );
- const rows = await db.threads.orderBy("createdAt").reverse().toArray();
- return rows.filter((t) => !t.archived && threadIdsWithMessage.has(t.id));
- }, []);
- const items = groupThreads(allThreads ?? []);
+ const { items } = useChatSidebarItems();
const storeThreadId = useChatRuntimeStore((s) => s.activeThreadId);
const activeId =
view.mode === "single" ? (view.threadId ?? storeThreadId) : view.pairId;
@@ -96,23 +51,10 @@ export function ThreadSidebar({
}
async function handleDelete(item: SidebarItem) {
- if (item.type === "single") {
- await db.messages.where("threadId").equals(item.id).delete();
- await db.threads.delete(item.id);
- } else {
- const paired = await db.threads.where("pairId").equals(item.id).toArray();
- for (const t of paired) {
- await db.messages.where("threadId").equals(t.id).delete();
- await db.threads.delete(t.id);
- }
- }
- if (activeId === item.id) {
- // Directly set a new view with a nonce rather than going through
- // onNewThread(), which may return early if the guard sees no
- // threadId and no activeThreadId (after we just cleared it).
- useChatRuntimeStore.getState().setActiveThreadId(null);
- onSelect({ mode: "single", newThreadNonce: crypto.randomUUID() });
- }
+ // Directly set a new view with a nonce rather than going through
+ // onNewThread(), which may return early if the guard sees no
+ // threadId and no activeThreadId (after we just cleared it).
+ await deleteChatItem(item, activeId ?? undefined, onSelect);
}
return (
diff --git a/studio/frontend/src/features/chat/utils/clear-all-chats.ts b/studio/frontend/src/features/chat/utils/clear-all-chats.ts
new file mode 100644
index 00000000000..eff87eb95f1
--- /dev/null
+++ b/studio/frontend/src/features/chat/utils/clear-all-chats.ts
@@ -0,0 +1,15 @@
+// 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 { db } from "../db";
+
+export async function countAllChats(): Promise<number> {
+ return db.threads.count();
+}
+
+export async function clearAllChats(): Promise<void> {
+ await db.transaction("rw", db.threads, db.messages, async () => {
+ await db.messages.clear();
+ await db.threads.clear();
+ });
+}
diff --git a/studio/frontend/src/features/chat/utils/export-chat-history.ts b/studio/frontend/src/features/chat/utils/export-chat-history.ts
new file mode 100644
index 00000000000..9c8b8fccc8c
--- /dev/null
+++ b/studio/frontend/src/features/chat/utils/export-chat-history.ts
@@ -0,0 +1,41 @@
+// 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 { db } from "../db";
+
+interface ExportedChat {
+ exportedAt: string;
+ version: 1;
+ threadCount: number;
+ threads: unknown[];
+ messages: unknown[];
+}
+
+export async function buildChatExport(): Promise<ExportedChat> {
+ const [threads, messages] = await Promise.all([
+ db.threads.toArray(),
+ db.messages.toArray(),
+ ]);
+ return {
+ exportedAt: new Date().toISOString(),
+ version: 1,
+ threadCount: threads.length,
+ threads,
+ messages,
+ };
+}
+
+export async function downloadChatExport(): Promise<void> {
+ const data = await buildChatExport();
+ const blob = new Blob([JSON.stringify(data, null, 2)], {
+ type: "application/json",
+ });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `unsloth-chats-${new Date().toISOString().slice(0, 10)}.json`;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ URL.revokeObjectURL(url);
+}
diff --git a/studio/frontend/src/features/data-recipes/hooks/use-recipe-sidebar-items.ts b/studio/frontend/src/features/data-recipes/hooks/use-recipe-sidebar-items.ts
new file mode 100644
index 00000000000..7cf70dc8eba
--- /dev/null
+++ b/studio/frontend/src/features/data-recipes/hooks/use-recipe-sidebar-items.ts
@@ -0,0 +1,22 @@
+// 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 { useEffect, useState } from "react";
+import { liveQuery } from "dexie";
+import { listRecipes } from "../data/recipes-db";
+import type { RecipeRecord } from "../types";
+
+export function useRecipeSidebarItems(enabled: boolean) {
+ const [recipes, setRecipes] = useState<RecipeRecord[]>([]);
+
+ useEffect(() => {
+ if (!enabled) return;
+ const sub = liveQuery(() => listRecipes()).subscribe({
+ next: (value) => setRecipes(value),
+ error: (err) => console.error("recipe sidebar liveQuery:", err),
+ });
+ return () => sub.unsubscribe();
+ }, [enabled]);
+
+ return recipes;
+}
diff --git a/studio/frontend/src/features/settings/api/api-keys.ts b/studio/frontend/src/features/settings/api/api-keys.ts
new file mode 100644
index 00000000000..73d7b50def3
--- /dev/null
+++ b/studio/frontend/src/features/settings/api/api-keys.ts
@@ -0,0 +1,41 @@
+// 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 { authFetch } from "@/features/auth/api";
+
+export interface ApiKey {
+ id: number;
+ name: string;
+ key_prefix: string;
+ created_at: string;
+ last_used_at: string | null;
+ expires_at: string | null;
+ is_active: boolean;
+}
+
+export async function fetchApiKeys(): Promise<ApiKey[]> {
+ const res = await authFetch("/api/auth/api-keys");
+ if (!res.ok) throw new Error("Failed to load API keys");
+ const data = (await res.json()) as { api_keys: ApiKey[] };
+ return data.api_keys.filter((k) => k.is_active);
+}
+
+export async function createApiKey(
+ name: string,
+ expiresInDays: number | null,
+): Promise<{ key: string; api_key: ApiKey }> {
+ const res = await authFetch("/api/auth/api-keys", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ name, expires_in_days: expiresInDays }),
+ });
+ if (!res.ok) throw new Error("Failed to create API key");
+ return res.json();
+}
+
+export async function revokeApiKey(keyId: number): Promise<void> {
+ const res = await authFetch(`/api/auth/api-keys/${keyId}`, {
+ method: "DELETE",
+ });
+ if (!res.ok) throw new Error("Failed to revoke API key");
+}
diff --git a/studio/frontend/src/features/settings/components/api-key-row.tsx b/studio/frontend/src/features/settings/components/api-key-row.tsx
new file mode 100644
index 00000000000..74b4ba396e8
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/api-key-row.tsx
@@ -0,0 +1,101 @@
+// 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 {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import {
+ Delete02Icon,
+ Copy01Icon,
+ MoreHorizontalIcon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { copyToClipboard } from "@/lib/copy-to-clipboard";
+import type { ApiKey } from "../api/api-keys";
+
+function relative(iso: string | null): string {
+ if (!iso) return "never";
+ const diff = Date.now() - new Date(iso).getTime();
+ const days = Math.floor(diff / 86400000);
+ if (days < 1) {
+ const hours = Math.floor(diff / 3600000);
+ if (hours < 1) return "just now";
+ return `${hours}h ago`;
+ }
+ if (days < 30) return `${days}d ago`;
+ if (days < 365) return `${Math.floor(days / 30)}mo ago`;
+ return `${Math.floor(days / 365)}y ago`;
+}
+
+function expiresText(iso: string | null): string {
+ if (!iso) return "never";
+ const diff = new Date(iso).getTime() - Date.now();
+ if (diff < 0) return "expired";
+ const days = Math.floor(diff / 86400000);
+ if (days < 1) return "today";
+ return `in ${days}d`;
+}
+
+export function ApiKeyRow({
+ apiKey,
+ onRevoke,
+}: {
+ apiKey: ApiKey;
+ onRevoke: (key: ApiKey) => void;
+}) {
+ const prefix = `sk-unsloth-${apiKey.key_prefix}…`;
+ return (
+ <div className="group flex items-center gap-3 border-b border-border/60 px-1 py-3 last:border-b-0 transition-colors hover:bg-accent/40">
+ <span
+ className="size-1.5 shrink-0 rounded-full bg-emerald-500"
+ aria-hidden="true"
+ />
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <div className="flex min-w-0 items-center justify-between gap-3">
+ <span className="truncate text-sm font-medium text-foreground" title={apiKey.name}>
+ {apiKey.name}
+ </span>
+ <code className="shrink-0 font-mono text-[11px] text-muted-foreground">
+ {prefix}
+ </code>
+ </div>
+ <div className="flex flex-wrap gap-x-1.5 text-[11px] text-muted-foreground">
+ <span>Created {relative(apiKey.created_at)}</span>
+ <span>·</span>
+ <span>Used {relative(apiKey.last_used_at)}</span>
+ <span>·</span>
+ <span>Expires {expiresText(apiKey.expires_at)}</span>
+ </div>
+ </div>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="size-7 p-0 opacity-0 transition-opacity group-hover:opacity-100 data-[state=open]:opacity-100 max-sm:!opacity-100 max-sm:size-9"
+ aria-label={`Actions for ${apiKey.name}`}
+ >
+ <HugeiconsIcon icon={MoreHorizontalIcon} className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={() => copyToClipboard(prefix)}>
+ <HugeiconsIcon icon={Copy01Icon} className="size-3.5 mr-2" />
+ Copy prefix
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ onClick={() => onRevoke(apiKey)}
+ className="text-destructive focus:text-destructive"
+ >
+ <HugeiconsIcon icon={Delete02Icon} className="size-3.5 mr-2" />
+ Revoke key
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/create-key-form.tsx b/studio/frontend/src/features/settings/components/create-key-form.tsx
new file mode 100644
index 00000000000..2166abf3cf0
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/create-key-form.tsx
@@ -0,0 +1,83 @@
+// 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 { Input } from "@/components/ui/input";
+import { cn } from "@/lib/utils";
+import { useState } from "react";
+import { createApiKey } from "../api/api-keys";
+
+const EXPIRY_PRESETS = [
+ { label: "Never", value: null as number | null },
+ { label: "7d", value: 7 },
+ { label: "30d", value: 30 },
+ { label: "90d", value: 90 },
+];
+
+export function CreateKeyForm({
+ onCreated,
+ onError,
+}: {
+ onCreated: (rawKey: string) => void;
+ onError: (message: string) => void;
+}) {
+ const [name, setName] = useState("");
+ const [expiry, setExpiry] = useState<number | null>(null);
+ const [loading, setLoading] = useState(false);
+
+ const handleSubmit = async (e: React.FormEvent) => {
+ e.preventDefault();
+ if (!name.trim() || loading) return;
+ setLoading(true);
+ try {
+ const result = await createApiKey(name.trim(), expiry);
+ onCreated(result.key);
+ setName("");
+ } catch (err) {
+ onError(err instanceof Error ? err.message : "Couldn't create key.");
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ return (
+ <form
+ onSubmit={handleSubmit}
+ className="flex flex-col gap-2 rounded-lg border border-border bg-muted/20 p-3"
+ >
+ <div className="flex flex-wrap items-center gap-2">
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder="Key name (e.g. production)"
+ className="h-8 min-w-[180px] flex-1 text-sm"
+ aria-label="New key name"
+ />
+ <div className="inline-flex items-center rounded-md border border-border bg-background p-0.5">
+ {EXPIRY_PRESETS.map((p) => {
+ const active = expiry === p.value;
+ return (
+ <button
+ key={p.label}
+ type="button"
+ onClick={() => setExpiry(p.value)}
+ aria-pressed={active}
+ className={cn(
+ "rounded px-2 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ active
+ ? "bg-accent text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {p.label}
+ </button>
+ );
+ })}
+ </div>
+ <Button type="submit" size="sm" disabled={loading || !name.trim()}>
+ {loading ? "Creating…" : "Create key"}
+ </Button>
+ </div>
+ </form>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/key-reveal-card.tsx b/studio/frontend/src/features/settings/components/key-reveal-card.tsx
new file mode 100644
index 00000000000..667351570c3
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/key-reveal-card.tsx
@@ -0,0 +1,71 @@
+// 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 { 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 { useState } from "react";
+
+export function KeyRevealCard({
+ rawKey,
+ onDone,
+}: {
+ rawKey: string;
+ onDone: () => void;
+}) {
+ const [copied, setCopied] = useState(false);
+
+ const handleCopy = () => {
+ if (copyToClipboard(rawKey)) {
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1800);
+ }
+ };
+
+ return (
+ <div className="flex flex-col gap-2 rounded-lg border border-emerald-500/30 bg-emerald-500/5 p-3">
+ <div className="flex items-center gap-1.5">
+ <HugeiconsIcon
+ icon={Tick02Icon}
+ className="size-3.5 text-emerald-600 dark:text-emerald-500"
+ />
+ <span className="text-xs font-medium text-emerald-700 dark:text-emerald-500">
+ New key created
+ </span>
+ </div>
+ <button
+ type="button"
+ onClick={handleCopy}
+ className={cn(
+ "flex w-full items-center justify-between gap-3 rounded-md border border-border bg-muted/40 px-3 py-2.5 font-mono text-sm transition-colors hover:bg-muted/60",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
+ copied && "border-emerald-500/40 bg-emerald-500/10",
+ )}
+ aria-label={copied ? "Key copied" : "Copy key"}
+ >
+ <code className="min-w-0 flex-1 break-all text-left text-foreground">
+ {rawKey}
+ </code>
+ <HugeiconsIcon
+ icon={copied ? Tick02Icon : Copy01Icon}
+ className={cn("size-4 shrink-0", copied && "text-emerald-600")}
+ />
+ </button>
+ <div className="flex items-center justify-between gap-3 pt-0.5">
+ <p className="text-[11px] text-muted-foreground">
+ Copy now — this won't be shown again.
+ </p>
+ <Button
+ type="button"
+ size="sm"
+ onClick={onDone}
+ className="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
+ >
+ Done
+ </Button>
+ </div>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/settings-row.tsx b/studio/frontend/src/features/settings/components/settings-row.tsx
new file mode 100644
index 00000000000..a08b7beac85
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/settings-row.tsx
@@ -0,0 +1,39 @@
+// 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 { cn } from "@/lib/utils";
+import type { ReactNode } from "react";
+
+export function SettingsRow({
+ label,
+ description,
+ children,
+ destructive,
+ className,
+}: {
+ label: string;
+ description?: string;
+ children?: ReactNode;
+ destructive?: boolean;
+ className?: string;
+}) {
+ return (
+ <div
+ className={cn(
+ "flex items-center justify-between gap-6 py-3",
+ destructive && "border-t border-border/60 mt-2 pt-4",
+ className,
+ )}
+ >
+ <div className="flex min-w-0 flex-col gap-0.5">
+ <span className="text-sm font-medium text-foreground">{label}</span>
+ {description ? (
+ <span className="text-xs text-muted-foreground leading-snug">
+ {description}
+ </span>
+ ) : null}
+ </div>
+ {children ? <div className="flex shrink-0 items-center">{children}</div> : null}
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/settings-section.tsx b/studio/frontend/src/features/settings/components/settings-section.tsx
new file mode 100644
index 00000000000..683dfb25e1b
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/settings-section.tsx
@@ -0,0 +1,30 @@
+// 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 type { ReactNode } from "react";
+
+export function SettingsSection({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description?: string;
+ children: ReactNode;
+}) {
+ return (
+ <section className="flex flex-col">
+ <div className="mb-1 flex flex-col gap-0.5">
+ <h2 className="text-base font-semibold font-heading text-foreground">
+ {title}
+ </h2>
+ {description ? (
+ <p className="text-xs text-muted-foreground leading-relaxed">
+ {description}
+ </p>
+ ) : null}
+ </div>
+ <div className="flex flex-col divide-y divide-border/60">{children}</div>
+ </section>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/theme-segmented.tsx b/studio/frontend/src/features/settings/components/theme-segmented.tsx
new file mode 100644
index 00000000000..10619953466
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/theme-segmented.tsx
@@ -0,0 +1,58 @@
+// 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 { cn } from "@/lib/utils";
+import {
+ LaptopIcon,
+ Moon02Icon,
+ Sun02Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { motion, useReducedMotion } from "motion/react";
+import { useTheme, type Theme } from "../stores/theme-store";
+
+const OPTIONS: { value: Theme; label: string; icon: typeof Sun02Icon }[] = [
+ { value: "light", label: "Light", icon: Sun02Icon },
+ { value: "dark", label: "Dark", icon: Moon02Icon },
+ { value: "system", label: "System", icon: LaptopIcon },
+];
+
+export function ThemeSegmented() {
+ const { theme, setTheme } = useTheme();
+ const reduced = useReducedMotion();
+ return (
+ <div className="inline-flex items-center rounded-md border border-border bg-muted/30 p-0.5">
+ {OPTIONS.map((opt) => {
+ const active = theme === opt.value;
+ return (
+ <button
+ key={opt.value}
+ type="button"
+ onClick={() => setTheme(opt.value)}
+ aria-pressed={active}
+ className={cn(
+ "relative flex h-7 items-center gap-1.5 rounded px-2.5 text-xs font-medium transition-colors",
+ active
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {active && (
+ <motion.span
+ layoutId="theme-pill"
+ className="absolute inset-0 rounded bg-background shadow-border"
+ transition={
+ reduced
+ ? { duration: 0 }
+ : { type: "spring", stiffness: 500, damping: 35, mass: 0.5 }
+ }
+ />
+ )}
+ <HugeiconsIcon icon={opt.icon} className="relative z-10 size-3.5" />
+ <span className="relative z-10">{opt.label}</span>
+ </button>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/update-studio-instructions.tsx b/studio/frontend/src/features/settings/components/update-studio-instructions.tsx
new file mode 100644
index 00000000000..e97ef9507c8
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/update-studio-instructions.tsx
@@ -0,0 +1,185 @@
+// 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 { cn } from "@/lib/utils";
+import { copyToClipboard } from "@/lib/copy-to-clipboard";
+import { Copy01Icon, Tick02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { AnimatePresence, motion, useReducedMotion } from "motion/react";
+import type { ReactElement } from "react";
+import { useEffect, useRef, useState } from "react";
+
+const STUDIO_UPDATE_CMD = "unsloth studio update";
+const STUDIO_UPDATE_FALLBACK_UNIX_CMD =
+ "curl -fsSL https://unsloth.ai/install.sh | sh";
+const STUDIO_UPDATE_FALLBACK_WINDOWS_CMD =
+ "irm https://unsloth.ai/install.ps1 | iex";
+
+export type UpdateShell = "windows" | "unix";
+
+function getStudioUpdateInstructionLine(shell: UpdateShell): string {
+ return shell === "windows" ? "Open PowerShell and run:" : "Open Terminal and run:";
+}
+
+function CopyableCommand({
+ command,
+ copyLabel,
+}: {
+ command: string;
+ copyLabel: string;
+}): ReactElement {
+ const [copied, setCopied] = useState(false);
+ const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
+
+ useEffect(() => {
+ return () => {
+ if (timerRef.current) {
+ clearTimeout(timerRef.current);
+ }
+ };
+ }, []);
+
+ const handleCopy = () => {
+ if (!copyToClipboard(command)) {
+ return;
+ }
+ setCopied(true);
+ if (timerRef.current) {
+ clearTimeout(timerRef.current);
+ }
+ timerRef.current = setTimeout(() => setCopied(false), 2000);
+ };
+
+ return (
+ <div className="flex min-w-0 items-stretch overflow-hidden rounded-md border border-border bg-muted/40">
+ <input
+ type="text"
+ readOnly
+ value={command}
+ className="min-w-0 flex-1 bg-transparent px-2 py-1.5 font-mono text-[11px] text-foreground outline-none"
+ title={command}
+ aria-label={`${copyLabel} text`}
+ />
+ <button
+ type="button"
+ onClick={handleCopy}
+ className="flex shrink-0 items-center justify-center border-l border-border px-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ title={copied ? "Copied" : "Copy command"}
+ aria-label={copied ? `${copyLabel} copied` : `Copy ${copyLabel}`}
+ >
+ {copied ? (
+ <HugeiconsIcon icon={Tick02Icon} className="size-4 text-emerald-600" />
+ ) : (
+ <HugeiconsIcon icon={Copy01Icon} className="size-4" />
+ )}
+ </button>
+ </div>
+ );
+}
+
+export function UpdateStudioInstructions({
+ className,
+ defaultShell,
+ showTitle = true,
+}: {
+ className?: string;
+ defaultShell: UpdateShell;
+ showTitle?: boolean;
+}): ReactElement {
+ const [shell, setShell] = useState<UpdateShell>(defaultShell);
+ const prefersReducedMotion = useReducedMotion();
+ const windows = shell === "windows";
+ const fadeTransition = prefersReducedMotion
+ ? { duration: 0 }
+ : { duration: 0.16, ease: [0.165, 0.84, 0.44, 1] as const };
+ const fadeInitial = prefersReducedMotion ? { opacity: 1 } : { opacity: 0, y: 2 };
+ const fadeAnimate = { opacity: 1, y: 0 };
+ const fadeExit = prefersReducedMotion ? { opacity: 1 } : { opacity: 0, y: -2 };
+
+ useEffect(() => {
+ setShell(defaultShell);
+ }, [defaultShell]);
+
+ return (
+ <div className={cn("flex flex-col gap-3", className)}>
+ <div
+ className={cn(
+ "flex items-center gap-3",
+ showTitle ? "justify-between" : "justify-start",
+ )}
+ >
+ {showTitle ? (
+ <p className="shrink-0 whitespace-nowrap text-sm font-semibold font-heading">
+ Update Unsloth Studio
+ </p>
+ ) : null}
+ <div className="flex shrink-0 items-center gap-0.5 text-[11px]">
+ <button
+ type="button"
+ onClick={() => setShell("windows")}
+ className={cn(
+ "px-0.5 py-0.5 font-medium transition-colors",
+ windows
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-emerald-600",
+ )}
+ aria-pressed={windows}
+ >
+ Windows
+ </button>
+ <span className="text-border">/</span>
+ <button
+ type="button"
+ onClick={() => setShell("unix")}
+ className={cn(
+ "px-0.5 py-0.5 font-medium transition-colors",
+ !windows
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-emerald-600",
+ )}
+ aria-pressed={!windows}
+ >
+ macOS/Linux
+ </button>
+ </div>
+ </div>
+ <AnimatePresence mode="wait" initial={false}>
+ <motion.p
+ key={`instruction-${shell}`}
+ initial={fadeInitial}
+ animate={fadeAnimate}
+ exit={fadeExit}
+ transition={fadeTransition}
+ className="text-xs text-muted-foreground leading-relaxed"
+ >
+ {getStudioUpdateInstructionLine(shell)}
+ </motion.p>
+ </AnimatePresence>
+ <CopyableCommand command={STUDIO_UPDATE_CMD} copyLabel="update command" />
+ <p className="text-xs text-muted-foreground leading-relaxed">
+ If that fails or unsloth studio update is unavailable, run:
+ </p>
+ <AnimatePresence mode="wait" initial={false}>
+ <motion.div
+ key={`fallback-${shell}`}
+ initial={fadeInitial}
+ animate={fadeAnimate}
+ exit={fadeExit}
+ transition={fadeTransition}
+ >
+ <CopyableCommand
+ command={
+ windows
+ ? STUDIO_UPDATE_FALLBACK_WINDOWS_CMD
+ : STUDIO_UPDATE_FALLBACK_UNIX_CMD
+ }
+ copyLabel="fallback command"
+ />
+ </motion.div>
+ </AnimatePresence>
+ <p className="text-xs text-muted-foreground leading-relaxed">
+ Restart Studio after updating for changes to take effect.
+ </p>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/components/usage-examples.tsx b/studio/frontend/src/features/settings/components/usage-examples.tsx
new file mode 100644
index 00000000000..603edb3984a
--- /dev/null
+++ b/studio/frontend/src/features/settings/components/usage-examples.tsx
@@ -0,0 +1,146 @@
+// 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 { cn } from "@/lib/utils";
+import { copyToClipboard } from "@/lib/copy-to-clipboard";
+import {
+ ArrowDown01Icon,
+ Copy01Icon,
+ Tick02Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { AnimatePresence, motion } from "motion/react";
+import { useMemo, useState } from "react";
+
+type Lang = "curl" | "python" | "tools";
+
+const TABS: { id: Lang; label: string }[] = [
+ { id: "curl", label: "curl" },
+ { id: "python", label: "Python" },
+ { id: "tools", label: "Tools" },
+];
+
+function buildSnippets(base: string) {
+ return {
+ curl: `curl ${base}/v1/chat/completions \\
+ -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{
+ "messages": [{"role": "user", "content": "Hello"}],
+ "stream": true
+ }'`,
+ python: `from openai import OpenAI
+
+client = OpenAI(
+ base_url="${base}/v1",
+ api_key="sk-unsloth-YOUR_KEY",
+)
+
+response = client.chat.completions.create(
+ model="current",
+ messages=[{"role": "user", "content": "Hello"}],
+ stream=True,
+)
+for chunk in response:
+ print(chunk.choices[0].delta.content or "", end="")`,
+ tools: `curl ${base}/v1/chat/completions \\
+ -H "Authorization: Bearer sk-unsloth-YOUR_KEY" \\
+ -H "Content-Type: application/json" \\
+ -d '{
+ "messages": [{"role": "user", "content": "Search Python 3.13 features"}],
+ "enable_tools": true,
+ "enabled_tools": ["web_search", "python"],
+ "stream": true
+ }'`,
+ };
+}
+
+export function UsageExamples() {
+ const [open, setOpen] = useState(false);
+ const [lang, setLang] = useState<Lang>("curl");
+ const [copied, setCopied] = useState(false);
+ const snippets = useMemo(
+ () =>
+ buildSnippets(
+ typeof window !== "undefined" ? window.location.origin : "",
+ ),
+ [],
+ );
+
+ const handleCopy = () => {
+ if (copyToClipboard(snippets[lang])) {
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1800);
+ }
+ };
+
+ return (
+ <section className="flex flex-col">
+ <button
+ type="button"
+ onClick={() => setOpen((o) => !o)}
+ className="flex w-fit items-center gap-1.5 rounded text-xs font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ aria-expanded={open}
+ >
+ <HugeiconsIcon
+ icon={ArrowDown01Icon}
+ className={cn("size-3.5 transition-transform", open && "rotate-180")}
+ />
+ {open ? "Hide usage examples" : "Show usage examples"}
+ </button>
+
+ <AnimatePresence initial={false}>
+ {open && (
+ <motion.div
+ initial={{ height: 0, opacity: 0 }}
+ animate={{ height: "auto", opacity: 1 }}
+ exit={{ height: 0, opacity: 0 }}
+ transition={{ duration: 0.18, ease: [0.165, 0.84, 0.44, 1] }}
+ className="overflow-hidden"
+ >
+ <div className="mt-3 overflow-hidden rounded-lg border border-border bg-muted/20">
+ <div className="flex items-center justify-between border-b border-border px-2 py-1.5">
+ <div className="flex items-center gap-0.5">
+ {TABS.map((t) => {
+ const active = lang === t.id;
+ return (
+ <button
+ key={t.id}
+ type="button"
+ onClick={() => setLang(t.id)}
+ aria-pressed={active}
+ className={cn(
+ "rounded px-2 py-1 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ active
+ ? "bg-background text-foreground shadow-border"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {t.label}
+ </button>
+ );
+ })}
+ </div>
+ <button
+ type="button"
+ onClick={handleCopy}
+ className="flex items-center gap-1 rounded px-1.5 py-1 text-[11px] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ aria-label="Copy snippet"
+ >
+ <HugeiconsIcon
+ icon={copied ? Tick02Icon : Copy01Icon}
+ className={cn("size-3.5", copied && "text-emerald-600")}
+ />
+ {copied ? "Copied" : "Copy"}
+ </button>
+ </div>
+ <pre className="overflow-x-auto p-3 font-mono text-[11px] leading-relaxed text-foreground">
+ {snippets[lang]}
+ </pre>
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </section>
+ );
+}
diff --git a/studio/frontend/src/features/settings/index.ts b/studio/frontend/src/features/settings/index.ts
new file mode 100644
index 00000000000..bf9e8fe21ab
--- /dev/null
+++ b/studio/frontend/src/features/settings/index.ts
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+export { SettingsDialog } from "./settings-dialog";
+export { useSettingsDialogStore } from "./stores/settings-dialog-store";
+export type { SettingsTab } from "./stores/settings-dialog-store";
diff --git a/studio/frontend/src/features/settings/settings-dialog.tsx b/studio/frontend/src/features/settings/settings-dialog.tsx
new file mode 100644
index 00000000000..0e2083b31aa
--- /dev/null
+++ b/studio/frontend/src/features/settings/settings-dialog.tsx
@@ -0,0 +1,142 @@
+// 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 {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { cn } from "@/lib/utils";
+import {
+ Cancel01Icon,
+ Key01Icon,
+ Message01Icon,
+ PaintBrush02Icon,
+ Settings02Icon,
+ SparklesIcon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { motion, useReducedMotion } from "motion/react";
+import { useSettingsDialogStore, type SettingsTab } from "./stores/settings-dialog-store";
+import { AboutTab } from "./tabs/about-tab";
+import { ApiKeysTab } from "./tabs/api-keys-tab";
+import { AppearanceTab } from "./tabs/appearance-tab";
+import { ChatTab } from "./tabs/chat-tab";
+import { GeneralTab } from "./tabs/general-tab";
+
+interface TabDef {
+ id: SettingsTab;
+ label: string;
+ icon: typeof Settings02Icon;
+}
+
+const TABS: TabDef[] = [
+ { id: "general", label: "General", icon: Settings02Icon },
+ { id: "appearance", label: "Appearance", icon: PaintBrush02Icon },
+ { id: "chat", label: "Chat", icon: Message01Icon },
+ { id: "api-keys", label: "API Keys", icon: Key01Icon },
+ { id: "about", label: "About", icon: SparklesIcon },
+];
+
+function renderTab(tab: SettingsTab) {
+ switch (tab) {
+ case "general":
+ return <GeneralTab />;
+ case "appearance":
+ return <AppearanceTab />;
+ case "chat":
+ return <ChatTab />;
+ case "api-keys":
+ return <ApiKeysTab />;
+ case "about":
+ return <AboutTab />;
+ }
+}
+
+export function SettingsDialog() {
+ const open = useSettingsDialogStore((s) => s.open);
+ const activeTab = useSettingsDialogStore((s) => s.activeTab);
+ const setActiveTab = useSettingsDialogStore((s) => s.setActiveTab);
+ const closeDialog = useSettingsDialogStore((s) => s.closeDialog);
+ const reduced = useReducedMotion();
+
+ return (
+ <Dialog open={open} onOpenChange={(o) => !o && closeDialog()}>
+ <DialogContent
+ showCloseButton={false}
+ overlayClassName="bg-background/40"
+ className={cn(
+ "!max-w-none h-[560px] w-[820px] p-0 overflow-hidden",
+ "shadow-border rounded-xl border-border",
+ "sm:h-[560px] sm:w-[820px]",
+ "max-sm:h-dvh max-sm:w-dvw max-sm:rounded-none",
+ )}
+ >
+ <DialogTitle className="sr-only">Settings</DialogTitle>
+ <DialogDescription className="sr-only">
+ Manage your Unsloth Studio preferences.
+ </DialogDescription>
+ <div className="flex h-full min-h-0">
+ <aside className="flex w-[200px] shrink-0 flex-col border-r border-border bg-muted/20 p-2">
+ <nav className="flex flex-col gap-0.5">
+ {TABS.map((tab) => {
+ const active = activeTab === tab.id;
+ return (
+ <button
+ key={tab.id}
+ type="button"
+ onClick={() => setActiveTab(tab.id)}
+ className={cn(
+ "relative flex h-9 items-center gap-2 rounded-md px-2.5 text-sm font-medium transition-colors",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
+ active
+ ? "text-foreground"
+ : "text-muted-foreground hover:text-foreground",
+ )}
+ >
+ {active && (
+ <motion.span
+ layoutId="settings-active-pill"
+ className="absolute inset-0 rounded-md bg-accent"
+ transition={
+ reduced
+ ? { duration: 0 }
+ : {
+ type: "spring",
+ stiffness: 500,
+ damping: 35,
+ mass: 0.5,
+ }
+ }
+ />
+ )}
+ <HugeiconsIcon
+ icon={tab.icon}
+ className="relative z-10 size-4"
+ />
+ <span className="relative z-10">{tab.label}</span>
+ </button>
+ );
+ })}
+ </nav>
+ </aside>
+
+ <main className="relative flex min-w-0 flex-1 flex-col">
+ <button
+ type="button"
+ onClick={closeDialog}
+ className="absolute top-3 right-3 z-10 flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ aria-label="Close settings"
+ >
+ <HugeiconsIcon icon={Cancel01Icon} className="size-4" />
+ </button>
+ <div className="flex min-h-0 flex-1 flex-col overflow-y-auto p-6 pr-12">
+ {renderTab(activeTab)}
+ </div>
+ </main>
+ </div>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/studio/frontend/src/features/settings/stores/settings-dialog-store.ts b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts
new file mode 100644
index 00000000000..75eb53048e5
--- /dev/null
+++ b/studio/frontend/src/features/settings/stores/settings-dialog-store.ts
@@ -0,0 +1,52 @@
+// 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 { create } from "zustand";
+
+export type SettingsTab =
+ | "general"
+ | "appearance"
+ | "chat"
+ | "api-keys"
+ | "about";
+
+interface SettingsDialogState {
+ open: boolean;
+ activeTab: SettingsTab;
+ openDialog: (tab?: SettingsTab) => void;
+ closeDialog: () => void;
+ setActiveTab: (tab: SettingsTab) => void;
+}
+
+const ACTIVE_TAB_KEY = "unsloth_settings_active_tab";
+
+function loadInitialTab(): SettingsTab {
+ if (typeof window === "undefined") return "general";
+ let stored: string | null = null;
+ try {
+ stored = window.localStorage.getItem(ACTIVE_TAB_KEY);
+ } catch {
+ return "general";
+ }
+ const valid: SettingsTab[] = ["general", "appearance", "chat", "api-keys", "about"];
+ return valid.includes(stored as SettingsTab) ? (stored as SettingsTab) : "general";
+}
+
+export const useSettingsDialogStore = create<SettingsDialogState>((set) => ({
+ open: false,
+ activeTab: loadInitialTab(),
+ openDialog: (tab) =>
+ set((state) => ({
+ open: true,
+ activeTab: tab ?? state.activeTab,
+ })),
+ closeDialog: () => set({ open: false }),
+ setActiveTab: (tab) => {
+ try {
+ window.localStorage.setItem(ACTIVE_TAB_KEY, tab);
+ } catch {
+ // ignore storage failures
+ }
+ set({ activeTab: tab });
+ },
+}));
diff --git a/studio/frontend/src/features/settings/stores/theme-store.ts b/studio/frontend/src/features/settings/stores/theme-store.ts
new file mode 100644
index 00000000000..1879459a766
--- /dev/null
+++ b/studio/frontend/src/features/settings/stores/theme-store.ts
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { useSyncExternalStore } from "react";
+
+export type Theme = "light" | "dark" | "system";
+export type ResolvedTheme = "light" | "dark";
+
+const STORAGE_KEY = "theme";
+
+function readStoredTheme(): Theme {
+ if (typeof window === "undefined") return "system";
+ let stored: string | null = null;
+ try {
+ stored = window.localStorage.getItem(STORAGE_KEY);
+ } catch {
+ return "system";
+ }
+ if (stored === "light" || stored === "dark" || stored === "system") return stored;
+ return "system";
+}
+
+function systemPrefersDark(): boolean {
+ if (typeof window === "undefined") return false;
+ return window.matchMedia("(prefers-color-scheme: dark)").matches;
+}
+
+function resolveTheme(theme: Theme): ResolvedTheme {
+ if (theme === "system") return systemPrefersDark() ? "dark" : "light";
+ return theme;
+}
+
+function applyToDocument(resolved: ResolvedTheme) {
+ if (typeof document === "undefined") return;
+ document.documentElement.classList.toggle("dark", resolved === "dark");
+}
+
+const listeners = new Set<() => void>();
+function subscribe(cb: () => void) {
+ listeners.add(cb);
+ if (typeof window === "undefined") {
+ return () => listeners.delete(cb);
+ }
+ const mq = window.matchMedia("(prefers-color-scheme: dark)");
+ const syncTheme = () => {
+ applyToDocument(resolveTheme(readStoredTheme()));
+ cb();
+ };
+ const onStorage = (e: StorageEvent) => {
+ if (e.key === STORAGE_KEY || e.key === null) syncTheme();
+ };
+ mq.addEventListener("change", syncTheme);
+ window.addEventListener("storage", onStorage);
+ return () => {
+ listeners.delete(cb);
+ mq.removeEventListener("change", syncTheme);
+ window.removeEventListener("storage", onStorage);
+ };
+}
+
+function getSnapshot(): Theme {
+ return readStoredTheme();
+}
+
+function getServerSnapshot(): Theme {
+ return "system";
+}
+
+/**
+ * Single source of truth for setting the theme. All writers (the Settings
+ * dialog's segmented control AND the sidebar dropdown's animated toggler)
+ * must route through this so the DOM class, localStorage, and React
+ * subscribers stay in sync.
+ */
+export function setTheme(next: Theme): void {
+ if (typeof window === "undefined") return;
+ // Persist "system" explicitly so next-themes (mounted with
+ // defaultTheme="light") doesn't clobber the choice on reload.
+ try {
+ window.localStorage.setItem(STORAGE_KEY, next);
+ } catch {
+ // ignore storage failures
+ }
+ applyToDocument(resolveTheme(next));
+ listeners.forEach((cb) => cb());
+}
+
+export function useTheme(): {
+ theme: Theme;
+ resolved: ResolvedTheme;
+ setTheme: (next: Theme) => void;
+} {
+ const theme = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
+ const resolved = resolveTheme(theme);
+ return { theme, resolved, setTheme };
+}
diff --git a/studio/frontend/src/features/settings/tabs/about-tab.tsx b/studio/frontend/src/features/settings/tabs/about-tab.tsx
new file mode 100644
index 00000000000..f25afc6d8f6
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/about-tab.tsx
@@ -0,0 +1,101 @@
+// 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 { ShutdownDialog } from "@/components/shutdown-dialog";
+import { UpdateStudioInstructions } from "../components/update-studio-instructions";
+import { usePlatformStore } from "@/config/env";
+import { removeTrainingUnloadGuard } from "@/features/training/hooks/use-training-unload-guard";
+import {
+ ArrowUpRight01Icon,
+ Book03Icon,
+ Cancel01Icon,
+ MessageNotification01Icon,
+} from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { useState } from "react";
+import { SettingsRow } from "../components/settings-row";
+import { SettingsSection } from "../components/settings-section";
+
+const VERSION: string =
+ (import.meta.env.VITE_APP_VERSION as string | undefined) ?? "dev";
+
+export function AboutTab() {
+ const deviceType = usePlatformStore((s) => s.deviceType);
+ const defaultShell = deviceType === "windows" ? "windows" : "unix";
+ const [shutdownOpen, setShutdownOpen] = useState(false);
+
+ return (
+ <div className="flex flex-col gap-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-lg font-semibold font-heading">About</h1>
+ <p className="text-xs text-muted-foreground">
+ Unsloth Studio build info and support.
+ </p>
+ </header>
+
+ <SettingsSection title="Studio">
+ <SettingsRow label="Version">
+ <code className="font-mono text-xs text-muted-foreground">{VERSION}</code>
+ </SettingsRow>
+ </SettingsSection>
+
+ <SettingsSection title="Updates">
+ <div className="py-2">
+ <UpdateStudioInstructions defaultShell={defaultShell} showTitle={false} />
+ </div>
+ </SettingsSection>
+
+ <SettingsSection title="Help">
+ <SettingsRow label="Documentation">
+ <a
+ href="https://unsloth.ai/docs"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground"
+ >
+ <HugeiconsIcon icon={Book03Icon} className="size-3.5" />
+ unsloth.ai/docs
+ <HugeiconsIcon icon={ArrowUpRight01Icon} className="size-3" />
+ </a>
+ </SettingsRow>
+ <SettingsRow label="Feedback">
+ <a
+ href="https://github.com/unslothai/unsloth/issues"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground"
+ >
+ <HugeiconsIcon icon={MessageNotification01Icon} className="size-3.5" />
+ Report an issue
+ <HugeiconsIcon icon={ArrowUpRight01Icon} className="size-3" />
+ </a>
+ </SettingsRow>
+ </SettingsSection>
+
+ <SettingsSection title="Danger zone">
+ <SettingsRow
+ destructive
+ label="Shut down Unsloth Studio"
+ description="Stops the Studio server process and ends your session."
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setShutdownOpen(true)}
+ className="text-destructive hover:text-destructive hover:border-destructive/60"
+ >
+ <HugeiconsIcon icon={Cancel01Icon} className="size-3.5 mr-1.5" />
+ Shut down
+ </Button>
+ </SettingsRow>
+ </SettingsSection>
+
+ <ShutdownDialog
+ open={shutdownOpen}
+ onOpenChange={setShutdownOpen}
+ onAfterShutdown={removeTrainingUnloadGuard}
+ />
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx b/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx
new file mode 100644
index 00000000000..e0fa6d87d25
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/api-keys-tab.tsx
@@ -0,0 +1,159 @@
+// 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 {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { Button } from "@/components/ui/button";
+import { AnimatePresence, motion, useReducedMotion } from "motion/react";
+import { useCallback, useEffect, useState } from "react";
+import { fetchApiKeys, revokeApiKey, type ApiKey } from "../api/api-keys";
+import { ApiKeyRow } from "../components/api-key-row";
+import { CreateKeyForm } from "../components/create-key-form";
+import { KeyRevealCard } from "../components/key-reveal-card";
+import { UsageExamples } from "../components/usage-examples";
+
+export function ApiKeysTab() {
+ const [keys, setKeys] = useState<ApiKey[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState<string | null>(null);
+ const [revokeTarget, setRevokeTarget] = useState<ApiKey | null>(null);
+ const [revoking, setRevoking] = useState(false);
+ const [revealed, setRevealed] = useState<string | null>(null);
+ const reduced = useReducedMotion();
+ const t = reduced
+ ? { duration: 0 }
+ : { duration: 0.18, ease: [0.165, 0.84, 0.44, 1] as const };
+
+ const load = useCallback(async () => {
+ setLoading(true);
+ setError(null);
+ try {
+ setKeys(await fetchApiKeys());
+ } catch (e) {
+ setError(e instanceof Error ? e.message : "Couldn't load API keys.");
+ } finally {
+ setLoading(false);
+ }
+ }, []);
+
+ useEffect(() => {
+ void load();
+ }, [load]);
+
+ const confirmRevoke = async () => {
+ if (!revokeTarget) return;
+ setRevoking(true);
+ try {
+ await revokeApiKey(revokeTarget.id);
+ await load();
+ setRevokeTarget(null);
+ } catch (e) {
+ setError(e instanceof Error ? e.message : "Couldn't revoke key.");
+ } finally {
+ setRevoking(false);
+ }
+ };
+
+ return (
+ <div className="flex flex-col gap-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-lg font-semibold font-heading">API Keys</h1>
+ <p className="text-xs text-muted-foreground">
+ Access Unsloth Studio programmatically via the OpenAI-compatible API.
+ </p>
+ </header>
+
+ <AnimatePresence mode="wait" initial={false}>
+ {revealed !== null ? (
+ <motion.div
+ key="reveal"
+ initial={{ opacity: 0, y: -4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: -4 }}
+ transition={t}
+ >
+ <KeyRevealCard
+ rawKey={revealed}
+ onDone={() => setRevealed(null)}
+ />
+ </motion.div>
+ ) : (
+ <motion.div
+ key="form"
+ initial={{ opacity: 0, y: 4 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: 4 }}
+ transition={t}
+ >
+ <CreateKeyForm
+ onCreated={(raw) => {
+ setRevealed(raw);
+ void load();
+ }}
+ onError={setError}
+ />
+ </motion.div>
+ )}
+ </AnimatePresence>
+
+ <section className="flex flex-col">
+ <h2 className="mb-2 text-sm font-semibold text-foreground">Your keys</h2>
+ {error ? (
+ <div className="rounded-md border border-destructive/20 bg-destructive/5 p-3 text-xs text-destructive">
+ {error}
+ </div>
+ ) : loading ? (
+ <div className="flex flex-col gap-2 py-2">
+ {[0, 1].map((i) => (
+ <div
+ key={i}
+ className="h-12 animate-pulse rounded-md bg-muted/40"
+ />
+ ))}
+ </div>
+ ) : keys.length === 0 ? (
+ <p className="py-6 text-center text-xs text-muted-foreground">
+ No API keys yet.
+ </p>
+ ) : (
+ <div className="flex flex-col">
+ {keys.map((k) => (
+ <ApiKeyRow key={k.id} apiKey={k} onRevoke={setRevokeTarget} />
+ ))}
+ </div>
+ )}
+ </section>
+
+ <UsageExamples />
+
+ <Dialog open={revokeTarget !== null} onOpenChange={(o) => !o && setRevokeTarget(null)}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>Revoke key “{revokeTarget?.name}”?</DialogTitle>
+ <DialogDescription>
+ Applications using this key will immediately lose access. This cannot be undone.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => setRevokeTarget(null)}>
+ Cancel
+ </Button>
+ <Button
+ onClick={confirmRevoke}
+ disabled={revoking}
+ className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
+ >
+ {revoking ? "Revoking…" : `Revoke “${revokeTarget?.name}”`}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/tabs/appearance-tab.tsx b/studio/frontend/src/features/settings/tabs/appearance-tab.tsx
new file mode 100644
index 00000000000..edcf3a9e4af
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/appearance-tab.tsx
@@ -0,0 +1,40 @@
+// 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 { Switch } from "@/components/ui/switch";
+import { useSidebarPin } from "@/hooks/use-sidebar-pin";
+import { SettingsRow } from "../components/settings-row";
+import { SettingsSection } from "../components/settings-section";
+import { ThemeSegmented } from "../components/theme-segmented";
+
+export function AppearanceTab() {
+ const { pinned, setPinned } = useSidebarPin();
+ return (
+ <div className="flex flex-col gap-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-lg font-semibold font-heading">Appearance</h1>
+ <p className="text-xs text-muted-foreground">
+ How Unsloth Studio looks on this device.
+ </p>
+ </header>
+
+ <SettingsSection title="Theme">
+ <SettingsRow
+ label="Color scheme"
+ description="Choose light, dark, or follow your system."
+ >
+ <ThemeSegmented />
+ </SettingsRow>
+ </SettingsSection>
+
+ <SettingsSection title="Layout">
+ <SettingsRow
+ label="Pin sidebar by default"
+ description="Keep the sidebar expanded instead of collapsing to icons."
+ >
+ <Switch checked={pinned} onCheckedChange={setPinned} />
+ </SettingsRow>
+ </SettingsSection>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/tabs/chat-tab.tsx b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
new file mode 100644
index 00000000000..d9ebfa457d6
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/chat-tab.tsx
@@ -0,0 +1,129 @@
+// 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 {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import {
+ clearAllChats,
+ countAllChats,
+} from "@/features/chat/utils/clear-all-chats";
+import { downloadChatExport } from "@/features/chat/utils/export-chat-history";
+import { Delete02Icon, Download02Icon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { useEffect, useState } from "react";
+import { SettingsRow } from "../components/settings-row";
+import { SettingsSection } from "../components/settings-section";
+
+export function ChatTab() {
+ const [confirmOpen, setConfirmOpen] = useState(false);
+ const [count, setCount] = useState<number | null>(null);
+ const [exporting, setExporting] = useState(false);
+ const [clearing, setClearing] = useState(false);
+
+ useEffect(() => {
+ void countAllChats().then(setCount);
+ }, []);
+
+ const handleExport = async () => {
+ setExporting(true);
+ try {
+ await downloadChatExport();
+ } finally {
+ setExporting(false);
+ }
+ };
+
+ const handleClear = async () => {
+ setClearing(true);
+ try {
+ await clearAllChats();
+ setCount(0);
+ setConfirmOpen(false);
+ } finally {
+ setClearing(false);
+ }
+ };
+
+ return (
+ <div className="flex flex-col gap-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-lg font-semibold font-heading">Chat</h1>
+ <p className="text-xs text-muted-foreground">
+ Manage your chat history stored on this device.
+ </p>
+ </header>
+
+ <SettingsSection title="Data">
+ <SettingsRow
+ label="Export chat history"
+ description="Download all chats and messages as a JSON file."
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleExport}
+ disabled={exporting || count === 0}
+ >
+ <HugeiconsIcon icon={Download02Icon} className="size-3.5 mr-1.5" />
+ {exporting ? "Exporting…" : "Export"}
+ </Button>
+ </SettingsRow>
+
+ <SettingsRow
+ destructive
+ label="Clear all chats"
+ description={
+ count === null
+ ? "Permanently delete every chat on this device."
+ : count === 0
+ ? "No chats to clear."
+ : `Permanently delete all ${count} chat${count === 1 ? "" : "s"} on this device.`
+ }
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setConfirmOpen(true)}
+ disabled={count === 0}
+ className="text-destructive hover:text-destructive hover:border-destructive/60"
+ >
+ <HugeiconsIcon icon={Delete02Icon} className="size-3.5 mr-1.5" />
+ Clear chats
+ </Button>
+ </SettingsRow>
+ </SettingsSection>
+
+ <Dialog open={confirmOpen} onOpenChange={setConfirmOpen}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>
+ Clear {count ?? 0} chat{count === 1 ? "" : "s"}?
+ </DialogTitle>
+ <DialogDescription>
+ This permanently deletes every chat and message stored on this device. This cannot be undone.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => setConfirmOpen(false)}>
+ Cancel
+ </Button>
+ <Button
+ onClick={handleClear}
+ disabled={clearing}
+ className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
+ >
+ {clearing ? "Clearing…" : `Clear ${count ?? 0} chat${count === 1 ? "" : "s"}`}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/settings/tabs/general-tab.tsx b/studio/frontend/src/features/settings/tabs/general-tab.tsx
new file mode 100644
index 00000000000..e1ad3fb58c3
--- /dev/null
+++ b/studio/frontend/src/features/settings/tabs/general-tab.tsx
@@ -0,0 +1,197 @@
+// 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 {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Switch } from "@/components/ui/switch";
+import { useChatRuntimeStore } from "@/features/chat/stores/chat-runtime-store";
+import { useEffect, useRef, useState } from "react";
+import { Eye, EyeOff } from "lucide-react";
+import { SettingsRow } from "../components/settings-row";
+import { SettingsSection } from "../components/settings-section";
+
+// Keys cleared by "Reset all local preferences".
+//
+// NEVER include auth / session keys here — resetting them would log the user
+// out, which is not what users expect from a "reset preferences" button.
+//
+// Explicitly EXCLUDED:
+// - "unsloth_auth_token" (auth: access token)
+// - "unsloth_auth_refresh_token" (auth: refresh token)
+// - "unsloth_auth_must_change_password" (auth: forced password change flag)
+// - "unsloth_onboarding_done" (session: would force re-onboarding)
+const PREFS_KEYS: string[] = [
+ // Appearance
+ "theme",
+ // UI state
+ "sidebar_pinned",
+ "unsloth_sidebar_navigate_open",
+ "unsloth_settings_active_tab",
+ // Chat runtime prefs
+ "unsloth_chat_auto_title",
+ "unsloth_hf_token",
+ "unsloth_auto_heal_tool_calls",
+ "unsloth_max_tool_calls_per_message",
+ "unsloth_tool_call_timeout",
+ "unsloth_chat_inference_params",
+ "unsloth_chat_collapsible_state",
+ // Chat presets
+ "unsloth_chat_custom_presets",
+ "unsloth_chat_active_preset",
+ "unsloth_chat_system_prompts",
+ "unsloth_chat_system_prompts_migrated",
+ // Training UI prefs
+ "unsloth_training_config_v1",
+ "unsloth_prev_max_steps",
+ "unsloth_prev_save_steps",
+ // Guided tour flags
+ "tour:studio:v1",
+];
+
+// Set to true from resetAllPrefs so the unmount-commit effect skips writing
+// back the in-memory draft — otherwise the cleanup would re-persist the old
+// HF token into localStorage after it was just cleared, and the subsequent
+// reload would read the re-written value.
+let resetInProgress = false;
+
+function resetAllPrefs() {
+ resetInProgress = true;
+ for (const key of PREFS_KEYS) {
+ try {
+ localStorage.removeItem(key);
+ } catch {
+ // ignore
+ }
+ }
+ window.location.reload();
+}
+
+export function GeneralTab() {
+ const hfToken = useChatRuntimeStore((s) => s.hfToken);
+ const setHfToken = useChatRuntimeStore((s) => s.setHfToken);
+ const autoTitle = useChatRuntimeStore((s) => s.autoTitle);
+ const setAutoTitle = useChatRuntimeStore((s) => s.setAutoTitle);
+
+ const [draftToken, setDraftToken] = useState(hfToken ?? "");
+ const [showToken, setShowToken] = useState(false);
+ const [confirmOpen, setConfirmOpen] = useState(false);
+
+ const draftRef = useRef(draftToken);
+ useEffect(() => {
+ draftRef.current = draftToken;
+ }, [draftToken]);
+
+ // Commit on unmount (dialog close / tab switch). Skip during reset-prefs
+ // flow so we don't re-persist the draft after localStorage was cleared.
+ useEffect(() => {
+ return () => {
+ if (resetInProgress) return;
+ const trimmed = draftRef.current.trim();
+ const current = useChatRuntimeStore.getState().hfToken;
+ if (trimmed !== current) {
+ useChatRuntimeStore.getState().setHfToken(trimmed);
+ }
+ };
+ }, []);
+
+ const commitToken = () => {
+ const trimmed = draftToken.trim();
+ if (trimmed !== draftToken) setDraftToken(trimmed);
+ if (trimmed !== hfToken) setHfToken(trimmed);
+ };
+
+ return (
+ <div className="flex flex-col gap-6">
+ <header className="flex flex-col gap-1">
+ <h1 className="text-lg font-semibold font-heading">General</h1>
+ <p className="text-xs text-muted-foreground">
+ Global preferences for Unsloth Studio.
+ </p>
+ </header>
+
+ <SettingsSection title="Account">
+ <SettingsRow
+ label="Hugging Face token"
+ description="Used to load gated models and push artifacts."
+ >
+ <div className="relative w-[260px]">
+ <Input
+ type={showToken ? "text" : "password"}
+ placeholder="hf_…"
+ value={draftToken}
+ onChange={(e) => setDraftToken(e.target.value)}
+ onBlur={commitToken}
+ className="h-8 w-full pr-8 font-mono text-xs"
+ />
+ <button
+ type="button"
+ onClick={() => setShowToken((s) => !s)}
+ className="absolute right-1.5 top-1/2 flex size-5 -translate-y-1/2 items-center justify-center rounded text-muted-foreground transition-colors hover:text-foreground"
+ aria-label={showToken ? "Hide token" : "Show token"}
+ tabIndex={-1}
+ >
+ {showToken ? <EyeOff className="size-3.5" /> : <Eye className="size-3.5" />}
+ </button>
+ </div>
+ </SettingsRow>
+ </SettingsSection>
+
+ <SettingsSection title="Chat defaults">
+ <SettingsRow
+ label="Auto-title new chats"
+ description="Generate a short title from the first message."
+ >
+ <Switch checked={autoTitle} onCheckedChange={setAutoTitle} />
+ </SettingsRow>
+ </SettingsSection>
+
+ <SettingsSection title="Danger zone">
+ <SettingsRow
+ destructive
+ label="Reset all local preferences"
+ description="Clears theme, tokens, sidebar state, and presets. Chats and API keys are not affected."
+ >
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setConfirmOpen(true)}
+ className="text-destructive hover:text-destructive hover:border-destructive/60"
+ >
+ Reset preferences
+ </Button>
+ </SettingsRow>
+ </SettingsSection>
+
+ <Dialog open={confirmOpen} onOpenChange={setConfirmOpen}>
+ <DialogContent className="max-w-md">
+ <DialogHeader>
+ <DialogTitle>Reset all local preferences?</DialogTitle>
+ <DialogDescription>
+ This clears your theme, tokens, and stored settings, then reloads
+ Studio. Chats and API keys are not affected.
+ </DialogDescription>
+ </DialogHeader>
+ <DialogFooter>
+ <Button variant="outline" onClick={() => setConfirmOpen(false)}>
+ Cancel
+ </Button>
+ <Button
+ onClick={resetAllPrefs}
+ className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
+ >
+ Reset and reload
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/studio/frontend/src/features/studio/studio-page.tsx b/studio/frontend/src/features/studio/studio-page.tsx
index 07a045685e3..d8a35359b87 100644
--- a/studio/frontend/src/features/studio/studio-page.tsx
+++ b/studio/frontend/src/features/studio/studio-page.tsx
@@ -14,7 +14,8 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Button } from "@/components/ui/button";
import { ArrowLeft01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { type ReactElement, useEffect, useState } from "react";
+import { type ReactElement, useCallback, useEffect, useMemo, useState } from "react";
+import { useSidebar } from "@/components/ui/sidebar";
import { DatasetPreviewDialog } from "./sections/dataset-preview-dialog";
import { DatasetSection } from "./sections/dataset-section";
import { ModelSection } from "./sections/model-section";
@@ -49,7 +50,12 @@ export function StudioPage(): ReactElement {
const closeDialog = useDatasetPreviewDialogStore((s) => s.close);
const [requestedTab, setRequestedTab] = useState("configure");
- const [selectedHistoryRunId, setSelectedHistoryRunId] = useState<string | null>(null);
+ const selectedHistoryRunId = useTrainingRuntimeStore((s) => s.selectedHistoryRunId);
+ const setSelectedHistoryRunId = useTrainingRuntimeStore((s) => s.setSelectedHistoryRunId);
+
+ useEffect(() => {
+ return () => setSelectedHistoryRunId(null);
+ }, [setSelectedHistoryRunId]);
// Derive activeTab: auto-switch to "current-run" only while training is
// genuinely running. Once training ends, honour whatever tab the user clicks.
@@ -61,9 +67,20 @@ export function StudioPage(): ReactElement {
? "configure"
: requestedTab;
+ const { setPinned } = useSidebar();
+ const pinSidebar = useCallback(() => setPinned(true), [setPinned]);
+
const tourEnabled = hasHydratedRuntime && !isHydratingRuntime;
const isConfigTour = activeTab === "configure";
- const tourSteps = activeTab === "current-run" ? studioTrainingTourSteps : studioTourSteps;
+ const baseTourSteps = activeTab === "current-run" ? studioTrainingTourSteps : studioTourSteps;
+ // Inject onEnter for navbar-targeting steps so the sidebar expands during the tour.
+ const tourSteps = useMemo(
+ () =>
+ baseTourSteps.map((step) =>
+ step.target === "navbar" ? { ...step, onEnter: pinSidebar } : step,
+ ),
+ [baseTourSteps, pinSidebar],
+ );
const tour = useGuidedTourController({
id: "studio",
steps: tourSteps,
@@ -86,6 +103,14 @@ export function StudioPage(): ReactElement {
}
}, [isTrainingRunning, requestedTab]);
+ // Selecting a run from the sidebar only sets selectedHistoryRunId; auto-switch
+ // to the History tab so the main panel reflects the selection.
+ useEffect(() => {
+ if (selectedHistoryRunId && requestedTab !== "history") {
+ setRequestedTab("history");
+ }
+ }, [selectedHistoryRunId, requestedTab]);
+
useEffect(() => {
ensureModelDefaultsLoaded();
ensureDatasetChecked();
@@ -106,7 +131,7 @@ export function StudioPage(): ReactElement {
})();
return (
- <div className="relative min-h-screen overflow-hidden bg-background">
+ <div className="relative min-h-screen bg-background">
<main className="relative z-10 mx-auto max-w-7xl px-4 py-4 sm:px-6">
<GuidedTour {...tour.tourProps} celebrate={isConfigTour} />
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.ts
new file mode 100644
index 00000000000..d5fefb283e5
--- /dev/null
+++ b/studio/frontend/src/features/training/hooks/use-training-history-sidebar.ts
@@ -0,0 +1,56 @@
+// 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 { useCallback, useEffect, useRef, useState } from "react";
+import { listTrainingRuns } from "../api/history-api";
+import type { TrainingRunSummary } from "../types/history";
+
+const SIDEBAR_LIMIT = 20;
+const RUNNING_POLL_MS = 5000;
+
+export function useTrainingHistorySidebarItems(enabled: boolean) {
+ const [items, setItems] = useState<TrainingRunSummary[]>([]);
+ const [loaded, setLoaded] = useState(false);
+ const controllerRef = useRef<AbortController | null>(null);
+ const inFlightRef = useRef(false);
+
+ const fetchRuns = useCallback(async () => {
+ if (inFlightRef.current) {
+ return;
+ }
+ const controller = new AbortController();
+ controllerRef.current = controller;
+ inFlightRef.current = true;
+ try {
+ const result = await listTrainingRuns(SIDEBAR_LIMIT, 0, controller.signal);
+ setItems(result.runs);
+ setLoaded(true);
+ } catch (err) {
+ if (err instanceof DOMException && err.name === "AbortError") return;
+ } finally {
+ if (controllerRef.current === controller) {
+ controllerRef.current = null;
+ }
+ inFlightRef.current = false;
+ }
+ }, []);
+
+ useEffect(() => {
+ if (!enabled) return;
+ void fetchRuns();
+ return () => {
+ controllerRef.current?.abort();
+ };
+ }, [enabled, fetchRuns]);
+
+ const hasRunning = items.some((r) => r.status === "running");
+ useEffect(() => {
+ if (!enabled || !hasRunning) return;
+ const timer = setInterval(() => {
+ void fetchRuns();
+ }, RUNNING_POLL_MS);
+ return () => clearInterval(timer);
+ }, [enabled, hasRunning, fetchRuns]);
+
+ return { items, loaded, refresh: fetchRuns };
+}
diff --git a/studio/frontend/src/features/training/hooks/use-training-unload-guard.ts b/studio/frontend/src/features/training/hooks/use-training-unload-guard.ts
new file mode 100644
index 00000000000..78c1e3d5c3e
--- /dev/null
+++ b/studio/frontend/src/features/training/hooks/use-training-unload-guard.ts
@@ -0,0 +1,40 @@
+// 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 { useEffect } from "react";
+import { useTrainingRuntimeStore } from "@/features/training";
+
+let currentHandler: ((e: BeforeUnloadEvent) => void) | null = null;
+
+/**
+ * Mounts a beforeunload guard that warns the user if training is running.
+ * Call once at the app root.
+ */
+export function useTrainingUnloadGuard() {
+ useEffect(() => {
+ const handler = (e: BeforeUnloadEvent) => {
+ if (!useTrainingRuntimeStore.getState().isTrainingRunning) return;
+ e.preventDefault();
+ e.returnValue = "";
+ };
+ currentHandler = handler;
+ window.addEventListener("beforeunload", handler);
+ return () => {
+ if (currentHandler === handler) currentHandler = null;
+ window.removeEventListener("beforeunload", handler);
+ };
+ }, []);
+}
+
+/**
+ * Removes the active beforeunload guard (if any).
+ * Call this before intentionally ending the session (e.g. shutting down
+ * the Studio server) so the "Server stopped" page can render without
+ * the browser prompting the user to confirm leaving.
+ */
+export function removeTrainingUnloadGuard() {
+ if (currentHandler) {
+ window.removeEventListener("beforeunload", currentHandler);
+ currentHandler = null;
+ }
+}
diff --git a/studio/frontend/src/features/training/index.ts b/studio/frontend/src/features/training/index.ts
index af34b306cf9..efce4ca9219 100644
--- a/studio/frontend/src/features/training/index.ts
+++ b/studio/frontend/src/features/training/index.ts
@@ -7,6 +7,7 @@ export {
useTrainingRuntimeStore,
} from "./stores/training-runtime-store";
export { useTrainingActions } from "./hooks/use-training-actions";
+export { useTrainingHistorySidebarItems } from "./hooks/use-training-history-sidebar";
export { useTrainingRuntimeLifecycle } from "./hooks/use-training-runtime-lifecycle";
export { useMaxStepsEpochsToggle } from "./hooks/use-max-steps-epochs-toggle";
export { HfDatasetSubsetSplitSelectors } from "./components/hf-dataset-subset-split-selectors";
diff --git a/studio/frontend/src/features/training/stores/training-runtime-store.ts b/studio/frontend/src/features/training/stores/training-runtime-store.ts
index a57c444c8d3..d958078330f 100644
--- a/studio/frontend/src/features/training/stores/training-runtime-store.ts
+++ b/studio/frontend/src/features/training/stores/training-runtime-store.ts
@@ -41,6 +41,7 @@ const initialState: TrainingRuntimeState = {
evalLossHistory: [],
resetGeneration: 0,
stopRequested: false,
+ selectedHistoryRunId: null,
};
function sortSeries(points: TrainingSeriesPoint[]): TrainingSeriesPoint[] {
@@ -171,6 +172,9 @@ export const useTrainingRuntimeStore = create<TrainingRuntimeStore>()((set) => (
sseConnected: false,
}),
+ setSelectedHistoryRunId: (selectedHistoryRunId) =>
+ set({ selectedHistoryRunId }),
+
applyStatus: (payload) =>
set((state) => {
const metricHistory = applyMetricHistoryFromStatus(payload);
diff --git a/studio/frontend/src/features/training/types/runtime.ts b/studio/frontend/src/features/training/types/runtime.ts
index 1bf319a5d1c..3e4dbd3b79b 100644
--- a/studio/frontend/src/features/training/types/runtime.ts
+++ b/studio/frontend/src/features/training/types/runtime.ts
@@ -99,6 +99,7 @@ export interface TrainingRuntimeState {
evalLossHistory: TrainingSeriesPoint[];
resetGeneration: number;
stopRequested: boolean;
+ selectedHistoryRunId: string | null;
}
export interface TrainingRuntimeActions {
@@ -115,6 +116,7 @@ export interface TrainingRuntimeActions {
applyProgress: (payload: TrainingProgressPayload, eventId?: number) => void;
setStartQueued: (jobId: string, message: string) => void;
setRuntimeError: (message: string) => void;
+ setSelectedHistoryRunId: (id: string | null) => void;
}
export type TrainingRuntimeStore = TrainingRuntimeState & TrainingRuntimeActions;
diff --git a/studio/frontend/src/hooks/use-mobile.ts b/studio/frontend/src/hooks/use-mobile.ts
index 9f505b5f3db..576d2d69da5 100644
--- a/studio/frontend/src/hooks/use-mobile.ts
+++ b/studio/frontend/src/hooks/use-mobile.ts
@@ -1,22 +1,23 @@
// 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 { useEffect, useState } from "react";
+import { useSyncExternalStore } from "react";
const MOBILE_BREAKPOINT = 768;
+const MEDIA_QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`;
-export function useIsMobile() {
- const [isMobile, setIsMobile] = useState<boolean | undefined>(undefined);
+function getSnapshot(): boolean {
+ if (typeof window === "undefined") return false;
+ return window.matchMedia(MEDIA_QUERY).matches;
+}
- useEffect(() => {
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
- const onChange = () => {
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
- };
- mql.addEventListener("change", onChange);
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
- return () => mql.removeEventListener("change", onChange);
- }, []);
+function subscribe(callback: () => void): () => void {
+ if (typeof window === "undefined") return () => {};
+ const mql = window.matchMedia(MEDIA_QUERY);
+ mql.addEventListener("change", callback);
+ return () => mql.removeEventListener("change", callback);
+}
- return !!isMobile;
+export function useIsMobile(): boolean {
+ return useSyncExternalStore(subscribe, getSnapshot, () => false);
}
diff --git a/studio/frontend/src/hooks/use-sidebar-pin.ts b/studio/frontend/src/hooks/use-sidebar-pin.ts
new file mode 100644
index 00000000000..71c780d9a41
--- /dev/null
+++ b/studio/frontend/src/hooks/use-sidebar-pin.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
+
+import { useCallback, useSyncExternalStore } from "react";
+
+const PINNED_KEY = "sidebar_pinned";
+
+function loadPinned(): boolean {
+ if (typeof window === "undefined") return true;
+ try {
+ const raw = window.localStorage.getItem(PINNED_KEY);
+ if (raw === null) return true;
+ return raw === "true";
+ } catch {
+ return true;
+ }
+}
+
+let pinnedValue = loadPinned();
+const listeners = new Set<() => void>();
+
+function subscribe(cb: () => void) {
+ listeners.add(cb);
+ if (typeof window === "undefined") {
+ return () => listeners.delete(cb);
+ }
+ const onStorage = (e: StorageEvent) => {
+ if (e.key === PINNED_KEY || e.key === null) {
+ pinnedValue = loadPinned();
+ cb();
+ }
+ };
+ window.addEventListener("storage", onStorage);
+ return () => {
+ listeners.delete(cb);
+ window.removeEventListener("storage", onStorage);
+ };
+}
+
+function setPinnedGlobal(next: boolean) {
+ pinnedValue = next;
+ try {
+ window.localStorage.setItem(PINNED_KEY, String(next));
+ } catch {}
+ listeners.forEach((cb) => cb());
+}
+
+export function useSidebarPin() {
+ const pinned = useSyncExternalStore(
+ subscribe,
+ () => pinnedValue,
+ () => false,
+ );
+
+ const setPinned = useCallback((value: boolean) => setPinnedGlobal(value), []);
+ const togglePinned = useCallback(() => setPinnedGlobal(!pinnedValue), []);
+
+ return { pinned, setPinned, togglePinned };
+}
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index d051b242457..8ee4f9eca60 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -15,439 +15,501 @@
@custom-variant dark (&:is(.dark *));
@font-face {
- font-family: "Hellix";
- src: url("/fonts/Hellix-SemiBold.woff2") format("woff2"),
- url("/fonts/Hellix-SemiBold.woff") format("woff");
- font-weight: 600;
- font-style: normal;
- font-display: swap;
+ font-family: "Hellix";
+ src: url("/fonts/Hellix-SemiBold.woff2") format("woff2"),
+ url("/fonts/Hellix-SemiBold.woff") format("woff");
+ font-weight: 600;
+ font-style: normal;
+ font-display: swap;
}
:root {
- /* Animation timing */
- --duration-micro: 100ms;
- --duration-fast: 150ms;
- --duration-normal: 200ms;
-
- /* Easing curves (Emil Kowalski) */
- --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
- --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
-
- --background: oklch(1 0 0);
- --foreground: oklch(0.2686 0 0);
- --card: oklch(1 0 0);
- --card-foreground: oklch(0.1281 0.0179 169.2764);
- --popover: oklch(1 0 0);
- --popover-foreground: oklch(0.1281 0.0179 169.2764);
- --primary: oklch(0.6929 0.1396 166.5513);
- --primary-foreground: oklch(1 0 0);
- --secondary: oklch(0.9596 0.0275 167.8295);
- --secondary-foreground: oklch(0.2868 0.0649 159.9823);
- --muted: oklch(0.9702 0 0);
- --muted-foreground: oklch(0.5486 0 0);
- --accent: oklch(0.9596 0.0275 167.8295);
- --accent-foreground: oklch(0.2868 0.0649 159.9823);
- --destructive: oklch(0.6368 0.2078 25.3313);
- --border: oklch(0.9208 0.0101 164.8536);
- --input: oklch(0.9208 0.0101 164.8536);
- --ring: oklch(0.6929 0.1396 166.5513);
- --chart-1: oklch(0.6929 0.1396 166.5513);
- --chart-2: oklch(0.694 0.1395 136.6059);
- --chart-3: oklch(0.7014 0.1193 197.5897);
- --chart-4: oklch(0.6926 0.1112 346.5775);
- --chart-5: oklch(0.7497 0.1003 85.0057);
- --radius: 1.2rem;
- --sidebar: oklch(0.975 0 0);
- --sidebar-foreground: oklch(0.1281 0.0179 169.2764);
- --sidebar-primary: oklch(0.6929 0.1396 166.5513);
- --sidebar-primary-foreground: oklch(1 0 0);
- --sidebar-accent: oklch(0.96 0.0279 166.55);
- --sidebar-accent-foreground: oklch(0.2868 0.0649 159.9823);
- --sidebar-border: oklch(0.9208 0.0101 164.8536);
- --sidebar-ring: oklch(0.6929 0.1396 166.5513);
- --destructive-foreground: oklch(1 0 0);
- --font-sans: "Inter Variable", ui-sans-serif, sans-serif, system-ui;
- --font-heading: "Hellix", "Space Grotesk Variable", var(--font-sans);
- --font-serif: Source Serif 4, serif;
- --font-mono: JetBrains Mono, monospace;
- --shadow-color: hsl(0 0% 0%);
- --shadow-opacity: 0;
- --shadow-blur: 0px;
- --shadow-spread: 0px;
- --shadow-offset-x: 0px;
- --shadow-offset-y: 0px;
- --letter-spacing: 0em;
- --spacing: 0.25rem;
- /*--shadow-2xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-sm:*/
- /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
- /* 0px 1px 2px 0px hsl(0 0% 0% / 0);*/
- /*--shadow:*/
- /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
- /* 0px 1px 2px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-md:*/
- /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
- /* 0px 2px 4px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-lg:*/
- /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
- /* 0px 4px 6px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-xl:*/
- /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
- /* 0px 8px 10px 0px hsl(0 0% 0% / 0);*/
- /*--shadow-2xl: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
- --tracking-normal: 0em;
+ /* Animation timing */
+ --duration-micro: 100ms;
+ --duration-fast: 150ms;
+ --duration-normal: 200ms;
+
+ /* Easing curves (Emil Kowalski) */
+ --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
+ --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
+
+ --background: oklch(1 0 0);
+ --foreground: oklch(0.2686 0 0);
+ --card: oklch(1 0 0);
+ --card-foreground: oklch(0.1281 0.0179 169.2764);
+ --popover: oklch(1 0 0);
+ --popover-foreground: oklch(0.1281 0.0179 169.2764);
+ --primary: oklch(0.6929 0.1396 166.5513);
+ --primary-foreground: oklch(1 0 0);
+ --secondary: oklch(0.9596 0.0275 167.8295);
+ --secondary-foreground: oklch(0.2868 0.0649 159.9823);
+ --muted: oklch(0.9702 0 0);
+ --muted-foreground: oklch(0.5486 0 0);
+ --accent: oklch(0.9596 0.0275 167.8295);
+ --accent-foreground: oklch(0.2868 0.0649 159.9823);
+ --destructive: oklch(0.6368 0.2078 25.3313);
+ --border: oklch(0.9208 0.0101 164.8536);
+ --input: oklch(0.9208 0.0101 164.8536);
+ --ring: oklch(0.6929 0.1396 166.5513);
+ --chart-1: oklch(0.6929 0.1396 166.5513);
+ --chart-2: oklch(0.694 0.1395 136.6059);
+ --chart-3: oklch(0.7014 0.1193 197.5897);
+ --chart-4: oklch(0.6926 0.1112 346.5775);
+ --chart-5: oklch(0.7497 0.1003 85.0057);
+ --radius: 0.625rem;
+ --sidebar: oklch(0.99 0 0);
+ --sidebar-foreground: oklch(0.1281 0.0179 169.2764);
+ --sidebar-primary: oklch(0.6929 0.1396 166.5513);
+ --sidebar-primary-foreground: oklch(1 0 0);
+ --sidebar-accent: oklch(0.96 0.0279 166.55);
+ --sidebar-accent-foreground: oklch(0.2868 0.0649 159.9823);
+ --sidebar-border: oklch(0.9208 0.0101 164.8536);
+ --sidebar-ring: oklch(0.6929 0.1396 166.5513);
+ --destructive-foreground: oklch(1 0 0);
+ --font-sans: "Inter Variable", ui-sans-serif, sans-serif, system-ui;
+ --font-heading: "Hellix", "Space Grotesk Variable", var(--font-sans);
+ --font-serif: Source Serif 4, serif;
+ --font-mono: JetBrains Mono, monospace;
+ --shadow-color: hsl(0 0% 0%);
+ --shadow-opacity: 0;
+ --shadow-blur: 0px;
+ --shadow-spread: 0px;
+ --shadow-offset-x: 0px;
+ --shadow-offset-y: 0px;
+ --letter-spacing: 0em;
+ --spacing: 0.25rem;
+ /*--shadow-2xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-sm:*/
+ /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
+ /* 0px 1px 2px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow:*/
+ /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
+ /* 0px 1px 2px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-md:*/
+ /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
+ /* 0px 2px 4px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-lg:*/
+ /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
+ /* 0px 4px 6px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-xl:*/
+ /* 0px 0px 0px 0px hsl(0 0% 0% / 0),*/
+ /* 0px 8px 10px 0px hsl(0 0% 0% / 0);*/
+ /*--shadow-2xl: 0px 0px 0px 0px hsl(0 0% 0% / 0);*/
+ --tracking-normal: -0.01em;
}
+
.dark {
- --background: oklch(0.24 0 0);
- --foreground: oklch(0.98 0 0);
- --card: oklch(0.28 0 0);
- --card-foreground: oklch(0.98 0 0);
- --popover: oklch(0.28 0 0);
- --popover-foreground: oklch(0.98 0 0);
- --primary: oklch(0.6929 0.1396 166.5513);
- --primary-foreground: oklch(1 0 0);
- --secondary: oklch(0.33 0 0);
- --secondary-foreground: oklch(0.98 0 0);
- --muted: oklch(0.33 0 0);
- --muted-foreground: oklch(0.70 0 0);
- --accent: oklch(0.33 0 0);
- --accent-foreground: oklch(0.98 0 0);
- --destructive: oklch(0.6368 0.2078 25.3313);
- --border: oklch(0.38 0 0);
- --input: oklch(0.38 0 0);
- --ring: oklch(0.6929 0.1396 166.5513);
- --chart-1: oklch(0.7511 0.1407 166.2284);
- --chart-2: oklch(0.75 0.14 136.5572);
- --chart-3: oklch(0.7554 0.1285 197.339);
- --chart-4: oklch(0.7503 0.1199 346.7805);
- --chart-5: oklch(0.799 0.1196 84.6633);
- --sidebar: oklch(0.24 0 0);
- --sidebar-foreground: oklch(0.98 0 0);
- --sidebar-primary: oklch(0.6929 0.1396 166.5513);
- --sidebar-primary-foreground: oklch(1 0 0);
- --sidebar-accent: oklch(0.33 0 0);
- --sidebar-accent-foreground: oklch(0.98 0 0);
- --sidebar-border: oklch(0.38 0 0);
- --sidebar-ring: oklch(0.6929 0.1396 166.5513);
- --destructive-foreground: oklch(1 0 0);
- --radius: 1.2rem;
- --font-sans: Geist, ui-sans-serif, sans-serif, system-ui;
- --font-serif: Source Serif 4, serif;
- --font-mono: JetBrains Mono, monospace;
- --shadow-color: hsl(0 0% 0%);
- --shadow-opacity: 0;
- --shadow-blur: 0px;
- --shadow-spread: 0px;
- --shadow-offset-x: 0px;
- --shadow-offset-y: 0px;
- --letter-spacing: 0em;
- --spacing: 0.25rem;
- --shadow-2xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);
- --shadow-xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);
- --shadow-sm: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 1px 2px 0px
- hsl(0 0% 0% / 0);
- --shadow: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 1px 2px 0px hsl(0 0% 0% / 0);
- --shadow-md: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 2px 4px 0px
- hsl(0 0% 0% / 0);
- --shadow-lg: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 4px 6px 0px
- hsl(0 0% 0% / 0);
- --shadow-xl: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 8px 10px 0px
- hsl(0 0% 0% / 0);
- --shadow-2xl: 0px 0px 0px 0px hsl(0 0% 0% / 0);
+ --background: oklch(0.24 0 0);
+ --foreground: oklch(0.98 0 0);
+ --card: oklch(0.28 0 0);
+ --card-foreground: oklch(0.98 0 0);
+ --popover: oklch(0.28 0 0);
+ --popover-foreground: oklch(0.98 0 0);
+ --primary: oklch(0.6929 0.1396 166.5513);
+ --primary-foreground: oklch(1 0 0);
+ --secondary: oklch(0.33 0 0);
+ --secondary-foreground: oklch(0.98 0 0);
+ --muted: oklch(0.33 0 0);
+ --muted-foreground: oklch(0.70 0 0);
+ --accent: oklch(0.33 0 0);
+ --accent-foreground: oklch(0.98 0 0);
+ --destructive: oklch(0.6368 0.2078 25.3313);
+ --border: oklch(0.38 0 0);
+ --input: oklch(0.38 0 0);
+ --ring: oklch(0.6929 0.1396 166.5513);
+ --chart-1: oklch(0.7511 0.1407 166.2284);
+ --chart-2: oklch(0.75 0.14 136.5572);
+ --chart-3: oklch(0.7554 0.1285 197.339);
+ --chart-4: oklch(0.7503 0.1199 346.7805);
+ --chart-5: oklch(0.799 0.1196 84.6633);
+ --sidebar: oklch(0.24 0 0);
+ --sidebar-foreground: oklch(0.98 0 0);
+ --sidebar-primary: oklch(0.6929 0.1396 166.5513);
+ --sidebar-primary-foreground: oklch(1 0 0);
+ --sidebar-accent: oklch(0.33 0 0);
+ --sidebar-accent-foreground: oklch(0.98 0 0);
+ --sidebar-border: oklch(0.38 0 0);
+ --sidebar-ring: oklch(0.6929 0.1396 166.5513);
+ --destructive-foreground: oklch(1 0 0);
+ --radius: 0.625rem;
+ --font-sans: Geist, ui-sans-serif, sans-serif, system-ui;
+ --font-serif: Source Serif 4, serif;
+ --font-mono: JetBrains Mono, monospace;
+ --shadow-color: hsl(0 0% 0%);
+ --shadow-opacity: 0;
+ --shadow-blur: 0px;
+ --shadow-spread: 0px;
+ --shadow-offset-x: 0px;
+ --shadow-offset-y: 0px;
+ --letter-spacing: 0em;
+ --spacing: 0.25rem;
+ --shadow-2xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);
+ --shadow-xs: 0px 0px 0px 0px hsl(0 0% 0% / 0);
+ --shadow-sm: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 1px 2px 0px hsl(0 0% 0% / 0);
+ --shadow: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 1px 2px 0px hsl(0 0% 0% / 0);
+ --shadow-md: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 2px 4px 0px hsl(0 0% 0% / 0);
+ --shadow-lg: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 4px 6px 0px hsl(0 0% 0% / 0);
+ --shadow-xl: 0px 0px 0px 0px hsl(0 0% 0% / 0), 0px 8px 10px 0px hsl(0 0% 0% / 0);
+ --shadow-2xl: 0px 0px 0px 0px hsl(0 0% 0% / 0);
}
@theme inline {
- --font-sans: "Inter Variable", ui-sans-serif, sans-serif, system-ui;
- --font-heading: "Hellix", "Space Grotesk Variable", var(--font-sans);
- --color-sidebar-ring: var(--sidebar-ring);
- --color-sidebar-border: var(--sidebar-border);
- --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
- --color-sidebar-accent: var(--sidebar-accent);
- --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
- --color-sidebar-primary: var(--sidebar-primary);
- --color-sidebar-foreground: var(--sidebar-foreground);
- --color-sidebar: var(--sidebar);
- --color-chart-5: var(--chart-5);
- --color-chart-4: var(--chart-4);
- --color-chart-3: var(--chart-3);
- --color-chart-2: var(--chart-2);
- --color-chart-1: var(--chart-1);
- --color-code-block: #181818;
- --color-ring: var(--ring);
- --color-input: var(--input);
- --color-border: var(--border);
- --color-destructive: var(--destructive);
- --color-accent-foreground: var(--accent-foreground);
- --color-accent: var(--accent);
- --color-muted-foreground: var(--muted-foreground);
- --color-muted: var(--muted);
- --color-secondary-foreground: var(--secondary-foreground);
- --color-secondary: var(--secondary);
- --color-primary-foreground: var(--primary-foreground);
- --color-primary: var(--primary);
- --color-popover-foreground: var(--popover-foreground);
- --color-popover: var(--popover);
- --color-card-foreground: var(--card-foreground);
- --color-card: var(--card);
- --color-foreground: var(--foreground);
- --color-background: var(--background);
- --radius-sm: calc(var(--radius) - 4px);
- --radius-md: calc(var(--radius) - 2px);
- --radius-lg: var(--radius);
- --radius-xl: calc(var(--radius) + 4px);
- --radius-2xl: calc(var(--radius) + 8px);
- --radius-3xl: calc(var(--radius) + 12px);
- --radius-4xl: calc(var(--radius) + 16px);
- --font-mono: JetBrains Mono, monospace;
- --font-serif: Source Serif 4, serif;
- --radius: 1.2rem;
- --tracking-tighter: calc(var(--tracking-normal) - 0.05em);
- --tracking-tight: calc(var(--tracking-normal) - 0.025em);
- --tracking-wide: calc(var(--tracking-normal) + 0.025em);
- --tracking-wider: calc(var(--tracking-normal) + 0.05em);
- --tracking-widest: calc(var(--tracking-normal) + 0.1em);
- --tracking-normal: var(--tracking-normal);
- /*--shadow-2xl: var(--shadow-2xl);*/
- /*--shadow-xl: var(--shadow-xl);*/
- /*--shadow-lg: var(--shadow-lg);*/
- /*--shadow-md: var(--shadow-md);*/
- /*--shadow: var(--shadow);*/
- /*--shadow-sm: var(--shadow-sm);*/
- /*--shadow-xs: var(--shadow-xs);*/
- /*--shadow-2xs: var(--shadow-2xs);*/
- /*--spacing: var(--spacing);*/
- /*--letter-spacing: var(--letter-spacing);*/
- /*--shadow-offset-y: var(--shadow-offset-y);*/
- /*--shadow-offset-x: var(--shadow-offset-x);*/
- /*--shadow-spread: var(--shadow-spread);*/
- /*--shadow-blur: var(--shadow-blur);*/
- /*--shadow-opacity: var(--shadow-opacity);*/
- /*--color-shadow-color: var(--shadow-color);*/
- --color-destructive-foreground: var(--destructive-foreground);
- --animate-pulse: pulse var(--duration) ease-out infinite;
- @keyframes pulse {
- 0%,
- 100% {
- box-shadow: 0 0 0 0 var(--pulse-color);
- }
- 50% {
- box-shadow: 0 0 0 8px var(--pulse-color);
- }
- }
- --animate-shiny-text: shiny-text 8s infinite;
- @keyframes shiny-text {
- 0%,
- 90%,
- 100% {
- background-position: calc(-100% - var(--shiny-width)) 0;
- }
- 30%,
- 60% {
- background-position: calc(100% + var(--shiny-width)) 0;
- }
- }
- --animate-shine: shine var(--duration) infinite linear
-;
- @keyframes shine {
- 0% {
- background-position: 0% 0%;
- }
- 50% {
- background-position: 100% 100%;
- }
- to {
- background-position: 0% 0%;
- }
- }}
+ --font-sans: "Inter Variable", ui-sans-serif, sans-serif, system-ui;
+ --font-heading: "Hellix", "Space Grotesk Variable", var(--font-sans);
+ --color-sidebar-ring: var(--sidebar-ring);
+ --color-sidebar-border: var(--sidebar-border);
+ --color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
+ --color-sidebar-accent: var(--sidebar-accent);
+ --color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
+ --color-sidebar-primary: var(--sidebar-primary);
+ --color-sidebar-foreground: var(--sidebar-foreground);
+ --color-sidebar: var(--sidebar);
+ --color-chart-5: var(--chart-5);
+ --color-chart-4: var(--chart-4);
+ --color-chart-3: var(--chart-3);
+ --color-chart-2: var(--chart-2);
+ --color-chart-1: var(--chart-1);
+ --color-code-block: #181818;
+ --color-ring: var(--ring);
+ --color-input: var(--input);
+ --color-border: var(--border);
+ --color-destructive: var(--destructive);
+ --color-accent-foreground: var(--accent-foreground);
+ --color-accent: var(--accent);
+ --color-muted-foreground: var(--muted-foreground);
+ --color-muted: var(--muted);
+ --color-secondary-foreground: var(--secondary-foreground);
+ --color-secondary: var(--secondary);
+ --color-primary-foreground: var(--primary-foreground);
+ --color-primary: var(--primary);
+ --color-popover-foreground: var(--popover-foreground);
+ --color-popover: var(--popover);
+ --color-card-foreground: var(--card-foreground);
+ --color-card: var(--card);
+ --color-foreground: var(--foreground);
+ --color-background: var(--background);
+ --radius-sm: calc(var(--radius) - 4px);
+ --radius-md: calc(var(--radius) - 2px);
+ --radius-lg: var(--radius);
+ --radius-xl: calc(var(--radius) + 4px);
+ --radius-2xl: calc(var(--radius) + 8px);
+ --radius-3xl: calc(var(--radius) + 12px);
+ --radius-4xl: calc(var(--radius) + 16px);
+ --font-mono: JetBrains Mono, monospace;
+ --font-serif: Source Serif 4, serif;
+ --radius: 0.625rem;
+ --tracking-tighter: calc(var(--tracking-normal) - 0.05em);
+ --tracking-tight: calc(var(--tracking-normal) - 0.025em);
+ --tracking-wide: calc(var(--tracking-normal) + 0.025em);
+ --tracking-wider: calc(var(--tracking-normal) + 0.05em);
+ --tracking-widest: calc(var(--tracking-normal) + 0.1em);
+ --tracking-normal: var(--tracking-normal);
+ /*--shadow-2xl: var(--shadow-2xl);*/
+ /*--shadow-xl: var(--shadow-xl);*/
+ /*--shadow-lg: var(--shadow-lg);*/
+ /*--shadow-md: var(--shadow-md);*/
+ /*--shadow: var(--shadow);*/
+ /*--shadow-sm: var(--shadow-sm);*/
+ /*--shadow-xs: var(--shadow-xs);*/
+ /*--shadow-2xs: var(--shadow-2xs);*/
+ /*--spacing: var(--spacing);*/
+ /*--letter-spacing: var(--letter-spacing);*/
+ /*--shadow-offset-y: var(--shadow-offset-y);*/
+ /*--shadow-offset-x: var(--shadow-offset-x);*/
+ /*--shadow-spread: var(--shadow-spread);*/
+ /*--shadow-blur: var(--shadow-blur);*/
+ /*--shadow-opacity: var(--shadow-opacity);*/
+ /*--color-shadow-color: var(--shadow-color);*/
+ --color-destructive-foreground: var(--destructive-foreground);
+ --animate-pulse: pulse var(--duration) ease-out infinite;
+
+ @keyframes pulse {
+
+ 0%,
+ 100% {
+ box-shadow: 0 0 0 0 var(--pulse-color);
+ }
+
+ 50% {
+ box-shadow: 0 0 0 8px var(--pulse-color);
+ }
+ }
+
+ --animate-shiny-text: shiny-text 8s infinite;
+
+ @keyframes shiny-text {
+
+ 0%,
+ 90%,
+ 100% {
+ background-position: calc(-100% - var(--shiny-width)) 0;
+ }
+
+ 30%,
+ 60% {
+ background-position: calc(100% + var(--shiny-width)) 0;
+ }
+ }
+
+ --animate-shine: shine var(--duration) infinite linear;
+
+ @keyframes shine {
+ 0% {
+ background-position: 0% 0%;
+ }
+
+ 50% {
+ background-position: 100% 100%;
+ }
+
+ to {
+ background-position: 0% 0%;
+ }
+ }
+}
@layer base {
- * {
- @apply border-border outline-ring/50;
- }
- body {
- @apply font-sans bg-background text-foreground;
- letter-spacing: var(--tracking-normal);
- }
- html {
- @apply font-sans;
- scrollbar-gutter: stable;
- }
- body[data-scroll-locked] {
- margin-right: 0 !important;
- }
- h1,
- h2,
- h3,
- h4,
- h5,
- h6 {
- font-family: var(--font-heading);
- }
- .font-medium,
- .font-semibold,
- .font-bold {
- font-family: var(--font-heading);
- }
+ * {
+ @apply border-border outline-ring/50;
+ }
+
+ body {
+ @apply font-sans bg-background text-foreground;
+ letter-spacing: var(--tracking-normal);
+ }
+
+ html {
+ @apply font-sans h-full;
+ }
+
+ body,
+ #root {
+ @apply h-full;
+ }
+
+ body[data-scroll-locked] {
+ margin-right: 0 !important;
+ }
+
+ h1,
+ h2,
+ h3,
+ h4,
+ h5,
+ h6 {
+ font-family: var(--font-sans);
+ letter-spacing: -0.02em;
+ }
}
@layer utilities {
- /* Heading font utility */
- .font-heading {
- font-family: var(--font-heading);
- }
-
- /* Elevated surface shadow (use ring-* for borders) */
- .shadow-border {
- --tw-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
- --tw-shadow-colored: 0 4px 16px var(--tw-shadow-color);
- box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000),
- var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
- }
- .dark .shadow-border {
- --tw-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
- }
-
- /* Fine-tuning Studio: equal default height, expandable when needed (md+) */
- .min-h-studio-config-column {
- @apply md:min-h-[470px];
- }
- .h-studio-config-column {
- @apply md:h-[470px];
- }
-
- [data-streamdown="unordered-list"] {
- list-style-type: disc;
- list-style-position: outside;
- padding-left: 1.25rem;
- margin-block: 0.5rem;
- }
-
- [data-streamdown="ordered-list"] {
- list-style-type: decimal;
- list-style-position: outside;
- padding-left: 1.25rem;
- margin-block: 0.5rem;
- }
-
- [data-streamdown="list-item"] {
- display: list-item;
- }
-
- /* Flatten code blocks: single border, language label, then code directly */
- [data-streamdown="code-block-body"] {
- border: none !important;
- border-radius: 0 !important;
- background: transparent !important;
- padding: 0 !important;
- }
- [data-streamdown="code-block"] {
- gap: 0;
- padding: 0.5rem;
- /* Wide lines must scroll inside the thread column, not widen past the composer (flex min-width:auto). */
- max-width: 100%;
- min-width: 0;
- overflow-x: auto;
- }
- [data-streamdown="code-block-header"] {
- padding-left: 0.75rem;
- }
-
- /* Chat thread: code slightly smaller by default; step up when the thread column is wide. */
- .aui-thread-root [data-streamdown="code-block"] {
- font-size: 0.8125rem;
- line-height: 1.55;
- }
-
- .aui-thread-root [data-streamdown="code-block-header"] {
- font-size: 0.6875rem;
- }
-
- @container (min-width: 36rem) {
- .aui-thread-root [data-streamdown="code-block"] {
- font-size: 0.875rem;
- }
-
- .aui-thread-root [data-streamdown="code-block-header"] {
- font-size: 0.75rem;
- }
- }
-
- /* Chat: use the app sans stack for UI + prose. */
- .aui-thread-root {
- --font-heading: var(--font-sans);
- font-family: var(--font-sans);
- }
-
- /* Keep monospace for code fences and inline code (not KaTeX). */
- .aui-thread-root [data-streamdown="code-block"] pre,
- .aui-thread-root [data-streamdown="code-block"] code {
- font-family: var(--font-mono), ui-monospace, monospace;
- }
-
- .aui-thread-root :where(p, li, td, th, blockquote, h1, h2, h3, h4, h5, h6) code {
- font-family: var(--font-mono), ui-monospace, monospace;
- }
-
- /* Align fenced code blocks with the main chat column even when nested in lists. */
- .aui-thread-root [data-streamdown="list-item"] > [data-streamdown="code-block"],
- .aui-thread-root [data-streamdown="list-item"] [data-streamdown="code-block"] {
- margin-left: -1.25rem;
- width: calc(100% + 1.25rem);
- max-width: calc(100% + 1.25rem);
- }
-
- .dark .aui-thread-root [data-streamdown="code-block"] {
- /* Streamdown `pre` uses `dark:bg-[var(--shiki-dark-bg,...)]`; keep one surface on the outer shell. */
- --shiki-dark-bg: transparent;
- background: var(--color-code-block);
- border: 1px solid oklch(1 0 0 / 0.07);
- }
+
+ /* Heading font utility */
+ .font-heading {
+ font-family: var(--font-heading);
+ }
+
+ /* Elevated surface shadow (use ring-* for borders) */
+ .shadow-border {
+ --tw-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
+ --tw-shadow-colored: 0 4px 16px var(--tw-shadow-color);
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000),
+ var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
+ }
+
+ .dark .shadow-border {
+ --tw-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
+ }
+
+ .chat-composer-surface {
+ border: 1px solid oklch(0.93 0 0 / 1);
+ background-clip: padding-box;
+ box-shadow:
+ 0 1px 2px oklch(0 0 0 / 0.04),
+ 0 6px 14px oklch(0 0 0 / 0.05),
+ 0 18px 40px oklch(0 0 0 / 0.05);
+ }
+
+ .dark .chat-composer-surface {
+ border-color: oklch(0.38 0 0 / 1);
+ box-shadow:
+ 0 1px 2px oklch(0 0 0 / 0.2),
+ 0 8px 20px oklch(0 0 0 / 0.25),
+ 0 22px 48px oklch(0 0 0 / 0.22);
+ }
+
+ /* Fine-tuning Studio: equal default height, expandable when needed (md+) */
+ .min-h-studio-config-column {
+ @apply md:min-h-[470px];
+ }
+
+ .h-studio-config-column {
+ @apply md:h-[470px];
+ }
+
+ [data-streamdown="unordered-list"] {
+ list-style-type: disc;
+ list-style-position: outside;
+ padding-left: 1.25rem;
+ margin-block: 0.5rem;
+ }
+
+ [data-streamdown="ordered-list"] {
+ list-style-type: decimal;
+ list-style-position: outside;
+ padding-left: 1.25rem;
+ margin-block: 0.5rem;
+ }
+
+ [data-streamdown="list-item"] {
+ display: list-item;
+ }
+
+ /* Flatten code blocks: single border, language label, then code directly */
+ [data-streamdown="code-block-body"] {
+ border: none !important;
+ border-radius: 0 !important;
+ background: transparent !important;
+ padding: 0 !important;
+ }
+
+ [data-streamdown="code-block"] {
+ gap: 0;
+ padding: 0.5rem;
+ /* Wide lines must scroll inside the thread column, not widen past the composer (flex min-width:auto). */
+ max-width: 100%;
+ min-width: 0;
+ overflow-x: auto;
+ }
+
+ [data-streamdown="code-block-header"] {
+ padding-left: 0.75rem;
+ }
+
+ /* Chat thread: code slightly smaller by default; step up when the thread column is wide. */
+ .aui-thread-root [data-streamdown="code-block"] {
+ font-size: 0.8125rem;
+ line-height: 1.55;
+ }
+
+ .aui-thread-root [data-streamdown="code-block-header"] {
+ font-size: 0.6875rem;
+ }
+
+ @container (min-width: 36rem) {
+ .aui-thread-root [data-streamdown="code-block"] {
+ font-size: 0.875rem;
+ }
+
+ .aui-thread-root [data-streamdown="code-block-header"] {
+ font-size: 0.75rem;
+ }
+ }
+
+ /* Chat: use the app sans stack for UI + prose. */
+ .aui-thread-root {
+ --font-heading: var(--font-sans);
+ font-family: var(--font-sans);
+ }
+
+ /* Keep monospace for code fences and inline code (not KaTeX). */
+ .aui-thread-root [data-streamdown="code-block"] pre,
+ .aui-thread-root [data-streamdown="code-block"] code {
+ font-family: var(--font-mono), ui-monospace, monospace;
+ }
+
+ .aui-thread-root :where(p, li, td, th, blockquote, h1, h2, h3, h4, h5, h6) code {
+ font-family: var(--font-mono), ui-monospace, monospace;
+ }
+
+ /* Align fenced code blocks with the main chat column even when nested in lists. */
+ .aui-thread-root [data-streamdown="list-item"] > [data-streamdown="code-block"],
+ .aui-thread-root [data-streamdown="list-item"] [data-streamdown="code-block"] {
+ margin-left: -1.25rem;
+ width: calc(100% + 1.25rem);
+ max-width: calc(100% + 1.25rem);
+ }
+
+ .dark .aui-thread-root [data-streamdown="code-block"] {
+ /* Streamdown `pre` uses `dark:bg-[var(--shiki-dark-bg,...)]`; keep one surface on the outer shell. */
+ --shiki-dark-bg: transparent;
+ background: var(--color-code-block);
+ border: 1px solid oklch(1 0 0 / 0.07);
+ }
}
-/* Minimal scrollbar — thumb only, no track */
+/* Flat scrollbar chrome */
* {
- scrollbar-width: thin;
- scrollbar-color: transparent transparent;
+ scrollbar-width: thin;
+ scrollbar-color: oklch(0.5 0 0 / 0.54) transparent;
}
-*:hover {
- scrollbar-color: oklch(0.6 0 0 / 0.3) transparent;
-}
-.dark *:hover {
- scrollbar-color: oklch(0.5 0 0 / 0.35) transparent;
+
+.dark * {
+ scrollbar-color: oklch(0.67 0 0 / 0.5) transparent;
}
/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
- width: 6px;
- height: 6px;
+ width: 8px;
+ height: 8px;
}
+
::-webkit-scrollbar-track {
- background: transparent;
+ background: transparent;
}
+
::-webkit-scrollbar-thumb {
- background: transparent;
- border-radius: 9999px;
+ background: oklch(0.5 0 0 / 0.54);
+ border-radius: 9999px;
+}
+
+::-webkit-scrollbar-button {
+ display: none;
+ width: 0;
+ height: 0;
+}
+
+.dark *::-webkit-scrollbar-thumb {
+ background: oklch(0.67 0 0 / 0.5);
}
-*:hover::-webkit-scrollbar-thumb {
- background: oklch(0.6 0 0 / 0.3);
+
+/* Chat viewport: solid track matching sidebar so the scrollbar reads as a
+ full-height rail flush to the right edge, without a separate decorative strip. */
+.aui-thread-viewport {
+ scrollbar-color: oklch(0.5 0 0 / 0.54) var(--sidebar);
}
-.dark *:hover::-webkit-scrollbar-thumb {
- background: oklch(0.5 0 0 / 0.35);
+
+.dark .aui-thread-viewport {
+ scrollbar-color: oklch(0.67 0 0 / 0.5) var(--sidebar);
+}
+
+.aui-thread-viewport::-webkit-scrollbar-track {
+ background: var(--sidebar);
+}
+
+[data-sidebar="content"] {
+ scrollbar-color: oklch(0.5 0 0 / 0.7) transparent;
+}
+
+.dark [data-sidebar="content"] {
+ scrollbar-color: oklch(0.72 0 0 / 0.65) transparent;
}
/*---break---*/
@layer base {
- * {
- @apply border-border outline-ring/50;
- }
- body {
- @apply bg-background text-foreground;
- }
+ * {
+ @apply border-border outline-ring/50;
+ }
+
+ body {
+ @apply bg-background text-foreground;
+ }
}
-::view-transition-old(root), ::view-transition-new(root) {
- animation: none;
- mix-blend-mode: normal;
-}
\ No newline at end of file
+::view-transition-old(root),
+::view-transition-new(root) {
+ animation: none;
+ mix-blend-mode: normal;
+}