mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend/copilot): reconnect on transient API errors to show Try Again button
StreamError.to_sse() strips the code field per AI SDK protocol, so the frontend can't detect retryable errors from the live SSE event alone. The retryable prefix is only in the persisted session message. Fix by triggering a reconnect (session reload) when the error text matches a transient API error, so the persisted retryable marker is loaded and the "Try Again" button appears immediately.
This commit is contained in:
@@ -222,12 +222,17 @@ export function useCopilotStream({
|
||||
return;
|
||||
}
|
||||
|
||||
// Only reconnect on network errors (not HTTP errors), and never
|
||||
// reconnect when the user explicitly stopped the stream.
|
||||
// Reconnect on network errors or transient API errors so the
|
||||
// persisted retryable-error marker is loaded and the "Try Again"
|
||||
// button appears. Without this, transient errors only show in the
|
||||
// onError callback (where StreamError strips the retryable prefix).
|
||||
if (isUserStoppingRef.current) return;
|
||||
const isNetworkError =
|
||||
error.name === "TypeError" || error.name === "AbortError";
|
||||
if (isNetworkError) {
|
||||
const isTransientApiError = errorDetail.includes(
|
||||
"connection interrupted",
|
||||
);
|
||||
if (isNetworkError || isTransientApiError) {
|
||||
handleReconnect(sessionId);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user