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: bring back the sidebar scrollbar without losing row width (#8147)

Michael Hana8dec4126f88
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 224405b0d1a..4174263a061 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -715,6 +715,45 @@ export function AppSidebar() {
const [scrolled, setScrolled] = useState(false);
// Bottom fade hides at the very bottom / for short lists so the last row isn't washed out.
const [canScrollDown, setCanScrollDown] = useState(false);
+ // Rail width: 0 where scrollbars overlay (macOS default) or the list fits,
+ // the platform's thin rail where they are classic. Only rows inside the
+ // scroller lose it, so the rows outside pad by it to keep one edge. Written
+ // to the DOM, and only on a change: state here would loop (React #185).
+ const railWidthRef = useRef<number | null>(null);
+ const measureScrollRail = useCallback((el: HTMLDivElement) => {
+ const rail = el.offsetWidth - el.clientWidth;
+ if (rail === railWidthRef.current) return;
+ railWidthRef.current = rail;
+ el.parentElement?.style.setProperty("--sidebar-rail", `${rail}px`);
+ }, []);
+
+ // A callback ref, not an effect: the mobile Sheet unmounts its subtree on
+ // close and the breakpoint swaps it for the desktop one, so the scroller is a
+ // new node each time and an effect keyed on a stable callback never re-runs.
+ // Still runs before paint.
+ const railObserverRef = useRef<ResizeObserver | null>(null);
+ const attachScroller = useCallback(
+ (el: HTMLDivElement | null) => {
+ railObserverRef.current?.disconnect();
+ railObserverRef.current = null;
+ scrollRef.current = el;
+ // Per node: a new parent has no variable yet even at the same rail, and
+ // the cache would otherwise skip the write.
+ railWidthRef.current = null;
+ if (!el) return;
+ measureScrollRail(el);
+ // Watch the box, not renders: the Images disclosure and the project
+ // toggles change the row count without rendering this component, and a
+ // scrollbar appearing shrinks the content box by its own width. Safe
+ // where the earlier observer was not: it writes a variable, never state,
+ // so there is no render to feed back (React #185).
+ const observer = new ResizeObserver(() => measureScrollRail(el));
+ observer.observe(el);
+ railObserverRef.current = observer;
+ },
+ [measureScrollRail],
+ );
+
// Driven only from onScroll + a content-change effect below. No
// ResizeObserver: its callback-driven setState caused a render loop (React
// #185). Both setters bail out when unchanged, so neither path can loop.
@@ -976,10 +1015,16 @@ export function AppSidebar() {
const usesDesktopTitlebar = usesCustomTitlebar || usesNativeMacTitlebar;
// One box for every row pill, so a hover pill has the same edges wherever it
- // lands. The list scroller hides its rail (index.css) instead of eating width.
+ // lands. Rows outside the list scroller add the rail width it does not lose,
+ // so both end on the same edge whether or not the scrollbar takes space.
+ // Logical sides, since the rail is on the inline end and moves under rtl.
const rowPadding = usesDesktopTitlebar
- ? "pl-[5px] pr-2"
- : "pl-1.5 pr-1.75";
+ ? "ps-[5px] pe-[calc(var(--sidebar-rail,0px)+5px)]"
+ : "ps-1.5 pe-[calc(var(--sidebar-rail,0px)+6px)]";
+
+ // Inside it the rail already sits in that space, so this is just the gap
+ // between a pill and the scrollbar, matched to the gap on the other side.
+ const scrollRowPadding = usesDesktopTitlebar ? "px-[5px]" : "px-1.5";
// One definition per row, so pinned rows and the flyout can't drift apart.
@@ -1978,7 +2023,7 @@ export function AppSidebar() {
</SidebarGroup>
<SidebarContent
- ref={scrollRef}
+ ref={attachScroller}
onScroll={(e) => syncScrollState(e.currentTarget)}
// Collapsible groups animate their height; re-measure the fade once the animation settles.
onAnimationEnd={(e) => {
@@ -1999,7 +2044,7 @@ export function AppSidebar() {
data-tour="navbar"
className={cn(
"group-data-[collapsible=icon]:px-0 py-0 shrink-0",
- rowPadding,
+ scrollRowPadding,
)}
>
@@ -2170,7 +2215,7 @@ export function AppSidebar() {
</CollapsibleTrigger>
</SidebarGroupLabel>
<CollapsibleContent>
- <SidebarGroupContent className={rowPadding}>
+ <SidebarGroupContent className={scrollRowPadding}>
<SidebarMenu>
{pinnedProjectRecords.map((project) => {
const projectChats =
@@ -2320,7 +2365,7 @@ export function AppSidebar() {
</CollapsibleTrigger>
</SidebarGroupLabel>
<CollapsibleContent>
- <SidebarGroupContent className={rowPadding}>
+ <SidebarGroupContent className={scrollRowPadding}>
<SidebarMenu>
{recentChatItems.map((item) =>
renderChatSidebarItem(item, "recent"),
@@ -2352,7 +2397,7 @@ export function AppSidebar() {
</CollapsibleTrigger>
</SidebarGroupLabel>
<CollapsibleContent>
- <SidebarGroupContent className={rowPadding}>
+ <SidebarGroupContent className={scrollRowPadding}>
<SidebarMenu>
{runItems.map((run) => {
// Explicit selection wins. Otherwise highlight the active job only while the "Current Run"
@@ -2454,7 +2499,8 @@ export function AppSidebar() {
>
{/* Fade above the profile box, shown only when there's more list below
the fold; at the bottom (or short lists) it fades so the last row
- shows fully (Gemini-style). No scroll rail to clear, so full width. */}
+ shows fully (Gemini-style). Stops at the rail: the thumb ends its
+ travel in this band and a full-width gradient washed it out. */}
<div
aria-hidden="true"
className={cn(
@@ -2462,7 +2508,7 @@ export function AppSidebar() {
// ramp is still part-transparent there and slices the last row
// mid-glyph. from-[8px] holds it opaque just across the clip, and
// matches the list's pb-2 so the gap is the same once it hides.
- "pointer-events-none absolute inset-x-0 bottom-full bg-gradient-to-t from-[var(--sidebar-surface)] from-[8px] to-[rgb(from_var(--sidebar-surface)_r_g_b/0)] transition-opacity duration-200",
+ "pointer-events-none absolute start-0 end-[var(--sidebar-rail,0px)] bottom-full bg-gradient-to-t from-[var(--sidebar-surface)] from-[8px] to-[rgb(from_var(--sidebar-surface)_r_g_b/0)] transition-opacity duration-200",
// Shorter fade with the update card so the list reads closer to
// it, but still tall enough to clear a row.
showUpdateCard ? "h-7" : "h-10",
diff --git a/studio/frontend/src/index.css b/studio/frontend/src/index.css
index 36eb75988d0..ef7ec1ea82e 100644
--- a/studio/frontend/src/index.css
+++ b/studio/frontend/src/index.css
@@ -33,10 +33,24 @@
scrolled, the TOP edge also fades so rows dissolve as they pass under the
pinned New Chat / Search header. */
/* Top edge: when scrolled, rows dissolve as they pass under the pinned
- New Chat / Search header (mask — fades content to transparent). */
+ New Chat / Search header (mask — fades content to transparent).
+ A mask covers the border box, scrollbar included, so the ramp dissolved
+ the thumb's top too. Second layer holds the rail column opaque (layers
+ union by default); nothing else is in that column, and at rail 0 it is
+ empty. */
.sidebar-scroll-fade.is-scrolled {
- -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
- mask-image: linear-gradient(to bottom, transparent 0, #000 14px);
+ -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px),
+ linear-gradient(to left, #000 var(--sidebar-rail, 0px), transparent 0);
+ mask-image: linear-gradient(to bottom, transparent 0, #000 14px),
+ linear-gradient(to left, #000 var(--sidebar-rail, 0px), transparent 0);
+ }
+ /* The rail is on the inline end, the left under rtl; a gradient cannot say
+ that. */
+ [dir="rtl"] .sidebar-scroll-fade.is-scrolled {
+ -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px),
+ linear-gradient(to right, #000 var(--sidebar-rail, 0px), transparent 0);
+ mask-image: linear-gradient(to bottom, transparent 0, #000 14px),
+ linear-gradient(to right, #000 var(--sidebar-rail, 0px), transparent 0);
}
/* Bottom edge: Gemini-style sticky gradient OVERLAY painted in the sidebar
background colour, so the last rows wash into the profile footer. Uses a
@@ -2667,49 +2681,42 @@ html[data-chat-font] .aui-root {
/* Settings and search: hide the scroll thumb at rest and reveal it only while
the area is hovered, so the rail never sits visible over content. */
+.sidebar-scroll-fade,
.run-settings-scroll,
.hover-scrollbar {
scrollbar-color: transparent transparent;
}
+.sidebar-scroll-fade::-webkit-scrollbar-thumb,
.run-settings-scroll::-webkit-scrollbar-thumb,
.hover-scrollbar::-webkit-scrollbar-thumb {
background: transparent;
}
+.sidebar-scroll-fade:hover,
.run-settings-scroll:hover,
.hover-scrollbar:hover {
scrollbar-color: oklch(0.5 0 0 / 0.4) transparent;
}
+.sidebar-scroll-fade:hover::-webkit-scrollbar-thumb,
.run-settings-scroll:hover::-webkit-scrollbar-thumb,
.hover-scrollbar:hover::-webkit-scrollbar-thumb {
background: oklch(0.5 0 0 / 0.4);
}
+.dark .sidebar-scroll-fade:hover,
.dark .run-settings-scroll:hover,
.dark .hover-scrollbar:hover {
scrollbar-color: oklch(0.72 0 0 / 0.4) transparent;
}
+.dark .sidebar-scroll-fade:hover::-webkit-scrollbar-thumb,
.dark .run-settings-scroll:hover::-webkit-scrollbar-thumb,
.dark .hover-scrollbar:hover::-webkit-scrollbar-thumb {
background: oklch(0.72 0 0 / 0.4);
}
-/* Sidebar list: no scroll rail. A rail narrows the rows inside the scroller,
- so their pills came out short of New Chat above it, by 8px on WebKit, a thin
- rail on Chromium, nothing under macOS overlay scrollbars. The thumb was
- already transparent at rest, and the fades still show there is more list. */
-.sidebar-scroll-fade {
- scrollbar-width: none;
-}
-
-.sidebar-scroll-fade::-webkit-scrollbar {
- width: 0;
- height: 0;
-}
-
/* Run settings: always reserve the scrollbar gutter so the header close
button keeps its position whether or not the scrollbar is showing. */
.run-settings-scroll {
diff --git a/studio/frontend/tests/sidebar-action-rows-inert.test.ts b/studio/frontend/tests/sidebar-action-rows-inert.test.ts
index 04acd9c9c76..daa0342f267 100644
--- a/studio/frontend/tests/sidebar-action-rows-inert.test.ts
+++ b/studio/frontend/tests/sidebar-action-rows-inert.test.ts
@@ -74,28 +74,92 @@ test("footer profile sits 11px above the sidebar edge", async () => {
});
test("every sidebar row pill sits in one shared box", async () => {
- // A recent chat's pill has to match New Chat's, so the padding is defined
- // once and every group takes it.
+ // A recent chat's pill has to match New Chat's. The rows inside the scroller
+ // lose the rail's width, so the rows outside add it back and both end on one
+ // edge; both pads match, so a pill sits the same distance from the scrollbar
+ // as from the near edge. Logical sides, since the rail moves under rtl.
const source = await sidebarSource();
assert.match(
source,
- /const rowPadding = usesDesktopTitlebar\s*\?\s*"pl-\[5px\] pr-2"\s*:\s*"pl-1\.5 pr-1\.75"/,
+ /const rowPadding = usesDesktopTitlebar\s*\?\s*"ps-\[5px\] pe-\[calc\(var\(--sidebar-rail,0px\)\+5px\)\]"\s*:\s*"ps-1\.5 pe-\[calc\(var\(--sidebar-rail,0px\)\+6px\)\]"/,
);
- // New Chat, the nav rows, pinned projects, Recents, training runs, footer.
- assert.equal(source.match(/(?<!const )rowPadding[,}]/g)?.length, 6);
+ assert.match(
+ source,
+ /const scrollRowPadding = usesDesktopTitlebar \? "px-\[5px\]" : "px-1\.5"/,
+ );
+ // New Chat and the footer sit outside the scroller.
+ assert.equal(source.match(/(?<!const )rowPadding[,}]/g)?.length, 2);
+ // Nav rows, pinned projects, Recents, training runs sit inside it.
+ assert.equal(source.match(/scrollRowPadding[,}]/g)?.length, 4);
assert.equal(source.match(/"pl-2 pr-\[5px\]"/g), null);
});
-test("the sidebar list keeps no scroll rail to steal row width", async () => {
- // A rail narrows every row under New Chat, which sits above the scroller.
+test("the sidebar list measures its scroll rail", async () => {
+ // 0 where scrollbars overlay, the platform's thin rail where they are
+ // classic. Read off the scroller and written to the DOM: state loops (#185).
+ const source = await sidebarSource();
+ assert.match(
+ source,
+ /const rail = el\.offsetWidth - el\.clientWidth;[\s\S]*el\.parentElement\?\.style\.setProperty\(\s*"--sidebar-rail",\s*`\$\{rail\}px`,?\s*\)/,
+ );
+ // A callback ref, not an effect: the Sheet unmounts on close and the
+ // breakpoint swaps subtrees, so the scroller is a new node each time.
+ assert.match(source, /ref=\{attachScroller\}/);
+ assert.match(
+ source,
+ /const attachScroller = useCallback\(\s*\(el: HTMLDivElement \| null\) => \{/,
+ );
+ assert.equal(/useLayoutEffect/.test(source), false);
+ // Old observer goes first, or a detached node keeps one.
+ assert.match(source, /railObserverRef\.current\?\.disconnect\(\);/);
+ // Cache is per node: a new parent has no variable even at the same width.
+ assert.match(source, /railWidthRef\.current = null;/);
+ // Measured on attach, or a list overflowing on arrival stays misaligned
+ // until something fires a scroll.
+ assert.match(source, /if \(!el\) return;\s*measureScrollRail\(el\);/);
+ // Then off the box, not off renders: the Images disclosure and the project
+ // toggles change the row count without rendering AppSidebar, and a scrollbar
+ // appearing shrinks the content box.
+ assert.match(
+ source,
+ /const observer = new ResizeObserver\(\(\) => measureScrollRail\(el\)\);\s*observer\.observe\(el\);\s*railObserverRef\.current = observer;/,
+ );
+ // Writes a variable, never state: that pairing is what looped.
+ assert.equal(
+ /new ResizeObserver\([^)]*set[A-Z]/.test(source),
+ false,
+ );
+ // And only on a change, so it cannot re-trigger itself.
+ assert.match(
+ source,
+ /if \(rail === railWidthRef\.current\) return;/,
+ );
+ // The fade stops at the rail too: the thumb ends its travel in that band.
+ assert.match(
+ source,
+ /absolute start-0 end-\[var\(--sidebar-rail,0px\)\] bottom-full/,
+ );
const css = await readFile(
new URL("../src/index.css", import.meta.url),
"utf8",
);
- assert.match(css, /\.sidebar-scroll-fade \{\s*scrollbar-width: none;\s*\}/);
+ // No width override: the rail keeps the width the rest of the app uses, and
+ // hiding it outright is what took the scrollbar away.
+ assert.equal(/\.sidebar-scroll-fade[^{]*\{[^}]*scrollbar-width/.test(css), false);
+ assert.equal(
+ /\.sidebar-scroll-fade::-webkit-scrollbar \{/.test(css),
+ false,
+ );
+ // Thumb stays hidden until the list is hovered, as the other lists do.
+ assert.match(css, /\.sidebar-scroll-fade:hover::-webkit-scrollbar-thumb,/);
+ // A mask covers the scrollbar, so the top fade keeps the rail column opaque.
+ assert.match(
+ css,
+ /mask-image: linear-gradient\(to bottom, transparent 0, #000 14px\),\s*linear-gradient\(to left, #000 var\(--sidebar-rail, 0px\), transparent 0\);/,
+ );
assert.match(
css,
- /\.sidebar-scroll-fade::-webkit-scrollbar \{\s*width: 0;\s*height: 0;\s*\}/,
+ /\[dir="rtl"\] \.sidebar-scroll-fade\.is-scrolled \{[\s\S]*linear-gradient\(to right, #000 var\(--sidebar-rail, 0px\), transparent 0\);/,
);
});