mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Improve SessionManager logic
This commit is contained in:
2 files changed
+32
-37
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user