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: open the Images and Audio workflows from the collapsed sidebar rail (#13731)

Daniel Han26d6059779f7
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 38081973035..9757f38c53d 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -640,6 +640,7 @@ function NavItem({
onIntent,
badge,
overlay,
+ flyout,
testId,
}: {
icon: typeof ZapIcon;
@@ -663,40 +664,45 @@ function NavItem({
badge?: string;
// Absolutely-positioned extras over the row, e.g. a disclosure chevron.
overlay?: ReactNode;
+ // Wraps the row in a hover flyout that names it, so the label tooltip is dropped.
+ flyout?: (row: ReactNode) => ReactNode;
}) {
- return (
- <SidebarMenuItem className={className}>
- <div className="relative">
- <SidebarMenuButton
- tooltip={tooltip ?? label}
- alwaysTooltip={alwaysTooltip && Boolean(tooltip)}
- disabled={disabled}
- onClick={onClick}
- onPointerEnter={disabled ? undefined : onIntent}
- onFocus={disabled ? undefined : onIntent}
- isActive={active}
- data-tour={dataTour}
- data-testid={testId}
- data-spinner={spinner ? "true" : undefined}
- className="sidebar-nav-btn h-[calc(33px*var(--ui-space-scale,1))] rounded-full gap-[calc(8.5px*var(--ui-space-scale,1))] pl-3 pr-2.5 font-medium group-data-[collapsible=icon]:!p-0 group-data-[collapsible=icon]:!size-[calc(28px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:my-[calc(2.5px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:mx-auto"
- >
- <HugeiconsIcon icon={icon} strokeWidth={1.75} className="size-icon! shrink-0 translate-x-0.5 group-data-[collapsible=icon]:translate-x-0 group-hover/menu-button:animate-icon-pop" />
- <span className="text-ui-14p5 leading-ui-19 tracking-nav">{label}</span>
- {badge && (
- <Badge variant="secondary" className="group-data-[collapsible=icon]:hidden">
- {badge}
- </Badge>
- )}
- {spinner && (
- // mr-1.5 plus the row's pr-2.5 makes 16px, matching the chat row spinner column.
- <Spinner className="ml-auto mr-1.5 size-3.5 shrink-0 text-muted-foreground group-data-[collapsible=icon]:hidden" />
- )}
- </SidebarMenuButton>
+ const row = (
+ <div className="relative">
+ <SidebarMenuButton
+ tooltip={flyout ? undefined : (tooltip ?? label)}
+ alwaysTooltip={alwaysTooltip && Boolean(tooltip)}
+ disabled={disabled}
+ onClick={onClick}
+ onPointerEnter={disabled ? undefined : onIntent}
+ onFocus={disabled ? undefined : onIntent}
+ isActive={active}
+ data-tour={dataTour}
+ data-testid={testId}
+ data-spinner={spinner ? "true" : undefined}
+ className="sidebar-nav-btn h-[calc(33px*var(--ui-space-scale,1))] rounded-full gap-[calc(8.5px*var(--ui-space-scale,1))] pl-3 pr-2.5 font-medium group-data-[collapsible=icon]:!p-0 group-data-[collapsible=icon]:!size-[calc(28px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:my-[calc(2.5px*var(--ui-space-scale,1))] group-data-[collapsible=icon]:mx-auto"
+ >
+ <HugeiconsIcon icon={icon} strokeWidth={1.75} className="size-icon! shrink-0 translate-x-0.5 group-data-[collapsible=icon]:translate-x-0 group-hover/menu-button:animate-icon-pop" />
+ <span className="text-ui-14p5 leading-ui-19 tracking-nav">{label}</span>
+ {badge && (
+ <Badge variant="secondary" className="group-data-[collapsible=icon]:hidden">
+ {badge}
+ </Badge>
+ )}
{spinner && (
- <Spinner className="pointer-events-none absolute right-1 top-1 hidden size-2.5 text-muted-foreground group-data-[collapsible=icon]:block" />
+ // mr-1.5 plus the row's pr-2.5 makes 16px, matching the chat row spinner column.
+ <Spinner className="ml-auto mr-1.5 size-3.5 shrink-0 text-muted-foreground group-data-[collapsible=icon]:hidden" />
)}
- {overlay}
- </div>
+ </SidebarMenuButton>
+ {spinner && (
+ <Spinner className="pointer-events-none absolute right-1 top-1 hidden size-2.5 text-muted-foreground group-data-[collapsible=icon]:block" />
+ )}
+ {overlay}
+ </div>
+ );
+ return (
+ <SidebarMenuItem className={className}>
+ {flyout ? flyout(row) : row}
{children}
</SidebarMenuItem>
);
@@ -1075,6 +1081,155 @@ function AudioMoreSubmenu(props: MediaMoreSubmenuProps<AudioWorkflowId>) {
);
}
+/** The collapsed rail hides the Images / Audio workflow rows, so the icon opens them as a flyout. */
+function MediaRailFlyout<Id extends string>({
+ label,
+ tabs,
+ current,
+ enabled,
+ onPick,
+ children,
+}: {
+ label: string;
+ tabs: ReadonlyArray<{ id: Id; icon: IconSvgElement; label: string }>;
+ current: Id | null;
+ enabled: (id: Id) => boolean;
+ onPick: (id: Id) => void;
+ children: ReactNode;
+}) {
+ const rowRef = useRef<HTMLDivElement | null>(null);
+ const contentRef = useRef<HTMLDivElement | null>(null);
+ const hover = useHoverFlyout(NAV_FLYOUT_INTENT, contentRef);
+ const { dismiss } = hover;
+ const [keyboardOpen, setKeyboardOpen] = useState(false);
+ const open = hover.open || keyboardOpen;
+ // Read on close, after the state above has already been cleared.
+ const returnFocus = useRef(false);
+ const setOpen = useCallback(
+ (next: boolean) => {
+ dismiss();
+ if (!next) setKeyboardOpen(false);
+ },
+ [dismiss],
+ );
+ const insideRow = (target: EventTarget | null) =>
+ target instanceof Node && Boolean(rowRef.current?.contains(target));
+ // Radix forwards onOpenAutoFocus at runtime but omits it from DropdownMenuContent's types.
+ const focusProps = {
+ onOpenAutoFocus: (event: Event) => {
+ // A hover preview must not pull focus off whatever the user is typing in.
+ if (!keyboardOpen) event.preventDefault();
+ },
+ } as Record<string, unknown>;
+ return (
+ <DropdownMenu open={open} onOpenChange={setOpen} modal={false}>
+ <div
+ ref={rowRef}
+ className="relative"
+ {...hover.trigger}
+ onKeyDown={(event) => {
+ if (event.key !== "ArrowRight") return;
+ event.preventDefault();
+ returnFocus.current = true;
+ setKeyboardOpen(true);
+ // An open hover preview never mounts again, so its open autofocus will not run.
+ if (hover.open) {
+ contentRef.current
+ ?.querySelector<HTMLElement>('[role="menuitem"]:not([data-disabled])')
+ ?.focus({ preventScroll: true });
+ }
+ }}
+ >
+ {children}
+ {/* Positions the menu over the icon; the icon's button keeps every press. */}
+ <DropdownMenuTrigger asChild>
+ <span
+ aria-hidden
+ tabIndex={-1}
+ className="pointer-events-none absolute inset-0"
+ />
+ </DropdownMenuTrigger>
+ </div>
+ <DropdownMenuContent
+ ref={contentRef}
+ side="right"
+ align="start"
+ sideOffset={6}
+ className="sidebar-more-menu w-44 p-1"
+ {...hover.content}
+ {...focusProps}
+ // A press elsewhere keeps its own focus; one on the icon keeps the menu open.
+ onPointerDownOutside={(event) => {
+ if (insideRow(event.target)) event.preventDefault();
+ else returnFocus.current = false;
+ }}
+ onFocusOutside={(event) => {
+ if (insideRow(event.target)) event.preventDefault();
+ else returnFocus.current = false;
+ }}
+ onCloseAutoFocus={(event) => {
+ event.preventDefault();
+ if (!returnFocus.current) return;
+ returnFocus.current = false;
+ rowRef.current
+ ?.querySelector<HTMLElement>('[data-sidebar="menu-button"]')
+ ?.focus({ preventScroll: true });
+ }}
+ >
+ <DropdownMenuLabel className="px-2 py-1.5">{label}</DropdownMenuLabel>
+ {tabs.map((tab) => (
+ <DropdownMenuItem
+ key={tab.id}
+ disabled={!enabled(tab.id)}
+ title={enabled(tab.id) ? undefined : WORKFLOW_UNAVAILABLE}
+ onSelect={() => onPick(tab.id)}
+ className={cn(current === tab.id && "bg-accent/60")}
+ >
+ <HugeiconsIcon icon={tab.icon} strokeWidth={1.75} />
+ <span className="min-w-0 flex-1 truncate">{tab.label}</span>
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+type RailFlyoutProps<Id extends string> = {
+ label: string;
+ active: boolean;
+ onPick: (id: Id) => void;
+ children: ReactNode;
+};
+
+function ImagesRailFlyout(props: RailFlyoutProps<WorkflowId>) {
+ const workflow = useImageWorkflowStore((s) => s.workflow);
+ const supported = useImageWorkflowStore((s) => s.supported);
+ const pageMode = useImageWorkflowStore((s) => s.pageMode);
+ const current = props.active && pageMode === "create" ? workflow : null;
+ return (
+ <MediaRailFlyout
+ {...props}
+ tabs={WORKFLOW_TABS}
+ current={current}
+ enabled={(id) => isWorkflowEnabled(id, supported)}
+ />
+ );
+}
+
+function AudioRailFlyout(props: RailFlyoutProps<AudioWorkflowId>) {
+ const workflow = useAudioWorkspaceStore((s) => s.workflow);
+ const requested = useAudioWorkspaceStore((s) => s.requestedWorkflow);
+ const current = props.active ? (requested ?? workflow) : null;
+ return (
+ <MediaRailFlyout
+ {...props}
+ tabs={AUDIO_WORKFLOWS}
+ current={current}
+ enabled={audioWorkflowAlwaysEnabled}
+ />
+ );
+}
+
export function AppSidebar() {
const t = useT();
const { isDark, toggleTheme, anchorRef } = useAnimatedThemeToggle();
@@ -5942,6 +6097,33 @@ export function AppSidebar() {
id === "images" && "group/images-item",
id === "audio" && "group/audio-item",
)}
+ flyout={
+ sidebarRowsLabelled ||
+ rowState.disabled ||
+ rowState.pending
+ ? undefined
+ : id === "images"
+ ? (navRow) => (
+ <ImagesRailFlyout
+ label={row.label}
+ active={row.active}
+ onPick={pickImagesWorkflow}
+ >
+ {navRow}
+ </ImagesRailFlyout>
+ )
+ : id === "audio"
+ ? (navRow) => (
+ <AudioRailFlyout
+ label={row.label}
+ active={row.active}
+ onPick={pickAudioWorkflow}
+ >
+ {navRow}
+ </AudioRailFlyout>
+ )
+ : undefined
+ }
// Off the Images page the list is folded, so the row offers a way to open it.
overlay={
id === "images" &&
diff --git a/studio/frontend/tests/media-rail-workflows.test.ts b/studio/frontend/tests/media-rail-workflows.test.ts
new file mode 100644
index 00000000000..d4da8e0e28c
--- /dev/null
+++ b/studio/frontend/tests/media-rail-workflows.test.ts
@@ -0,0 +1,70 @@
+// 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";
+
+const SIDEBAR = readSrc("components/app-sidebar.tsx");
+
+function block(source: string, start: string, end: string): string {
+ const from = source.indexOf(start);
+ assert.notEqual(from, -1, `missing ${start}`);
+ const to = source.indexOf(end, from + start.length);
+ assert.notEqual(to, -1, `missing ${end} after ${start}`);
+ return source.slice(from, to);
+}
+
+test("the collapsed rail opens the Images and Audio workflows from their icons", () => {
+ const inline = block(SIDEBAR, "{inlineNavIds.map((id) => {", "{/* Unpinned destinations");
+ const flyout = block(inline, "flyout={", "\n >");
+ // Only the collapsed rail, where the workflow rows under the icon are not listed.
+ assert.match(flyout, /sidebarRowsLabelled \|\|/);
+ assert.match(flyout, /rowState\.disabled \|\|/);
+ assert.match(
+ flyout,
+ /<ImagesRailFlyout\s+label=\{row\.label\}\s+active=\{row\.active\}\s+onPick=\{pickImagesWorkflow\}/,
+ );
+ assert.match(
+ flyout,
+ /<AudioRailFlyout\s+label=\{row\.label\}\s+active=\{row\.active\}\s+onPick=\{pickAudioWorkflow\}/,
+ );
+ // The collapsed list still renders nothing, so the flyout is the only switcher there.
+ assert.match(
+ SIDEBAR,
+ /listed=\{!collapsed && \(active \? pageMode !== "train" : expanded\)\}/,
+ );
+});
+
+test("the rail flyout lists every workflow and greys out what the model cannot do", () => {
+ const images = block(SIDEBAR, "function ImagesRailFlyout(", "function AudioRailFlyout(");
+ assert.match(images, /tabs=\{WORKFLOW_TABS\}/);
+ assert.match(images, /enabled=\{\(id\) => isWorkflowEnabled\(id, supported\)\}/);
+ assert.match(
+ images,
+ /const current = props\.active && pageMode === "create" \? workflow : null;/,
+ );
+
+ const menu = block(SIDEBAR, "function MediaRailFlyout<", "type RailFlyoutProps<");
+ assert.match(menu, /useHoverFlyout\(NAV_FLYOUT_INTENT, contentRef\)/);
+ assert.match(menu, /event\.key !== "ArrowRight"/);
+ assert.match(menu, /\{tabs\.map\(\(tab\) => \(/);
+ assert.match(menu, /disabled=\{!enabled\(tab\.id\)\}/);
+ assert.match(menu, /onSelect=\{\(\) => onPick\(tab\.id\)\}/);
+ // A press on the icon itself stays a page open, not a menu toggle.
+ assert.match(menu, /className="pointer-events-none absolute inset-0"/);
+ assert.match(menu, /if \(insideRow\(event\.target\)\) event\.preventDefault\(\);/);
+ // Escape hands focus back to the icon only after a keyboard open, never after a press elsewhere.
+ assert.match(menu, /returnFocus\.current = true;\s+setKeyboardOpen\(true\);/);
+ assert.match(menu, /else returnFocus\.current = false;/);
+ assert.match(menu, /if \(!returnFocus\.current\) return;/);
+ // ArrowRight on an already-open hover preview moves focus into it.
+ assert.match(menu, /if \(hover\.open\) \{\s+contentRef\.current\s+\?\.querySelector<HTMLElement>\('\[role="menuitem"\]:not\(\[data-disabled\]\)'\)/);
+});
+
+test("a row with a flyout drops its label tooltip, every other row keeps it", () => {
+ const nav = block(SIDEBAR, "function NavItem({", "const WORKFLOW_UNAVAILABLE");
+ assert.match(nav, /tooltip=\{flyout \? undefined : \(tooltip \?\? label\)\}/);
+ assert.match(nav, /\{flyout \? flyout\(row\) : row\}/);
+});
diff --git a/studio/frontend/tests/more-menu-separator-gap.test.ts b/studio/frontend/tests/more-menu-separator-gap.test.ts
index f931812d694..368c524ec10 100644
--- a/studio/frontend/tests/more-menu-separator-gap.test.ts
+++ b/studio/frontend/tests/more-menu-separator-gap.test.ts
@@ -32,6 +32,8 @@ test("the More flyout's rule sits as far from its rows as the menu's own edge",
const className = /\sclassName="([^"]*)"/.exec(tag);
if (
className &&
+ // The rail's media flyouts share these placement props; only More holds this ref.
+ /\sref=\{moreContentRef\}/.test(tag) &&
/\sside="right"/.test(tag) &&
/\salign="start"/.test(tag) &&
/\ssideOffset=\{6\}/.test(tag)