Add react query provider to app

This commit is contained in:
Lucas Oliveira 2025-09-04 18:16:28 -03:00
parent 70d3434e5b
commit 047fb305c6
3 changed files with 100 additions and 87 deletions

View file

@ -22,6 +22,7 @@ import {
Zap, Zap,
} from "lucide-react"; } from "lucide-react";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { useGetNudgesQuery } from "../api/queries/useGetNudgesQuery";
interface Message { interface Message {
role: "user" | "assistant"; role: "user" | "assistant";
@ -191,7 +192,7 @@ function ChatPage() {
"Upload failed with status:", "Upload failed with status:",
response.status, response.status,
"Response:", "Response:",
errorText errorText,
); );
throw new Error("Failed to process document"); throw new Error("Failed to process document");
} }
@ -244,7 +245,7 @@ function ChatPage() {
...prev, ...prev,
[endpoint]: result.response_id, [endpoint]: result.response_id,
})); }));
// If this is a new conversation (no currentConversationId), set it now // If this is a new conversation (no currentConversationId), set it now
if (!currentConversationId) { if (!currentConversationId) {
setCurrentConversationId(result.response_id); setCurrentConversationId(result.response_id);
@ -436,8 +437,8 @@ function ChatPage() {
// 2. It's different from the last loaded conversation AND // 2. It's different from the last loaded conversation AND
// 3. User is not in the middle of an interaction // 3. User is not in the middle of an interaction
if ( if (
conversationData && conversationData &&
conversationData.messages && conversationData.messages &&
lastLoadedConversationRef.current !== conversationData.response_id && lastLoadedConversationRef.current !== conversationData.response_id &&
!isUserInteracting && !isUserInteracting &&
!isForkingInProgress !isForkingInProgress
@ -445,7 +446,7 @@ function ChatPage() {
console.log( console.log(
"Loading conversation with", "Loading conversation with",
conversationData.messages.length, conversationData.messages.length,
"messages" "messages",
); );
// Convert backend message format to frontend Message interface // Convert backend message format to frontend Message interface
const convertedMessages: Message[] = conversationData.messages.map( const convertedMessages: Message[] = conversationData.messages.map(
@ -459,7 +460,7 @@ function ChatPage() {
content: msg.content, content: msg.content,
timestamp: new Date(msg.timestamp || new Date()), timestamp: new Date(msg.timestamp || new Date()),
// Add any other necessary properties // Add any other necessary properties
}) }),
); );
setMessages(convertedMessages); setMessages(convertedMessages);
@ -471,11 +472,7 @@ function ChatPage() {
[conversationData.endpoint]: conversationData.response_id, [conversationData.endpoint]: conversationData.response_id,
})); }));
} }
}, [ }, [conversationData, isUserInteracting, isForkingInProgress]);
conversationData,
isUserInteracting,
isForkingInProgress,
]);
// Handle new conversation creation - only reset messages when placeholderConversation is set // Handle new conversation creation - only reset messages when placeholderConversation is set
useEffect(() => { useEffect(() => {
@ -547,7 +544,7 @@ function ChatPage() {
console.log( console.log(
"Chat page received file upload error event:", "Chat page received file upload error event:",
filename, filename,
error error,
); );
// Replace the last message with error message // Replace the last message with error message
@ -561,37 +558,37 @@ function ChatPage() {
window.addEventListener( window.addEventListener(
"fileUploadStart", "fileUploadStart",
handleFileUploadStart as EventListener handleFileUploadStart as EventListener,
); );
window.addEventListener( window.addEventListener(
"fileUploaded", "fileUploaded",
handleFileUploaded as EventListener handleFileUploaded as EventListener,
); );
window.addEventListener( window.addEventListener(
"fileUploadComplete", "fileUploadComplete",
handleFileUploadComplete as EventListener handleFileUploadComplete as EventListener,
); );
window.addEventListener( window.addEventListener(
"fileUploadError", "fileUploadError",
handleFileUploadError as EventListener handleFileUploadError as EventListener,
); );
return () => { return () => {
window.removeEventListener( window.removeEventListener(
"fileUploadStart", "fileUploadStart",
handleFileUploadStart as EventListener handleFileUploadStart as EventListener,
); );
window.removeEventListener( window.removeEventListener(
"fileUploaded", "fileUploaded",
handleFileUploaded as EventListener handleFileUploaded as EventListener,
); );
window.removeEventListener( window.removeEventListener(
"fileUploadComplete", "fileUploadComplete",
handleFileUploadComplete as EventListener handleFileUploadComplete as EventListener,
); );
window.removeEventListener( window.removeEventListener(
"fileUploadError", "fileUploadError",
handleFileUploadError as EventListener handleFileUploadError as EventListener,
); );
}; };
}, [endpoint, setPreviousResponseIds]); }, [endpoint, setPreviousResponseIds]);
@ -617,6 +614,10 @@ function ChatPage() {
}; };
}, [isFilterDropdownOpen]); }, [isFilterDropdownOpen]);
const { data: nudges = [], refetch: refetchNudges } = useGetNudgesQuery(
previousResponseIds[endpoint],
);
const handleSSEStream = async (userMessage: Message) => { const handleSSEStream = async (userMessage: Message) => {
const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow"; const apiEndpoint = endpoint === "chat" ? "/api/chat" : "/api/langflow";
@ -719,7 +720,7 @@ function ChatPage() {
console.log( console.log(
"Received chunk:", "Received chunk:",
chunk.type || chunk.object, chunk.type || chunk.object,
chunk chunk,
); );
// Extract response ID if present // Extract response ID if present
@ -735,14 +736,14 @@ function ChatPage() {
if (chunk.delta.function_call) { if (chunk.delta.function_call) {
console.log( console.log(
"Function call in delta:", "Function call in delta:",
chunk.delta.function_call chunk.delta.function_call,
); );
// Check if this is a new function call // Check if this is a new function call
if (chunk.delta.function_call.name) { if (chunk.delta.function_call.name) {
console.log( console.log(
"New function call:", "New function call:",
chunk.delta.function_call.name chunk.delta.function_call.name,
); );
const functionCall: FunctionCall = { const functionCall: FunctionCall = {
name: chunk.delta.function_call.name, name: chunk.delta.function_call.name,
@ -758,7 +759,7 @@ function ChatPage() {
else if (chunk.delta.function_call.arguments) { else if (chunk.delta.function_call.arguments) {
console.log( console.log(
"Function call arguments delta:", "Function call arguments delta:",
chunk.delta.function_call.arguments chunk.delta.function_call.arguments,
); );
const lastFunctionCall = const lastFunctionCall =
currentFunctionCalls[currentFunctionCalls.length - 1]; currentFunctionCalls[currentFunctionCalls.length - 1];
@ -770,14 +771,14 @@ function ChatPage() {
chunk.delta.function_call.arguments; chunk.delta.function_call.arguments;
console.log( console.log(
"Accumulated arguments:", "Accumulated arguments:",
lastFunctionCall.argumentsString lastFunctionCall.argumentsString,
); );
// Try to parse arguments if they look complete // Try to parse arguments if they look complete
if (lastFunctionCall.argumentsString.includes("}")) { if (lastFunctionCall.argumentsString.includes("}")) {
try { try {
const parsed = JSON.parse( const parsed = JSON.parse(
lastFunctionCall.argumentsString lastFunctionCall.argumentsString,
); );
lastFunctionCall.arguments = parsed; lastFunctionCall.arguments = parsed;
lastFunctionCall.status = "completed"; lastFunctionCall.status = "completed";
@ -785,7 +786,7 @@ function ChatPage() {
} catch (e) { } catch (e) {
console.log( console.log(
"Arguments not yet complete or invalid JSON:", "Arguments not yet complete or invalid JSON:",
e e,
); );
} }
} }
@ -818,7 +819,7 @@ function ChatPage() {
else if (toolCall.function.arguments) { else if (toolCall.function.arguments) {
console.log( console.log(
"Tool call arguments delta:", "Tool call arguments delta:",
toolCall.function.arguments toolCall.function.arguments,
); );
const lastFunctionCall = const lastFunctionCall =
currentFunctionCalls[ currentFunctionCalls[
@ -832,7 +833,7 @@ function ChatPage() {
toolCall.function.arguments; toolCall.function.arguments;
console.log( console.log(
"Accumulated tool arguments:", "Accumulated tool arguments:",
lastFunctionCall.argumentsString lastFunctionCall.argumentsString,
); );
// Try to parse arguments if they look complete // Try to parse arguments if they look complete
@ -841,7 +842,7 @@ function ChatPage() {
) { ) {
try { try {
const parsed = JSON.parse( const parsed = JSON.parse(
lastFunctionCall.argumentsString lastFunctionCall.argumentsString,
); );
lastFunctionCall.arguments = parsed; lastFunctionCall.arguments = parsed;
lastFunctionCall.status = "completed"; lastFunctionCall.status = "completed";
@ -849,7 +850,7 @@ function ChatPage() {
} catch (e) { } catch (e) {
console.log( console.log(
"Tool arguments not yet complete or invalid JSON:", "Tool arguments not yet complete or invalid JSON:",
e e,
); );
} }
} }
@ -881,7 +882,7 @@ function ChatPage() {
console.log( console.log(
"Error parsing function call on finish:", "Error parsing function call on finish:",
fc, fc,
e e,
); );
} }
} }
@ -897,12 +898,12 @@ function ChatPage() {
console.log( console.log(
"🟢 CREATING function call (added):", "🟢 CREATING function call (added):",
chunk.item.id, chunk.item.id,
chunk.item.tool_name || chunk.item.name chunk.item.tool_name || chunk.item.name,
); );
// Try to find an existing pending call to update (created by earlier deltas) // Try to find an existing pending call to update (created by earlier deltas)
let existing = currentFunctionCalls.find( let existing = currentFunctionCalls.find(
(fc) => fc.id === chunk.item.id (fc) => fc.id === chunk.item.id,
); );
if (!existing) { if (!existing) {
existing = [...currentFunctionCalls] existing = [...currentFunctionCalls]
@ -911,7 +912,7 @@ function ChatPage() {
(fc) => (fc) =>
fc.status === "pending" && fc.status === "pending" &&
!fc.id && !fc.id &&
fc.name === (chunk.item.tool_name || chunk.item.name) fc.name === (chunk.item.tool_name || chunk.item.name),
); );
} }
@ -924,7 +925,7 @@ function ChatPage() {
chunk.item.inputs || existing.arguments; chunk.item.inputs || existing.arguments;
console.log( console.log(
"🟢 UPDATED existing pending function call with id:", "🟢 UPDATED existing pending function call with id:",
existing.id existing.id,
); );
} else { } else {
const functionCall: FunctionCall = { const functionCall: FunctionCall = {
@ -942,7 +943,7 @@ function ChatPage() {
currentFunctionCalls.map((fc) => ({ currentFunctionCalls.map((fc) => ({
id: fc.id, id: fc.id,
name: fc.name, name: fc.name,
})) })),
); );
} }
} }
@ -953,7 +954,7 @@ function ChatPage() {
) { ) {
console.log( console.log(
"Function args delta (Realtime API):", "Function args delta (Realtime API):",
chunk.delta chunk.delta,
); );
const lastFunctionCall = const lastFunctionCall =
currentFunctionCalls[currentFunctionCalls.length - 1]; currentFunctionCalls[currentFunctionCalls.length - 1];
@ -964,7 +965,7 @@ function ChatPage() {
lastFunctionCall.argumentsString += chunk.delta || ""; lastFunctionCall.argumentsString += chunk.delta || "";
console.log( console.log(
"Accumulated arguments (Realtime API):", "Accumulated arguments (Realtime API):",
lastFunctionCall.argumentsString lastFunctionCall.argumentsString,
); );
} }
} }
@ -975,26 +976,26 @@ function ChatPage() {
) { ) {
console.log( console.log(
"Function args done (Realtime API):", "Function args done (Realtime API):",
chunk.arguments chunk.arguments,
); );
const lastFunctionCall = const lastFunctionCall =
currentFunctionCalls[currentFunctionCalls.length - 1]; currentFunctionCalls[currentFunctionCalls.length - 1];
if (lastFunctionCall) { if (lastFunctionCall) {
try { try {
lastFunctionCall.arguments = JSON.parse( lastFunctionCall.arguments = JSON.parse(
chunk.arguments || "{}" chunk.arguments || "{}",
); );
lastFunctionCall.status = "completed"; lastFunctionCall.status = "completed";
console.log( console.log(
"Parsed function arguments (Realtime API):", "Parsed function arguments (Realtime API):",
lastFunctionCall.arguments lastFunctionCall.arguments,
); );
} catch (e) { } catch (e) {
lastFunctionCall.arguments = { raw: chunk.arguments }; lastFunctionCall.arguments = { raw: chunk.arguments };
lastFunctionCall.status = "error"; lastFunctionCall.status = "error";
console.log( console.log(
"Error parsing function arguments (Realtime API):", "Error parsing function arguments (Realtime API):",
e e,
); );
} }
} }
@ -1008,14 +1009,14 @@ function ChatPage() {
console.log( console.log(
"🔵 UPDATING function call (done):", "🔵 UPDATING function call (done):",
chunk.item.id, chunk.item.id,
chunk.item.tool_name || chunk.item.name chunk.item.tool_name || chunk.item.name,
); );
console.log( console.log(
"🔵 Looking for existing function calls:", "🔵 Looking for existing function calls:",
currentFunctionCalls.map((fc) => ({ currentFunctionCalls.map((fc) => ({
id: fc.id, id: fc.id,
name: fc.name, name: fc.name,
})) })),
); );
// Find existing function call by ID or name // Find existing function call by ID or name
@ -1023,14 +1024,14 @@ function ChatPage() {
(fc) => (fc) =>
fc.id === chunk.item.id || fc.id === chunk.item.id ||
fc.name === chunk.item.tool_name || fc.name === chunk.item.tool_name ||
fc.name === chunk.item.name fc.name === chunk.item.name,
); );
if (functionCall) { if (functionCall) {
console.log( console.log(
"🔵 FOUND existing function call, updating:", "🔵 FOUND existing function call, updating:",
functionCall.id, functionCall.id,
functionCall.name functionCall.name,
); );
// Update existing function call with completion data // Update existing function call with completion data
functionCall.status = functionCall.status =
@ -1053,7 +1054,7 @@ function ChatPage() {
"🔴 WARNING: Could not find existing function call to update:", "🔴 WARNING: Could not find existing function call to update:",
chunk.item.id, chunk.item.id,
chunk.item.tool_name, chunk.item.tool_name,
chunk.item.name chunk.item.name,
); );
} }
} }
@ -1074,7 +1075,7 @@ function ChatPage() {
fc.name === chunk.item.name || fc.name === chunk.item.name ||
fc.name === chunk.item.type || fc.name === chunk.item.type ||
fc.name.includes(chunk.item.type.replace("_call", "")) || fc.name.includes(chunk.item.type.replace("_call", "")) ||
chunk.item.type.includes(fc.name) chunk.item.type.includes(fc.name),
); );
if (functionCall) { if (functionCall) {
@ -1118,12 +1119,12 @@ function ChatPage() {
"🟡 CREATING tool call (added):", "🟡 CREATING tool call (added):",
chunk.item.id, chunk.item.id,
chunk.item.tool_name || chunk.item.name, chunk.item.tool_name || chunk.item.name,
chunk.item.type chunk.item.type,
); );
// Dedupe by id or pending with same name // Dedupe by id or pending with same name
let existing = currentFunctionCalls.find( let existing = currentFunctionCalls.find(
(fc) => fc.id === chunk.item.id (fc) => fc.id === chunk.item.id,
); );
if (!existing) { if (!existing) {
existing = [...currentFunctionCalls] existing = [...currentFunctionCalls]
@ -1135,7 +1136,7 @@ function ChatPage() {
fc.name === fc.name ===
(chunk.item.tool_name || (chunk.item.tool_name ||
chunk.item.name || chunk.item.name ||
chunk.item.type) chunk.item.type),
); );
} }
@ -1151,7 +1152,7 @@ function ChatPage() {
chunk.item.inputs || existing.arguments; chunk.item.inputs || existing.arguments;
console.log( console.log(
"🟡 UPDATED existing pending tool call with id:", "🟡 UPDATED existing pending tool call with id:",
existing.id existing.id,
); );
} else { } else {
const functionCall = { const functionCall = {
@ -1172,7 +1173,7 @@ function ChatPage() {
id: fc.id, id: fc.id,
name: fc.name, name: fc.name,
type: fc.type, type: fc.type,
})) })),
); );
} }
} }
@ -1268,6 +1269,9 @@ function ChatPage() {
if (!controller.signal.aborted && thisStreamId === streamIdRef.current) { if (!controller.signal.aborted && thisStreamId === streamIdRef.current) {
setMessages((prev) => [...prev, finalMessage]); setMessages((prev) => [...prev, finalMessage]);
setStreamingMessage(null); setStreamingMessage(null);
if (previousResponseIds[endpoint]) {
refetchNudges();
}
} }
// Store the response ID for the next request for this endpoint // Store the response ID for the next request for this endpoint
@ -1280,7 +1284,7 @@ function ChatPage() {
...prev, ...prev,
[endpoint]: newResponseId, [endpoint]: newResponseId,
})); }));
// If this is a new conversation (no currentConversationId), set it now // If this is a new conversation (no currentConversationId), set it now
if (!currentConversationId) { if (!currentConversationId) {
setCurrentConversationId(newResponseId); setCurrentConversationId(newResponseId);
@ -1385,6 +1389,9 @@ function ChatPage() {
timestamp: new Date(), timestamp: new Date(),
}; };
setMessages((prev) => [...prev, assistantMessage]); setMessages((prev) => [...prev, assistantMessage]);
if (result.response_id) {
refetchNudges();
}
// Store the response ID if present for this endpoint // Store the response ID if present for this endpoint
if (result.response_id) { if (result.response_id) {
@ -1392,7 +1399,7 @@ function ChatPage() {
...prev, ...prev,
[endpoint]: result.response_id, [endpoint]: result.response_id,
})); }));
// If this is a new conversation (no currentConversationId), set it now // If this is a new conversation (no currentConversationId), set it now
if (!currentConversationId) { if (!currentConversationId) {
setCurrentConversationId(result.response_id); setCurrentConversationId(result.response_id);
@ -1440,7 +1447,7 @@ function ChatPage() {
const handleForkConversation = ( const handleForkConversation = (
messageIndex: number, messageIndex: number,
event?: React.MouseEvent event?: React.MouseEvent,
) => { ) => {
// Prevent any default behavior and stop event propagation // Prevent any default behavior and stop event propagation
if (event) { if (event) {
@ -1508,7 +1515,7 @@ function ChatPage() {
const renderFunctionCalls = ( const renderFunctionCalls = (
functionCalls: FunctionCall[], functionCalls: FunctionCall[],
messageIndex?: number messageIndex?: number,
) => { ) => {
if (!functionCalls || functionCalls.length === 0) return null; if (!functionCalls || functionCalls.length === 0) return null;
@ -1737,12 +1744,6 @@ function ChatPage() {
); );
}; };
const suggestionChips = [
"Show me this quarter's top 10 deals",
"Summarize recent client interactions",
"Search OpenSearch for mentions of our competitors",
];
const handleSuggestionClick = (suggestion: string) => { const handleSuggestionClick = (suggestion: string) => {
setInput(suggestion); setInput(suggestion);
inputRef.current?.focus(); inputRef.current?.focus();
@ -1883,7 +1884,7 @@ function ChatPage() {
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
{renderFunctionCalls( {renderFunctionCalls(
message.functionCalls || [], message.functionCalls || [],
index index,
)} )}
<p className="text-foreground whitespace-pre-wrap break-words overflow-wrap-anywhere"> <p className="text-foreground whitespace-pre-wrap break-words overflow-wrap-anywhere">
{message.content} {message.content}
@ -1914,7 +1915,7 @@ function ChatPage() {
<div className="flex-1"> <div className="flex-1">
{renderFunctionCalls( {renderFunctionCalls(
streamingMessage.functionCalls, streamingMessage.functionCalls,
messages.length messages.length,
)} )}
<p className="text-foreground whitespace-pre-wrap break-words overflow-wrap-anywhere"> <p className="text-foreground whitespace-pre-wrap break-words overflow-wrap-anywhere">
{streamingMessage.content} {streamingMessage.content}
@ -1963,8 +1964,8 @@ function ChatPage() {
{!streamingMessage && ( {!streamingMessage && (
<div className="flex-shrink-0 p-6 pb-4 flex justify-center"> <div className="flex-shrink-0 p-6 pb-4 flex justify-center">
<div className="w-full max-w-[75%] relative"> <div className="w-full max-w-[75%] relative">
<div className="flex gap-2 justify-start overflow-hidden"> <div className="flex gap-2 justify-start overflow-x-auto scrollbar-hide">
{suggestionChips.map((suggestion, index) => ( {(nudges as string[]).map((suggestion: string, index: number) => (
<button <button
key={index} key={index}
onClick={() => handleSuggestionClick(suggestion)} onClick={() => handleSuggestionClick(suggestion)}
@ -2070,7 +2071,7 @@ function ChatPage() {
const filteredFilters = availableFilters.filter((filter) => const filteredFilters = availableFilters.filter((filter) =>
filter.name filter.name
.toLowerCase() .toLowerCase()
.includes(filterSearchTerm.toLowerCase()) .includes(filterSearchTerm.toLowerCase()),
); );
if (e.key === "Escape") { if (e.key === "Escape") {
@ -2088,7 +2089,7 @@ function ChatPage() {
if (e.key === "ArrowDown") { if (e.key === "ArrowDown") {
e.preventDefault(); e.preventDefault();
setSelectedFilterIndex((prev) => setSelectedFilterIndex((prev) =>
prev < filteredFilters.length - 1 ? prev + 1 : 0 prev < filteredFilters.length - 1 ? prev + 1 : 0,
); );
return; return;
} }
@ -2096,7 +2097,7 @@ function ChatPage() {
if (e.key === "ArrowUp") { if (e.key === "ArrowUp") {
e.preventDefault(); e.preventDefault();
setSelectedFilterIndex((prev) => setSelectedFilterIndex((prev) =>
prev > 0 ? prev - 1 : filteredFilters.length - 1 prev > 0 ? prev - 1 : filteredFilters.length - 1,
); );
return; return;
} }
@ -2114,7 +2115,7 @@ function ChatPage() {
) { ) {
e.preventDefault(); e.preventDefault();
handleFilterSelect( handleFilterSelect(
filteredFilters[selectedFilterIndex] filteredFilters[selectedFilterIndex],
); );
return; return;
} }
@ -2133,7 +2134,7 @@ function ChatPage() {
) { ) {
e.preventDefault(); e.preventDefault();
handleFilterSelect( handleFilterSelect(
filteredFilters[selectedFilterIndex] filteredFilters[selectedFilterIndex],
); );
return; return;
} }
@ -2213,7 +2214,7 @@ function ChatPage() {
.filter((filter) => .filter((filter) =>
filter.name filter.name
.toLowerCase() .toLowerCase()
.includes(filterSearchTerm.toLowerCase()) .includes(filterSearchTerm.toLowerCase()),
) )
.map((filter, index) => ( .map((filter, index) => (
<button <button
@ -2239,7 +2240,7 @@ function ChatPage() {
{availableFilters.filter((filter) => {availableFilters.filter((filter) =>
filter.name filter.name
.toLowerCase() .toLowerCase()
.includes(filterSearchTerm.toLowerCase()) .includes(filterSearchTerm.toLowerCase()),
).length === 0 && ).length === 0 &&
filterSearchTerm && ( filterSearchTerm && (
<div className="px-2 py-3 text-sm text-muted-foreground"> <div className="px-2 py-3 text-sm text-muted-foreground">

View file

@ -8,6 +8,7 @@ import { KnowledgeFilterProvider } from "@/contexts/knowledge-filter-context";
import { ChatProvider } from "@/contexts/chat-context"; import { ChatProvider } from "@/contexts/chat-context";
import { LayoutWrapper } from "@/components/layout-wrapper"; import { LayoutWrapper } from "@/components/layout-wrapper";
import { Toaster } from "@/components/ui/sonner"; import { Toaster } from "@/components/ui/sonner";
import Providers from "./providers";
const inter = Inter({ const inter = Inter({
variable: "--font-sans", variable: "--font-sans",
@ -28,7 +29,6 @@ export const metadata: Metadata = {
title: "OpenRAG", title: "OpenRAG",
description: "Open source RAG (Retrieval Augmented Generation) system", description: "Open source RAG (Retrieval Augmented Generation) system",
}; };
export default function RootLayout({ export default function RootLayout({
children, children,
}: Readonly<{ }: Readonly<{
@ -45,17 +45,17 @@ export default function RootLayout({
enableSystem enableSystem
disableTransitionOnChange disableTransitionOnChange
> >
<AuthProvider> <Providers>
<TaskProvider> <AuthProvider>
<KnowledgeFilterProvider> <TaskProvider>
<ChatProvider> <KnowledgeFilterProvider>
<LayoutWrapper> <ChatProvider>
{children} <LayoutWrapper>{children}</LayoutWrapper>
</LayoutWrapper> </ChatProvider>
</ChatProvider> </KnowledgeFilterProvider>
</KnowledgeFilterProvider> </TaskProvider>
</TaskProvider> </AuthProvider>
</AuthProvider> </Providers>
</ThemeProvider> </ThemeProvider>
<Toaster /> <Toaster />
</body> </body>

View file

@ -0,0 +1,12 @@
"use client";
import { QueryClientProvider } from "@tanstack/react-query";
import { getQueryClient } from "@/app/api/get-query-client";
import type * as React from "react";
export default function Providers({ children }: { children: React.ReactNode }) {
const queryClient = getQueryClient();
return (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
);
}