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.

fix(prompt storage): follow up, restore prompt list bookmarking, the kind pill and drag autoscroll (#9788)

Leo Borcherding591601b08b0d
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 5f1d6bfa0ff..99f25fa6eb7 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -128,8 +128,11 @@ import {
} from "@/features/chat/prompt-storage/prompt-storage-dialog";
import {
listPromptEntries,
+ listPromptLists,
type PromptEntry,
+ type PromptListEntry,
} from "@/features/chat/api/prompts-api";
+import { PromptCountBadge } from "@/features/chat/prompt-storage/prompt-count-badge";
import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferences-store";
import { useChatProjects } from "@/features/chat/hooks/use-chat-projects";
import { NewProjectDialog } from "@/features/chat/components/new-project-dialog";
@@ -5297,12 +5300,9 @@ const Composer: FC<{
// Saved-prompt Run-list calls this directly, so honour disableQueue here
// too: queuing from the project new-chat composer misbinds the thread.
if (disableQueue) return false;
- return startHydratedPromptQueue(
- items,
- waitForCurrentRun,
- undefined,
- onAborted,
- );
+ // false here only means an identical start is already pending and will run: not a refusal.
+ startHydratedPromptQueue(items, waitForCurrentRun, undefined, onAborted);
+ return true;
},
[aui, startHydratedPromptQueue, threadIsRunning, disableQueue],
);
@@ -5342,6 +5342,7 @@ const Composer: FC<{
<ComposerToolsMenu
side={effectiveMenuSide}
researchAvailable={!researchUsed}
+ audioUploadBusy={audioUpload.busy}
/>
{/* While dictating, show only the "+"; hide the pill and tool toggles
so the waveform is the sole status indicator. */}
@@ -6418,7 +6419,8 @@ function attachmentAcceptForPicker(accept: string, audioEnabled: boolean): strin
const ComposerToolsMenu: FC<{
side?: "top" | "bottom";
researchAvailable: boolean;
-}> = ({ side = "bottom", researchAvailable }) => {
+ audioUploadBusy: boolean;
+}> = ({ side = "bottom", researchAvailable, audioUploadBusy }) => {
const t = useT();
const navigate = useNavigate();
const toolsEnabled = useChatRuntimeStore((s) => s.toolsEnabled);
@@ -6580,13 +6582,20 @@ const ComposerToolsMenu: FC<{
const messageCount = useAuiState(({ thread }) => thread.messages.length);
const exportDisabled = incognito || !activeThreadId || messageCount === 0;
const { startQueue } = useContext(PromptQueueContext);
+ const { overlay: generatedImageOverlay } = useGeneratedImageOverlay();
+ const menuIsDictating = useAuiState((s) => s.composer.dictation != null);
const plusPins = usePlusMenuPrefsStore((s) => s.pins);
const [recentPrompts, setRecentPrompts] = useState<PromptEntry[]>([]);
+ const [recentLists, setRecentLists] = useState<PromptListEntry[]>([]);
+ const recentSeqRef = useRef(0);
const refreshRecentPrompts = useCallback(async () => {
+ recentSeqRef.current += 1;
+ const seq = recentSeqRef.current;
try {
const rows = await listPromptEntries();
+ if (seq !== recentSeqRef.current) return;
const byRecent = [...rows].sort((a, b) => b.updatedAt - a.updatedAt);
// Pinned prompts take over the submenu; fall back to the 3 most recent
// when nothing is pinned.
@@ -6594,9 +6603,56 @@ const ComposerToolsMenu: FC<{
const pinned = byRecent.filter((p) => pinnedIds.includes(p.id));
setRecentPrompts(pinned.length > 0 ? pinned : byRecent.slice(0, 3));
} catch {
+ // Clear, don't keep: a stale list row would run its cached items.
+ if (seq === recentSeqRef.current) setRecentPrompts([]);
+ }
+ try {
+ const rows = await listPromptLists();
+ if (seq !== recentSeqRef.current) return;
+ const pinnedIds = usePlusMenuPrefsStore.getState().pinnedListIds;
+ setRecentLists(rows.filter((l) => pinnedIds.includes(l.id)));
+ } catch {
+ if (seq === recentSeqRef.current) setRecentLists([]);
}
}, []);
+ const runPromptList = useCallback(
+ (items: string[], fromDialog = false) => {
+ // A queue started while recording would swallow the held transcript send.
+ if (menuIsDictating) {
+ toast.error("Finish dictating before running a list");
+ return;
+ }
+ // Starting the queue cancels an in-flight transcription, which would discard it.
+ if (audioUploadBusy) {
+ toast.error("Wait for the transcription to finish before running a list");
+ return;
+ }
+ // Mid image edit, startQueue would bypass the overlay's prompt rewrite.
+ if (generatedImageOverlay) {
+ toast.error("Close the image editor before running a list", {
+ description: "Saved lists cannot be applied to a generated image.",
+ });
+ return;
+ }
+ const started = startQueue(items, undefined, () => {
+ if (fromDialog) setPromptStorageOpen(true);
+ toast.info("Saved list was not queued", {
+ description: "The chat changed before the queue was ready. Try again.",
+ });
+ });
+ if (started) {
+ setPromptStorageOpen(false);
+ return;
+ }
+ // startQueue refuses synchronously without calling onAborted.
+ toast.error("Couldn't queue that list here", {
+ description: "Open a chat first, then run the list.",
+ });
+ },
+ [startQueue, generatedImageOverlay, menuIsDictating, audioUploadBusy, setPromptStorageOpen],
+ );
+
// Adjustable "+" menu items, keyed by id. Pinned ones render at the top
// level; the rest fall into the "More" overflow submenu. The core items
// (photos, web search, code) and "More" itself are always shown and live
@@ -6652,13 +6708,21 @@ const ComposerToolsMenu: FC<{
>
{recentPrompts.map((p) => (
<DropdownMenuItem
- key={p.id}
+ key={`prompt:${p.id}`}
onSelect={() => aui.composer().setText(p.text)}
>
<span className="truncate">{p.name}</span>
</DropdownMenuItem>
))}
- {recentPrompts.length > 0 ? <DropdownMenuSeparator /> : null}
+ {recentLists.map((l) => (
+ <DropdownMenuItem key={`list:${l.id}`} onSelect={() => runPromptList(l.items)}>
+ <span className="truncate">{l.name}</span>
+ <PromptCountBadge count={l.items.length} />
+ </DropdownMenuItem>
+ ))}
+ {recentPrompts.length > 0 || recentLists.length > 0 ? (
+ <DropdownMenuSeparator />
+ ) : null}
<DropdownMenuItem onSelect={() => setPromptStorageOpen(true)}>
All saved prompts…
</DropdownMenuItem>
@@ -6790,17 +6854,7 @@ const ComposerToolsMenu: FC<{
onUse={(text) => {
aui.composer().setText(text);
}}
- onRunList={(items) => {
- const started = startQueue(items, undefined, () => {
- setPromptStorageOpen(true);
- toast.info("Saved list was not queued", {
- description: "The chat changed before the queue was ready. Try again.",
- });
- });
- if (started) {
- setPromptStorageOpen(false);
- }
- }}
+ onRunList={(items) => runPromptList(items, true)}
/>
<DropdownMenu
onOpenChange={(open) => {
diff --git a/studio/frontend/src/features/chat/prompt-storage/autoscroll.ts b/studio/frontend/src/features/chat/prompt-storage/autoscroll.ts
new file mode 100644
index 00000000000..9f18611e5d1
--- /dev/null
+++ b/studio/frontend/src/features/chat/prompt-storage/autoscroll.ts
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+export const AUTOSCROLL_EDGE = 48;
+export const AUTOSCROLL_MAX_STEP = 14;
+
+/** Per-frame scroll step near a pane edge: negative up, positive down, 0 holds. */
+export function autoscrollDelta(
+ pointerY: number,
+ paneTop: number,
+ paneBottom: number,
+ edge: number = AUTOSCROLL_EDGE,
+ maxStep: number = AUTOSCROLL_MAX_STEP,
+): number {
+ // Bands overlap on short panes: use the half the pointer is in.
+ const band = Math.min(edge, (paneBottom - paneTop) / 2);
+ if (band <= 0) return 0;
+
+ if (pointerY < paneTop + band) {
+ const depth = Math.min(band, paneTop + band - pointerY);
+ return -(depth / band) * maxStep;
+ }
+ if (pointerY > paneBottom - band) {
+ const depth = Math.min(band, pointerY - (paneBottom - band));
+ return (depth / band) * maxStep;
+ }
+ return 0;
+}
+
+export interface VerticalSpan {
+ top: number;
+ bottom: number;
+}
+
+/** Pane rect clipped by ancestors and viewport (nested scrollers report full height); null if hidden. */
+export function clipSpan(
+ span: VerticalSpan,
+ clips: readonly VerticalSpan[],
+): VerticalSpan | null {
+ let { top, bottom } = span;
+ for (const clip of clips) {
+ top = Math.max(top, clip.top);
+ bottom = Math.min(bottom, clip.bottom);
+ }
+ return bottom > top ? { top, bottom } : null;
+}
diff --git a/studio/frontend/src/features/chat/prompt-storage/prompt-count-badge.tsx b/studio/frontend/src/features/chat/prompt-storage/prompt-count-badge.tsx
new file mode 100644
index 00000000000..19e61ea3ab9
--- /dev/null
+++ b/studio/frontend/src/features/chat/prompt-storage/prompt-count-badge.tsx
@@ -0,0 +1,16 @@
+// 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 type { ReactElement } from "react";
+
+export function PromptCountBadge({ count }: { count: number }): ReactElement {
+ return (
+ <span
+ className="ml-auto flex h-4 min-w-4 shrink-0 items-center justify-center rounded-full bg-muted px-1 text-ui-11 font-medium tabular-nums text-muted-foreground"
+ title={`${count} prompts`}
+ aria-label={`${count} prompts`}
+ >
+ {count}
+ </span>
+ );
+}
diff --git a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
index 0e99fcca00e..918e11af125 100644
--- a/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
+++ b/studio/frontend/src/features/chat/prompt-storage/prompt-storage-dialog.tsx
@@ -1790,6 +1790,9 @@ function PromptListDetail({
pending: boolean;
runMutation: (id: string, fn: () => Promise<void>) => Promise<void>;
}): ReactElement {
+ const pinnedListIds = usePlusMenuPrefsStore((s) => s.pinnedListIds);
+ const togglePinnedList = usePlusMenuPrefsStore((s) => s.togglePinnedList);
+ const isPinned = pinnedListIds.includes(entry.id);
const [preview, setPreview] = useState(false);
const [confirmingDelete, setConfirmingDelete] = useState(false);
@@ -1932,6 +1935,19 @@ function PromptListDetail({
)}
</div>
<div className="flex shrink-0 flex-wrap items-center gap-1 border-t border-border/50 pt-3">
+ <button
+ type="button"
+ onClick={() => togglePinnedList(entry.id)}
+ className={cn(
+ "flex h-8 w-8 items-center justify-center rounded-lg transition-colors",
+ isPinned
+ ? "text-primary hover:bg-primary/10"
+ : "text-muted-foreground hover:bg-muted hover:text-foreground",
+ )}
+ title={isPinned ? "Unpin from + menu" : "Pin to + menu"}
+ >
+ <BookmarkIcon className={cn("size-4", isPinned && "fill-primary")} />
+ </button>
<button
type="button"
onClick={() => onExport(exportValue)}
@@ -2108,6 +2124,7 @@ export function PromptStorageDialog({
const [exportCtx, setExportCtx] = useState<ExportModalCtx | null>(null);
const importRef = useRef<HTMLInputElement>(null);
const pinnedPromptIds = usePlusMenuPrefsStore((s) => s.pinnedPromptIds);
+ const pinnedListIds = usePlusMenuPrefsStore((s) => s.pinnedListIds);
const [promptEntries, setPromptEntries] = useState<PromptEntry[]>([]);
const [promptLists, setPromptLists] = useState<PromptListEntry[]>([]);
@@ -2575,6 +2592,11 @@ export function PromptStorageDialog({
selected={!showNewList && entry.id === selectedListId}
current={entry.id === selectedListId}
dirty={listDrafts.has(entry.id)}
+ leading={
+ pinnedListIds.includes(entry.id) ? (
+ <BookmarkIcon className="size-3 shrink-0 fill-primary text-primary" />
+ ) : null
+ }
onSelect={() => {
setShowNewList(false);
setSelectedListId(entry.id);
diff --git a/studio/frontend/src/features/chat/prompt-storage/sortable-prompt-items.tsx b/studio/frontend/src/features/chat/prompt-storage/sortable-prompt-items.tsx
index 29225efc787..00d587ee7d9 100644
--- a/studio/frontend/src/features/chat/prompt-storage/sortable-prompt-items.tsx
+++ b/studio/frontend/src/features/chat/prompt-storage/sortable-prompt-items.tsx
@@ -3,6 +3,7 @@
import { MarkdownPreview } from "@/components/markdown/markdown-preview";
import { cn } from "@/lib/utils";
+import { autoscrollDelta, clipSpan } from "./autoscroll";
import { flipShifts, insertionIndex, ownsDrag } from "./reorder";
import { GripVerticalIcon, XIcon } from "lucide-react";
import {
@@ -100,8 +101,21 @@ function nextUid(): string {
return `i${uidSeq}`;
}
-// Rows are keyed by a synthetic uid, not array index: index keys would swap the values under
-// the caret on reorder and break the animation.
+// Scrollable ancestors, nearest first, so running the inner pane out hands off to the dialog.
+function findScrollParents(el: HTMLElement | null): HTMLElement[] {
+ const out: HTMLElement[] = [];
+ let node = el?.parentElement ?? null;
+ while (node) {
+ const overflowY = getComputedStyle(node).overflowY;
+ // Scrollability is checked per frame instead: rows grow as you type.
+ if (overflowY === "auto" || overflowY === "scroll") out.push(node);
+ node = node.parentElement;
+ }
+ return out;
+}
+
+// Rows are keyed by a synthetic uid, not array index: index keys would swap the
+// values under the caret on reorder and break the animation.
export function SortablePromptItems({
items,
onChange,
@@ -134,8 +148,7 @@ export function SortablePromptItems({
setUids(rowUids);
}
- // Layout offsets, not client rects: a rect moves with the scroll position, so scrolling the
- // pane between reorders would bake that distance into every transform.
+ // Layout offsets, not client rects: rects shift with scroll, which autoscroll changes per frame.
const measureOffsets = useCallback(() => {
const offsets = new Map<string, number>();
rowRefs.current.forEach((el, uid) => offsets.set(uid, el.offsetTop));
@@ -207,6 +220,8 @@ export function SortablePromptItems({
if (!draggingUid) return;
const container = containerRef.current;
if (!container) return;
+ const scrollers = findScrollParents(container);
+ let raf = 0;
const evaluate = () => {
const order = uidsRef.current;
@@ -224,6 +239,30 @@ export function SortablePromptItems({
if (to !== from) applyOrder(from, to);
};
+ // pointerdown suppresses native drag scrolling, so scroll here and re-run the hit-test.
+ const tick = () => {
+ for (let i = 0; i < scrollers.length; i++) {
+ const scroller = scrollers[i];
+ const limit = scroller.scrollHeight - scroller.clientHeight;
+ if (limit <= 0) continue;
+ const span = clipSpan(scroller.getBoundingClientRect(), [
+ ...scrollers.slice(i + 1).map((el) => el.getBoundingClientRect()),
+ { top: 0, bottom: window.innerHeight },
+ ]);
+ if (!span) continue;
+ const delta = autoscrollDelta(pointerYRef.current, span.top, span.bottom);
+ if (delta === 0) continue;
+ const before = scroller.scrollTop;
+ const next = Math.max(0, Math.min(limit, before + delta));
+ if (next === before) continue;
+ scroller.scrollTop = next;
+ evaluate();
+ break;
+ }
+ raf = requestAnimationFrame(tick);
+ };
+ raf = requestAnimationFrame(tick);
+
const endDrag = () => {
pointerIdRef.current = null;
setDraggingUid(null);
@@ -257,6 +296,7 @@ export function SortablePromptItems({
// Release entirely outside the page, where no move follows to catch it.
window.addEventListener("blur", endDrag);
return () => {
+ cancelAnimationFrame(raf);
window.removeEventListener("pointermove", onMove);
window.removeEventListener("pointerup", onPointerEnd);
window.removeEventListener("pointercancel", onPointerEnd);
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index 3abe9487092..1074dbf9241 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -121,7 +121,13 @@ import {
exportConversationCsv,
exportConversationMarkdown,
} from "./prompt-storage/prompt-storage-dialog";
-import { listPromptEntries, type PromptEntry } from "./api/prompts-api";
+import {
+ listPromptEntries,
+ listPromptLists,
+ type PromptEntry,
+ type PromptListEntry,
+} from "./api/prompts-api";
+import { PromptCountBadge } from "./prompt-storage/prompt-count-badge";
import { McpComposerButton } from "./mcp-composer-button";
import { PermissionModeComposerPill } from "./permission-mode-select";
import { reasoningCapsFromLoad } from "./lib/apply-inference-status-to-store";
@@ -616,6 +622,10 @@ export function SharedComposer({
},
[],
);
+ // Audio files still being read into base64, which pendingAudio cannot see yet.
+ const audioDecodingRef = useRef(0);
+ // Attachments still classifying or converting; a ref so runPromptList reads it synchronously.
+ const attachingRef = useRef(0);
useEffect(() => {
textRef.current = text;
pendingImagesRef.current = pendingImages;
@@ -627,15 +637,30 @@ export function SharedComposer({
const [skillsOpen, setSkillsOpen] = useState(false);
const [promptStorageOpen, setPromptStorageOpen] = useState(false);
const [recentPrompts, setRecentPrompts] = useState<PromptEntry[]>([]);
+ const [recentLists, setRecentLists] = useState<PromptListEntry[]>([]);
+ const recentSeqRef = useRef(0);
const refreshRecentPrompts = useCallback(async () => {
+ recentSeqRef.current += 1;
+ const seq = recentSeqRef.current;
try {
const rows = await listPromptEntries();
+ if (seq !== recentSeqRef.current) return;
const byRecent = [...rows].sort((a, b) => b.updatedAt - a.updatedAt);
// Pinned prompts take over the submenu; fall back to the 3 most recent.
const pinnedIds = usePlusMenuPrefsStore.getState().pinnedPromptIds;
const pinned = byRecent.filter((p) => pinnedIds.includes(p.id));
setRecentPrompts(pinned.length > 0 ? pinned : byRecent.slice(0, 3));
} catch {
+ // Clear, don't keep: a stale list row would run its cached items.
+ if (seq === recentSeqRef.current) setRecentPrompts([]);
+ }
+ try {
+ const rows = await listPromptLists();
+ if (seq !== recentSeqRef.current) return;
+ const pinnedIds = usePlusMenuPrefsStore.getState().pinnedListIds;
+ setRecentLists(rows.filter((l) => pinnedIds.includes(l.id)));
+ } catch {
+ if (seq === recentSeqRef.current) setRecentLists([]);
}
}, []);
const plusPins = usePlusMenuPrefsStore((s) => s.pins);
@@ -1051,7 +1076,7 @@ export function SharedComposer({
ta.style.overflowY = ta.scrollHeight > maxHeight ? "auto" : "hidden";
}, [text]);
- const addFiles = useCallback(
+ const addFilesUntracked = useCallback(
async (input: FileList | readonly File[] | null) => {
if (!input?.length) return;
// Compare takes audio, so an audio-only 3GP must not be read off its
@@ -1071,10 +1096,18 @@ export function SharedComposer({
audioSizeError ??= sizeError;
continue;
}
- fileToBase64(file).then((base64) => {
- setPendingAudio({ name: file.name, base64, contentType: file.type });
- setPendingAudioStore(base64, file.name);
- });
+ audioDecodingRef.current += 1;
+ fileToBase64(file)
+ .then((base64) => {
+ setPendingAudio({ name: file.name, base64, contentType: file.type });
+ setPendingAudioStore(base64, file.name);
+ })
+ .catch(() => {
+ toast.error("Could not read that audio file.");
+ })
+ .finally(() => {
+ audioDecodingRef.current -= 1;
+ });
continue;
}
// video_base64 targets the single loaded GGUF, so at most one side of a compare could answer. Say
@@ -1121,30 +1154,46 @@ export function SharedComposer({
[setPendingAudioStore, attachUnavailableReason],
);
+ const trackAttaching = useCallback(async (work: () => Promise<void>) => {
+ attachingRef.current += 1;
+ try {
+ await work();
+ } finally {
+ attachingRef.current -= 1;
+ }
+ }, []);
+
+ const addFiles = useCallback(
+ (input: FileList | readonly File[] | null) =>
+ trackAttaching(() => addFilesUntracked(input)),
+ [trackAttaching, addFilesUntracked],
+ );
+
const handleFilePaste = useCallback(
(event: ClipboardEvent<HTMLTextAreaElement>) => {
pasteClipboardFiles(
event,
- async (pasted) => {
- // Classify before the check, so a pasted audio-only 3GP is not read
- // as unsupported on its extension alone.
- const files = await classifiedAttachmentFiles(pasted);
- // Let addFiles report audio size errors.
- const supported = files.some(
- (file) =>
- isAudioAttachmentFile(file) ||
- (isChatImageFile(file) && file.size <= MAX_IMAGE_SIZE),
- );
- if (!supported) throw new Error("Unsupported compare attachment");
- await addFiles(files);
- },
+ (pasted) =>
+ trackAttaching(async () => {
+ // Classify before the check, so a pasted audio-only 3GP is not read
+ // as unsupported on its extension alone.
+ const files = await classifiedAttachmentFiles(pasted);
+ // Let addFiles report audio size errors.
+ const supported = files.some(
+ (file) =>
+ isAudioAttachmentFile(file) ||
+ (isChatImageFile(file) && file.size <= MAX_IMAGE_SIZE),
+ );
+ if (!supported) throw new Error("Unsupported compare attachment");
+ await addFilesUntracked(files);
+ }),
() =>
toast.error("Could not paste files.", {
description: "Compare supports images and audio within the attachment size limits.",
}),
);
},
- [addFiles],
+ [trackAttaching, addFilesUntracked],
);
const removePendingImage = useCallback((id: string) => {
@@ -2139,6 +2188,75 @@ export function SharedComposer({
{ enabled: chatActive },
);
+ const runPromptList = useCallback(
+ (items: string[]) => {
+ const filtered = items.filter((p) => p.trim());
+ if (!filtered.length) return;
+ // `running` lags the 200ms poll, so ask the handles directly like the poll does.
+ const liveRunning =
+ busy || Object.values(handlesRef.current).some((h) => h.isRunning());
+ if (liveRunning || isQueueRunningRef.current) {
+ toast.error("Wait for the current response to finish");
+ return;
+ }
+ // A compare send holds the loading lease while it prepares, before `comparing` is set.
+ if (useChatRuntimeStore.getState().modelLoading) {
+ toast.info("A model is loading", {
+ description: "Wait for it to finish or cancel it first.",
+ });
+ return;
+ }
+ if (isDictating) {
+ toast.error("Finish dictating before running a list");
+ return;
+ }
+ // send() cancels an in-flight transcription, which would discard it.
+ if (audioUpload.busy) {
+ toast.error("Wait for the transcription to finish before running a list");
+ return;
+ }
+ // Only the first send would carry staged attachments; refuse rather than clear.
+ if (
+ pendingImagesRef.current.length > 0 ||
+ pendingAudioRef.current ||
+ audioDecodingRef.current > 0 ||
+ attachingRef.current > 0
+ ) {
+ toast.error("Remove the staged attachment before running a list", {
+ description: "Only the first prompt in the list would carry it.",
+ });
+ return;
+ }
+ const hasCompareHandles = Boolean(
+ handlesRef.current["model1"] || handlesRef.current["model2"],
+ );
+ const isGeneralizedCompare =
+ hasCompareHandles && Boolean(model1?.id && model2?.id);
+ if (hasCompareHandles && !isGeneralizedCompare) {
+ toast.error("Pick a model in each pane to compare", {
+ description:
+ "Use the model dropdown above each pane, then send your prompt.",
+ });
+ return;
+ }
+ setPromptStorageOpen(false);
+ queueRef.current = filtered;
+ queueIndexRef.current = 0;
+ isQueueRunningRef.current = true;
+ setIsQueueRunning(true);
+ setQueueProgress({ current: 1, total: filtered.length });
+ toast(`Prompt 1 / ${filtered.length}`, {
+ description:
+ filtered[0].length > 80 ? `${filtered[0].slice(0, 80)}…` : filtered[0],
+ });
+ setCurrentText(filtered[0]);
+ setTimeout(() => {
+ sendRef.current?.();
+ }, 100);
+ },
+ [busy, isDictating, audioUpload.busy, handlesRef, model1?.id, model2?.id, setCurrentText],
+ );
+
// Adjustable "+" menu items, keyed by id. Pinned ones render at the top level; the rest fall into
// the "More" overflow submenu. Core items and "More" itself live outside this map.
const plusMenuNodes: Record<PlusMenuItemId, ReactNode> = {
@@ -2188,7 +2306,7 @@ export function SharedComposer({
>
{recentPrompts.map((p) => (
<DropdownMenuItem
- key={p.id}
+ key={`prompt:${p.id}`}
onSelect={() => {
setCurrentText(p.text);
requestAnimationFrame(() => textareaRef.current?.focus());
@@ -2197,7 +2315,15 @@ export function SharedComposer({
<span className="truncate">{p.name}</span>
</DropdownMenuItem>
))}
- {recentPrompts.length > 0 ? <DropdownMenuSeparator /> : null}
+ {recentLists.map((l) => (
+ <DropdownMenuItem key={`list:${l.id}`} onSelect={() => runPromptList(l.items)}>
+ <span className="truncate">{l.name}</span>
+ <PromptCountBadge count={l.items.length} />
+ </DropdownMenuItem>
+ ))}
+ {recentPrompts.length > 0 || recentLists.length > 0 ? (
+ <DropdownMenuSeparator />
+ ) : null}
<DropdownMenuItem onSelect={() => setPromptStorageOpen(true)}>
All saved prompts…
</DropdownMenuItem>
@@ -2336,33 +2462,7 @@ export function SharedComposer({
setCurrentText(t);
requestAnimationFrame(() => textareaRef.current?.focus());
}}
- onRunList={(items) => {
- const filtered = items.filter((p) => p.trim());
- if (!filtered.length) return;
- const hasCompareHandles = Boolean(
- handlesRef.current["model1"] || handlesRef.current["model2"],
- );
- const isGeneralizedCompare =
- hasCompareHandles && Boolean(model1?.id && model2?.id);
- if (hasCompareHandles && !isGeneralizedCompare) {
- toast.error("Pick a model in each pane to compare", {
- description:
- "Use the model dropdown above each pane, then send your prompt.",
- });
- return;
- }
- setPromptStorageOpen(false);
- queueRef.current = filtered;
- queueIndexRef.current = 0;
- isQueueRunningRef.current = true;
- setIsQueueRunning(true);
- setQueueProgress({ current: 1, total: filtered.length });
- toast(`Prompt 1 / ${filtered.length}`, {
- description: filtered[0].length > 80 ? filtered[0].slice(0, 80) + "…" : filtered[0],
- });
- setCurrentText(filtered[0]);
- setTimeout(() => { sendRef.current?.(); }, 100);
- }}
+ onRunList={runPromptList}
/>
{/* Gemini-style drop affordance, mirrored from the single composer. */}
<div
diff --git a/studio/frontend/src/features/chat/stores/plus-menu-prefs-store.ts b/studio/frontend/src/features/chat/stores/plus-menu-prefs-store.ts
index 73364dfb8c7..00f55afd530 100644
--- a/studio/frontend/src/features/chat/stores/plus-menu-prefs-store.ts
+++ b/studio/frontend/src/features/chat/stores/plus-menu-prefs-store.ts
@@ -52,6 +52,8 @@ export interface PlusMenuPrefsState {
// the menu pins above, since prompts are addressed by their stable server id.
pinnedPromptIds: string[];
togglePinnedPrompt: (id: string) => void;
+ pinnedListIds: string[];
+ togglePinnedList: (id: string) => void;
}
export const usePlusMenuPrefsStore = create<PlusMenuPrefsState>()(
@@ -69,6 +71,13 @@ export const usePlusMenuPrefsStore = create<PlusMenuPrefsState>()(
? state.pinnedPromptIds.filter((x) => x !== id)
: [...state.pinnedPromptIds, id],
})),
+ pinnedListIds: [],
+ togglePinnedList: (id) =>
+ set((state) => ({
+ pinnedListIds: state.pinnedListIds.includes(id)
+ ? state.pinnedListIds.filter((x) => x !== id)
+ : [...state.pinnedListIds, id],
+ })),
}),
{
name: PLUS_MENU_PINS_STORAGE_KEY,
@@ -81,6 +90,7 @@ export const usePlusMenuPrefsStore = create<PlusMenuPrefsState>()(
...current,
pins: { ...DEFAULT_PINS, ...(saved?.pins ?? {}) },
pinnedPromptIds: saved?.pinnedPromptIds ?? [],
+ pinnedListIds: saved?.pinnedListIds ?? [],
};
},
},
diff --git a/studio/frontend/tests/chat-audio-upload.test.ts b/studio/frontend/tests/chat-audio-upload.test.ts
index 188fd103d43..605fecf7641 100644
--- a/studio/frontend/tests/chat-audio-upload.test.ts
+++ b/studio/frontend/tests/chat-audio-upload.test.ts
@@ -487,10 +487,13 @@ test("Compare queue setup preserves an upload until a queued send is accepted",
);
assert.doesNotMatch(advanceQueue, /audioUpload\.cancel\(\)/);
- const runListStart = sharedComposerSource.indexOf("onRunList={(items) => {");
+ // The dialog's Run button and bookmarked lists share runPromptList.
+ assert.match(sharedComposerSource, /onRunList=\{runPromptList\}/);
+ const runListStart = sharedComposerSource.indexOf("const runPromptList = useCallback(");
+ assert.ok(runListStart >= 0);
const runList = sharedComposerSource.slice(
runListStart,
- sharedComposerSource.indexOf(" }}", runListStart),
+ sharedComposerSource.indexOf("\n );", runListStart),
);
const incompleteModelGuard = runList.indexOf(
"if (hasCompareHandles && !isGeneralizedCompare)",
diff --git a/studio/frontend/tests/prompt-list-drag-autoscroll.test.ts b/studio/frontend/tests/prompt-list-drag-autoscroll.test.ts
new file mode 100644
index 00000000000..03862bf0e88
--- /dev/null
+++ b/studio/frontend/tests/prompt-list-drag-autoscroll.test.ts
@@ -0,0 +1,78 @@
+// 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 {
+ AUTOSCROLL_EDGE,
+ AUTOSCROLL_MAX_STEP,
+ autoscrollDelta,
+ clipSpan,
+} from "../src/features/chat/prompt-storage/autoscroll.ts";
+
+const TOP = 100;
+const BOTTOM = 500;
+
+test("a pointer in the middle of the pane does not scroll it", () => {
+ assert.equal(autoscrollDelta(300, TOP, BOTTOM), 0);
+ assert.equal(autoscrollDelta(TOP + AUTOSCROLL_EDGE, TOP, BOTTOM), 0);
+ assert.equal(autoscrollDelta(BOTTOM - AUTOSCROLL_EDGE, TOP, BOTTOM), 0);
+});
+
+test("nearing the top edge scrolls up, nearing the bottom scrolls down", () => {
+ assert.ok(autoscrollDelta(TOP + 10, TOP, BOTTOM) < 0);
+ assert.ok(autoscrollDelta(BOTTOM - 10, TOP, BOTTOM) > 0);
+});
+
+test("the step ramps with depth into the edge band", () => {
+ const shallow = autoscrollDelta(BOTTOM - AUTOSCROLL_EDGE + 1, TOP, BOTTOM);
+ const deep = autoscrollDelta(BOTTOM - 1, TOP, BOTTOM);
+ assert.ok(deep > shallow);
+ assert.ok(shallow > 0);
+});
+
+test("the step is capped at the maximum even far past the edge", () => {
+ assert.equal(autoscrollDelta(BOTTOM + 5000, TOP, BOTTOM), AUTOSCROLL_MAX_STEP);
+ assert.equal(autoscrollDelta(TOP - 5000, TOP, BOTTOM), -AUTOSCROLL_MAX_STEP);
+});
+
+test("a pane shorter than two edge bands still picks a single direction", () => {
+ const shortTop = 0;
+ const shortBottom = 40;
+ const up = autoscrollDelta(2, shortTop, shortBottom);
+ const down = autoscrollDelta(38, shortTop, shortBottom);
+ assert.ok(up < 0);
+ assert.ok(down > 0);
+ assert.equal(autoscrollDelta(20, shortTop, shortBottom), 0);
+});
+
+test("a zero-height pane never scrolls", () => {
+ assert.equal(autoscrollDelta(50, 50, 50), 0);
+});
+
+test("an unclipped pane keeps its own span", () => {
+ assert.deepEqual(clipSpan({ top: TOP, bottom: BOTTOM }, []), {
+ top: TOP,
+ bottom: BOTTOM,
+ });
+});
+
+test("a pane clipped by an ancestor reports the visible span", () => {
+ // The list pane runs past the bottom of the dialog body that scrolls it.
+ const span = clipSpan({ top: 100, bottom: 900 }, [{ top: 0, bottom: 400 }]);
+ assert.deepEqual(span, { top: 100, bottom: 400 });
+});
+
+test("clipping is what puts the edge back within the pointer's reach", () => {
+ const pane = { top: 100, bottom: 2000 };
+ const viewport = { top: 0, bottom: 800 };
+ assert.equal(autoscrollDelta(790, pane.top, pane.bottom), 0);
+ const span = clipSpan(pane, [viewport]);
+ assert.ok(span);
+ assert.ok(autoscrollDelta(790, span.top, span.bottom) > 0);
+});
+
+test("a pane scrolled entirely out of view has no span", () => {
+ assert.equal(clipSpan({ top: 500, bottom: 900 }, [{ top: 0, bottom: 400 }]), null);
+ assert.equal(clipSpan({ top: 400, bottom: 900 }, [{ top: 0, bottom: 400 }]), null);
+});