OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat: Sidebar Overlay Enhancement (#2340)
Jason Dong10d3b983b358
diff --git a/frontend/app/chat/_components/assistant-message.tsx b/frontend/app/chat/_components/assistant-message.tsxindex 7d4cac7c6..fde923e29 100644--- a/frontend/app/chat/_components/assistant-message.tsx+++ b/frontend/app/chat/_components/assistant-message.tsx@@ -189,7 +189,12 @@ export function AssistantMessage({isAssistantunstyledContent={unstyledMessageContent}icon={- <div className="w-8 h-8 flex items-center justify-center flex-shrink-0 select-none">+ <div+ className={cn(+ "w-8 h-8 flex items-center justify-center flex-shrink-0 select-none",+ isInitialGreeting && "mt-4",+ )}+ >{/* Dog icon with bark animation when greeting */}<motion.divinitial={isInitialGreeting ? { rotate: -5, y: -1 } : false}diff --git a/frontend/app/chat/_components/nudges.test.tsx b/frontend/app/chat/_components/nudges.test.tsxnew file mode 100644index 000000000..79b358b5b--- /dev/null+++ b/frontend/app/chat/_components/nudges.test.tsx@@ -0,0 +1,41 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import Nudges from "./nudges";++describe("Nudges", () => {+ it("renders suggestions and handles clicks", async () => {+ const user = userEvent.setup();+ const handleClick = vi.fn();+ const suggestions = ["Suggestion 1", "Suggestion 2"];++ render(+ <Nudges+ nudges={suggestions}+ onboarding={false}+ handleSuggestionClick={handleClick}+ />,+ );++ const firstSuggestion = screen.getByTestId("suggestion-0");+ expect(firstSuggestion).toBeInTheDocument();+ expect(firstSuggestion).toHaveTextContent("Suggestion 1");++ await user.click(firstSuggestion);+ expect(handleClick).toHaveBeenCalledWith("Suggestion 1");+ });++ it("renders with onboarding theme classes", () => {+ const suggestions = ["Nudge A"];+ render(+ <Nudges+ nudges={suggestions}+ onboarding={true}+ handleSuggestionClick={() => {}}+ />,+ );++ const button = screen.getByTestId("suggestion-0");+ expect(button.className).toContain("text-foreground");+ });+});diff --git a/frontend/app/chat/_components/nudges.tsx b/frontend/app/chat/_components/nudges.tsxindex c41ad9d77..8326d7e66 100644--- a/frontend/app/chat/_components/nudges.tsx+++ b/frontend/app/chat/_components/nudges.tsx@@ -16,7 +16,7 @@ export default function Nudges({const isCloudBrand = useIsCloudBrand();return (- <div className="flex-shrink-0 h-12 w-full overflow-hidden">+ <div className="flex-shrink-0 w-full"><AnimatePresence>{nudges.length > 0 && (<motion.div@@ -28,27 +28,23 @@ export default function Nudges({ease: "easeInOut",}}>- <div className="relative flex">- <div className="w-full">- <div className="flex gap-3 justify-start overflow-x-auto scrollbar-hide">- {nudges.map((suggestion: string, index: number) => (- <button- type="button"- key={index}- data-testid={`suggestion-${index}`}- onClick={() => handleSuggestionClick(suggestion)}- className={cn(- onboarding || isCloudBrand- ? "text-foreground"- : "text-placeholder-foreground hover:text-foreground",- "ibm-chat-bubble bg-background border hover:bg-background/50 px-2 py-1.5 rounded-lg text-sm transition-colors whitespace-nowrap",- )}- >- {suggestion}- </button>- ))}- </div>- </div>+ <div className="flex flex-wrap gap-2 justify-start">+ {nudges.map((suggestion: string, index: number) => (+ <button+ type="button"+ key={index}+ data-testid={`suggestion-${index}`}+ onClick={() => handleSuggestionClick(suggestion)}+ className={cn(+ onboarding || isCloudBrand+ ? "text-foreground"+ : "text-placeholder-foreground hover:text-foreground",+ "ibm-chat-bubble bg-background border hover:bg-background/50 px-2 py-1.5 rounded-lg text-sm transition-colors max-w-full break-words",+ )}+ >+ {suggestion}+ </button>+ ))}</div></motion.div>)}diff --git a/frontend/app/chat/page.tsx b/frontend/app/chat/page.tsxindex 71dd6e3b4..5739070ac 100644--- a/frontend/app/chat/page.tsx+++ b/frontend/app/chat/page.tsx@@ -958,9 +958,11 @@ function ChatPage() {)}<StickToBottom.Content- className={cn("flex flex-col min-h-full overflow-x-hidden p-6")}+ className={cn(+ "flex flex-col min-h-full overflow-x-hidden px-3 py-6 sm:p-6",+ )}>- <div className="flex flex-col place-self-center space-y-6 max-w-content w-full mx-auto">+ <div className="flex flex-col space-y-6 max-w-content w-full sm:mx-auto">{messages.length === 0 && !streamingMessage ? (<div className="flex items-center justify-center h-full text-muted-foreground"><div className="text-center">@@ -1081,7 +1083,7 @@ function ChatPage() {</>)}{!streamingMessage && (- <div className="pl-10">+ <div className="pl-0 sm:pl-10"><Nudgesnudges={loading ? [] : (nudges as string[])}handleSuggestionClick={handleSuggestionClick}@@ -1090,7 +1092,7 @@ function ChatPage() {)}</div></StickToBottom.Content>- <div className="p-6 pt-0 max-w-content mx-auto w-full">+ <div className="px-3 pb-6 pt-0 max-w-content w-full sm:px-6 sm:mx-auto">{/* Input Area - Fixed at bottom */}<ChatInputref={chatInputRef}diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsxindex 9221b8e55..62929477f 100644--- a/frontend/app/layout.tsx+++ b/frontend/app/layout.tsx@@ -11,6 +11,7 @@ import { BrandProvider } from "@/contexts/brand-context";import { ChatProvider } from "@/contexts/chat-context";import { ConsoleStatusProvider } from "@/contexts/console-status-context";import { KnowledgeFilterProvider } from "@/contexts/knowledge-filter-context";+import { SidebarOverlayProvider } from "@/contexts/sidebar-overlay-context";import { TaskProvider } from "@/contexts/task-context";import { UnsavedChangesProvider } from "@/contexts/unsaved-changes-context";import Providers from "./providers";@@ -66,7 +67,9 @@ export default function RootLayout({<ConsoleStatusProvider><ChatProvider><UnsavedChangesProvider>- <LayoutWrapper>{children}</LayoutWrapper>+ <SidebarOverlayProvider>+ <LayoutWrapper>{children}</LayoutWrapper>+ </SidebarOverlayProvider></UnsavedChangesProvider></ChatProvider></ConsoleStatusProvider>diff --git a/frontend/app/onboarding/_components/generic-onboarding.test.tsx b/frontend/app/onboarding/_components/generic-onboarding.test.tsxnew file mode 100644index 000000000..5d7934df3--- /dev/null+++ b/frontend/app/onboarding/_components/generic-onboarding.test.tsx@@ -0,0 +1,91 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { TooltipProvider } from "@/components/ui/tooltip";+import { GenericOnboarding } from "./generic-onboarding";++vi.mock("@/app/api/queries/useGetModelsQuery", () => ({+ useGetModelCatalogQuery: vi.fn().mockReturnValue({+ data: {+ providers: [+ {+ key: "openai",+ models: [{ model: "gpt-4o" }, { model: "gpt-4o-mini" }],+ embedding_models: [+ { model: "text-embedding-3-small" },+ { model: "text-embedding-3-large" },+ ],+ },+ ],+ },+ }),+}));++vi.mock("@/components/models/model-selector", () => ({+ ModelSelector: ({ value, onValueChange, options = [] }: any) => (+ <select+ data-testid="model-selector"+ value={value}+ onChange={(e) => onValueChange?.(e.target.value)}+ >+ {options.map((m: any) => (+ <option key={m.value} value={m.value}>+ {m.label}+ </option>+ ))}+ </select>+ ),+}));++describe("GenericOnboarding", () => {+ it("seeds credentials and synchronizes parent settings", async () => {+ const user = userEvent.setup();+ const mockSetSettings = vi.fn();++ render(+ <TooltipProvider>+ <GenericOnboarding+ provider="openai"+ isEmbedding={false}+ setSettings={mockSetSettings}+ providers={+ {+ custom: { openai: { credential_values: { api_key: "sk-test" } } },+ } as any+ }+ />+ </TooltipProvider>,+ );++ expect(mockSetSettings).toHaveBeenCalled();++ // Check input change+ const apiKeyInput = screen.getByLabelText(/API Key/i);+ await user.clear(apiKeyInput);+ await user.type(apiKeyInput, "sk-new-key");++ expect(mockSetSettings).toHaveBeenCalled();+ });++ it("handles embedding mode and model selection", async () => {+ const user = userEvent.setup();+ const mockSetSettings = vi.fn();++ render(+ <TooltipProvider>+ <GenericOnboarding+ provider="openai"+ isEmbedding={true}+ setSettings={mockSetSettings}+ providers={{ custom: {} } as any}+ />+ </TooltipProvider>,+ );++ expect(mockSetSettings).toHaveBeenCalled();++ const selector = screen.getByTestId("model-selector");+ await user.selectOptions(selector, "text-embedding-3-large");+ expect(mockSetSettings).toHaveBeenCalled();+ });+});diff --git a/frontend/app/onboarding/_components/generic-onboarding.tsx b/frontend/app/onboarding/_components/generic-onboarding.tsxindex 7f3a8be99..13d426550 100644--- a/frontend/app/onboarding/_components/generic-onboarding.tsx+++ b/frontend/app/onboarding/_components/generic-onboarding.tsx@@ -1,5 +1,11 @@-import type { Dispatch, SetStateAction } from "react";-import { useMemo, useState } from "react";+import {+ type Dispatch,+ type SetStateAction,+ useEffect,+ useMemo,+ useRef,+ useState,+} from "react";import { useGetModelCatalogQuery } from "@/app/api/queries/useGetModelsQuery";import { LabelInput } from "@/components/label-input";import {@@ -48,12 +54,10 @@ export function GenericOnboarding({() => new Set(savedSecretFieldsForProvider(providers, provider)),[providers, provider],);- const savedValues = useMemo(- () => savedCredentialValuesForProvider(providers, provider),- [providers, provider],- );- const [credentials, setCredentials] = useState<Record<string, string>>({});+ const [credentials, setCredentials] = useState<Record<string, string>>(() =>+ savedCredentialValuesForProvider(providers, provider),+ );const [model, setModel] = useState("");const [azureAuthMethod, setAzureAuthMethod] = useState(providers?.custom?.[provider]?.auth_method ?? "api_key",@@ -62,6 +66,12 @@ export function GenericOnboarding({providers?.custom?.[provider]?.auth_method ?? "username_api_key",);+ // Stable ref so syncParentSettings can be called from effects without+ // needing to be listed in deps (it only reads provider/isEmbedding which+ // are stable within a single render of this component).+ const setSettingsRef = useRef(setSettings);+ setSettingsRef.current = setSettings;+const syncParentSettings = (nextCredentials: Record<string, string>,nextModel: string,@@ -90,8 +100,7 @@ export function GenericOnboarding({submitted[key] = trimmed;}}-- setSettings((prev) => ({+ setSettingsRef.current((prev) => ({...prev,...(isEmbedding? { embedding_provider: provider, embedding_model: nextModel }@@ -118,14 +127,6 @@ export function GenericOnboarding({}));};- // Seed the non-secret fields from what is already saved, once per provider.- const [seededFor, setSeededFor] = useState<string | undefined>();- if (seededFor !== provider) {- setSeededFor(provider);- setCredentials(savedValues);- syncParentSettings(savedValues, model);- }-const catalogEntry = catalog?.providers?.find((entry) => entry.key === provider,);@@ -139,16 +140,18 @@ export function GenericOnboarding({}));}, [catalogEntry, isEmbedding]);- // Default to the first model the catalogue lists for this provider.- const [prevModels, setPrevModels] = useState<typeof models | undefined>();- if (models !== prevModels) {- setPrevModels(models);- if (!model && models.length > 0) {- const defaultModel = models[0].value;- setModel(defaultModel);- syncParentSettings(credentials, defaultModel);- }- }+ // Default to the first model when the catalogue loads or provider changes.+ const defaultedModelRef = useRef<string | undefined>(undefined);+ useEffect(() => {+ if (model || models.length === 0) return;+ const defaultModel = models[0].value;+ // Only set once per provider so switching back doesn't re-default.+ if (defaultedModelRef.current === `${provider}:${defaultModel}`) return;+ defaultedModelRef.current = `${provider}:${defaultModel}`;+ setModel(defaultModel);+ syncParentSettings(credentials, defaultModel);+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [models, model, provider]);const handleCredentialChange = (fieldKey: string, newValue: string) => {const nextCredentials = { ...credentials, [fieldKey]: newValue };diff --git a/frontend/app/onboarding/_components/onboarding-card.tsx b/frontend/app/onboarding/_components/onboarding-card.tsxindex 5e53f0e96..ced209fbc 100644--- a/frontend/app/onboarding/_components/onboarding-card.tsx+++ b/frontend/app/onboarding/_components/onboarding-card.tsx@@ -1,5 +1,6 @@"use client";+import * as TooltipPrimitive from "@radix-ui/react-tooltip";import { useIsFetching, useQueryClient } from "@tanstack/react-query";import { AnimatePresence, motion } from "framer-motion";import { X } from "lucide-react";@@ -620,48 +621,65 @@ const OnboardingCard = ({const Logo = chrome.logo;const selected = modelProvider === providerKey;return (- <TabsTrigger- key={providerKey}- value={providerKey}- data-testid={`${providerKey}-${isEmbedding ? "embedding" : "llm"}-tab`}- className={cn(- error &&- selected &&- "data-[state=active]:border-destructive",- // Fixed 3-up basis so every card is the same width- // (like a grid) while flex still fills the row.- "min-w-52 grow-0 basis-[calc((100%_-_1.5rem)/3)]",- )}- >- <TabTrigger- selected={selected}- isLoading={isLoadingModels}- >- <div+ <Tooltip key={providerKey}>+ <TooltipTrigger asChild>+ <TabsTrigger+ value={providerKey}+ data-testid={`${providerKey}-${isEmbedding ? "embedding" : "llm"}-tab`}className={cn(- "flex items-center justify-center gap-2 w-8 h-8 rounded-none border",- selected- ? (chrome.tabLogoBgColor ?? chrome.logoBgColor)- : "bg-muted",+ error &&+ selected &&+ "data-[state=active]:border-destructive",+ // Fixed 3-up basis so every card is the same width+ // (like a grid) while flex still fills the row.+ "min-w-52 grow-0 basis-[calc((100%_-_1.5rem)/3)]",)}>- <Logo- className={cn(- "w-4 h-4 shrink-0",- selected- ? (chrome.tabLogoColor ?? chrome.logoColor)- : "text-muted-foreground",+ <TabTrigger+ selected={selected}+ isLoading={isLoadingModels}+ >+ <div+ className={cn(+ "flex items-center justify-center gap-2 w-8 h-8 rounded-none border",+ selected+ ? (chrome.tabLogoBgColor ??+ chrome.logoBgColor)+ : "bg-muted",+ )}+ >+ <Logo+ className={cn(+ "w-4 h-4 shrink-0",+ selected+ ? (chrome.tabLogoColor ??+ chrome.logoColor)+ : "text-muted-foreground",+ )}+ />+ </div>+ {chrome.name}+ {providerBadges[providerKey] && (+ <span className="absolute right-0 top-0 rounded border border-muted-foreground/40 bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">+ {providerBadges[providerKey]}+ </span>)}- />- </div>+ </TabTrigger>+ </TabsTrigger>+ </TooltipTrigger>+ <TooltipContent+ side="bottom"+ sideOffset={6}+ className="bg-black text-white border-none rounded-md px-2.5 py-1.5 text-xs shadow-lg [&>svg]:fill-black"+ >{chrome.name}- {providerBadges[providerKey] && (- <span className="absolute right-0 top-0 rounded border border-muted-foreground/40 bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground">- {providerBadges[providerKey]}- </span>- )}- </TabTrigger>- </TabsTrigger>+ <TooltipPrimitive.Arrow+ className="fill-black"+ width={10}+ height={5}+ />+ </TooltipContent>+ </Tooltip>);})}</TabsList>diff --git a/frontend/app/onboarding/_components/onboarding-content.tsx b/frontend/app/onboarding/_components/onboarding-content.tsxindex d4b3ad546..3718832d1 100644--- a/frontend/app/onboarding/_components/onboarding-content.tsx+++ b/frontend/app/onboarding/_components/onboarding-content.tsx@@ -292,9 +292,9 @@ export function OnboardingContent({initial="instant"mass={1}>- <StickToBottom.Content className="flex flex-col min-h-full overflow-x-hidden px-8 py-6">+ <StickToBottom.Content className="flex flex-col min-h-full w-full px-4 py-6 sm:px-8"><div- className="flex flex-col place-self-center w-full space-y-6"+ className="flex flex-col w-full max-w-full space-y-6"data-testid="onboarding-content">{/* Step 1 - LLM Provider */}diff --git a/frontend/app/onboarding/_components/progress-bar.test.tsx b/frontend/app/onboarding/_components/progress-bar.test.tsxnew file mode 100644index 000000000..372d57901--- /dev/null+++ b/frontend/app/onboarding/_components/progress-bar.test.tsx@@ -0,0 +1,24 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { ProgressBar } from "./progress-bar";++vi.mock("@/lib/analytics", () => ({+ trackButton: vi.fn(),+}));++describe("ProgressBar", () => {+ it("renders progress bar and handles skip overview click", async () => {+ const user = userEvent.setup();+ const handleSkip = vi.fn();++ render(<ProgressBar currentStep={2} totalSteps={5} onSkip={handleSkip} />);++ expect(screen.getByText("3/5")).toBeInTheDocument();+ const skipButton = screen.getByTestId("skip-overview-button");+ expect(skipButton).toBeInTheDocument();++ await user.click(skipButton);+ expect(handleSkip).toHaveBeenCalledTimes(1);+ });+});diff --git a/frontend/app/onboarding/_components/progress-bar.tsx b/frontend/app/onboarding/_components/progress-bar.tsxindex 2c04aebce..f16b8c571 100644--- a/frontend/app/onboarding/_components/progress-bar.tsx+++ b/frontend/app/onboarding/_components/progress-bar.tsx@@ -16,10 +16,9 @@ export function ProgressBar({const progressPercentage = ((currentStep + 1) / totalSteps) * 100;return (- <div className="w-full flex items-center px-6 gap-4">- <div className="flex-1" />- <div className="flex items-center gap-3">- <div className="w-48 h-1 bg-background dark:bg-muted rounded-full overflow-hidden">+ <div className="w-full flex flex-wrap items-center justify-center px-6 gap-4">+ <div className="flex items-center gap-3 min-w-0">+ <div className="w-32 sm:w-48 h-1 bg-background dark:bg-muted rounded-full overflow-hidden"><divclassName="h-full transition-all duration-300 ease-in-out"data-testid={`progress-bar-${currentStep}`}@@ -33,27 +32,25 @@ export function ProgressBar({{currentStep + 1}/{totalSteps}</span></div>- <div className="flex-1 flex justify-end">- {currentStep > 1 && onSkip && (- <Button- variant="link"- data-testid="skip-overview-button"- size="sm"- onClick={() => {- trackButton({- CTA: "Skip Overview",- elementId: "skip-overview-button",- namespace: "onboarding",- });- onSkip?.();- }}- className="flex items-center gap-2 text-mmd !text-placeholder-foreground hover:!text-foreground hover:!no-underline"- >- Skip overview- <ArrowRight className="w-4 h-4" />- </Button>- )}- </div>+ {currentStep > 1 && onSkip && (+ <Button+ variant="link"+ data-testid="skip-overview-button"+ size="sm"+ onClick={() => {+ trackButton({+ CTA: "Skip Overview",+ elementId: "skip-overview-button",+ namespace: "onboarding",+ });+ onSkip?.();+ }}+ className="flex items-center gap-2 text-mmd !text-placeholder-foreground hover:!text-foreground hover:!no-underline"+ >+ Skip overview+ <ArrowRight className="w-4 h-4" />+ </Button>+ )}</div>);}diff --git a/frontend/app/settings/_components/connectors-tab.tsx b/frontend/app/settings/_components/connectors-tab.tsxindex 31a2cd933..1388232f9 100644--- a/frontend/app/settings/_components/connectors-tab.tsx+++ b/frontend/app/settings/_components/connectors-tab.tsx@@ -35,7 +35,7 @@ export function ConnectorsTab() {</CardDescription></CardHeader><CardContent>- <div className="bg-muted rounded-md p-4 font-mono text-sm">+ <div className="bg-muted rounded-md p-4 font-mono text-sm overflow-x-auto"><div className="text-muted-foreground"><div><span className="mr-3 text-placeholder-foreground">27</span>@@ -45,9 +45,11 @@ export function ConnectorsTab() {<span className="mr-3 text-placeholder-foreground">28</span><span># Create credentials here:</span></div>- <div>- <span className="mr-3 text-placeholder-foreground">29</span>- <span>+ <div className="flex flex-wrap">+ <span className="mr-3 text-placeholder-foreground shrink-0">+ 29+ </span>+ <span className="break-all"># https://console.cloud.google.com/apis/credentials</span></div>diff --git a/frontend/components/chat-renderer.test.tsx b/frontend/components/chat-renderer.test.tsxnew file mode 100644index 000000000..b626abd96--- /dev/null+++ b/frontend/components/chat-renderer.test.tsx@@ -0,0 +1,220 @@+import { fireEvent, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { renderWithProviders } from "@/test-utils/render";+import { ChatRenderer } from "./chat-renderer";++const {+ mockCollapseSidebar,+ mockExpandSidebar,+ mockHideNow,+ mockUnpinSidebar,+ mockShowSidebar,+ mockHideSidebar,+} = vi.hoisted(() => ({+ mockCollapseSidebar: vi.fn(),+ mockExpandSidebar: vi.fn(),+ mockHideNow: vi.fn(),+ mockUnpinSidebar: vi.fn(),+ mockShowSidebar: vi.fn(),+ mockHideSidebar: vi.fn(),+}));++const mockPush = vi.fn();+vi.mock("next/navigation", () => ({+ usePathname: () => "/chat",+ useRouter: () => ({ push: mockPush }),+}));++vi.mock("@/app/api/queries/useGetConversationsQuery", () => ({+ useGetConversationsQuery: () => ({+ data: [],+ isLoading: false,+ refetch: vi.fn(),+ }),+}));++vi.mock("@/app/api/queries/useGetFilterByIdQuery", () => ({+ getFilterById: vi.fn(),+}));++vi.mock("@/app/api/mutations/useUpdateOnboardingStateMutation", () => ({+ useUpdateOnboardingStateMutation: () => ({+ mutate: vi.fn(),+ }),+}));++vi.mock("@/contexts/auth-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/auth-context")>()),+ useAuth: () => ({+ isAuthenticated: true,+ isNoAuthMode: false,+ }),+}));++vi.mock("@/contexts/brand-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/brand-context")>()),+ useIsCloudBrand: () => false,+}));++vi.mock("@/contexts/chat-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/chat-context")>()),+ useChat: () => ({+ endpoint: "http://localhost",+ refreshTrigger: 0,+ refreshTriggerSilent: 0,+ refreshConversations: 0,+ startNewConversation: vi.fn(),+ setConversationFilter: vi.fn(),+ setOnboardingComplete: vi.fn(),+ currentConversationId: null,+ conversations: [],+ isLoading: false,+ }),+}));++vi.mock("@/hooks/use-permissions", () => ({+ usePermissions: () => ({+ can: () => true,+ isLoading: false,+ rbacEnforced: false,+ }),+}));++vi.mock("@/components/navigation", () => ({+ Navigation: () => <div data-testid="navigation" />,+}));++vi.mock("@/lib/analytics", () => ({+ page: vi.fn(),+}));++vi.mock("@/hooks/use-narrow-layout", () => ({+ useNarrowLayout: vi.fn().mockReturnValue(false),+}));++vi.mock("@/contexts/sidebar-overlay-context", () => ({+ useSidebarOverlay: vi.fn().mockReturnValue({+ isVisible: false,+ isPinned: false,+ isCollapsed: false,+ show: mockShowSidebar,+ hide: mockHideSidebar,+ hideNow: mockHideNow,+ pin: vi.fn(),+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ collapse: mockCollapseSidebar,+ }),+}));++import { useSidebarOverlay } from "@/contexts/sidebar-overlay-context";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";++describe("ChatRenderer", () => {+ const defaultSettings: any = {+ onboarding: {+ current_step: 4,+ },+ };++ it("renders wide layout and responds to separator resize drag & keyboard events", () => {+ // Stub ResizeObserver+ global.ResizeObserver = class {+ observe() {}+ unobserve() {}+ disconnect() {}+ } as any;++ const chromeDiv = document.createElement("div");+ chromeDiv.id = "app-top-chrome";+ Object.defineProperty(chromeDiv, "offsetHeight", {+ value: 60,+ configurable: true,+ });+ document.body.appendChild(chromeDiv);++ renderWithProviders(+ <ChatRenderer settings={defaultSettings}>+ <div data-testid="child-content">Content</div>+ </ChatRenderer>,+ );++ expect(screen.getByTestId("child-content")).toBeInTheDocument();+ expect(screen.getByTestId("navigation")).toBeInTheDocument();++ const separator = screen.getByRole("separator", { name: "Resize sidebar" });+ expect(separator).toBeInTheDocument();++ // Mouse drag+ fireEvent.mouseDown(separator, { clientX: 200 });+ expect(mockHideNow).toHaveBeenCalled();+ fireEvent.mouseMove(document, { clientX: 250 });+ expect(mockExpandSidebar).toHaveBeenCalled();+ fireEvent.mouseMove(document, { clientX: 20 });+ expect(mockCollapseSidebar).toHaveBeenCalled();+ fireEvent.mouseUp(document);++ // Keyboard resize+ fireEvent.keyDown(separator, { key: "ArrowRight" });+ expect(mockExpandSidebar).toHaveBeenCalled();+ fireEvent.keyDown(separator, { key: "ArrowLeft" });++ document.body.removeChild(chromeDiv);+ });++ it("renders collapsed overlay in wide layout when collapsed", () => {+ vi.mocked(useSidebarOverlay).mockReturnValue({+ isVisible: true,+ isPinned: false,+ isCollapsed: true,+ show: mockShowSidebar,+ hide: mockHideSidebar,+ hideNow: mockHideNow,+ pin: vi.fn(),+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ collapse: mockCollapseSidebar,+ });++ renderWithProviders(+ <ChatRenderer settings={defaultSettings}>+ <div>Content</div>+ </ChatRenderer>,+ );++ const nav = screen.getByRole("navigation");+ fireEvent.mouseEnter(nav);+ expect(mockShowSidebar).toHaveBeenCalled();+ fireEvent.mouseLeave(nav);+ expect(mockHideSidebar).toHaveBeenCalled();+ });++ it("renders narrow layout with pinned overlay backdrop", async () => {+ const user = userEvent.setup();+ vi.mocked(useNarrowLayout).mockReturnValue(true);+ vi.mocked(useSidebarOverlay).mockReturnValue({+ isVisible: true,+ isPinned: true,+ isCollapsed: false,+ show: mockShowSidebar,+ hide: mockHideSidebar,+ hideNow: mockHideNow,+ pin: vi.fn(),+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ collapse: mockCollapseSidebar,+ });++ renderWithProviders(+ <ChatRenderer settings={defaultSettings}>+ <div>Content</div>+ </ChatRenderer>,+ );++ const closeNavBtn = screen.getByLabelText("Close navigation");+ expect(closeNavBtn).toBeInTheDocument();+ await user.click(closeNavBtn);+ expect(mockUnpinSidebar).toHaveBeenCalled();+ });+});diff --git a/frontend/components/chat-renderer.tsx b/frontend/components/chat-renderer.tsxindex 27ebc3ce5..3a07b6a3f 100644--- a/frontend/components/chat-renderer.tsx+++ b/frontend/components/chat-renderer.tsx@@ -4,7 +4,13 @@ import { useQueryClient } from "@tanstack/react-query";import { motion } from "framer-motion";import { File, Loader2 } from "lucide-react";import { usePathname, useRouter } from "next/navigation";-import { useCallback, useEffect, useRef, useState } from "react";+import {+ useCallback,+ useEffect,+ useLayoutEffect,+ useRef,+ useState,+} from "react";import { useUpdateOnboardingStateMutation } from "@/app/api/mutations/useUpdateOnboardingStateMutation";import {type ChatConversation,@@ -15,16 +21,19 @@ import type { Settings } from "@/app/api/queries/useGetSettingsQuery";import { OnboardingBlocked } from "@/app/onboarding/_components/onboarding-blocked";import { OnboardingContent } from "@/app/onboarding/_components/onboarding-content";import { ProgressBar } from "@/app/onboarding/_components/progress-bar";-import { AnimatedConditional } from "@/components/animated-conditional";import { Navigation } from "@/components/navigation";import { useAuth } from "@/contexts/auth-context";import { useIsCloudBrand } from "@/contexts/brand-context";import { useChat } from "@/contexts/chat-context";+import { useSidebarOverlay } from "@/contexts/sidebar-overlay-context";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";import { usePermissions } from "@/hooks/use-permissions";import { page } from "@/lib/analytics";import {ANIMATION_DURATION,HEADER_HEIGHT,+ SIDEBAR_HIDE_THRESHOLD,+ SIDEBAR_MIN_WIDTH,SIDEBAR_WIDTH,TOTAL_ONBOARDING_STEPS,} from "@/lib/constants";@@ -43,6 +52,76 @@ export function ChatRenderer({const { isAuthenticated, isNoAuthMode } = useAuth();const { can, isLoading: isPermLoading, rbacEnforced } = usePermissions();const isCloudBrand = useIsCloudBrand();+ const isNarrow = useNarrowLayout();+ const {+ isVisible: sidebarOverlayVisible,+ isPinned: sidebarPinned,+ isCollapsed: sidebarCollapsed,+ show: handleSidebarMouseEnter,+ hide: handleSidebarMouseLeave,+ hideNow,+ unpin: unpinSidebar,+ collapse: collapseSidebar,+ expand: expandSidebar,+ } = useSidebarOverlay();++ const [sidebarWidth, setSidebarWidth] = useState(SIDEBAR_WIDTH);+ const [isResizeDragging, setIsResizeDragging] = useState(false);+ const isDraggingRef = useRef(false);+ const dragStartXRef = useRef(0);+ const dragStartWidthRef = useRef(SIDEBAR_WIDTH);+ const prevCollapsedRef = useRef(false);+ if (prevCollapsedRef.current && !sidebarCollapsed && !isDraggingRef.current) {+ setSidebarWidth(SIDEBAR_WIDTH);+ }+ prevCollapsedRef.current = sidebarCollapsed;++ const handleResizeMouseDown = useCallback(+ (e: React.MouseEvent) => {+ e.preventDefault();+ isDraggingRef.current = true;+ setIsResizeDragging(true);+ hideNow();+ dragStartXRef.current = e.clientX;+ dragStartWidthRef.current = sidebarCollapsed ? 0 : sidebarWidth;++ const onMouseMove = (ev: MouseEvent) => {+ if (!isDraggingRef.current) return;+ const delta = ev.clientX - dragStartXRef.current;+ const next = dragStartWidthRef.current + delta;+ if (next < SIDEBAR_HIDE_THRESHOLD) {+ collapseSidebar();+ } else {+ expandSidebar();+ setSidebarWidth(+ Math.min(SIDEBAR_WIDTH, Math.max(SIDEBAR_MIN_WIDTH, next)),+ );+ }+ };++ const onMouseUp = () => {+ isDraggingRef.current = false;+ setIsResizeDragging(false);+ document.removeEventListener("mousemove", onMouseMove);+ document.removeEventListener("mouseup", onMouseUp);+ };++ document.addEventListener("mousemove", onMouseMove);+ document.addEventListener("mouseup", onMouseUp);+ },+ [sidebarWidth, sidebarCollapsed, collapseSidebar, expandSidebar, hideNow],+ );++ const [topChromeHeight, setTopChromeHeight] = useState(0);++ useLayoutEffect(() => {+ const el = document.getElementById("app-top-chrome");+ if (!el) return;+ const ro = new ResizeObserver(() => setTopChromeHeight(el.offsetHeight));+ ro.observe(el);+ setTopChromeHeight(el.offsetHeight);+ return () => ro.disconnect();+ }, []);const {endpoint,refreshTrigger,@@ -256,11 +335,6 @@ export function ChatRenderer({pathname.startsWith(path),);- const x = showLayout ? "0px" : `calc(-${SIDEBAR_WIDTH / 2}px + 50vw)`;- const y = showLayout ? "0px" : `calc(-${HEADER_HEIGHT / 2}px + 50vh)`;- const translateY = showLayout ? "0px" : `-50vh`;- const translateX = showLayout ? "0px" : `-50vw`;-// Onboarding is admin-only. When the workspace still needs onboarding// (!showLayout) and RBAC is enforced, a non-admin must not see the wizard —// they get a "contact your administrator" screen instead. It renders inside@@ -277,37 +351,145 @@ export function ChatRenderer({}const isOnboardingBlocked = needsOnboardingGate && !can("config:write");- // For all other pages, render with Langflow-styled navigation and task menureturn (<>- {/* Sidebar Navigation */}- <div- className="shrink-0 overflow-hidden"- style={{ width: SIDEBAR_WIDTH }}- >- <AnimatedConditional- isOpen={showLayout}- slide- className="border-r bg-background overflow-hidden h-full w-full"+ {!isNarrow && showLayout && (+ <div+ className="shrink-0 overflow-hidden relative flex border-r bg-background"+ style={{+ width: sidebarCollapsed ? 0 : sidebarWidth,+ transition: isDraggingRef.current ? "none" : "width 200ms ease",+ }}>- {showLayout && (- <Navigation- conversations={conversations}- isConversationsLoading={isConversationsLoading}- onNewConversation={handleNewConversation}- onSelectionChange={setIsSelectingChats}- />+ {!sidebarCollapsed && (+ <>+ <div className="h-full w-full overflow-hidden">+ <Navigation+ conversations={conversations}+ isConversationsLoading={isConversationsLoading}+ onNewConversation={handleNewConversation}+ onSelectionChange={setIsSelectingChats}+ />+ </div>+ <div+ role="separator"+ aria-orientation="vertical"+ aria-label="Resize sidebar"+ tabIndex={0}+ className="absolute right-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-primary/20 active:bg-primary/30 focus-visible:bg-primary/40 transition-colors z-10"+ onMouseDown={handleResizeMouseDown}+ onKeyDown={(e) => {+ const STEP = 20;+ if (e.key === "ArrowRight") {+ e.preventDefault();+ const next = (sidebarCollapsed ? 0 : sidebarWidth) + STEP;+ if (next < SIDEBAR_HIDE_THRESHOLD) {+ collapseSidebar();+ } else {+ expandSidebar();+ setSidebarWidth(+ Math.min(+ SIDEBAR_WIDTH,+ Math.max(SIDEBAR_MIN_WIDTH, next),+ ),+ );+ }+ } else if (e.key === "ArrowLeft") {+ e.preventDefault();+ const next = (sidebarCollapsed ? 0 : sidebarWidth) - STEP;+ if (next < SIDEBAR_HIDE_THRESHOLD) {+ collapseSidebar();+ } else {+ expandSidebar();+ setSidebarWidth(+ Math.min(+ SIDEBAR_WIDTH,+ Math.max(SIDEBAR_MIN_WIDTH, next),+ ),+ );+ }+ }+ }}+ >+ <div className="absolute inset-y-0 -left-1 -right-1" />+ </div>+ </>)}- </AnimatedConditional>- </div>+ </div>+ )}+ {!isNarrow && showLayout && sidebarCollapsed && !isResizeDragging && (+ <div+ className="fixed left-0 bottom-0 z-40 pointer-events-none"+ style={{ width: SIDEBAR_WIDTH, top: topChromeHeight }}+ >+ <nav+ className="h-full w-full pointer-events-auto"+ style={{+ opacity: sidebarOverlayVisible ? 1 : 0,+ transition: "opacity 150ms ease",+ visibility: sidebarOverlayVisible ? "visible" : "hidden",+ }}+ onMouseEnter={handleSidebarMouseEnter}+ onMouseLeave={handleSidebarMouseLeave}+ >+ <div className="h-full w-full border-r bg-background shadow-xl">+ <Navigation+ conversations={conversations}+ isConversationsLoading={isConversationsLoading}+ onNewConversation={handleNewConversation}+ onSelectionChange={setIsSelectingChats}+ />+ </div>+ </nav>+ </div>+ )}- {/* Main Content */}<mainclassName={cn(- "overflow-hidden flex-1 flex items-center justify-center",+ "overflow-hidden flex-1 min-w-0 flex items-center justify-center relative",isSelectingChats && "relative",)}>+ {isNarrow && showLayout && (+ <>+ {sidebarPinned && (+ <button+ type="button"+ aria-label="Close navigation"+ className="fixed inset-0 z-30 bg-black/40 cursor-default border-0"+ style={{ top: topChromeHeight }}+ onClick={unpinSidebar}+ />+ )}+ <div+ className="fixed left-0 bottom-0 z-40 pointer-events-none"+ style={{ width: SIDEBAR_WIDTH, top: topChromeHeight }}+ >+ <nav+ className="h-full w-full pointer-events-auto"+ style={{+ opacity: sidebarOverlayVisible ? 1 : 0,+ transition: "opacity 200ms ease",+ visibility: sidebarOverlayVisible ? "visible" : "hidden",+ }}+ onMouseEnter={handleSidebarMouseEnter}+ onMouseLeave={handleSidebarMouseLeave}+ >+ <div className="h-full w-full border-r bg-background shadow-xl flex flex-col">+ <div className="flex-1 min-h-0">+ <Navigation+ conversations={conversations}+ isConversationsLoading={isConversationsLoading}+ onNewConversation={handleNewConversation}+ onSelectionChange={setIsSelectingChats}+ onNavigate={unpinSidebar}+ />+ </div>+ </div>+ </nav>+ </div>+ </>+ )}{isSelectingChats && (<div className="absolute inset-0 z-10 backdrop-blur-sm bg-background/60 flex items-center justify-center"><div className="flex flex-col items-center gap-3 text-center px-8">@@ -325,38 +507,33 @@ export function ChatRenderer({</div>)}<motion.div- initial={{- width: showLayout ? "100%" : "100vw",- height: showLayout ? "100%" : "100vh",- x: x,- y: y,- translateX: translateX,- translateY: translateY,- }}- animate={{- width: showLayout ? "100%" : "850px",- border: showLayout ? "0" : "1px solid hsl(var(--border))",- borderRadius: showLayout || isCloudBrand ? "0" : "16px",- height: showLayout ? "100%" : "800px",- x: x,- y: y,- translateX: translateX,- translateY: translateY,- }}+ animate={+ showLayout+ ? { border: "0", borderRadius: "0" }+ : {+ border: "1px solid hsl(var(--border))",+ borderRadius: isCloudBrand ? "0" : "16px",+ }+ }transition={{duration: ANIMATION_DURATION,ease: "easeOut",}}+ style={+ showLayout+ ? { width: undefined, height: undefined }+ : { width: "min(850px, 100vw)", height: "800px" }+ }className={cn(- "flex h-full w-full max-w-full max-h-full items-center justify-center overflow-y-auto",+ "flex h-full w-full max-w-full max-h-full items-center justify-center overflow-y-auto overflow-x-hidden",!showLayout &&- "absolute max-h-[calc(100vh-190px)] shadow-[0px_2px_4px_-2px_#0000001A,0px_4px_6px_-1px_#0000001A]",+ "max-h-[calc(100vh-190px)] shadow-[0px_2px_4px_-2px_#0000001A,0px_4px_6px_-1px_#0000001A]",showLayout && !isOnChatPage && "bg-background",)}><divclassName={cn(- "h-full bg-background w-full",+ "h-full bg-background w-full min-w-0 overflow-x-hidden",showLayout && !isOnChatPage && "p-6 container",showLayout && isSmallWidthPath && "max-w-content mx-auto",!showLayout && "p-0 py-2",diff --git a/frontend/components/console-status/button.test.tsx b/frontend/components/console-status/button.test.tsxnew file mode 100644index 000000000..502382f5c--- /dev/null+++ b/frontend/components/console-status/button.test.tsx@@ -0,0 +1,48 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { ConsoleStatusButton } from "./button";++vi.mock("@/hooks/use-narrow-layout", () => ({+ useNarrowLayout: vi.fn().mockReturnValue(false),+}));++import { useNarrowLayout } from "@/hooks/use-narrow-layout";++describe("ConsoleStatusButton", () => {+ it("renders in wide mode and handles clicks", async () => {+ const user = userEvent.setup();+ const handleClick = vi.fn();++ render(+ <ConsoleStatusButton+ onClick={handleClick}+ isOpen={false}+ overallStatus="healthy"+ />,+ );++ const button = screen.getByRole("button", { name: "Console Status" });+ expect(button).toBeInTheDocument();+ expect(screen.getByText("Console Status")).toBeInTheDocument();++ await user.click(button);+ expect(handleClick).toHaveBeenCalledTimes(1);+ });++ it("renders in narrow mode with unhealthy status dot", () => {+ vi.mocked(useNarrowLayout).mockReturnValue(true);++ render(+ <ConsoleStatusButton+ onClick={() => {}}+ isOpen={true}+ overallStatus="unhealthy"+ />,+ );++ const button = screen.getByRole("button", { name: "Console Status" });+ expect(button).toBeInTheDocument();+ expect(screen.queryByText("Console Status")).not.toBeInTheDocument();+ });+});diff --git a/frontend/components/console-status/button.tsx b/frontend/components/console-status/button.tsxindex b1a31299b..7f27c4eb0 100644--- a/frontend/components/console-status/button.tsx+++ b/frontend/components/console-status/button.tsx@@ -2,6 +2,7 @@import { EvCharger } from "lucide-react";import type { ComponentState } from "@/app/api/queries/useConsoleStatusQuery";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";import { statusTokens } from "@/lib/status-utils";import { cn } from "@/lib/utils";@@ -16,6 +17,8 @@ export function ConsoleStatusButton({isOpen,overallStatus,}: ConsoleStatusButtonProps) {+ const isNarrow = useNarrowLayout();+return (<buttontype="button"@@ -24,28 +27,51 @@ export function ConsoleStatusButton({aria-expanded={isOpen}aria-controls="console-status-panel"aria-haspopup="dialog"+ aria-label="Console Status"className={cn(- "flex items-center gap-2 px-3 py-2 rounded-lg",- "bg-zinc-800 border border-zinc-700 text-zinc-200 text-sm font-medium",- "hover:bg-zinc-700 hover:border-zinc-600 transition-colors shadow-lg",- isOpen && "bg-zinc-700 border-zinc-500",+ "relative flex items-center gap-2 rounded-lg transition-colors",+ isNarrow+ ? "h-8 w-8 justify-center hover:bg-muted"+ : "px-3 py-2 bg-zinc-800 border border-zinc-700 text-zinc-200 text-sm font-medium hover:bg-zinc-700 hover:border-zinc-600 shadow-lg",+ !isNarrow && isOpen && "bg-zinc-700 border-zinc-500",)}>- <EvCharger size={14} className="shrink-0 text-zinc-400" />- <span>Console Status</span>- {overallStatus && (- <span className="relative flex h-2 w-2 shrink-0">- {overallStatus === "unhealthy" && (- <span className="absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75 animate-ping motion-reduce:hidden" />- )}- <span- className={cn(- "relative inline-flex h-2 w-2 rounded-full",- statusTokens(overallStatus).dot,+ <EvCharger+ size={isNarrow ? 16 : 14}+ className={cn(+ "shrink-0",+ isNarrow ? "text-muted-foreground" : "text-zinc-400",+ )}+ />+ {!isNarrow && <span>Console Status</span>}+ {overallStatus &&+ (isNarrow ? (+ /* Narrow: top-right corner dot, matching the bell */+ <span className="absolute right-1 top-1 flex h-2 w-2">+ {overallStatus === "unhealthy" && (+ <span className="absolute inline-flex h-full w-full rounded-full bg-destructive opacity-75 animate-ping motion-reduce:hidden" />)}- />- </span>- )}+ <span+ className={cn(+ "relative inline-flex h-2 w-2 rounded-full",+ statusTokens(overallStatus).dot,+ )}+ />+ </span>+ ) : (+ /* Wide: inline dot after the label */+ <span className="relative flex h-2 w-2 shrink-0">+ {overallStatus === "unhealthy" && (+ <span className="absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75 animate-ping motion-reduce:hidden" />+ )}+ <span+ className={cn(+ "relative inline-flex h-2 w-2 rounded-full",+ statusTokens(overallStatus).dot,+ )}+ />+ </span>+ ))}</button>);}diff --git a/frontend/components/header.test.tsx b/frontend/components/header.test.tsxnew file mode 100644index 000000000..c8c094fda--- /dev/null+++ b/frontend/components/header.test.tsx@@ -0,0 +1,129 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { Header } from "./header";++const {+ mockToggleTaskMenu,+ mockToggleConsole,+ mockShowSidebar,+ mockHideSidebar,+ mockPinSidebar,+ mockUnpinSidebar,+ mockExpandSidebar,+} = vi.hoisted(() => ({+ mockToggleTaskMenu: vi.fn(),+ mockToggleConsole: vi.fn(),+ mockShowSidebar: vi.fn(),+ mockHideSidebar: vi.fn(),+ mockPinSidebar: vi.fn(),+ mockUnpinSidebar: vi.fn(),+ mockExpandSidebar: vi.fn(),+}));++vi.mock("@/contexts/brand-context", () => ({+ useIsCloudBrand: () => false,+}));++vi.mock("@/contexts/auth-context", () => ({+ useAuth: () => ({ runMode: "oss" }),+}));++vi.mock("@/contexts/task-context", () => ({+ useTask: () => ({ tasks: [] }),+}));++vi.mock("@/contexts/console-status-context", () => ({+ useToggleTaskMenu: () => mockToggleTaskMenu,+ useConsoleStatus: () => ({+ hasProblem: false,+ toggle: mockToggleConsole,+ isOpen: false,+ overallStatus: "healthy",+ }),+}));++vi.mock("./provider-health-banner", () => ({+ useProviderHealth: () => ({ isUnhealthy: false }),+}));++vi.mock("@/components/user-nav", () => ({+ UserNav: () => <div data-testid="user-nav" />,+}));++vi.mock("@/hooks/use-narrow-layout", () => ({+ useNarrowLayout: vi.fn().mockReturnValue(false),+}));++vi.mock("@/contexts/sidebar-overlay-context", () => ({+ useSidebarOverlay: vi.fn().mockReturnValue({+ show: mockShowSidebar,+ hide: mockHideSidebar,+ isPinned: false,+ isCollapsed: false,+ pin: mockPinSidebar,+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ }),+}));++import { useSidebarOverlay } from "@/contexts/sidebar-overlay-context";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";++describe("Header", () => {+ it("renders brand and header elements in wide non-collapsed layout", () => {+ render(<Header />);+ expect(screen.getByText("OpenRAG")).toBeInTheDocument();+ expect(screen.queryByLabelText("Open navigation")).not.toBeInTheDocument();+ });++ it("renders expand button when collapsed in wide layout", async () => {+ const user = userEvent.setup();+ vi.mocked(useSidebarOverlay).mockReturnValue({+ show: mockShowSidebar,+ hide: mockHideSidebar,+ isPinned: false,+ isCollapsed: true,+ pin: mockPinSidebar,+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ isVisible: false,+ hideNow: vi.fn(),+ collapse: vi.fn(),+ });++ render(<Header />);+ const openBtn = screen.getByLabelText("Open navigation");+ expect(openBtn).toBeInTheDocument();++ await user.hover(openBtn);+ expect(mockShowSidebar).toHaveBeenCalled();++ await user.click(openBtn);+ expect(mockExpandSidebar).toHaveBeenCalled();+ });++ it("renders open/close navigation toggle in narrow layout", async () => {+ const user = userEvent.setup();+ vi.mocked(useNarrowLayout).mockReturnValue(true);+ vi.mocked(useSidebarOverlay).mockReturnValue({+ show: mockShowSidebar,+ hide: mockHideSidebar,+ isPinned: false,+ isCollapsed: false,+ pin: mockPinSidebar,+ unpin: mockUnpinSidebar,+ expand: mockExpandSidebar,+ isVisible: false,+ hideNow: vi.fn(),+ collapse: vi.fn(),+ });++ render(<Header />);+ const navBtn = screen.getByLabelText("Open navigation");+ expect(navBtn).toBeInTheDocument();++ await user.click(navBtn);+ expect(mockPinSidebar).toHaveBeenCalled();+ });+});diff --git a/frontend/components/header.tsx b/frontend/components/header.tsxindex bd9b6e6c7..792e7eca4 100644--- a/frontend/components/header.tsx+++ b/frontend/components/header.tsx@@ -1,6 +1,6 @@"use client";-import { Bell } from "lucide-react";+import { Bell, PanelLeft } from "lucide-react";import { BrandSwitcher } from "@/components/brand-switcher";import { ConsoleStatusButton } from "@/components/console-status";import { DevRoleToggle } from "@/components/dev-role-toggle";@@ -12,7 +12,9 @@ import {useConsoleStatus,useToggleTaskMenu,} from "@/contexts/console-status-context";+import { useSidebarOverlay } from "@/contexts/sidebar-overlay-context";import { useTask } from "@/contexts/task-context";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";import { cn } from "@/lib/utils";import { useProviderHealth } from "./provider-health-banner";@@ -21,6 +23,16 @@ export function Header() {const { tasks } = useTask();const toggleTaskMenu = useToggleTaskMenu();const { runMode } = useAuth();+ const isNarrow = useNarrowLayout();+ const {+ show: showSidebar,+ hide: hideSidebar,+ isPinned,+ isCollapsed,+ pin: pinSidebar,+ unpin: unpinSidebar,+ expand: expandSidebar,+ } = useSidebarOverlay();const {hasProblem,@@ -47,15 +59,39 @@ export function Header() {return (<header className={cn(`flex w-full h-full items-center justify-between`)}><div className="header-start-display px-[16px]">- {/* Logo/Title */}- <div className="flex items-center">- <Logo className="fill-foreground" width={24} height={22} />- <span- className="text-lg font-semibold pl-2.5"- style={{ fontFamily: '"IBM Plex Mono", monospace' }}- >- OpenRAG- </span>+ <div className="flex items-center gap-2">+ {isNarrow ? (+ <button+ type="button"+ aria-label={isPinned ? "Close navigation" : "Open navigation"}+ onMouseEnter={showSidebar}+ onMouseLeave={hideSidebar}+ onClick={isPinned ? unpinSidebar : pinSidebar}+ className="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"+ >+ <PanelLeft className="size-5" />+ </button>+ ) : isCollapsed ? (+ <button+ type="button"+ aria-label="Open navigation"+ onMouseEnter={showSidebar}+ onMouseLeave={hideSidebar}+ onClick={expandSidebar}+ className="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"+ >+ <PanelLeft className="size-5" />+ </button>+ ) : null}+ <div className="flex items-center">+ <Logo className="fill-foreground" width={24} height={22} />+ <span+ className="text-lg font-semibold pl-2.5"+ style={{ fontFamily: '"IBM Plex Mono", monospace' }}+ >+ OpenRAG+ </span>+ </div></div></div><div className="header-end-division">diff --git a/frontend/components/layout-wrapper.tsx b/frontend/components/layout-wrapper.tsxindex 1afec756a..f07cf2468 100644--- a/frontend/components/layout-wrapper.tsx+++ b/frontend/components/layout-wrapper.tsx@@ -101,7 +101,7 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {return (<divclassName={cn(- "h-screen w-screen flex flex-col relative",+ "h-screen w-full max-w-full flex flex-col relative overflow-x-hidden",isCloudBrand ? "bg-background" : "bg-muted dark:bg-black",)}>diff --git a/frontend/components/navigation.test.tsx b/frontend/components/navigation.test.tsxnew file mode 100644index 000000000..11782f7e7--- /dev/null+++ b/frontend/components/navigation.test.tsx@@ -0,0 +1,79 @@+import { fireEvent, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { KnowledgeFilterProvider } from "@/contexts/knowledge-filter-context";+import { renderWithProviders } from "@/test-utils/render";+import { Navigation } from "./navigation";++vi.mock("next/navigation", () => ({+ usePathname: () => "/chat",+ useRouter: () => ({ push: vi.fn() }),+}));++vi.mock("@/contexts/brand-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/brand-context")>()),+ useIsCloudBrand: () => false,+}));++vi.mock("@/contexts/auth-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/auth-context")>()),+ useAuth: () => ({ isNoAuthMode: false }),+}));++vi.mock("@/contexts/chat-context", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/contexts/chat-context")>()),+ useChat: () => ({+ currentConversationId: "conv-1",+ loadConversation: vi.fn(),+ startNewConversation: vi.fn(),+ deleteConversation: vi.fn(),+ renameConversation: vi.fn(),+ loading: false,+ }),+}));++vi.mock("@/hooks/use-permissions", () => ({+ usePermissions: () => ({+ can: () => true,+ canAny: () => true,+ isPending: false,+ rbacEnforced: false,+ }),+}));++vi.mock("@/app/api/queries/useGetFiltersQuery", () => ({+ useGetFiltersQuery: () => ({+ data: [],+ isLoading: false,+ }),+}));++describe("Navigation", () => {+ it("triggers onNavigate when route link or conversation item is clicked", async () => {+ const user = userEvent.setup();+ const handleNavigate = vi.fn();++ const conversations = [+ {+ response_id: "conv-1",+ title: "Test Conversation",+ timestamp: "2025-01-01T00:00:00Z",+ },+ ];++ renderWithProviders(+ <KnowledgeFilterProvider>+ <Navigation+ conversations={conversations as any}+ isConversationsLoading={false}+ onNavigate={handleNavigate}+ />+ </KnowledgeFilterProvider>,+ );++ // Test conversation item click triggers onNavigate+ const conversationItem = screen.getByText("Test Conversation");+ await user.click(conversationItem);+ expect(handleNavigate).toHaveBeenCalled();+ });+});diff --git a/frontend/components/navigation.tsx b/frontend/components/navigation.tsxindex ef3a4c0cb..2673338ca 100644--- a/frontend/components/navigation.tsx+++ b/frontend/components/navigation.tsx@@ -72,6 +72,7 @@ interface NavigationProps {isConversationsLoading?: boolean;onNewConversation?: () => void;onSelectionChange?: (isSelecting: boolean) => void;+ onNavigate?: () => void;}export function Navigation({@@ -79,6 +80,7 @@ export function Navigation({isConversationsLoading = false,onNewConversation,onSelectionChange,+ onNavigate,}: NavigationProps = {}) {const isCloudBrand = useIsCloudBrand();const pathname = usePathname();@@ -396,7 +398,11 @@ export function Navigation({{isDisabled ? (<div className={tabClassName}>{tabContent}</div>) : (- <Link href={route.href} className={tabClassName}>+ <Link+ href={route.href}+ className={tabClassName}+ onClick={onNavigate}+ >{tabContent}</Link>)}@@ -584,6 +590,7 @@ export function Navigation({}if (loading || isConversationsLoading) return;loadConversation(conversation);+ onNavigate?.();// Don't refresh - just loading an existing conversation}}disabled={loading || isConversationsLoading}diff --git a/frontend/components/provider-health-banner.test.tsx b/frontend/components/provider-health-banner.test.tsxnew file mode 100644index 000000000..a41f5a5cf--- /dev/null+++ b/frontend/components/provider-health-banner.test.tsx@@ -0,0 +1,70 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { ProviderHealthBanner } from "./provider-health-banner";++const mockPush = vi.fn();+vi.mock("next/navigation", () => ({+ useRouter: () => ({ push: mockPush }),+}));++vi.mock("@/app/api/queries/useProviderHealthQuery", () => ({+ useProviderHealthQuery: vi.fn(),+}));++vi.mock("@/contexts/chat-context", () => ({+ useChat: () => ({ hasChatError: false }),+}));++vi.mock("@/hooks/use-narrow-layout", () => ({+ useNarrowLayout: vi.fn().mockReturnValue(false),+}));++import { useProviderHealthQuery } from "@/app/api/queries/useProviderHealthQuery";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";++describe("ProviderHealthBanner", () => {+ it("renders unhealthy state and navigates to fix setup", async () => {+ const user = userEvent.setup();+ vi.mocked(useProviderHealthQuery).mockReturnValue({+ data: {+ status: "unhealthy",+ provider: "openai",+ llm_error: "Invalid API Key",+ },+ isLoading: false,+ isFetching: false,+ error: null,+ isError: false,+ } as any);++ render(<ProviderHealthBanner />);++ expect(+ screen.getByText(/OpenAI error - Invalid API Key/i),+ ).toBeInTheDocument();+ const fixButton = screen.getByRole("button", { name: "Fix Setup" });+ await user.click(fixButton);+ expect(mockPush).toHaveBeenCalledWith("/settings?setup=openai");+ });++ it("renders in narrow mode", () => {+ vi.mocked(useNarrowLayout).mockReturnValue(true);+ vi.mocked(useProviderHealthQuery).mockReturnValue({+ data: {+ status: "unhealthy",+ provider: "openai",+ llm_error: "Invalid API Key",+ },+ isLoading: false,+ isFetching: false,+ error: null,+ isError: false,+ } as any);++ render(<ProviderHealthBanner />);+ expect(+ screen.getByText(/OpenAI error - Invalid API Key/i),+ ).toBeInTheDocument();+ });+});diff --git a/frontend/components/provider-health-banner.tsx b/frontend/components/provider-health-banner.tsxindex 10342803f..f026ec9b0 100644--- a/frontend/components/provider-health-banner.tsx+++ b/frontend/components/provider-health-banner.tsx@@ -6,6 +6,7 @@ import { useProviderHealthQuery } from "@/app/api/queries/useProviderHealthQueryimport { getProviderChrome } from "@/components/models/model-helpers";import { Banner, BannerIcon, BannerTitle } from "@/components/ui/banner";import { useChat } from "@/contexts/chat-context";+import { useNarrowLayout } from "@/hooks/use-narrow-layout";import { cn } from "@/lib/utils";import { Button } from "./ui/button";@@ -51,6 +52,7 @@ export function useProviderHealth() {export function ProviderHealthBanner({ className }: ProviderHealthBannerProps) {const { isLoading, isHealthy, isUnhealthy, health } = useProviderHealth();const router = useRouter();+ const isNarrow = useNarrowLayout();// Only show banner when provider is unhealthy (not when backend is unavailable)if (isLoading || isHealthy) {@@ -110,17 +112,27 @@ export function ProviderHealthBanner({ className }: ProviderHealthBannerProps) {<BannerclassName={cn("bg-red-50 dark:bg-red-950 text-foreground border-accent-red border-b w-full",+ isNarrow && "flex-wrap gap-y-1 py-2",className,)}><BannerIcon- className="text-accent-red-foreground"+ className="text-accent-red-foreground shrink-0"icon={AlertTriangle}/>- <BannerTitle className="font-medium flex items-center gap-2">+ <BannerTitle+ className={cn(+ "font-medium flex items-center gap-2",+ isNarrow && "text-xs",+ )}+ >{bannerLabel}</BannerTitle>- <Button size="sm" onClick={() => router.push(settingsUrl)}>+ <Button+ size="sm"+ className="shrink-0"+ onClick={() => router.push(settingsUrl)}+ >Fix Setup</Button></Banner>diff --git a/frontend/contexts/sidebar-overlay-context.test.tsx b/frontend/contexts/sidebar-overlay-context.test.tsxnew file mode 100644index 000000000..912db07f6--- /dev/null+++ b/frontend/contexts/sidebar-overlay-context.test.tsx@@ -0,0 +1,103 @@+import { act, renderHook } from "@testing-library/react";+import type { ReactNode } from "react";+import { describe, expect, it, vi } from "vitest";+import {+ SidebarOverlayProvider,+ useSidebarOverlay,+} from "./sidebar-overlay-context";++describe("SidebarOverlayContext", () => {+ it("provides fallback default callbacks when used outside provider", () => {+ const { result } = renderHook(() => useSidebarOverlay());+ expect(result.current.isVisible).toBe(false);+ expect(result.current.isPinned).toBe(false);+ expect(result.current.isCollapsed).toBe(false);+ // Call fallback functions to ensure coverage+ result.current.show();+ result.current.hide();+ result.current.hideNow();+ result.current.pin();+ result.current.unpin();+ result.current.expand();+ result.current.collapse();+ });++ it("manages visibility, pinned, and collapsed states correctly", () => {+ vi.useFakeTimers();++ const wrapper = ({ children }: { children: ReactNode }) => (+ <SidebarOverlayProvider>{children}</SidebarOverlayProvider>+ );++ const { result } = renderHook(() => useSidebarOverlay(), { wrapper });++ expect(result.current.isVisible).toBe(false);+ expect(result.current.isPinned).toBe(false);+ expect(result.current.isCollapsed).toBe(false);++ // show+ act(() => {+ result.current.show();+ });+ expect(result.current.isVisible).toBe(true);++ // hide with timeout+ act(() => {+ result.current.hide();+ });+ expect(result.current.isVisible).toBe(true);+ act(() => {+ vi.advanceTimersByTime(250);+ });+ expect(result.current.isVisible).toBe(false);++ // hideNow+ act(() => {+ result.current.show();+ });+ expect(result.current.isVisible).toBe(true);+ act(() => {+ result.current.hideNow();+ });+ expect(result.current.isVisible).toBe(false);++ // pin & unpin+ act(() => {+ result.current.pin();+ });+ expect(result.current.isPinned).toBe(true);+ expect(result.current.isVisible).toBe(true);++ // hide while pinned should do nothing+ act(() => {+ result.current.hide();+ });+ act(() => {+ vi.advanceTimersByTime(250);+ });+ expect(result.current.isVisible).toBe(true);++ // unpin+ act(() => {+ result.current.unpin();+ });+ expect(result.current.isPinned).toBe(false);+ act(() => {+ vi.advanceTimersByTime(250);+ });+ expect(result.current.isVisible).toBe(false);++ // collapse & expand+ act(() => {+ result.current.collapse();+ });+ expect(result.current.isCollapsed).toBe(true);++ act(() => {+ result.current.expand();+ });+ expect(result.current.isCollapsed).toBe(false);++ vi.useRealTimers();+ });+});diff --git a/frontend/contexts/sidebar-overlay-context.tsx b/frontend/contexts/sidebar-overlay-context.tsxnew file mode 100644index 000000000..dd7d78cb3--- /dev/null+++ b/frontend/contexts/sidebar-overlay-context.tsx@@ -0,0 +1,124 @@+"use client";++import {+ createContext,+ type ReactNode,+ use,+ useCallback,+ useMemo,+ useRef,+ useState,+} from "react";++interface SidebarOverlayContextType {+ isVisible: boolean;+ isPinned: boolean;+ isCollapsed: boolean;+ show: () => void;+ hide: () => void;+ hideNow: () => void;+ pin: () => void;+ unpin: () => void;+ expand: () => void;+ collapse: () => void;+}++const SidebarOverlayContext = createContext<+ SidebarOverlayContextType | undefined+>(undefined);++export function SidebarOverlayProvider({ children }: { children: ReactNode }) {+ const [isVisible, setIsVisible] = useState(false);+ const [isPinned, setIsPinned] = useState(false);+ const [isCollapsed, setIsCollapsed] = useState(false);+ const hideTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);++ const show = useCallback(() => {+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);+ setIsVisible(true);+ }, []);++ const hide = useCallback(() => {+ if (isPinned) return;+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);+ hideTimerRef.current = setTimeout(() => {+ hideTimerRef.current = null;+ setIsVisible(false);+ }, 200);+ }, [isPinned]);++ const pin = useCallback(() => {+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);+ setIsPinned(true);+ setIsVisible(true);+ }, []);++ const unpin = useCallback(() => {+ setIsPinned(false);+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);+ hideTimerRef.current = setTimeout(() => {+ hideTimerRef.current = null;+ setIsVisible(false);+ }, 200);+ }, []);++ const hideNow = useCallback(() => {+ if (hideTimerRef.current) clearTimeout(hideTimerRef.current);+ setIsVisible(false);+ }, []);++ const collapse = useCallback(() => setIsCollapsed(true), []);+ const expand = useCallback(() => setIsCollapsed(false), []);++ const value = useMemo(+ () => ({+ isVisible,+ isPinned,+ isCollapsed,+ show,+ hide,+ hideNow,+ pin,+ unpin,+ expand,+ collapse,+ }),+ [+ isVisible,+ isPinned,+ isCollapsed,+ show,+ hide,+ hideNow,+ pin,+ unpin,+ expand,+ collapse,+ ],+ );++ return (+ <SidebarOverlayContext.Provider value={value}>+ {children}+ </SidebarOverlayContext.Provider>+ );+}++export function useSidebarOverlay(): SidebarOverlayContextType {+ const ctx = use(SidebarOverlayContext);+ if (!ctx) {+ return {+ isVisible: false,+ isPinned: false,+ isCollapsed: false,+ show: () => {},+ hide: () => {},+ hideNow: () => {},+ pin: () => {},+ unpin: () => {},+ expand: () => {},+ collapse: () => {},+ };+ }+ return ctx;+}diff --git a/frontend/hooks/use-narrow-layout.test.ts b/frontend/hooks/use-narrow-layout.test.tsnew file mode 100644index 000000000..ee28172b7--- /dev/null+++ b/frontend/hooks/use-narrow-layout.test.ts@@ -0,0 +1,36 @@+import { act, renderHook } from "@testing-library/react";+import { describe, expect, it, vi } from "vitest";+import { useNarrowLayout } from "./use-narrow-layout";++describe("useNarrowLayout", () => {+ it("returns true when viewport matches narrow query and false otherwise", () => {+ let changeHandler: (() => void) | null = null;+ let matchesValue = false;++ vi.stubGlobal(+ "matchMedia",+ vi.fn().mockImplementation((query: string) => ({+ matches: matchesValue,+ media: query,+ addEventListener: vi.fn((event: string, handler: () => void) => {+ if (event === "change") changeHandler = handler;+ }),+ removeEventListener: vi.fn(),+ })),+ );++ const { result, rerender } = renderHook(() => useNarrowLayout());+ expect(result.current).toBe(false);++ matchesValue = true;+ act(() => {+ if (changeHandler) {+ (changeHandler as () => void)();+ }+ });+ rerender();+ expect(result.current).toBe(true);++ vi.unstubAllGlobals();+ });+});diff --git a/frontend/hooks/use-narrow-layout.ts b/frontend/hooks/use-narrow-layout.tsnew file mode 100644index 000000000..4c4c1ca0b--- /dev/null+++ b/frontend/hooks/use-narrow-layout.ts@@ -0,0 +1,32 @@+import { useSyncExternalStore } from "react";++const NARROW_BREAKPOINT = 720;++/**+ * Returns true when the viewport width is at or below NARROW_BREAKPOINT.+ * Edit that constant to change when the collapsed sidebar layout kicks in.+ *+ * Uses useSyncExternalStore so the value is correct on the first client+ * render — no 1-2 second flash where the wide layout briefly renders on a+ * narrow viewport before the useEffect hydration fix kicks in.+ */++function subscribe(cb: () => void) {+ const mq = window.matchMedia(`(max-width: ${NARROW_BREAKPOINT}px)`);+ mq.addEventListener("change", cb);+ return () => mq.removeEventListener("change", cb);+}++function getSnapshot() {+ return window.matchMedia(`(max-width: ${NARROW_BREAKPOINT}px)`).matches;+}++function getServerSnapshot() {+ // During SSR we don't know the viewport — default to false (wide).+ // The client will correct immediately on first paint via getSnapshot.+ return false;+}++export function useNarrowLayout(): boolean {+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);+}diff --git a/frontend/lib/constants.ts b/frontend/lib/constants.tsindex 38f242ef1..1cb4a3a2a 100644--- a/frontend/lib/constants.ts+++ b/frontend/lib/constants.ts@@ -43,6 +43,10 @@ export const SEARCH_CONSTANTS = {export const ANIMATION_DURATION = 0.4;export const SIDEBAR_WIDTH = 280;+/** Minimum width before the resizable sidebar auto-hides (px) */+export const SIDEBAR_HIDE_THRESHOLD = 120;+/** Minimum visible width for a resized sidebar (px) */+export const SIDEBAR_MIN_WIDTH = 180;export const HEADER_HEIGHT = 54;export const TOTAL_ONBOARDING_STEPS = 4;