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: Library grid Sort menu, tidier toolbar menus and card icons (#11978)

Michael Han5f6b249ed9a5
diff --git a/studio/frontend/src/features/library/components/library-actions.tsx b/studio/frontend/src/features/library/components/library-actions.tsx
index 1bad807936a..4252cc5302f 100644
--- a/studio/frontend/src/features/library/components/library-actions.tsx
+++ b/studio/frontend/src/features/library/components/library-actions.tsx
@@ -109,7 +109,7 @@ export function LibraryActionsMenu({
</DropdownMenuTrigger>
<DropdownMenuContent
align="end"
- className="w-60"
+ className="library-actions-menu w-52"
onClick={(event) => event.stopPropagation()}
>
<DropdownMenuItem onSelect={() => actions.chatAbout(target)}>
@@ -147,7 +147,7 @@ export function LibraryActionsMenu({
<HugeiconsIcon icon={FolderExportIcon} strokeWidth={1.75} className={ICON} />
{t("library.menu.addToFolder")}
</DropdownMenuSubTrigger>
- <DropdownMenuSubContent className="max-h-[min(--spacing(80),var(--radix-dropdown-menu-content-available-height))] w-56">
+ <DropdownMenuSubContent className="library-actions-menu max-h-[min(--spacing(80),var(--radix-dropdown-menu-content-available-height))] w-48">
<DropdownMenuItem onSelect={() => actions.moveToNewFolder(target)}>
<HugeiconsIcon icon={FolderAddIcon} strokeWidth={1.75} className={ICON} />
{t("library.menu.newFolder")}
diff --git a/studio/frontend/src/features/library/components/library-cards.tsx b/studio/frontend/src/features/library/components/library-cards.tsx
index 2e244b56021..50fbdec5015 100644
--- a/studio/frontend/src/features/library/components/library-cards.tsx
+++ b/studio/frontend/src/features/library/components/library-cards.tsx
@@ -42,6 +42,15 @@ export function KindIcon({ item, className }: { item: LibraryItem; className?: s
);
}
+// Audio and code glyphs are thin line art, so they get a larger size.
+const CARD_ICON_CLASS = "size-7";
+const LARGE_CARD_ICON_CLASS = "size-8.5";
+
+function cardIconClass(item: LibraryItem): string {
+ const kind = fileKind(item);
+ return kind === "audio" || kind === "code" ? LARGE_CARD_ICON_CLASS : CARD_ICON_CLASS;
+}
+
const MIN_THUMB_RATIO = 2 / 3;
const MAX_THUMB_RATIO = 3 / 2;
@@ -62,7 +71,7 @@ function ImageThumb({
if (failed || (url !== null && url === brokenUrl)) {
return (
<div className={cn("flex aspect-square items-center justify-center", className)}>
- <KindIcon item={item} className="h-auto w-1/4 max-w-9" />
+ <KindIcon item={item} className="h-auto w-1/5 max-w-7" />
</div>
);
}
@@ -198,7 +207,7 @@ export function ItemCard({ item }: { item: LibraryItem }) {
{item.name}
</p>
<div className="flex flex-1 items-center justify-center">
- <KindIcon item={item} className="size-9" />
+ <KindIcon item={item} className={cardIconClass(item)} />
</div>
<p className="truncate pr-6 text-ui-13 text-muted-foreground">
{showTime && formatCardTime(item.updatedAt, locale)}
@@ -228,7 +237,7 @@ function FolderCard({
className={CARD_SURFACE}
>
<div className="flex aspect-square items-center justify-center">
- <HugeiconsIcon icon={Folder01Icon} strokeWidth={1.5} className="size-9" />
+ <HugeiconsIcon icon={Folder01Icon} strokeWidth={1.5} className={CARD_ICON_CLASS} />
</div>
</CardFrame>
<button
diff --git a/studio/frontend/src/features/library/components/library-toolbar.tsx b/studio/frontend/src/features/library/components/library-toolbar.tsx
index 9933d4fcb17..820d0d1f1c8 100644
--- a/studio/frontend/src/features/library/components/library-toolbar.tsx
+++ b/studio/frontend/src/features/library/components/library-toolbar.tsx
@@ -31,11 +31,11 @@ import { type TranslationKey, useT } from "@/i18n";
import { SheetIcon, TestTubeOutlineIcon } from "@/lib/hugeicons-derived";
import { cn } from "@/lib/utils";
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
-import { ChevronDownIcon } from "lucide-react";
+import { ArrowDownUpIcon, ChevronDownIcon } from "lucide-react";
import type { LibrarySource } from "../api";
import type { LibraryTypeFilter } from "../file-kind";
import { EMPTY_FILTERS, type LibraryFilters, filtersActive } from "../filters";
-import type { LibraryView } from "../settings-store";
+import type { LibrarySortKey, LibraryView } from "../settings-store";
const ICON = "size-icon";
const ROUND_BUTTON =
@@ -67,6 +67,24 @@ const VIEW_OPTIONS = [
{ value: "list", label: "library.toolbar.listView", icon: LeftToRightListBulletIcon },
] satisfies MenuOption<LibraryView>[];
+export type LibrarySortChoice = "default" | LibrarySortKey;
+
+export interface LibrarySortMenuProps {
+ value: LibrarySortChoice;
+ onChange: (next: LibrarySortChoice) => void;
+ /** The view orders by last activity rather than modified time. */
+ activity?: boolean;
+ /** False where only folders show, which have no size. */
+ showSize?: boolean;
+}
+
+const SORT_OPTIONS: { value: LibrarySortChoice; label: TranslationKey }[] = [
+ { value: "default", label: "library.toolbar.sortDefault" },
+ { value: "name", label: "library.toolbar.sortName" },
+ { value: "modified", label: "library.toolbar.sortModified" },
+ { value: "size", label: "library.toolbar.sortSize" },
+];
+
function toggled<T>(set: Set<T>, value: T): Set<T> {
const next = new Set(set);
if (next.has(value)) next.delete(value);
@@ -98,7 +116,12 @@ function FilterMenu({
>
<HugeiconsIcon icon={icon} strokeWidth={1.75} className={ICON} />
<span className="flex-1">{t(label)}</span>
- {checked && <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} className="size-4" />}
+ {/* Always rendered so the menu width does not change when ticked. */}
+ <HugeiconsIcon
+ icon={Tick02Icon}
+ strokeWidth={2}
+ className={cn("ml-2 size-4", !checked && "invisible")}
+ />
</DropdownMenuItem>
);
@@ -114,18 +137,9 @@ function FilterMenu({
<HugeiconsIcon icon={FilterMailIcon} strokeWidth={1.75} className="size-5" />
</button>
</DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-48">
- <DropdownMenuLabel className="px-3 pb-1 pt-2 text-muted-foreground font-normal">
- {t("library.toolbar.source")}
- </DropdownMenuLabel>
- {SOURCE_OPTIONS.map((entry) =>
- option(entry, filters.sources.has(entry.value), () =>
- onChange({ ...filters, sources: toggled(filters.sources, entry.value) }),
- ),
- )}
+ <DropdownMenuContent align="end" sideOffset={4} className="w-max min-w-36">
{showTypes && (
<>
- <DropdownMenuSeparator className="mx-3" />
<DropdownMenuLabel className="px-3 pb-1 pt-2 text-muted-foreground font-normal">
{t("library.toolbar.fileType")}
</DropdownMenuLabel>
@@ -134,8 +148,17 @@ function FilterMenu({
onChange({ ...filters, types: toggled(filters.types, entry.value) }),
),
)}
+ <DropdownMenuSeparator className="mx-3" />
</>
)}
+ <DropdownMenuLabel className="px-3 pb-1 pt-2 text-muted-foreground font-normal">
+ {t("library.toolbar.source")}
+ </DropdownMenuLabel>
+ {SOURCE_OPTIONS.map((entry) =>
+ option(entry, filters.sources.has(entry.value), () =>
+ onChange({ ...filters, sources: toggled(filters.sources, entry.value) }),
+ ),
+ )}
{filtersActive(filters) && (
<>
<DropdownMenuSeparator className="mx-3" />
@@ -151,6 +174,60 @@ function FilterMenu({
);
}
+function SortMenu({
+ value,
+ onChange,
+ activity = false,
+ showSize = true,
+}: LibrarySortMenuProps) {
+ const t = useT();
+ // Suggested orders "Modified" by last activity, as its list view header says.
+ const options = SORT_OPTIONS.filter((option) => showSize || option.value !== "size").map(
+ (option) =>
+ activity && option.value === "modified"
+ ? { ...option, label: "library.list.lastActivity" as TranslationKey }
+ : option,
+ );
+ const current = options.find((option) => option.value === value);
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ className="flex h-9 shrink-0 items-center gap-1.5 rounded-full px-3 text-ui-14 text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-open:bg-muted data-open:text-foreground dark:text-foreground/70"
+ >
+ <ArrowDownUpIcon strokeWidth={1.75} className="size-[calc(16px*var(--ui-space-scale,1))]" />
+ {value === "default" || !current ? t("library.toolbar.sort") : t(current.label)}
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" sideOffset={4} className="w-max min-w-36">
+ {options.map(({ value: option, label }) => {
+ const checked = option === value;
+ return (
+ <DropdownMenuItem
+ key={option}
+ role="menuitemradio"
+ aria-checked={checked}
+ onSelect={() => onChange(option)}
+ >
+ <span className="flex-1">{t(label)}</span>
+ <span
+ aria-hidden="true"
+ className={cn(
+ "ml-2 flex size-4 shrink-0 items-center justify-center rounded-full border-[1.5px]",
+ checked ? "border-foreground bg-foreground" : "border-muted-foreground/60",
+ )}
+ >
+ {checked && <span className="size-1.5 rounded-full bg-background" />}
+ </span>
+ </DropdownMenuItem>
+ );
+ })}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
export type NewAction =
| "note"
| "image"
@@ -205,6 +282,7 @@ export function LibraryToolbar({
filterMode,
view,
onViewChange,
+ sort,
search,
onSearchChange,
searchPlaceholder,
@@ -216,6 +294,8 @@ export function LibraryToolbar({
filterMode: "none" | "source" | "all";
view: LibraryView;
onViewChange: (view: LibraryView) => void;
+ /** Grid view only: list view sorts by column headers. */
+ sort?: LibrarySortMenuProps;
search: string;
onSearchChange: (value: string) => void;
searchPlaceholder: string;
@@ -226,15 +306,13 @@ export function LibraryToolbar({
return (
<div className="flex min-w-0 items-center gap-2">
{filterMode !== "none" && (
- <>
- <FilterMenu
- filters={filters}
- onChange={onFiltersChange}
- showTypes={filterMode === "all"}
- />
- <span className="mx-1.5 h-6 w-px shrink-0 bg-border" aria-hidden="true" />
- </>
+ <FilterMenu
+ filters={filters}
+ onChange={onFiltersChange}
+ showTypes={filterMode === "all"}
+ />
)}
+ {sort && <SortMenu {...sort} />}
{VIEW_OPTIONS.map(({ value, label, icon }) => (
<button
key={value}
diff --git a/studio/frontend/src/features/library/library-page.tsx b/studio/frontend/src/features/library/library-page.tsx
index 1c215b638b5..aca324da2a0 100644
--- a/studio/frontend/src/features/library/library-page.tsx
+++ b/studio/frontend/src/features/library/library-page.tsx
@@ -65,7 +65,11 @@ import { ConfirmDeleteDialog, NameDialog } from "./components/library-dialogs";
import { LibraryList } from "./components/library-list";
import { LibraryPreview } from "./components/library-preview";
import { LibraryHeader } from "./components/library-header";
-import { LibraryToolbar, type NewAction } from "./components/library-toolbar";
+import {
+ type LibrarySortChoice,
+ LibraryToolbar,
+ type NewAction,
+} from "./components/library-toolbar";
import { EMPTY_FILTERS, type LibraryFilters, filtersActive, matchesFilters } from "./filters";
import { LIBRARY_TABS, type LibrarySearch, type LibraryTab } from "./search";
import { useLibraryStore } from "./store";
@@ -212,7 +216,7 @@ function LibraryView({ search }: { search: LibrarySearch }) {
const openSettings = useSettingsDialogStore((s) => s.openDialog);
const [query, setQuery] = useState("");
- const [filters, setFilters] = useState<LibraryFilters>(() =>
+ const [chosenFilters, setFilters] = useState<LibraryFilters>(() =>
search.filter === "files" ? { sources: new Set(), types: new Set(FILE_TYPES) } : EMPTY_FILTERS,
);
const [selection, setSelection] = useState<Set<string>>(new Set());
@@ -245,6 +249,27 @@ function LibraryView({ search }: { search: LibrarySearch }) {
[navigate],
);
+ // "Default order" falls back to the sort in Library settings.
+ const gridSortValue = (search.sort ? SORT_STATES[search.sort].key : "default") as LibrarySortChoice;
+ const gridSort = {
+ value: gridSortValue,
+ activity: tab === "suggested" && !folderId,
+ showSize: Boolean(folderId) || tab !== "folders",
+ // Reselecting the checked key keeps its direction, which list view may have flipped.
+ onChange: (choice: LibrarySortChoice) =>
+ choice !== gridSortValue &&
+ go(
+ {
+ ...search,
+ sort:
+ choice === "default"
+ ? undefined
+ : sortParam({ key: choice, desc: choice !== "name" }),
+ },
+ true,
+ ),
+ };
+
const [parentOfOpen, setParentOfOpen] = useState<string | null>(null);
if (currentFolder && currentFolder.parentId !== parentOfOpen) {
setParentOfOpen(currentFolder.parentId);
@@ -268,6 +293,9 @@ function LibraryView({ search }: { search: LibrarySearch }) {
const needle = query.trim().toLowerCase();
const kindFilter = folderId ? undefined : KIND_TABS[tab];
+ // Folders have no filter menu, so tab filters do not apply inside them.
+ const filterMode = folderId || tab === "folders" ? "none" : kindFilter ? "source" : "all";
+ const filters = filterMode === "none" ? EMPTY_FILTERS : chosenFilters;
const shownTabs = LIBRARY_TABS.filter((entry) => entry === tab || tabVisible(entry));
@@ -849,9 +877,10 @@ function LibraryView({ search }: { search: LibrarySearch }) {
<LibraryToolbar
filters={filters}
onFiltersChange={setFilters}
- filterMode={!folderId && tab === "folders" ? "none" : kindFilter ? "source" : "all"}
+ filterMode={filterMode}
view={view}
onViewChange={setView}
+ sort={view === "grid" && (folderId || tab !== "favorites") ? gridSort : undefined}
search={query}
onSearchChange={setQuery}
searchPlaceholder={t(folderId ? "library.searchFolder" : "library.searchLibrary")}
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 6159a5b209d..285db413014 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -3014,6 +3014,11 @@ export const en = {
gridView: "Grid view",
listView: "List view",
settings: "Library settings",
+ sort: "Sort",
+ sortDefault: "Default order",
+ sortName: "Name",
+ sortModified: "Modified",
+ sortSize: "Size",
},
// Entries of the New menu.
create: {
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index 06b5464a1ac..e34de4b368a 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -2055,6 +2055,13 @@ html[data-chat-font] .aui-root {
box-shadow: 0 8px 28px -6px var(--background) !important;
}
+ /* Library card menus: match the card menu button so they stand off the cards. */
+ .dark [data-slot="dropdown-menu-content"].library-actions-menu,
+ .dark [data-slot="dropdown-menu-sub-content"].library-actions-menu {
+ --accent: var(--color-neutral-600);
+ background-color: var(--color-neutral-700);
+ }
+
/* Model selector: tighter than the menus above so it lifts off the
composer it overlaps (chatbox geometry). Account menu stays flat. */
.dark .unsloth-model-selector-menu {