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: keep the prompt queue's more menu open while queued prompts send (#12546)

Leo Borcherding813d8af7ba1f
diff --git a/studio/frontend/src/components/assistant-ui/prompt-queue-list.tsx b/studio/frontend/src/components/assistant-ui/prompt-queue-list.tsx
index e6d247f302a..32d3ea0f178 100644
--- a/studio/frontend/src/components/assistant-ui/prompt-queue-list.tsx
+++ b/studio/frontend/src/components/assistant-ui/prompt-queue-list.tsx
@@ -20,6 +20,7 @@ import {
DropdownMenuSeparator,
} from "@/components/ui/dropdown-menu";
import { NonModalDropdownMenu } from "@/components/ui/non-modal-dropdown-menu";
+import { COMPOSER_INPUT_SELECTOR } from "@/features/settings";
import {
Tooltip,
TooltipContent,
@@ -52,6 +53,8 @@ type PromptQueueListProps = {
};
/** The queue engine owns dispatch and validates every mutation against live IDs. */
+const MENU_OR_TRIGGER = "[data-slot='dropdown-menu-content'], [data-queue-menu]";
+
export function PromptQueueList({
entry,
items,
@@ -72,6 +75,17 @@ export function PromptQueueList({
const composingRef = useRef(false);
const composingTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const editFromMenuRef = useRef(false);
+ const pointerDownRef = useRef<{ target: EventTarget | null; at: number }>({
+ target: null,
+ at: 0,
+ });
+ useEffect(() => {
+ const note = (event: PointerEvent) => {
+ pointerDownRef.current = { target: event.target, at: event.timeStamp };
+ };
+ document.addEventListener("pointerdown", note, true);
+ return () => document.removeEventListener("pointerdown", note, true);
+ }, []);
const instructionsId = useId();
const editingItem = items.find(
(item) => item.id === editingId && item.canEdit,
@@ -397,6 +411,29 @@ export function PromptQueueList({
className="w-56 rounded-2xl border border-border/60 p-1.5 shadow-lg"
// Opening the menu must not select an item on pointer release.
onPointerUpCapture={(event) => event.preventDefault()}
+ // A queued send focuses the composer: stay open and take focus back, or Escape lands there.
+ // Any other focus move, or one a pointer just caused, dismisses as before.
+ onFocusOutside={(event) => {
+ const { target, relatedTarget, timeStamp } =
+ event.detail.originalEvent;
+ const down = pointerDownRef.current;
+ const byPointer =
+ timeStamp - down.at < 1000 &&
+ down.target instanceof Element &&
+ !down.target.closest(MENU_OR_TRIGGER);
+ if (
+ byPointer ||
+ !(target instanceof Element) ||
+ !target.matches(COMPOSER_INPUT_SELECTOR)
+ )
+ return;
+ event.preventDefault();
+ if (
+ relatedTarget instanceof HTMLElement &&
+ relatedTarget.closest(MENU_OR_TRIGGER)
+ )
+ relatedTarget.focus({ preventScroll: true });
+ }}
onCloseAutoFocus={(event) => {
if (!editFromMenuRef.current) return;
event.preventDefault();