fix(webui): keep queued prompts scoped across session switches

This commit is contained in:
chengyongru authored and chengyongru committed 2026-09-08 15:16:54 +08:00
1 parent f47b8f2315
commit 2b6c91472b
2 files changed
+43 -5

No files matched your search

+10 -5
View File
@@ -963,7 +963,7 @@ export function ThreadComposer({
const secondEnterPromptIdRef = useRef<string | null>(null);
const draggedQueuedPromptIdRef = useRef<string | null>(null);
const previousPendingQueueKeyRef = useRef(pendingQueueKey);
const wasStreamingRef = useRef(isStreaming);
const previousQueueRunRef = useRef({ key: pendingQueueKey, isStreaming });
const skipNextQueuedFlushRef = useRef(false);
const skipQueuedPromptPersistRef = useRef(false);
const voiceShortcutDownRef = useRef(false);
@@ -1895,16 +1895,21 @@ export function ThreadComposer({
}, [onSend, queuedPrompts]);
useEffect(() => {
const wasStreaming = wasStreamingRef.current;
wasStreamingRef.current = isStreaming;
const previous = previousQueueRunRef.current;
previousQueueRunRef.current = { key: pendingQueueKey, isStreaming };
if (!isStreaming) secondEnterPromptIdRef.current = null;
if (!wasStreaming || isStreaming || queuedPrompts.length === 0) return;
// Switching to an idle session is not completion of the previous session's run.
if (previous.key !== pendingQueueKey) {
skipNextQueuedFlushRef.current = false;
return;
}
if (!previous.isStreaming || isStreaming || queuedPrompts.length === 0) return;
if (skipNextQueuedFlushRef.current) {
skipNextQueuedFlushRef.current = false;
return;
}
sendNextQueuedPrompt();
}, [sendNextQueuedPrompt, isStreaming, queuedPrompts.length]);
}, [sendNextQueuedPrompt, isStreaming, pendingQueueKey, queuedPrompts.length]);
const handleStop = useCallback(() => {
secondEnterPromptIdRef.current = null;