mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
Only fetch session tokens when chat state is idle to avoid resetting during streaming (#4104)
This commit is contained in:
@@ -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 => {
|
||||
@@ -211,10 +212,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(() => {
|
||||
|
||||
Reference in New Issue
Block a user