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: browser Downloads button matches the toolbar and closes on a second click (#13226)

Michael Han04e9b26f6468
diff --git a/studio/frontend/src/features/browser/browser-panel.tsx b/studio/frontend/src/features/browser/browser-panel.tsx
index 9d2c50de6cf..94e1c046ea2 100644
--- a/studio/frontend/src/features/browser/browser-panel.tsx
+++ b/studio/frontend/src/features/browser/browser-panel.tsx
@@ -207,6 +207,9 @@ const PILL = cn(
const TOOLBAR_BUTTON =
"size-8 text-foreground disabled:hover:text-foreground disabled:opacity-30";
+/** IconButton's own look, for toolbar buttons rendered elsewhere (DownloadsButton). */
+const TOOLBAR_ICON_BUTTON =
+ "flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:opacity-35 disabled:hover:bg-transparent disabled:hover:text-muted-foreground";
const NAV_BUTTON =
"size-8 rounded-md text-foreground disabled:hover:text-foreground disabled:opacity-30";
const NAV_ICON = "size-4.5";
@@ -245,7 +248,7 @@ function IconButton({
onClick={onClick}
disabled={disabled}
className={cn(
- "flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-[color-mix(in_oklab,var(--foreground)_calc(6%*var(--contrast-wash-gain,1)),transparent)] hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default disabled:opacity-35 disabled:hover:bg-transparent disabled:hover:text-muted-foreground",
+ TOOLBAR_ICON_BUTTON,
className,
)}
>
@@ -1060,7 +1063,7 @@ function WebActions({ tab, visible }: { tab: BrowserTab | undefined; visible: bo
<>
<AnnotatePageButton tab={tab} />
{/* Recent downloads and the one in flight; saving the page itself is in the menu. */}
- <DownloadsButton className={NAV_BUTTON} visible={visible} />
+ <DownloadsButton className={cn(TOOLBAR_ICON_BUTTON, NAV_BUTTON)} visible={visible} />
</>
);
}
@@ -1680,7 +1683,7 @@ function BrowserFileToolbar({
>
<HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} className="size-4.5" />
</IconButton>
- <DownloadsButton className={NAV_BUTTON} visible={visible} idleHidden={true} />
+ <DownloadsButton className={cn(TOOLBAR_ICON_BUTTON, NAV_BUTTON)} visible={visible} idleHidden={true} />
<PanelMenu tab={tab}>
<div className="flex items-start gap-3 px-3 py-2 text-sm">
<KindIcon name={entry.name} contentType={entry.contentType} className="mt-0.5 size-4.5" mono={true} />
@@ -2238,7 +2241,7 @@ function VideoFileToolbar({
</DropdownMenuContent>
</DropdownMenu>
</div>
- <DownloadsButton className={NAV_BUTTON} visible={visible} idleHidden={true} />
+ <DownloadsButton className={cn(TOOLBAR_ICON_BUTTON, NAV_BUTTON)} visible={visible} idleHidden={true} />
<PanelMenu tab={tab} />
</>
);
diff --git a/studio/frontend/src/features/browser/downloads-button.tsx b/studio/frontend/src/features/browser/downloads-button.tsx
index f0c2ea4152d..f5a9f71783c 100644
--- a/studio/frontend/src/features/browser/downloads-button.tsx
+++ b/studio/frontend/src/features/browser/downloads-button.tsx
@@ -26,7 +26,7 @@ import {
ArrowUpRight01Icon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { useEffect, useState } from "react";
+import { useEffect, useRef, useState } from "react";
import { type FinishedDownload, mountDownloadsButton, useDownloadActivity } from "./download-activity";
import { formatSize, revealLabelKey } from "./download-format";
import { type Target, openTarget, revealTarget } from "./download-open";
@@ -323,6 +323,7 @@ export function DownloadsButton({
visible && finished ? "finished" : "closed",
);
const [hovered, setHovered] = useState(false);
+ const anchorRef = useRef<HTMLSpanElement>(null);
// Only finishes after mount pop the notice. An open list shows recorded ones itself; the rest still need it.
const [seen, setSeen] = useState(finishedSequence);
if (finishedSequence !== seen) {
@@ -363,6 +364,7 @@ export function DownloadsButton({
<Popover open={mode !== "closed"} onOpenChange={(open) => (open ? setMode("list") : close())}>
<PopoverAnchor asChild={true}>
<span
+ ref={anchorRef}
className={cn(
"relative flex shrink-0",
idleHidden && !active && !finished && mode === "closed" && "hidden",
@@ -394,6 +396,11 @@ export function DownloadsButton({
align="end"
sideOffset={8}
onOpenAutoFocus={(event) => mode === "finished" && event.preventDefault()}
+ // The button is only the anchor: a press on it would dismiss here, then its click reopen.
+ // Pointer only: focus arriving by keyboard still closes, so Enter reopens with autofocus.
+ onPointerDownOutside={(event) => {
+ if (anchorRef.current?.contains(event.target as Node)) event.preventDefault();
+ }}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
className={cn(