This commit is contained in:
@@ -21,6 +21,12 @@ type ChatSessionData = {
|
||||
|
||||
type SendChatResponse = {
|
||||
memorySuggestions?: unknown[];
|
||||
memoryAction?: {
|
||||
type: string;
|
||||
intent?: string;
|
||||
status?: string;
|
||||
error?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export function useMentorChat(sessionId: string | null) {
|
||||
@@ -64,12 +70,18 @@ export function useMentorChat(sessionId: string | null) {
|
||||
setInput("");
|
||||
setPendingState(createPendingStateOnSend(content));
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: (data) => {
|
||||
setPendingState(null);
|
||||
queryClient.invalidateQueries({ queryKey: ["chat-session", sessionId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["chat-sessions"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["ai-memory-suggestions"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["ai-knows"] });
|
||||
if (
|
||||
data.memoryAction?.type === "memory_created" ||
|
||||
data.memoryAction?.type === "memory_suggestion_accepted"
|
||||
) {
|
||||
queryClient.invalidateQueries({ queryKey: ["ai-memory"] });
|
||||
}
|
||||
},
|
||||
onError: (_err, content) => {
|
||||
setPendingState(createPendingStateOnError(content));
|
||||
|
||||
Reference in New Issue
Block a user