Skip to content
Merged
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
6 changes: 4 additions & 2 deletions ui/desktop/src/hooks/useChatEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
TextContent,
} from '../types/message';
import { ChatType } from '../types/chat';
import { ChatState } from '../types/chatState';

// Helper function to determine if a message is a user message
const isUserMessage = (message: Message): boolean => {
Expand Down Expand Up @@ -208,10 +209,11 @@ export const useChatEngine = ({
console.error('Error fetching session token count:', err);
}
};
if (chat.id) {
// Only fetch session tokens when chat state is idle to avoid resetting during streaming
if (chat.id && chatState === ChatState.Idle) {
fetchSessionTokens();
}
}, [chat.id, messages]);
}, [chat.id, messages, chatState]);

// Update token counts when sessionMetadata changes from the message stream
useEffect(() => {
Expand Down
Loading