fix: prevent 'active request' error from showing blocking error screen (#8398)

Signed-off-by: Michael Neale <michael.neale@gmail.com>
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
Michael Neale
2026-04-09 15:04:16 +10:00
committed by GitHub
parent e200a896a2
commit 331d1e2efb
2 changed files with 14 additions and 2 deletions
@@ -130,6 +130,7 @@ impl SessionEventBus {
request_id: String, request_id: String,
) -> Result<CancellationToken, String> { ) -> Result<CancellationToken, String> {
let mut requests = self.active_requests.lock().await; let mut requests = self.active_requests.lock().await;
requests.retain(|_id, token| !token.is_cancelled());
if !requests.is_empty() { if !requests.is_empty() {
return Err("Session already has an active request".into()); return Err("Session already has an active request".into());
} }
+13 -2
View File
@@ -643,7 +643,12 @@ export function useChatStream({
activeRequestSessionIdRef.current = null; activeRequestSessionIdRef.current = null;
activeAbortRef.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] [addListener, onFinish, reloadConversation]
@@ -783,7 +788,13 @@ export function useChatStream({
const { msg: userMessage, images } = input; const { msg: userMessage, images } = input;
const currentState = stateRef.current; 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; return;
} }