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 Images workflows from More when Images is unpinned (#13101)

Nilay8016226e3dc9
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index cb89903738e..1a092b53166 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -939,7 +939,21 @@ function MoreMenuItem({
);
}
-function AudioMoreSubmenu({
+type MediaMoreSubmenuProps<Id extends string> = {
+ icon: typeof ZapIcon;
+ label: string;
+ active: boolean;
+ disabled?: boolean;
+ tooltip?: string;
+ badge?: string;
+ spinner?: boolean;
+ onIntent?: () => void;
+ onOpen: () => void;
+ onPick: (id: Id) => void;
+ contentProps: ComponentProps<typeof DropdownMenuSubContent>;
+};
+
+function MediaMoreSubmenu<Id extends string>({
icon,
label,
active,
@@ -951,22 +965,14 @@ function AudioMoreSubmenu({
onOpen,
onPick,
contentProps,
-}: {
- icon: typeof ZapIcon;
- label: string;
- active: boolean;
- disabled?: boolean;
- tooltip?: string;
- badge?: string;
- spinner?: boolean;
- onIntent?: () => void;
- onOpen: () => void;
- onPick: (id: AudioWorkflowId) => void;
- contentProps: ComponentProps<typeof DropdownMenuSubContent>;
+ tabs,
+ current,
+ enabled,
+}: MediaMoreSubmenuProps<Id> & {
+ tabs: ReadonlyArray<{ id: Id; icon: IconSvgElement; label: string }>;
+ current: Id | null;
+ enabled: (id: Id) => boolean;
}) {
- const workflow = useAudioWorkspaceStore((s) => s.workflow);
- const requested = useAudioWorkspaceStore((s) => s.requestedWorkflow);
- const current = active ? (requested ?? workflow) : null;
return (
<DropdownMenuSub>
<DropdownMenuSubTrigger
@@ -974,7 +980,7 @@ function AudioMoreSubmenu({
title={tooltip}
onPointerEnter={disabled ? undefined : onIntent}
onFocus={disabled ? undefined : onIntent}
- // click opens Audio; hover and keyboard still open the workflows.
+ // click opens the page; hover or keyboard opens its workflows.
onClick={(event) => {
if (disabled) return;
event.preventDefault();
@@ -990,9 +996,11 @@ function AudioMoreSubmenu({
)}
</DropdownMenuSubTrigger>
<DropdownMenuSubContent {...contentProps} className="sidebar-more-menu w-44 p-1">
- {AUDIO_WORKFLOWS.map((tab) => (
+ {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")}
>
@@ -1005,6 +1013,35 @@ function AudioMoreSubmenu({
);
}
+function ImagesMoreSubmenu(props: MediaMoreSubmenuProps<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 (
+ <MediaMoreSubmenu
+ {...props}
+ tabs={WORKFLOW_TABS}
+ current={current}
+ enabled={(id) => isWorkflowEnabled(id, supported)}
+ />
+ );
+}
+
+function AudioMoreSubmenu(props: MediaMoreSubmenuProps<AudioWorkflowId>) {
+ const workflow = useAudioWorkspaceStore((s) => s.workflow);
+ const requested = useAudioWorkspaceStore((s) => s.requestedWorkflow);
+ const current = props.active ? (requested ?? workflow) : null;
+ return (
+ <MediaMoreSubmenu
+ {...props}
+ tabs={AUDIO_WORKFLOWS}
+ current={current}
+ enabled={audioWorkflowAlwaysEnabled}
+ />
+ );
+}
+
export function AppSidebar() {
const t = useT();
const { isDark, toggleTheme, anchorRef } = useAnimatedThemeToggle();
@@ -2896,10 +2933,10 @@ export function AppSidebar() {
// The Projects row repeats the section, so it only earns its place while the section is absent.
const navRowPinned = (item: SidebarNavItemPref) =>
sidebarNavRowPinned(item, sidebarNavAuto, { projectsSectionShowing });
- // Audio steps out of More while its page is open: a pin for the visit, never saved.
+ // audio and images are temporarily pinned while active without saving the preference.
const { inline: inlineNavIds, overflow: overflowNavIds } = placeNavRows(
sidebarNav.map((item) => ({ id: item.id, pinned: navRowPinned(item) })),
- navRows.audio.active ? "audio" : null,
+ navRows.audio.active ? "audio" : navRows.images.active ? "images" : null,
);
// The mobile sheet shows labels regardless of the desktop pin state.
const sidebarRowsLabelled = isMobile || sidebarState !== "collapsed";
@@ -2908,6 +2945,11 @@ export function AppSidebar() {
sidebarRowsLabelled &&
!(navRows.images.active && imagesPageMode === "train");
const audioWorkflowsListed = sidebarRowsLabelled;
+ const pickImagesWorkflow = (workflowId: WorkflowId) => {
+ useImageWorkflowStore.getState().setWorkflow(workflowId);
+ navigate({ to: "/images" });
+ closeMobileIfOpen();
+ };
// Sidebar and More-flyout picks only ask; the Audio page switches once it is free to.
const pickAudioWorkflow = (workflowId: AudioWorkflowId) => {
useAudioWorkspaceStore.getState().requestWorkflow(workflowId);
@@ -5560,13 +5602,7 @@ export function AppSidebar() {
<ImagesWorkflowList
active={row.active}
collapsed={!sidebarRowsLabelled}
- onPick={(workflowId) => {
- useImageWorkflowStore
- .getState()
- .setWorkflow(workflowId);
- navigate({ to: "/images" });
- closeMobileIfOpen();
- }}
+ onPick={pickImagesWorkflow}
/>
) : id === "audio" ? (
<AudioWorkflowList
@@ -5664,28 +5700,37 @@ export function AppSidebar() {
const row = navRows[id];
// Same pending handling as the inline rows above.
const rowState = resolveNavRowState(row);
- if (id === "audio") {
- return (
+ if (id === "images" || id === "audio") {
+ const submenu = {
+ icon: row.icon,
+ label: row.label,
+ badge: row.badge,
+ active: row.active,
+ disabled: rowState.disabled,
+ tooltip: rowState.tooltip,
+ spinner: rowState.spinner,
+ onIntent: row.onIntent,
+ onOpen: () => {
+ setMoreOpen(false);
+ row.onClick();
+ },
+ contentProps: {
+ ...sidebarSubmenuOffsets,
+ // portaled outside the flyout, so its hover grace must include the submenu.
+ ...moreHover.content,
+ },
+ };
+ return id === "images" ? (
+ <ImagesMoreSubmenu
+ key={id}
+ {...submenu}
+ onPick={pickImagesWorkflow}
+ />
+ ) : (
<AudioMoreSubmenu
key={id}
- icon={row.icon}
- label={row.label}
- badge={row.badge}
- active={row.active}
- disabled={rowState.disabled}
- tooltip={rowState.tooltip}
- spinner={rowState.spinner}
- onIntent={row.onIntent}
- onOpen={() => {
- setMoreOpen(false);
- row.onClick();
- }}
+ {...submenu}
onPick={pickAudioWorkflow}
- contentProps={{
- ...sidebarSubmenuOffsets,
- // Portaled outside the flyout, so the flyout's hover grace has to cover it too.
- ...moreHover.content,
- }}
/>
);
}
diff --git a/studio/frontend/tests/audio-sidebar-workflows.test.ts b/studio/frontend/tests/audio-sidebar-workflows.test.ts
index 7c5d70e223a..0172f571c7b 100644
--- a/studio/frontend/tests/audio-sidebar-workflows.test.ts
+++ b/studio/frontend/tests/audio-sidebar-workflows.test.ts
@@ -101,22 +101,22 @@ test("a pinned Audio row lists its workflows and hands picks to the page as requ
test("More opens Audio's workflows in a submenu that keeps the flyout open on the way in", () => {
const more = block(SIDEBAR, "{overflowNavIds.map((id) => {", "<MoreMenuItem");
+ assert.match(more, /if \(id === "images" \|\| id === "audio"\) \{/);
assert.match(
more,
- /if \(id === "audio"\) \{\s*return \(\s*<AudioMoreSubmenu/,
+ /<AudioMoreSubmenu\s+key=\{id\}\s+\{\.\.\.submenu\}\s+onPick=\{pickAudioWorkflow\}/,
);
- assert.match(more, /disabled=\{rowState\.disabled\}/);
+ assert.match(more, /disabled: rowState\.disabled,/);
assert.match(more, /\.\.\.sidebarSubmenuOffsets,/);
assert.match(more, /\.\.\.moreHover\.content,/);
- assert.match(more, /onPick=\{pickAudioWorkflow\}/);
const resolves =
SIDEBAR.match(/const rowState = resolveNavRowState\(row\);/g) ?? [];
assert.equal(resolves.length, 2);
const submenu = block(
SIDEBAR,
- "function AudioMoreSubmenu(",
- "export function AppSidebar()",
+ "function MediaMoreSubmenu<",
+ "function ImagesMoreSubmenu(",
);
assert.match(submenu, /<DropdownMenuSubTrigger/);
assert.match(
@@ -124,17 +124,29 @@ test("More opens Audio's workflows in a submenu that keeps the flyout open on th
/className=\{cn\("gap-2\.5", active && "bg-accent\/60"\)\}/,
);
assert.match(submenu, /<DropdownMenuSubContent \{\.\.\.contentProps\}/);
- assert.match(submenu, /AUDIO_WORKFLOWS\.map/);
+ assert.match(submenu, /tabs\.map/);
assert.match(submenu, /onSelect=\{\(\) => onPick\(tab\.id\)\}/);
assert.match(submenu, /current === tab\.id && "bg-accent\/60"/);
assert.doesNotMatch(submenu, /max-h/);
+
+ const audio = block(
+ SIDEBAR,
+ "function AudioMoreSubmenu(",
+ "export function AppSidebar()",
+ );
+ assert.match(audio, /tabs=\{AUDIO_WORKFLOWS\}/);
+ assert.match(
+ audio,
+ /const current = props\.active \? \(requested \?\? workflow\) : null;/,
+ );
+ assert.match(audio, /enabled=\{audioWorkflowAlwaysEnabled\}/);
});
test("clicking Audio in More opens the page, and the open page keeps the row out of More", () => {
const submenu = block(
SIDEBAR,
- "function AudioMoreSubmenu(",
- "export function AppSidebar()",
+ "function MediaMoreSubmenu<",
+ "function ImagesMoreSubmenu(",
);
// preventing the click stops Radix from opening the submenu; keys keep the parent behavior.
assert.match(
@@ -146,7 +158,7 @@ test("clicking Audio in More opens the page, and the open page keeps the row out
const more = block(SIDEBAR, "{overflowNavIds.map((id) => {", "<MoreMenuItem");
assert.match(
more,
- /onOpen=\{\(\) => \{\s*setMoreOpen\(false\);\s*row\.onClick\(\);\s*\}\}/,
+ /onOpen: \(\) => \{\s*setMoreOpen\(false\);\s*row\.onClick\(\);\s*\},/,
);
// omitting a workflow request preserves the page's current workflow.
assert.match(
@@ -156,7 +168,7 @@ test("clicking Audio in More opens the page, and the open page keeps the row out
assert.match(
SIDEBAR,
- /const \{ inline: inlineNavIds, overflow: overflowNavIds \} = placeNavRows\(\s*sidebarNav\.map\(\(item\) => \(\{ id: item\.id, pinned: navRowPinned\(item\) \}\)\),\s*navRows\.audio\.active \? "audio" : null,\s*\);/,
+ /const \{ inline: inlineNavIds, overflow: overflowNavIds \} = placeNavRows\(\s*sidebarNav\.map\(\(item\) => \(\{ id: item\.id, pinned: navRowPinned\(item\) \}\)\),\s*navRows\.audio\.active \? "audio" : navRows\.images\.active \? "images" : null,\s*\);/,
);
});
@@ -189,7 +201,8 @@ test("a nav row's New pill sits beside its label, clear of the trailing disclosu
"{overflowNavIds.map((id) => {",
"<DropdownMenuSeparator",
);
- assert.equal(more.match(/badge=\{row\.badge\}/g)?.length, 2);
+ assert.match(more, /badge: row\.badge,/);
+ assert.match(more, /badge=\{row\.badge\}/);
});
test("Audio is still unpinned by default", () => {
diff --git a/studio/frontend/tests/images-more-workflows.test.ts b/studio/frontend/tests/images-more-workflows.test.ts
new file mode 100644
index 00000000000..b11b6b82174
--- /dev/null
+++ b/studio/frontend/tests/images-more-workflows.test.ts
@@ -0,0 +1,73 @@
+// 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("an unpinned Images row opens its workflows from More", () => {
+ const more = block(SIDEBAR, "{overflowNavIds.map((id) => {", "<MoreMenuItem");
+ assert.match(
+ more,
+ /<ImagesMoreSubmenu\s+key=\{id\}\s+\{\.\.\.submenu\}\s+onPick=\{pickImagesWorkflow\}/,
+ );
+
+ const images = block(
+ SIDEBAR,
+ "function ImagesMoreSubmenu(",
+ "function AudioMoreSubmenu(",
+ );
+ assert.match(images, /<MediaMoreSubmenu/);
+ 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 submenu = block(
+ SIDEBAR,
+ "function MediaMoreSubmenu<",
+ "function ImagesMoreSubmenu(",
+ );
+ assert.match(submenu, /disabled=\{!enabled\(tab\.id\)\}/);
+ assert.match(
+ submenu,
+ /title=\{enabled\(tab\.id\) \? undefined : WORKFLOW_UNAVAILABLE\}/,
+ );
+});
+
+test("an Images workflow picked from More or the sidebar selects it and opens Images", () => {
+ const pick = block(SIDEBAR, "const pickImagesWorkflow =", "};");
+ assert.match(
+ pick,
+ /useImageWorkflowStore\.getState\(\)\.setWorkflow\(workflowId\);/,
+ );
+ assert.match(pick, /navigate\(\{ to: "\/images" \}\);/);
+ assert.match(pick, /closeMobileIfOpen\(\);/);
+ assert.match(
+ SIDEBAR,
+ /<ImagesWorkflowList\s+active=\{row\.active\}\s+collapsed=\{!sidebarRowsLabelled\}\s+onPick=\{pickImagesWorkflow\}/,
+ );
+});
+
+test("the open Images page keeps its row, and so its workflows, on the sidebar", () => {
+ assert.match(
+ SIDEBAR,
+ /placeNavRows\([\s\S]*?navRows\.images\.active \? "images" : null,\s*\);/,
+ );
+});