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 Audio from More and keep it in the sidebar while it is open (#12807)

Etherl5472cfa14fe7
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index ddcd4b9060c..200befa1f0e 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -240,7 +240,7 @@ import type {
SidebarNavItemPref,
} from "@/features/settings";
import { useEffectiveProfile, UserAvatar } from "@/features/profile";
-import { resolveNavRowState } from "@/components/nav-row-state";
+import { placeNavRows, resolveNavRowState } from "@/components/nav-row-state";
import { createNavigationCoalescer } from "@/components/sidebar-navigation";
import { fetchDeviceType, usePlatformStore } from "@/config/env";
import { videoNavHint } from "@/config/hardware-verdict";
@@ -961,6 +961,7 @@ function AudioMoreSubmenu({
badge,
spinner,
onIntent,
+ onOpen,
onPick,
contentProps,
}: {
@@ -972,6 +973,7 @@ function AudioMoreSubmenu({
badge?: string;
spinner?: boolean;
onIntent?: () => void;
+ onOpen: () => void;
onPick: (id: AudioWorkflowId) => void;
contentProps: ComponentProps<typeof DropdownMenuSubContent>;
}) {
@@ -985,6 +987,12 @@ function AudioMoreSubmenu({
title={tooltip}
onPointerEnter={disabled ? undefined : onIntent}
onFocus={disabled ? undefined : onIntent}
+ // A click opens Audio itself; hover and the keyboard still open the workflows.
+ onClick={(event) => {
+ if (disabled) return;
+ event.preventDefault();
+ onOpen();
+ }}
className={cn("gap-2.5", active && "bg-accent/60")}
>
<HugeiconsIcon icon={icon} strokeWidth={1.75} />
@@ -2872,14 +2880,11 @@ 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 });
- const unpinnedNavIds = sidebarNav
- .filter((item) => !navRowPinned(item))
- .map((item) => item.id);
- // More needs two or more rows to be worth a click; with exactly one unpinned, the menu and that row are both dropped.
- const overflowNavIds = unpinnedNavIds.length > 1 ? unpinnedNavIds : [];
- const inlineNavIds = sidebarNav
- .filter((item) => navRowPinned(item))
- .map((item) => item.id);
+ // Audio steps out of More while its page is open: a pin for the visit, never saved.
+ const { inline: inlineNavIds, overflow: overflowNavIds } = placeNavRows(
+ sidebarNav.map((item) => ({ id: item.id, pinned: navRowPinned(item) })),
+ navRows.audio.active ? "audio" : null,
+ );
// The mobile sheet shows labels regardless of the desktop pin state.
const sidebarRowsLabelled = isMobile || sidebarState !== "collapsed";
// Mirrors ImagesWorkflowList's own test: it decides which row owns the highlight.
@@ -5604,6 +5609,10 @@ export function AppSidebar() {
tooltip={rowState.tooltip}
spinner={rowState.spinner}
onIntent={row.onIntent}
+ onOpen={() => {
+ setMoreOpen(false);
+ row.onClick();
+ }}
onPick={pickAudioWorkflow}
contentProps={{
...sidebarSubmenuOffsets,
diff --git a/studio/frontend/src/components/nav-row-state.ts b/studio/frontend/src/components/nav-row-state.ts
index a15ce53133f..06f45a84f63 100644
--- a/studio/frontend/src/components/nav-row-state.ts
+++ b/studio/frontend/src/components/nav-row-state.ts
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// How a sidebar nav row renders once its pending state is folded in. Its own import-free
-// module so it is testable: app-sidebar.tsx pulls in the whole shell.
+// Where a sidebar nav row goes and how it renders once its pending state is folded in. Its own
+// import-free module so it is testable: app-sidebar.tsx pulls in the whole shell.
export type NavRowState = {
disabled?: boolean;
@@ -46,3 +46,24 @@ export function resolveNavRowState(row: NavRowState): {
pending: false,
};
}
+
+/**
+ * Split the nav rows between the sidebar and its "More" flyout, keeping their order.
+ *
+ * More needs two or more rows to be worth a click: with exactly one unpinned, the menu and that
+ * row are both dropped. `shown` is a row the current page puts on the sidebar without pinning it,
+ * in its own slot. It leaves More, but the count is taken first, so surfacing it never hides
+ * another row.
+ */
+export function placeNavRows<Id extends string>(
+ rows: readonly { id: Id; pinned: boolean }[],
+ shown: Id | null,
+): { inline: Id[]; overflow: Id[] } {
+ const unpinned = rows.filter((row) => !row.pinned).map((row) => row.id);
+ return {
+ inline: rows
+ .filter((row) => row.pinned || row.id === shown)
+ .map((row) => row.id),
+ overflow: unpinned.length > 1 ? unpinned.filter((id) => id !== shown) : [],
+ };
+}
diff --git a/studio/frontend/tests/audio-sidebar-workflows.test.ts b/studio/frontend/tests/audio-sidebar-workflows.test.ts
index 9d7cbc2add0..905996175ba 100644
--- a/studio/frontend/tests/audio-sidebar-workflows.test.ts
+++ b/studio/frontend/tests/audio-sidebar-workflows.test.ts
@@ -130,6 +130,36 @@ test("More opens Audio's workflows in a submenu that keeps the flyout open on th
assert.doesNotMatch(submenu, /max-h/);
});
+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()",
+ );
+ // preventing the click stops Radix from opening the submenu; keys keep the parent behavior.
+ assert.match(
+ submenu,
+ /onClick=\{\(event\) => \{\s*if \(disabled\) return;\s*event\.preventDefault\(\);\s*onOpen\(\);\s*\}\}/,
+ );
+ assert.doesNotMatch(submenu, /onKeyDown/);
+
+ const more = block(SIDEBAR, "{overflowNavIds.map((id) => {", "<MoreMenuItem");
+ assert.match(
+ more,
+ /onOpen=\{\(\) => \{\s*setMoreOpen\(false\);\s*row\.onClick\(\);\s*\}\}/,
+ );
+ // omitting a workflow request preserves the page's current workflow.
+ assert.match(
+ SIDEBAR,
+ /audio: \{[\s\S]*?onClick: \(\) => \{\s*navigateFromRow\(\{ to: "\/audio" \}\);\s*closeMobileIfOpen\(\);\s*\}/,
+ );
+
+ 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*\);/,
+ );
+});
+
test("the Audio row stays lit while hovered, like Images", () => {
const css = readSrc("index.css");
assert.match(
diff --git a/studio/frontend/tests/sidebar-nav-placement.test.ts b/studio/frontend/tests/sidebar-nav-placement.test.ts
new file mode 100644
index 00000000000..946fc2be957
--- /dev/null
+++ b/studio/frontend/tests/sidebar-nav-placement.test.ts
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// active pages surface their unpinned row without changing its stored pin state.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+
+const { placeNavRows } = await import("../src/components/nav-row-state.ts");
+
+const SHIPPED = [
+ { id: "hub", pinned: true },
+ { id: "projects", pinned: true },
+ { id: "library", pinned: true },
+ { id: "images", pinned: true },
+ { id: "video", pinned: false },
+ { id: "audio", pinned: false },
+ { id: "train", pinned: true },
+ { id: "recipes", pinned: false },
+ { id: "export", pinned: false },
+ { id: "api", pinned: false },
+];
+
+function onlyUnpinned(...ids: string[]) {
+ return SHIPPED.map((row) => ({ id: row.id, pinned: !ids.includes(row.id) }));
+}
+
+test("with nothing surfaced, pinned rows stay inline and the rest go to More", () => {
+ assert.deepEqual(placeNavRows(SHIPPED, null), {
+ inline: ["hub", "projects", "library", "images", "train"],
+ overflow: ["video", "audio", "recipes", "export", "api"],
+ });
+});
+
+test("a surfaced row takes its own slot and leaves More", () => {
+ assert.deepEqual(placeNavRows(SHIPPED, "audio"), {
+ inline: ["hub", "projects", "library", "images", "audio", "train"],
+ overflow: ["video", "recipes", "export", "api"],
+ });
+});
+
+test("surfacing a pinned row changes nothing", () => {
+ const pinned = SHIPPED.map((row) => ({
+ ...row,
+ pinned: row.pinned || row.id === "audio",
+ }));
+ assert.deepEqual(placeNavRows(pinned, "audio"), placeNavRows(pinned, null));
+});
+
+test("surfacing never hides the row it shared More with", () => {
+ const rows = onlyUnpinned("video", "audio");
+ assert.deepEqual(placeNavRows(rows, null).overflow, ["video", "audio"]);
+ assert.deepEqual(placeNavRows(rows, "audio").overflow, ["video"]);
+});
+
+test("a lone unpinned row is still dropped with More, unless its page surfaces it", () => {
+ const rows = onlyUnpinned("audio");
+ const away = placeNavRows(rows, null);
+ assert.deepEqual(away.overflow, []);
+ assert.ok(!away.inline.includes("audio"));
+ const here = placeNavRows(rows, "audio");
+ assert.deepEqual(here.overflow, []);
+ assert.deepEqual(
+ here.inline,
+ SHIPPED.map((row) => row.id),
+ );
+});
+
+test("a lone unpinned row of another page stays dropped on Audio", () => {
+ const rows = onlyUnpinned("video");
+ for (const shown of [null, "audio"]) {
+ const placed = placeNavRows(rows, shown);
+ assert.deepEqual(placed.overflow, []);
+ assert.ok(!placed.inline.includes("video"));
+ }
+});
diff --git a/studio/frontend/tests/sidebar-projects-nav-auto.test.ts b/studio/frontend/tests/sidebar-projects-nav-auto.test.ts
index 1e9afc08604..d9eaf6c73eb 100644
--- a/studio/frontend/tests/sidebar-projects-nav-auto.test.ts
+++ b/studio/frontend/tests/sidebar-projects-nav-auto.test.ts
@@ -151,24 +151,22 @@ test("the sidebar and the customizer resolve the row the same way", async () =>
const customizer = await readSrcAsync(
"features/settings/components/sidebar-nav-customizer.tsx",
);
- // Both split their rows with the shared resolver rather than reading `pinned` directly.
assert.match(
sidebar,
/sidebarNavRowPinned\(item, sidebarNavAuto, \{ projectsSectionShowing \}\)/,
);
- assert.match(sidebar, /\.filter\(\(item\) => !navRowPinned\(item\)\)/);
- assert.match(sidebar, /\.filter\(\(item\) => navRowPinned\(item\)\)/);
+ assert.match(
+ sidebar,
+ /placeNavRows\(\s*sidebarNav\.map\(\(item\) => \(\{ id: item\.id, pinned: navRowPinned\(item\) \}\)\),/,
+ );
assert.match(customizer, /checked=\{pinned\}/);
- // And the switch records the decision alongside the new placement.
assert.match(
customizer,
/sidebarNavAuto: sidebarNavAutoAfterChoice\(sidebarNavAuto, item\.id\)/,
);
});
-// Train and Recipes list their runs where the folders go. The row read that as the section being
-// gone and pinned itself back to the top, so walking to Train turned a row the user had put away
-// back on, and walking back turned it off again.
+// Train and Recipes reuse the folder section, so route rendering must not repin a hidden Projects row.
test("a route that borrows the section does not bring the row back", async () => {
const sidebar = await readSrcAsync("components/app-sidebar.tsx");
assert.match(