diff --git a/ui/desktop/src/components/BaseChat.tsx b/ui/desktop/src/components/BaseChat.tsx index 44fd7e7216ad..e51e74744069 100644 --- a/ui/desktop/src/components/BaseChat.tsx +++ b/ui/desktop/src/components/BaseChat.tsx @@ -157,6 +157,7 @@ function BaseChatContent({ updateMessageStreamBody, sessionMetadata, isUserMessage, + clearError, } = useChatEngine({ chat, setChat, @@ -434,21 +435,51 @@ function BaseChatContent({ {error.message || 'Honk! Goose experienced an error while responding'} - {/* Regular retry button for non-token-limit errors */} -
{ - // Find the last user message - const lastUserMessage = messages.reduceRight( - (found, m) => found || (m.role === 'user' ? m : null), - null as Message | null - ); - if (lastUserMessage) { - append(lastUserMessage); - } - }} - > - Retry Last Message + {/* Action buttons for non-token-limit errors */} +
+
{ + // Create a contextLengthExceeded message similar to token limit errors + const contextMessage: Message = { + id: `context-${Date.now()}`, + role: 'assistant', + created: Math.floor(Date.now() / 1000), + content: [ + { + type: 'contextLengthExceeded', + msg: 'Summarization requested due to error. Creating summary to help resolve the issue.', + }, + ], + display: true, + sendToLLM: false, + }; + + // Add the context message to trigger ContextHandler + const updatedMessages = [...messages, contextMessage]; + setMessages(updatedMessages); + + // Clear the error state since we're handling it with summarization + clearError(); + }} + > + Summarize Conversation +
+
{ + // Find the last user message + const lastUserMessage = messages.reduceRight( + (found, m) => found || (m.role === 'user' ? m : null), + null as Message | null + ); + if (lastUserMessage) { + append(lastUserMessage); + } + }} + > + Retry Last Message +
@@ -472,7 +503,7 @@ function BaseChatContent({ {/* Fixed loading indicator at bottom left of chat container */} {isLoading && (
- setError(undefined), }; }; diff --git a/ui/desktop/src/hooks/useMessageStream.ts b/ui/desktop/src/hooks/useMessageStream.ts index 83ecc9e9ff1d..4850e8b1a2c0 100644 --- a/ui/desktop/src/hooks/useMessageStream.ts +++ b/ui/desktop/src/hooks/useMessageStream.ts @@ -173,6 +173,9 @@ export interface UseMessageStreamHelpers { /** Session metadata including token counts */ sessionMetadata: SessionMetadata | null; + + /** Clear error state */ + setError: (error: Error | undefined) => void; } /** @@ -709,5 +712,6 @@ export function useMessageStream({ notifications, currentModelInfo, sessionMetadata, + setError, }; }