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.

Studio: draw the command palette like chat search (#12511)

Michael Han767a9f02e7ef
diff --git a/studio/frontend/src/components/command-palette.tsx b/studio/frontend/src/components/command-palette.tsx
index 0ca6c5ff9ce..bf6a8cd5d8f 100644
--- a/studio/frontend/src/components/command-palette.tsx
+++ b/studio/frontend/src/components/command-palette.tsx
@@ -7,7 +7,6 @@ import {
CommandDialog,
CommandEmpty,
CommandGroup,
- CommandInput,
CommandItem,
CommandList,
CommandSeparator,
@@ -28,9 +27,11 @@ import {
useShortcutLabel,
} from "@/features/settings";
import { useT, type TranslationKey } from "@/i18n";
+import { cn } from "@/lib/utils";
import { useCommandPaletteStore } from "@/stores/command-palette";
import {
AudioWave01Icon,
+ Cancel01Icon,
ChefHatIcon,
DashboardCircleIcon,
DownloadSquare01Icon,
@@ -48,8 +49,32 @@ import {
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import { useNavigate, useRouterState } from "@tanstack/react-router";
+import { Command as CommandPrimitive } from "cmdk";
import { Moon } from "lucide-react";
-import { useEffect, useState } from "react";
+import { type ComponentProps, useEffect, useState } from "react";
+
+// Surface, header and rows follow chat search (chat-search-dialog.tsx).
+const ROW_CLASS =
+ "gap-3 rounded-full px-3 py-2.5 text-ui-13 font-medium data-selected:bg-muted data-selected:text-foreground *:[svg]:text-muted-foreground data-selected:*:[svg]:text-muted-foreground";
+
+function PaletteItem({
+ className,
+ ...props
+}: ComponentProps<typeof CommandItem>) {
+ return <CommandItem className={cn(ROW_CLASS, className)} {...props} />;
+}
+
+function PaletteShortcut({
+ className,
+ ...props
+}: ComponentProps<typeof CommandShortcut>) {
+ return (
+ <CommandShortcut
+ className={cn("text-ui-11 font-normal", className)}
+ {...props}
+ />
+ );
+}
// matches sidebar: drop interior bubble paths
const TestTubeOutlineIcon = TestTube01Icon.slice(0, 3) as typeof TestTube01Icon;
@@ -162,7 +187,8 @@ export function CommandPalette() {
<CommandDialog
open={isOpen}
onOpenChange={setOpen}
- className="w-140 max-w-[calc(100%-2rem)] sm:max-w-140"
+ className="chat-search-surface rounded-3xl! max-sm:rounded-none! top-[calc(50%+var(--studio-window-chrome-top,0px)/2)] -translate-y-1/2 w-[calc(635px*var(--ui-space-scale,1))] max-w-[calc(100%-2rem)] gap-0 p-0 ring-0 duration-[180ms] ease-[cubic-bezier(0.16,1,0.3,1)] sm:max-w-[calc(635px*var(--ui-space-scale,1))]"
+ overlayClassName="bg-transparent supports-backdrop-filter:backdrop-blur-none"
>
<PaletteContent />
</CommandDialog>
@@ -181,11 +207,11 @@ function WorkspaceItem({
const label = useShortcutLabel(workspace.id);
if (!available) return null;
return (
- <CommandItem onSelect={onSelect} keywords={workspace.aliases}>
+ <PaletteItem onSelect={onSelect} keywords={workspace.aliases}>
<HugeiconsIcon icon={workspace.icon} strokeWidth={1.75} />
<span>{t(workspace.labelKey)}</span>
- {label && <CommandShortcut>{label}</CommandShortcut>}
- </CommandItem>
+ {label && <PaletteShortcut>{label}</PaletteShortcut>}
+ </PaletteItem>
);
}
@@ -222,17 +248,44 @@ function PaletteContent() {
});
return (
- <Command>
- <CommandInput
- placeholder={t("shell.commandPalette.placeholder")}
- value={query}
- onValueChange={setQuery}
- />
- <CommandList className="max-h-105">
- <CommandEmpty className="text-muted-foreground text-xs">
+ <Command className="rounded-3xl p-0">
+ <div className="flex items-center gap-3 border-b border-border/40 px-4 py-3">
+ <HugeiconsIcon
+ icon={Search01Icon}
+ strokeWidth={2}
+ className="size-4 shrink-0 text-muted-foreground"
+ />
+ <CommandPrimitive.Input
+ placeholder={t("shell.commandPalette.placeholder")}
+ value={query}
+ onValueChange={setQuery}
+ className="flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
+ />
+ {/* cmdk runs the selected row on an Enter from anywhere inside it, so keep this one on the button. */}
+ <button
+ type="button"
+ onClick={close}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") e.stopPropagation();
+ }}
+ className="flex size-6 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
+ aria-label={t("common.close")}
+ >
+ <HugeiconsIcon
+ icon={Cancel01Icon}
+ strokeWidth={2}
+ className="size-4"
+ />
+ </button>
+ </div>
+ <CommandList className="cmd-native-scrollbar hover-scrollbar h-[calc(420px*var(--ui-space-scale,1))] max-h-[60dvh] p-1">
+ <CommandEmpty className="py-6 text-center text-xs text-muted-foreground">
{t("shell.commandPalette.noResults")}
</CommandEmpty>
- <CommandGroup heading={t("shell.commandPalette.navigation")}>
+ <CommandGroup
+ heading={t("shell.commandPalette.navigation")}
+ className="p-0"
+ >
{WORKSPACES.map((workspace) => (
<WorkspaceItem
key={workspace.id}
@@ -240,41 +293,44 @@ function PaletteContent() {
onSelect={runAndClose(() => void triggerShortcut(workspace.id))}
/>
))}
- <CommandItem
+ <PaletteItem
onSelect={runAndClose(() => void navigate({ to: "/library" }))}
>
<HugeiconsIcon icon={LibrariesIcon} strokeWidth={1.75} />
<span>{t("shell.navigation.library")}</span>
- </CommandItem>
- <CommandItem
+ </PaletteItem>
+ <PaletteItem
onSelect={runAndClose(() => void navigate({ to: "/api-monitor" }))}
keywords={["api", "monitor", "requests"]}
>
<HugeiconsIcon icon={InternetIcon} strokeWidth={1.75} />
<span>{t("shell.navigation.api")}</span>
- </CommandItem>
- <CommandItem onSelect={openSettings()} keywords={["preferences"]}>
+ </PaletteItem>
+ <PaletteItem onSelect={openSettings()} keywords={["preferences"]}>
<HugeiconsIcon icon={Settings02Icon} strokeWidth={1.75} />
<span>{t("shell.navigation.settings")}</span>
{settingsLabel && (
- <CommandShortcut>{settingsLabel}</CommandShortcut>
+ <PaletteShortcut>{settingsLabel}</PaletteShortcut>
)}
- </CommandItem>
+ </PaletteItem>
</CommandGroup>
<CommandSeparator />
- <CommandGroup heading={t("shell.commandPalette.actions")}>
+ <CommandGroup
+ heading={t("shell.commandPalette.actions")}
+ className="p-0"
+ >
{newChatAvailable && (
- <CommandItem
+ <PaletteItem
onSelect={runAndClose(() => void triggerShortcut("newChat"))}
>
<HugeiconsIcon icon={PencilEdit02Icon} strokeWidth={1.75} />
<span>{t("shell.navigation.newChat")}</span>
{newChatLabel && (
- <CommandShortcut>{newChatLabel}</CommandShortcut>
+ <PaletteShortcut>{newChatLabel}</PaletteShortcut>
)}
- </CommandItem>
+ </PaletteItem>
)}
- <CommandItem
+ <PaletteItem
onSelect={runAndClose(() =>
useChatSearchStore.getState().open({
opener: useCommandPaletteStore.getState().opener,
@@ -283,9 +339,9 @@ function PaletteContent() {
>
<HugeiconsIcon icon={Search01Icon} strokeWidth={1.75} />
<span>{t("shell.commandPalette.searchChats")}</span>
- {searchLabel && <CommandShortcut>{searchLabel}</CommandShortcut>}
- </CommandItem>
- <CommandItem
+ {searchLabel && <PaletteShortcut>{searchLabel}</PaletteShortcut>}
+ </PaletteItem>
+ <PaletteItem
ref={anchorRef as React.Ref<HTMLDivElement>}
onSelect={runAndClose(() => void toggleTheme())}
keywords={["theme"]}
@@ -300,17 +356,20 @@ function PaletteContent() {
? t("shell.navigation.lightMode")
: t("shell.navigation.darkMode")}
</span>
- </CommandItem>
+ </PaletteItem>
</CommandGroup>
{/* Settings pages only once the user types. */}
{hasQuery && (
<>
<CommandSeparator />
- <CommandGroup heading={t("shell.navigation.settings")}>
+ <CommandGroup
+ heading={t("shell.navigation.settings")}
+ className="p-0"
+ >
{SETTINGS_TABS.filter((tab) =>
settingsTabVisible(tab, isOwner),
).map((tab) => (
- <CommandItem
+ <PaletteItem
key={tab}
keywords={DIALOG_SETTINGS_SEARCH_INDEX[tab].map((key) =>
t(key),
@@ -323,7 +382,7 @@ function PaletteContent() {
</span>
<span className="text-muted-foreground">→</span>
<span>{t(SETTINGS_TAB_LABELS[tab])}</span>
- </CommandItem>
+ </PaletteItem>
))}
</CommandGroup>
</>
diff --git a/studio/frontend/tests/command-palette-search-style.test.ts b/studio/frontend/tests/command-palette-search-style.test.ts
new file mode 100644
index 00000000000..f8503f51236
--- /dev/null
+++ b/studio/frontend/tests/command-palette-search-style.test.ts
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+import { readSrc } from "./helpers/kit.ts";
+
+// The command palette is drawn like chat search: same surface, header row and pill rows.
+
+const PALETTE = readSrc("components/command-palette.tsx");
+const SEARCH = readSrc("features/chat/components/chat-search-dialog.tsx");
+
+function dialogClasses(source: string): string[] {
+ const match = /<CommandDialog[\s\S]*?className="([^"]+)"\s*overlayClassName="([^"]+)"/.exec(source);
+ assert.ok(match);
+ return [match[1], match[2]];
+}
+
+test("the palette dialog uses the chat search surface", () => {
+ assert.deepEqual(dialogClasses(PALETTE), dialogClasses(SEARCH));
+ assert.match(PALETTE, /<Command className="rounded-3xl p-0">/);
+});
+
+test("the palette header is chat search's search, input and close row", () => {
+ const header = 'className="flex items-center gap-3 border-b border-border/40 px-4 py-3"';
+ assert.ok(SEARCH.includes(header));
+ assert.ok(PALETTE.includes(header));
+ assert.doesNotMatch(PALETTE, /<CommandInput\b/);
+ assert.match(PALETTE, /<CommandPrimitive\.Input\s+placeholder=\{t\("shell\.commandPalette\.placeholder"\)\}/);
+ assert.match(PALETTE, /icon=\{Cancel01Icon\}/);
+ assert.match(PALETTE, /aria-label=\{t\("common\.close"\)\}/);
+});
+
+test("Enter on the close button closes instead of running the selected row", () => {
+ // The button sits inside cmdk, whose root handles Enter by selecting the highlighted row.
+ const button = /<button\s+type="button"\s+onClick=\{close\}([\s\S]*?)aria-label=/.exec(PALETTE);
+ assert.ok(button);
+ assert.match(button[1], /onKeyDown=\{\(e\) => \{\s*if \(e\.key === "Enter"\) e\.stopPropagation\(\);\s*\}\}/);
+});
+
+test("palette rows are chat search's pill rows", () => {
+ assert.match(PALETTE, /const ROW_CLASS =\s*"gap-3 rounded-full px-3 py-2\.5 text-ui-13 font-medium data-selected:bg-muted/);
+ assert.match(SEARCH, /rounded-full px-3 py-2\.5 text-sm outline-hidden data-selected:bg-muted/);
+ // Every row goes through PaletteItem.
+ assert.doesNotMatch(PALETTE.split("function PaletteContent()")[1], /<CommandItem\b/);
+});
+
+test("the list keeps chat search's fixed height and scrollbar", () => {
+ assert.match(
+ PALETTE,
+ /<CommandList className="cmd-native-scrollbar hover-scrollbar h-\[calc\(420px\*var\(--ui-space-scale,1\)\)\] max-h-\[60dvh\] p-1">/,
+ );
+});