Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions ui/desktop/src/components/BaseChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ function BaseChatContent({
updateMessageStreamBody,
sessionMetadata,
isUserMessage,
clearError,
} = useChatEngine({
chat,
setChat,
Expand Down Expand Up @@ -434,21 +435,51 @@ function BaseChatContent({
{error.message || 'Honk! Goose experienced an error while responding'}
</div>

{/* Regular retry button for non-token-limit errors */}
<div
className="px-3 py-2 mt-2 text-center whitespace-nowrap cursor-pointer text-textStandard border border-borderSubtle hover:bg-bgSubtle rounded-full inline-block transition-all duration-150"
onClick={async () => {
// 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 */}
<div className="flex gap-2 mt-2">
<div
className="px-3 py-2 text-center whitespace-nowrap cursor-pointer text-textStandard border border-borderSubtle hover:bg-bgSubtle rounded-full inline-block transition-all duration-150"
onClick={async () => {
// 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
</div>
<div
className="px-3 py-2 text-center whitespace-nowrap cursor-pointer text-textStandard border border-borderSubtle hover:bg-bgSubtle rounded-full inline-block transition-all duration-150"
onClick={async () => {
// 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
</div>
</div>
</div>
</>
Expand All @@ -472,7 +503,7 @@ function BaseChatContent({
{/* Fixed loading indicator at bottom left of chat container */}
{isLoading && (
<div className="absolute bottom-1 left-4 z-20 pointer-events-none">
<LoadingGoose
<LoadingGoose
message={isLoadingSummary ? 'summarizing conversation…' : undefined}
isWaiting={isWaiting}
isStreaming={isStreaming}
Expand Down
4 changes: 4 additions & 0 deletions ui/desktop/src/hooks/useChatEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const useChatEngine = ({
updateMessageStreamBody,
notifications,
sessionMetadata,
setError,
} = useMessageStream({
api: getApiUrl('/reply'),
id: chat.id,
Expand Down Expand Up @@ -402,5 +403,8 @@ export const useChatEngine = ({

// Utilities
isUserMessage,

// Error management
clearError: () => setError(undefined),
};
};
4 changes: 4 additions & 0 deletions ui/desktop/src/hooks/useMessageStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ export interface UseMessageStreamHelpers {

/** Session metadata including token counts */
sessionMetadata: SessionMetadata | null;

/** Clear error state */
setError: (error: Error | undefined) => void;
}

/**
Expand Down Expand Up @@ -709,5 +712,6 @@ export function useMessageStream({
notifications,
currentModelInfo,
sessionMetadata,
setError,
};
}
Loading