Improve SessionManager logic

This commit is contained in:
Alex Gleason committed 2025-09-11 14:05:01 -05:00
1 parent 11b9aa9e20
commit d7fc8f62e8
2 files changed
+32 -37

No files matched your search

+5 -3
View File
@@ -73,12 +73,16 @@ export function useAIChat({
};
initSession();
}, [sessionManager, projectId, tools, customTools, systemPrompt, maxSteps]);
}, [sessionManager, projectId, tools, customTools, maxSteps, systemPrompt]);
// Subscribe to atomic session events for efficient updates
useSessionSubscription('messageAdded', (updatedProjectId: string, message: AIMessage) => {
if (updatedProjectId === projectId) {
setMessages(prev => [...prev, message]);
// Whenever an assistant message is added, it means streaming is done (until we get another streamingUpdate)
if (message.role === 'assistant') {
setStreamingMessage(undefined);
}
}
}, [projectId]);
@@ -119,8 +123,6 @@ export function useAIChat({
}
}, [projectId]);
// Actions
const sendMessage = useCallback(async (content: string, providerModel: string) => {
await sessionManager.sendMessage(projectId, content, providerModel);