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: tighten the prompt queue pause comments

danielhanchend5c9ac310ebc
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index a91f54d99c6..c5e20492e56 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -3075,9 +3075,7 @@ export function AppSidebar() {
item.type === "compare"
? (item.threadIds ?? []).some((id) => Boolean(runningByThreadId[id]))
: Boolean(runningByThreadId[item.id]);
- // A paused queue is not activity. The entry survives a Stop now that the composer
- // pauses instead of deleting the run, so without this the row keeps spinning for
- // work the user explicitly stopped, with nothing left to ever clear it.
+ // A paused queue is not activity: its entry outlives Stop, so the row would spin on.
const hasQueuedActivity = threadIds.some((threadId) => {
const entry = queueByThreadId[threadId];
return Boolean(entry) && !entry.paused;
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index cb7c1c49c05..7b331981334 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -708,12 +708,7 @@ function pumpPromptQueues() {
dispatchQueuedPrompt(run, item, run.generation)
.catch(() => undefined)
.finally(() => {
- // The dispatching flag is keyed on the run, not on the attempt, so a
- // dispatch that a pause superseded would release the flag a LIVE dispatch
- // is holding. Pausing bumps the generation and clears the flag, so after
- // Stop then Resume the old attempt's probe can settle while the new one is
- // still in flight: it frees the flag, re-pumps, and the same prompt is
- // appended twice. Only the attempt that still owns the generation releases.
+ // Releasing a live attempt's flag makes Stop then Resume append twice.
if (
promptQueueRuns.get(run.id) === run &&
dispatchGeneration !== run.generation
@@ -1315,9 +1310,7 @@ function pausePromptQueueRun(threadIds?: string[]) {
deletePromptQueueRun(run);
} else {
run.items = plan.retainedItemIndexes.map((index) => run.items[index]);
- // Scan from where the run actually was, not from the head of the list. A
- // findIndex from 0 rewinds onto any undispatched item the run has already
- // moved past, so Resume would send it AFTER prompts that already went out.
+ // From 0 this rewinds onto an item already passed, replaying it out of order.
const resumeFrom = plan.retainedItemIndexes.findIndex(
(index) => index >= Math.max(run.index, 0),
);
@@ -1361,15 +1354,8 @@ function resumePromptQueueRun(threadIds?: string[]) {
continue;
}
run.paused = false;
- // prevStoreRunning is the one that matters. handlePromptQueueRunState writes it
- // BEFORE its `if (run.paused) return`, so a rising edge seen while paused (the
- // user stops the queue and then sends an ordinary message in the same chat, or a
- // shared alias picks up another run) is left behind. Clearing paused without
- // clearing this lets the following idle edge take the advancePromptQueue branch,
- // which completes and SKIPS the first retained prompt without ever sending it --
- // the same silent prompt loss this PR set out to fix, through the new path.
- // The other two are defensive: pausePromptQueueRun already clears the idle wait,
- // and an edit-armed retry timer self-clears.
+ // prevStoreRunning is recorded before the paused early-return, so a stale rising
+ // edge would let the next idle edge skip a prompt. The other two are defensive.
run.waitingForTargetIdle = false;
run.prevStoreRunning = false;
clearPromptQueueRetryTimer(run);
diff --git a/studio/frontend/src/features/chat/utils/confirm-stop-running-chats.ts b/studio/frontend/src/features/chat/utils/confirm-stop-running-chats.ts
index 77f52acbf33..c43e6382b4b 100644
--- a/studio/frontend/src/features/chat/utils/confirm-stop-running-chats.ts
+++ b/studio/frontend/src/features/chat/utils/confirm-stop-running-chats.ts
@@ -70,9 +70,7 @@ export async function confirmStopRunningChatsIfNeeded(
const aliasesByQueuedRun = new Map<string, string[]>();
for (const threadId of promptQueueThreadIds) {
const entry = promptQueuesByThreadId[threadId];
- // A paused queue is not a running chat. Its entry outlives the composer Stop
- // now that Stop pauses rather than deletes the run, so counting it here would
- // put a chat the user has already stopped into the "still running" list.
+ // A paused queue is not a running chat: its entry outlives Stop.
if (!entry || entry.paused) {
continue;
}
diff --git a/tests/studio/test_prompt_queue_pause_side_effects.py b/tests/studio/test_prompt_queue_pause_side_effects.py
index ed6d0e8535b..55aa17544b8 100644
--- a/tests/studio/test_prompt_queue_pause_side_effects.py
+++ b/tests/studio/test_prompt_queue_pause_side_effects.py
@@ -1,13 +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
-"""Contracts for the paths a paused prompt queue reaches without being edited by it.
-
-Pausing instead of deleting keeps the run, and therefore its PromptQueueUIEntry,
-alive after the user presses Stop. Everything that treated "an entry exists" as
-"work is happening" silently starts reporting a chat the user has already stopped.
-These pin the three places that had to learn about `paused`.
-"""
+"""A paused run keeps its PromptQueueUIEntry, so every reader of "an entry exists"
+had to learn about `paused`. These pin those places and the two dispatch races."""
from pathlib import Path
@@ -22,8 +17,6 @@ CONFIRM = (
def test_the_sidebar_work_spinner_ignores_a_paused_queue():
- # Measured before the guard: BEFORE 0 sidebar spinners after Stop settled,
- # AFTER 1, on the same probe against two builds of the same commit pair.
block = SIDEBAR.split("const hasQueuedActivity", 1)[1]
block = block.split("const showQueuedActivity", 1)[0]
assert "entry.paused" in block
@@ -36,9 +29,6 @@ def test_a_paused_queue_is_not_a_running_chat_in_the_stop_dialog():
def test_resume_clears_the_stale_running_edge_so_it_cannot_skip_a_prompt():
- # handlePromptQueueRunState records prevStoreRunning before it returns for a paused
- # run, so a rising edge seen while paused survives. Resuming without clearing it
- # lets the next idle edge advance past the first retained prompt without sending it.
resume = THREAD.split("function resumePromptQueueRun(threadIds?: string[])", 1)[1]
resume = resume.split("function stopPromptQueueRun", 1)[0]
assert "run.prevStoreRunning = false" in resume
@@ -47,8 +37,6 @@ def test_resume_clears_the_stale_running_edge_so_it_cannot_skip_a_prompt():
def test_a_superseded_dispatch_does_not_release_the_live_dispatch_flag():
- # Without this the same prompt is appended twice when Stop then Resume happen
- # while a document-indexing probe is still outstanding.
pump = THREAD.split("function pumpPromptQueues()", 1)[1]
pump = pump.split("async function dispatchQueuedPrompt(", 1)[0]
assert "const dispatchGeneration = run.generation" in pump