From 331d1e2efb0c913d78127f89677dad0dcce53480 Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Thu, 9 Apr 2026 15:04:16 +1000 Subject: [PATCH] fix: prevent 'active request' error from showing blocking error screen (#8398) Signed-off-by: Michael Neale Signed-off-by: Douwe Osinga Co-authored-by: Douwe Osinga --- crates/goose-server/src/session_event_bus.rs | 1 + ui/desktop/src/hooks/useChatStream.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/goose-server/src/session_event_bus.rs b/crates/goose-server/src/session_event_bus.rs index 7a9e1974..aa94231c 100644 --- a/crates/goose-server/src/session_event_bus.rs +++ b/crates/goose-server/src/session_event_bus.rs @@ -130,6 +130,7 @@ impl SessionEventBus { request_id: String, ) -> Result { let mut requests = self.active_requests.lock().await; + requests.retain(|_id, token| !token.is_cancelled()); if !requests.is_empty() { return Err("Session already has an active request".into()); } diff --git a/ui/desktop/src/hooks/useChatStream.ts b/ui/desktop/src/hooks/useChatStream.ts index 0306b3ea..0121eaf5 100644 --- a/ui/desktop/src/hooks/useChatStream.ts +++ b/ui/desktop/src/hooks/useChatStream.ts @@ -643,7 +643,12 @@ export function useChatStream({ activeRequestSessionIdRef.current = null; activeAbortRef.current = null; } - onFinish('Submit error: ' + errorMessage(error)); + const msg = errorMessage(error); + if (msg.includes('already has an active request')) { + dispatch({ type: 'SET_CHAT_STATE', payload: ChatState.Idle }); + } else { + onFinish('Submit error: ' + msg); + } } }, [addListener, onFinish, reloadConversation] @@ -783,7 +788,13 @@ export function useChatStream({ const { msg: userMessage, images } = input; const currentState = stateRef.current; - if (!currentState.session || currentState.chatState === ChatState.LoadingConversation) { + if ( + !currentState.session || + currentState.chatState === ChatState.LoadingConversation || + currentState.chatState === ChatState.Streaming || + currentState.chatState === ChatState.Thinking || + currentState.chatState === ChatState.Compacting + ) { return; }