This commit is contained in:
@@ -19,6 +19,10 @@ type ChatSessionData = {
|
||||
messages: MentorChatMessage[];
|
||||
};
|
||||
|
||||
type SendChatResponse = {
|
||||
memorySuggestions?: unknown[];
|
||||
};
|
||||
|
||||
export function useMentorChat(sessionId: string | null) {
|
||||
const queryClient = useQueryClient();
|
||||
const bottomRef = useRef<HTMLDivElement>(null);
|
||||
@@ -54,7 +58,7 @@ export function useMentorChat(sessionId: string | null) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(body.error ?? "Send failed");
|
||||
}
|
||||
return res.json();
|
||||
return res.json() as Promise<SendChatResponse>;
|
||||
},
|
||||
onMutate: (content) => {
|
||||
setInput("");
|
||||
@@ -64,6 +68,8 @@ export function useMentorChat(sessionId: string | null) {
|
||||
setPendingState(null);
|
||||
queryClient.invalidateQueries({ queryKey: ["chat-session", sessionId] });
|
||||
queryClient.invalidateQueries({ queryKey: ["chat-sessions"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["ai-memory-suggestions"] });
|
||||
queryClient.invalidateQueries({ queryKey: ["ai-knows"] });
|
||||
},
|
||||
onError: (_err, content) => {
|
||||
setPendingState(createPendingStateOnError(content));
|
||||
|
||||
Reference in New Issue
Block a user