diff --git a/frontend/src/app/api/queries/useGetSettingsQuery.ts b/frontend/src/app/api/queries/useGetSettingsQuery.ts index 59ed0538..b0c8ba9b 100644 --- a/frontend/src/app/api/queries/useGetSettingsQuery.ts +++ b/frontend/src/app/api/queries/useGetSettingsQuery.ts @@ -25,57 +25,18 @@ interface Settings { ingest?: IngestSettings; } -const DEFAULT_SETTINGS: Settings = { - flow_id: "1098eea1-6649-4e1d-aed1-b77249fb8dd0", - ingest_flow_id: "5488df7c-b93f-4f87-a446-b67028bc0813", - langflow_edit_url: "", - langflow_ingest_edit_url: "", - langflow_public_url: "", - agent: { - llm_model: "gpt-4", - system_prompt: "", - }, - ingest: { - embedding_model: "text-embedding-ada-002", - chunk_size: 1000, - chunk_overlap: 200, - }, -}; - export const useGetSettingsQuery = ( options?: Omit, "queryKey" | "queryFn">, ) => { const queryClient = useQueryClient(); - function cancel() { - queryClient.removeQueries({ queryKey: ["settings"] }); - } - async function getSettings(): Promise { - try { - const response = await fetch("/api/settings"); - if (response.ok) { - const settings = await response.json(); - // Merge with defaults to ensure all properties exist - return { - ...DEFAULT_SETTINGS, - ...settings, - agent: { - ...DEFAULT_SETTINGS.agent, - ...settings.agent, - }, - ingest: { - ...DEFAULT_SETTINGS.ingest, - ...settings.ingest, - }, - }; - } else { - console.error("Failed to fetch settings"); - return DEFAULT_SETTINGS; - } - } catch (error) { - console.error("Error getting settings", error); - return DEFAULT_SETTINGS; + const response = await fetch("/api/settings"); + if (response.ok) { + // Merge with defaults to ensure all properties exist + return await response.json(); + } else { + throw new Error("Failed to fetch settings"); } } @@ -88,5 +49,5 @@ export const useGetSettingsQuery = ( queryClient, ); - return { ...queryResult, cancel }; + return queryResult; }; diff --git a/frontend/src/components/layout-wrapper.tsx b/frontend/src/components/layout-wrapper.tsx index c84b5641..4e4ec9cf 100644 --- a/frontend/src/components/layout-wrapper.tsx +++ b/frontend/src/components/layout-wrapper.tsx @@ -1,37 +1,44 @@ -"use client" +"use client"; -import { usePathname } from "next/navigation" -import { Bell } from "lucide-react" -import { Button } from "@/components/ui/button" -import { Navigation } from "@/components/navigation" -import { UserNav } from "@/components/user-nav" -import { TaskNotificationMenu } from "@/components/task-notification-menu" -import { KnowledgeFilterDropdown } from "@/components/knowledge-filter-dropdown" -import { KnowledgeFilterPanel } from "@/components/knowledge-filter-panel" +import { Bell, Loader2 } from "lucide-react"; +import { usePathname } from "next/navigation"; +import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery"; +import { KnowledgeFilterDropdown } from "@/components/knowledge-filter-dropdown"; +import { KnowledgeFilterPanel } from "@/components/knowledge-filter-panel"; +import { Navigation } from "@/components/navigation"; +import { TaskNotificationMenu } from "@/components/task-notification-menu"; +import { Button } from "@/components/ui/button"; +import { UserNav } from "@/components/user-nav"; +import { useAuth } from "@/contexts/auth-context"; +import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context"; // import { GitHubStarButton } from "@/components/github-star-button" // import { DiscordLink } from "@/components/discord-link" -import { useTask } from "@/contexts/task-context" -import { useKnowledgeFilter } from "@/contexts/knowledge-filter-context" -import { useAuth } from "@/contexts/auth-context" -import { Loader2 } from "lucide-react" +import { useTask } from "@/contexts/task-context"; export function LayoutWrapper({ children }: { children: React.ReactNode }) { - const pathname = usePathname() - const { tasks, isMenuOpen, toggleMenu } = useTask() - const { selectedFilter, setSelectedFilter, isPanelOpen } = useKnowledgeFilter() - const { isLoading } = useAuth() - + const pathname = usePathname(); + const { tasks, isMenuOpen, toggleMenu } = useTask(); + const { selectedFilter, setSelectedFilter, isPanelOpen } = + useKnowledgeFilter(); + const { isLoading, isAuthenticated } = useAuth(); + const { isLoading: isSettingsLoading } = useGetSettingsQuery({ + enabled: isAuthenticated, + }); + // List of paths that should not show navigation - const authPaths = ['/login', '/auth/callback'] - const isAuthPage = authPaths.includes(pathname) - + const authPaths = ["/login", "/auth/callback"]; + const isAuthPage = authPaths.includes(pathname); + // Calculate active tasks for the bell icon - const activeTasks = tasks.filter(task => - task.status === 'pending' || task.status === 'running' || task.status === 'processing' - ) - + const activeTasks = tasks.filter( + (task) => + task.status === "pending" || + task.status === "running" || + task.status === "processing", + ); + // Show loading state when backend isn't ready - if (isLoading) { + if (isLoading || isSettingsLoading) { return (
@@ -39,18 +46,14 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {

Starting OpenRAG...

- ) + ); } - + if (isAuthPage) { // For auth pages, render without navigation - return ( -
- {children} -
- ) + return
{children}
; } - + // For all other pages, render with Langflow-styled navigation and task menu return (
@@ -58,7 +61,14 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
{/* Logo/Title */}
- + @@ -69,11 +79,11 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
{/* Knowledge Filter Dropdown */} - - + {/* GitHub Star Button */} {/* */} @@ -92,10 +102,10 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
)} - + {/* Separator */}
- +
@@ -103,18 +113,24 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
-
-
- {children} -
+
+
{children}
- ) -} \ No newline at end of file + ); +}