From f861a311871ec6717d7f9050eb9146bcd98dcf96 Mon Sep 17 00:00:00 2001 From: David Katz Date: Fri, 22 Aug 2025 11:49:36 -0400 Subject: [PATCH 1/2] get rid of faking out of context --- ui/desktop/src/components/BaseChat.tsx | 105 +++++++++++-------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/ui/desktop/src/components/BaseChat.tsx b/ui/desktop/src/components/BaseChat.tsx index e075897c25f8..e79c64a9fd38 100644 --- a/ui/desktop/src/components/BaseChat.tsx +++ b/ui/desktop/src/components/BaseChat.tsx @@ -119,7 +119,7 @@ function BaseChatContent({ const [hasStartedUsingRecipe, setHasStartedUsingRecipe] = React.useState(false); const [currentRecipeTitle, setCurrentRecipeTitle] = React.useState(null); - const { isCompacting } = useContextManager(); + const { isCompacting, handleManualCompaction } = useContextManager(); // Use shared chat engine const { @@ -383,67 +383,54 @@ function BaseChatContent({ )} - {error && - !(error as Error & { isTokenLimitError?: boolean }).isTokenLimitError && ( - <> -
-
- {error.message || 'Honk! Goose experienced an error while responding'} -
+ {error && ( + <> +
+
+ {error.message || 'Honk! Goose experienced an error while responding'} +
- {/* 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 -
+ {/* Action buttons for all errors including token limit errors */} +
+
{ + // Clear the error state first + clearError(); + + // Use the same manual compaction function that the "Compact" button in the + // context window alert uses. This properly calls the backend summarization API + // and handles the response correctly. + await handleManualCompaction( + messages, + setMessages, + append, + undefined, // clearAlerts - not needed here since we don't have alerts to clear + setAncestorMessages + ); + }} + > + 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
- - )} - - {/* Token limit errors should be handled by ContextHandler, not shown here */} - {error && - (error as Error & { isTokenLimitError?: boolean }).isTokenLimitError && <>} +
+ + )}
) : showPopularTopics ? ( From ddf7560ae4a506824133d25b9dd9ef3890e58ae0 Mon Sep 17 00:00:00 2001 From: David Katz Date: Fri, 22 Aug 2025 11:51:35 -0400 Subject: [PATCH 2/2] rm comments --- ui/desktop/src/components/BaseChat.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ui/desktop/src/components/BaseChat.tsx b/ui/desktop/src/components/BaseChat.tsx index e79c64a9fd38..076be0dbf016 100644 --- a/ui/desktop/src/components/BaseChat.tsx +++ b/ui/desktop/src/components/BaseChat.tsx @@ -395,12 +395,8 @@ function BaseChatContent({
{ - // Clear the error state first clearError(); - // Use the same manual compaction function that the "Compact" button in the - // context window alert uses. This properly calls the backend summarization API - // and handles the response correctly. await handleManualCompaction( messages, setMessages,