Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

feat: Design update cardless (#2415)

Mike Fortman057859d57135
diff --git a/frontend/app/globals.css b/frontend/app/globals.css
index 2e82a67d8..8e72960c1 100644
--- a/frontend/app/globals.css
+++ b/frontend/app/globals.css
@@ -683,12 +683,17 @@
}
}
- /* IBM Settings: inline links (Link/link-primary) */
- [data-theme="ibm"] .ibm-settings-page a[href] {
+ /* IBM Settings: inline links (Link/link-primary) — tabs are links too, but
+ they use the blue underline border, not text-decoration */
+ [data-theme="ibm"]
+ .ibm-settings-page
+ a[href]:not([data-slot="tabs-trigger"]) {
color: hsl(var(--link-primary));
}
- [data-theme="ibm"] .ibm-settings-page a[href]:hover {
+ [data-theme="ibm"]
+ .ibm-settings-page
+ a[href]:not([data-slot="tabs-trigger"]):hover {
text-decoration: underline;
text-underline-offset: 2px;
}
diff --git a/frontend/app/onboarding/_components/progress-bar.tsx b/frontend/app/onboarding/_components/progress-bar.tsx
index f16b8c571..7e425a6bd 100644
--- a/frontend/app/onboarding/_components/progress-bar.tsx
+++ b/frontend/app/onboarding/_components/progress-bar.tsx
@@ -17,6 +17,7 @@ export function ProgressBar({
return (
<div className="w-full flex flex-wrap items-center justify-center px-6 gap-4">
+ <div className="hidden sm:block sm:flex-1" />
<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">
<div
@@ -32,25 +33,27 @@ export function ProgressBar({
{currentStep + 1}/{totalSteps}
</span>
</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 className="w-full sm:w-auto sm:flex-1 flex justify-center sm: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>
</div>
);
}
diff --git a/frontend/app/settings/_components/agent-settings-section.test.tsx b/frontend/app/settings/_components/agent-settings-section.test.tsx
new file mode 100644
index 000000000..a79ab8d83
--- /dev/null
+++ b/frontend/app/settings/_components/agent-settings-section.test.tsx
@@ -0,0 +1,63 @@
+import { fireEvent, screen, waitFor } from "@testing-library/react";
+import { HttpResponse, http } from "msw";
+import { describe, expect, it, vi } from "vitest";
+import { authPresets } from "@/test-utils/fixtures/auth";
+import { makeSettings } from "@/test-utils/fixtures/settings";
+import { renderWithProviders } from "@/test-utils/render";
+import { AgentSettingsSection } from "./agent-settings-section";
+
+vi.mock("@/lib/analytics", () => ({ trackButton: vi.fn() }));
+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+
+function handlers() {
+ return [
+ http.get("/api/settings", () =>
+ HttpResponse.json(
+ makeSettings({
+ agent: {
+ system_prompt: "Be helpful.",
+ default_system_prompt: "Default instructions.",
+ },
+ }),
+ ),
+ ),
+ http.get("/api/models/catalog", () => HttpResponse.json({ providers: [] })),
+ http.get("/api/models/providers", () => HttpResponse.json({})),
+ ];
+}
+
+function renderSection() {
+ return renderWithProviders(<AgentSettingsSection />, {
+ providers: ["tooltip", "auth", "brand", "unsavedChanges"],
+ auth: authPresets.admin,
+ handlers: handlers(),
+ });
+}
+
+describe("AgentSettingsSection", () => {
+ it("updates the system prompt as the user types", async () => {
+ renderSection();
+
+ const textarea = await screen.findByPlaceholderText(
+ "Enter your agent instructions here...",
+ );
+ await waitFor(() => expect(textarea).toHaveValue("Be helpful."));
+
+ fireEvent.change(textarea, { target: { value: "Be very helpful." } });
+ expect(textarea).toHaveValue("Be very helpful.");
+ });
+
+ it("restores the default system prompt when 'Restore default' is clicked", async () => {
+ renderSection();
+
+ const textarea = await screen.findByPlaceholderText(
+ "Enter your agent instructions here...",
+ );
+ await waitFor(() => expect(textarea).toHaveValue("Be helpful."));
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /restore default/i }),
+ );
+ expect(textarea).toHaveValue("Default instructions.");
+ });
+});
diff --git a/frontend/app/settings/_components/agent-settings-section.tsx b/frontend/app/settings/_components/agent-settings-section.tsx
index b066d7451..e38bbe481 100644
--- a/frontend/app/settings/_components/agent-settings-section.tsx
+++ b/frontend/app/settings/_components/agent-settings-section.tsx
@@ -20,13 +20,7 @@ import {
import { ModelSelector } from "@/components/models/model-selector";
import { RequirePermission } from "@/components/require-permission";
import { Button } from "@/components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
+import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { useAuth } from "@/contexts/auth-context";
import { useIsCloudBrand } from "@/contexts/brand-context";
@@ -237,6 +231,15 @@ export function AgentSettingsSection() {
}
}),
)
+ .then(() =>
+ // The flow reset above only replaces the Langflow graph. The system
+ // prompt lives in a separate store, so restore must persist the
+ // default there too, or it reverts on refresh while leaving Save
+ // stuck enabled against it.
+ updateSettingsMutation.mutateAsync({
+ system_prompt: DEFAULT_AGENT_SETTINGS.system_prompt,
+ }),
+ )
.then(() => {
setSystemPrompt(DEFAULT_AGENT_SETTINGS.system_prompt);
setUserEdited(false);
@@ -254,180 +257,179 @@ export function AgentSettingsSection() {
};
return (
- <Card id="agent-card">
- <CardHeader>
- <div className="flex items-center justify-between mb-3">
- <CardTitle
+ <section id="agent-card" className="space-y-8">
+ <header className="flex flex-col gap-6 md:flex-row md:items-start md:justify-between">
+ <div className="max-w-[685px] space-y-3">
+ <h3
className={cn(
- "text-lg",
+ "text-lg font-semibold leading-tight tracking-tight",
isCloudBrand && "ibm-settings-section-title",
)}
>
Agent
- </CardTitle>
- <RequirePermission perm="flows:edit">
- <div className="flex gap-2">
- <ConfirmationDialog
- trigger={
- <Button ignoreTitleCase={true} variant="outline">
- Restore flow
- </Button>
- }
- title="Restore default Agent flow"
- description="This restores defaults and discards all custom settings and overrides. This can't be undone."
- confirmText="Restore"
- variant="destructive"
- onConfirm={handleRestoreRetrievalFlow}
- isLoading={isRestoringFlow}
- />
- <ConfirmationDialog
- trigger={
- <Button>
- <LangflowIcon />
- Edit in Langflow
- </Button>
- }
- title="Edit Agent flow in Langflow"
- description={
- <>
- <p className="mb-2">
- You&apos;re entering Langflow. You can edit the{" "}
- <b>Agent flow</b> and other underlying flows. Manual
- changes to components, wiring, or I/O can break this
- experience.
- </p>
- <p className="mb-2">
- To enable editing, you need to unlock the flow by clicking
- on its name and disabling the <b>Lock flow</b> option.
- </p>
- <p>You can restore this flow from Settings.</p>
- </>
- }
- confirmText="Proceed"
- confirmIcon={<ArrowUpRight />}
- onConfirm={handleEditInLangflow}
- variant="warning"
- />
- </div>
- </RequirePermission>
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ This Agent retrieves from your knowledge and generates chat
+ responses. Edit in Langflow for full control.
+ </p>
</div>
- <CardDescription>
- This Agent retrieves from your knowledge and generates chat responses.
- Edit in Langflow for full control.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <div className="space-y-6">
- <div className="space-y-6">
- <LabelWrapper
- label="Language model"
- helperText={
- needsExplicitLlmModel ? undefined : "Model used for chat"
+ <RequirePermission perm="flows:edit">
+ <div className="flex shrink-0 gap-2">
+ <ConfirmationDialog
+ trigger={
+ <Button ignoreTitleCase={true} variant="outline">
+ Restore flow
+ </Button>
}
+ title="Restore default Agent flow"
+ description="This restores defaults and discards all custom settings and overrides. This can't be undone."
+ confirmText="Restore"
+ variant="destructive"
+ onConfirm={handleRestoreRetrievalFlow}
+ isLoading={isRestoringFlow}
+ />
+ <ConfirmationDialog
+ trigger={
+ <Button>
+ <LangflowIcon />
+ Edit in Langflow
+ </Button>
+ }
+ title="Edit Agent flow in Langflow"
description={
- needsExplicitLlmModel
- ? "Select or enter an Azure deployment name before chatting"
- : undefined
+ <>
+ <p className="mb-2">
+ You&apos;re entering Langflow. You can edit the{" "}
+ <b>Agent flow</b> and other underlying flows. Manual changes
+ to components, wiring, or I/O can break this experience.
+ </p>
+ <p className="mb-2">
+ To enable editing, you need to unlock the flow by clicking
+ on its name and disabling the <b>Lock flow</b> option.
+ </p>
+ <p>You can restore this flow from Settings.</p>
+ </>
}
- id="language-model"
- required={true}
- >
- <ModelSelector
- groupedOptions={groupedLlmModels}
- custom
- noOptionsPlaceholder={
- isLoadingAnyLlmModels
- ? "Loading models..."
- : catalogError
- ? "Could not load the model catalogue. Retry later."
- : "No language models detected. Configure a provider first."
- }
- value={settings.agent?.llm_model || ""}
- selectedProvider={settings.agent?.llm_provider}
- onValueChange={handleModelChange}
- searchPlaceholder={
- requiresExplicitModelSelection(settings.agent?.llm_provider)
- ? "Search models or type Azure deployment name"
- : undefined
- }
- hasError={needsExplicitLlmModel}
- defaultOpen={openLlmSelector}
- />
- </LabelWrapper>
- {settings.agent?.llm_model && selectedLlmGroup && (
- <ModelFeatures
- model={
- selectedLlm?.model ?? { model: settings.agent.llm_model }
- }
- providerName={selectedLlmGroup.group}
- provider={selectedLlmGroup.provider}
- />
- )}
+ confirmText="Proceed"
+ confirmIcon={<ArrowUpRight />}
+ onConfirm={handleEditInLangflow}
+ variant="warning"
+ />
</div>
- <div className="space-y-2">
- <LabelWrapper label="Agent Instructions" id="system-prompt">
- <Textarea
- id="system-prompt"
- placeholder="Enter your agent instructions here..."
- value={systemPrompt}
- onChange={(e) => {
- setUserEdited(true);
- setSystemPrompt(e.target.value);
- }}
- rows={6}
- className={`resize-none ${
- systemPrompt.length > MAX_SYSTEM_PROMPT_CHARS
- ? "!border-destructive focus:border-destructive"
- : ""
- }`}
- />
- </LabelWrapper>
+ </RequirePermission>
+ </header>
+ <div className="space-y-6">
+ <div className="space-y-6">
+ <LabelWrapper
+ label="Language model"
+ helperText={
+ needsExplicitLlmModel ? undefined : "Model used for chat"
+ }
+ description={
+ needsExplicitLlmModel
+ ? "Select or enter an Azure deployment name before chatting"
+ : undefined
+ }
+ id="language-model"
+ required={true}
+ >
+ <ModelSelector
+ groupedOptions={groupedLlmModels}
+ custom
+ noOptionsPlaceholder={
+ isLoadingAnyLlmModels
+ ? "Loading models..."
+ : catalogError
+ ? "Could not load the model catalogue. Retry later."
+ : "No language models detected. Configure a provider first."
+ }
+ value={settings.agent?.llm_model || ""}
+ selectedProvider={settings.agent?.llm_provider}
+ onValueChange={handleModelChange}
+ searchPlaceholder={
+ requiresExplicitModelSelection(settings.agent?.llm_provider)
+ ? "Search models or type Azure deployment name"
+ : undefined
+ }
+ hasError={needsExplicitLlmModel}
+ defaultOpen={openLlmSelector}
+ />
+ </LabelWrapper>
+ {settings.agent?.llm_model && selectedLlmGroup && (
+ <ModelFeatures
+ model={selectedLlm?.model ?? { model: settings.agent.llm_model }}
+ providerName={selectedLlmGroup.group}
+ provider={selectedLlmGroup.provider}
+ />
+ )}
+ </div>
+ <div className="space-y-2">
+ <div className="flex items-center justify-between gap-4">
+ <Label htmlFor="system-prompt" className="font-medium !text-mmd">
+ Agent instructions
+ </Label>
<span
- className={`text-xs ${
+ aria-live="polite"
+ className={cn(
+ "text-xs tabular-nums",
systemPrompt.length > MAX_SYSTEM_PROMPT_CHARS
? "text-destructive"
- : "text-muted-foreground"
- }`}
+ : "text-muted-foreground",
+ )}
>
- {systemPrompt.length}/{MAX_SYSTEM_PROMPT_CHARS} characters
+ {systemPrompt.length}/{MAX_SYSTEM_PROMPT_CHARS}
</span>
</div>
- <div className="flex justify-end pt-2 gap-2">
- {settings.agent?.default_system_prompt && (
- <Button
- onClick={() => {
- setUserEdited(true);
- setSystemPrompt(settings.agent?.default_system_prompt || "");
- }}
- variant="outline"
- size="sm"
- disabled={systemPrompt === settings.agent.default_system_prompt}
- >
- Restore Default
- </Button>
+ <Textarea
+ id="system-prompt"
+ placeholder="Enter your agent instructions here..."
+ value={systemPrompt}
+ onChange={(e) => {
+ setUserEdited(true);
+ setSystemPrompt(e.target.value);
+ }}
+ rows={14}
+ className={cn(
+ "resize-y",
+ systemPrompt.length > MAX_SYSTEM_PROMPT_CHARS &&
+ "!border-destructive focus:border-destructive",
)}
+ />
+ </div>
+ <div className="flex justify-end gap-4 pt-2">
+ {settings.agent?.default_system_prompt && (
<Button
- onClick={handleSystemPromptSave}
- disabled={
- updateSettingsMutation.isPending ||
- systemPrompt.length > MAX_SYSTEM_PROMPT_CHARS
- }
- className="min-w-[120px]"
- size="sm"
- variant="outline"
+ ignoreTitleCase={true}
+ onClick={() => {
+ setUserEdited(true);
+ setSystemPrompt(settings.agent?.default_system_prompt || "");
+ }}
+ variant="ghost"
+ disabled={systemPrompt === settings.agent.default_system_prompt}
>
- {updateSettingsMutation.isPending ? (
- <>
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- Saving...
- </>
- ) : (
- "Save Agent Instructions"
- )}
+ Restore default
</Button>
- </div>
+ )}
+ <Button
+ ignoreTitleCase={true}
+ onClick={handleSystemPromptSave}
+ disabled={
+ updateSettingsMutation.isPending ||
+ systemPrompt.length > MAX_SYSTEM_PROMPT_CHARS
+ }
+ className="min-w-[120px]"
+ >
+ {updateSettingsMutation.isPending ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ Saving...
+ </>
+ ) : (
+ "Save agent instructions"
+ )}
+ </Button>
</div>
- </CardContent>
- </Card>
+ </div>
+ </section>
);
}
diff --git a/frontend/app/settings/_components/api-keys-section.test.tsx b/frontend/app/settings/_components/api-keys-section.test.tsx
new file mode 100644
index 000000000..7451a2e2e
--- /dev/null
+++ b/frontend/app/settings/_components/api-keys-section.test.tsx
@@ -0,0 +1,73 @@
+import { fireEvent, screen, waitFor, within } from "@testing-library/react";
+import { HttpResponse, http } from "msw";
+import { describe, expect, it, vi } from "vitest";
+import { authPresets } from "@/test-utils/fixtures/auth";
+import { renderWithProviders } from "@/test-utils/render";
+import { ApiKeysSection } from "./api-keys-section";
+
+vi.mock("@/lib/analytics", () => ({ trackButton: vi.fn() }));
+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+
+function renderSection(keys: unknown[] = []) {
+ let revoked: string | null = null;
+ const utils = renderWithProviders(<ApiKeysSection />, {
+ providers: ["tooltip", "auth", "brand"],
+ auth: authPresets.rbacDisabled,
+ handlers: [
+ http.get("/api/keys", () => HttpResponse.json({ keys })),
+ http.delete("/api/keys/:key_id", ({ params }) => {
+ revoked = params.key_id as string;
+ return HttpResponse.json({ success: true });
+ }),
+ ],
+ });
+ return { ...utils, getRevoked: () => revoked };
+}
+
+describe("ApiKeysSection", () => {
+ it("opens the create-key dialog from the header button", async () => {
+ renderSection([]);
+
+ fireEvent.click(
+ await screen.findByRole("button", { name: /^create key$/i }),
+ );
+
+ expect(
+ await screen.findByRole("heading", { name: /create api key/i }),
+ ).toBeInTheDocument();
+ });
+
+ it("opens the create-key dialog from the empty state", async () => {
+ renderSection([]);
+
+ fireEvent.click(
+ await screen.findByRole("button", {
+ name: /create your first api key/i,
+ }),
+ );
+
+ expect(
+ await screen.findByRole("heading", { name: /create api key/i }),
+ ).toBeInTheDocument();
+ });
+
+ it("revokes an existing API key from the list", async () => {
+ const { getRevoked } = renderSection([
+ {
+ key_id: "key-1",
+ name: "My Key",
+ key_prefix: "sk-abc",
+ created_at: "2024-01-01T00:00:00Z",
+ last_used_at: null,
+ },
+ ]);
+
+ const row = (await screen.findByText("My Key")).closest("tr");
+ if (!row) throw new Error("row not found");
+ fireEvent.click(within(row).getByRole("button"));
+
+ fireEvent.click(await screen.findByRole("button", { name: /^revoke$/i }));
+
+ await waitFor(() => expect(getRevoked()).toBe("key-1"));
+ });
+});
diff --git a/frontend/app/settings/_components/api-keys-section.tsx b/frontend/app/settings/_components/api-keys-section.tsx
index 640a1b30e..50fa70844 100644
--- a/frontend/app/settings/_components/api-keys-section.tsx
+++ b/frontend/app/settings/_components/api-keys-section.tsx
@@ -10,13 +10,6 @@ import { ConfirmationDialog } from "@/components/confirmation-dialog";
import { LabelWrapper } from "@/components/label-wrapper";
import { RequirePermission } from "@/components/require-permission";
import { Button } from "@/components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
import {
Dialog,
DialogContent,
@@ -106,131 +99,133 @@ export function ApiKeysSection() {
return (
<>
- <Card>
- <CardHeader>
- <div className="flex items-center justify-between mb-3">
- <CardTitle
+ <section className="space-y-8">
+ <header className="flex items-start justify-between gap-6">
+ <div className="max-w-[685px] space-y-3">
+ <h3
className={cn(
- "text-lg",
+ "text-lg font-semibold leading-tight tracking-tight",
isCloudBrand && "ibm-settings-section-title",
)}
>
API Keys
- </CardTitle>
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ API keys allow programmatic access to OpenRAG via the public API.
+ Keep your keys secure and never share them publicly.
+ </p>
+ </div>
+ <RequirePermission perm="apikeys:create:self">
+ <Button
+ className="shrink-0"
+ onClick={() => setCreateKeyDialogOpen(true)}
+ size="sm"
+ >
+ <Plus className="h-4 w-4 mr-2" />
+ Create Key
+ </Button>
+ </RequirePermission>
+ </header>
+ {apiKeysLoading ? (
+ <div className="flex items-center justify-center py-8">
+ <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
+ </div>
+ ) : apiKeysData?.keys && apiKeysData.keys.length > 0 ? (
+ <div className="border rounded-lg overflow-hidden">
+ <table className="w-full">
+ <thead className="bg-muted/50">
+ <tr>
+ <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
+ Name
+ </th>
+ <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
+ Key
+ </th>
+ <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
+ Created
+ </th>
+ <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
+ Last Used
+ </th>
+ <th className="text-right text-sm font-medium text-muted-foreground px-4 py-3">
+ Actions
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {apiKeysData.keys.map((key) => (
+ <tr key={key.key_id} className="border-t">
+ <td className="px-4 py-3 text-sm font-medium">
+ {key.name}
+ </td>
+ <td className="px-4 py-3">
+ <code className="text-sm bg-muted px-2 py-1 rounded">
+ {key.key_prefix}...
+ </code>
+ </td>
+ <td className="px-4 py-3 text-sm text-muted-foreground">
+ {formatDate(key.created_at)}
+ </td>
+ <td className="px-4 py-3 text-sm text-muted-foreground">
+ {formatDate(key.last_used_at)}
+ </td>
+ <td className="px-4 py-3 text-right">
+ <ConfirmationDialog
+ trigger={
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-destructive hover:text-destructive hover:bg-destructive/10"
+ >
+ <Trash2 className="h-4 w-4" />
+ </Button>
+ }
+ title="Revoke API Key"
+ description={
+ <>
+ Are you sure you want to revoke the API key{" "}
+ <strong>{key.name}</strong>? This action cannot be
+ undone and any applications using this key will stop
+ working.
+ </>
+ }
+ confirmText="Revoke"
+ variant="destructive"
+ onConfirm={(closeDialog) => {
+ trackButton({
+ CTA: "Revoke API Key",
+ elementId: "revoke-api-key-button",
+ namespace: "settings",
+ });
+ revokeApiKeyMutation.mutate({ key_id: key.key_id });
+ closeDialog();
+ }}
+ />
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ ) : (
+ <div className="text-center py-8">
+ <Key className="h-12 w-12 mx-auto text-muted-foreground/50 mb-4" />
+ <p className="text-muted-foreground mb-4">
+ No API keys yet. Create one to get started.
+ </p>
<RequirePermission perm="apikeys:create:self">
- <Button onClick={() => setCreateKeyDialogOpen(true)} size="sm">
+ <Button
+ variant="outline"
+ onClick={() => setCreateKeyDialogOpen(true)}
+ size="sm"
+ >
<Plus className="h-4 w-4 mr-2" />
- Create Key
+ Create your first API key
</Button>
</RequirePermission>
</div>
- <CardDescription>
- API keys allow programmatic access to OpenRAG via the public API.
- Keep your keys secure and never share them publicly.
- </CardDescription>
- </CardHeader>
- <CardContent>
- {apiKeysLoading ? (
- <div className="flex items-center justify-center py-8">
- <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
- </div>
- ) : apiKeysData?.keys && apiKeysData.keys.length > 0 ? (
- <div className="border rounded-lg overflow-hidden">
- <table className="w-full">
- <thead className="bg-muted/50">
- <tr>
- <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
- Name
- </th>
- <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
- Key
- </th>
- <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
- Created
- </th>
- <th className="text-left text-sm font-medium text-muted-foreground px-4 py-3">
- Last Used
- </th>
- <th className="text-right text-sm font-medium text-muted-foreground px-4 py-3">
- Actions
- </th>
- </tr>
- </thead>
- <tbody>
- {apiKeysData.keys.map((key) => (
- <tr key={key.key_id} className="border-t">
- <td className="px-4 py-3 text-sm font-medium">
- {key.name}
- </td>
- <td className="px-4 py-3">
- <code className="text-sm bg-muted px-2 py-1 rounded">
- {key.key_prefix}...
- </code>
- </td>
- <td className="px-4 py-3 text-sm text-muted-foreground">
- {formatDate(key.created_at)}
- </td>
- <td className="px-4 py-3 text-sm text-muted-foreground">
- {formatDate(key.last_used_at)}
- </td>
- <td className="px-4 py-3 text-right">
- <ConfirmationDialog
- trigger={
- <Button
- variant="ghost"
- size="sm"
- className="text-destructive hover:text-destructive hover:bg-destructive/10"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- }
- title="Revoke API Key"
- description={
- <>
- Are you sure you want to revoke the API key{" "}
- <strong>{key.name}</strong>? This action cannot be
- undone and any applications using this key will
- stop working.
- </>
- }
- confirmText="Revoke"
- variant="destructive"
- onConfirm={(closeDialog) => {
- trackButton({
- CTA: "Revoke API Key",
- elementId: "revoke-api-key-button",
- namespace: "settings",
- });
- revokeApiKeyMutation.mutate({ key_id: key.key_id });
- closeDialog();
- }}
- />
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- </div>
- ) : (
- <div className="text-center py-8">
- <Key className="h-12 w-12 mx-auto text-muted-foreground/50 mb-4" />
- <p className="text-muted-foreground mb-4">
- No API keys yet. Create one to get started.
- </p>
- <RequirePermission perm="apikeys:create:self">
- <Button
- variant="outline"
- onClick={() => setCreateKeyDialogOpen(true)}
- size="sm"
- >
- <Plus className="h-4 w-4 mr-2" />
- Create your first API key
- </Button>
- </RequirePermission>
- </div>
- )}
- </CardContent>
- </Card>
+ )}
+ </section>
<Dialog open={createKeyDialogOpen} onOpenChange={setCreateKeyDialogOpen}>
<DialogContent>
diff --git a/frontend/app/settings/_components/ingest-preview-settings-section.test.tsx b/frontend/app/settings/_components/ingest-preview-settings-section.test.tsx
new file mode 100644
index 000000000..7f172d052
--- /dev/null
+++ b/frontend/app/settings/_components/ingest-preview-settings-section.test.tsx
@@ -0,0 +1,53 @@
+import { HttpResponse, http } from "msw";
+import { describe, expect, it, vi } from "vitest";
+import { IngestionTab } from "@/app/settings/_components/ingestion-tab";
+import { readIngestPreviewSettings } from "@/hooks/use-ingest-preview-settings";
+import { authPresets, withAuth } from "@/test-utils/fixtures/auth";
+import { makeSettings } from "@/test-utils/fixtures/settings";
+import {
+ renderWithProviders,
+ screen,
+ userEvent,
+ waitFor,
+} from "@/test-utils/render";
+
+vi.mock("@/lib/analytics", () => ({ trackButton: vi.fn() }));
+vi.mock("sonner", () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
+
+function renderTab() {
+ return renderWithProviders(<IngestionTab />, {
+ providers: ["tooltip", "auth", "unsavedChanges", "task"],
+ auth: withAuth(authPresets.admin, { me: { run_mode: "oss" } }),
+ handlers: [
+ http.get("/api/settings", () =>
+ HttpResponse.json(
+ makeSettings({
+ knowledge: { chunk_size: 1024, chunk_overlap: 50 },
+ show_vlm_settings: false,
+ }),
+ ),
+ ),
+ http.get("/api/models/catalog", () =>
+ HttpResponse.json({ providers: [] }),
+ ),
+ http.get("/api/models/providers", () => HttpResponse.json({})),
+ ],
+ });
+}
+
+describe("IngestPreviewSettingsSection", () => {
+ it("persists the auto-open choice when Save changes is clicked", async () => {
+ const user = userEvent.setup();
+ renderTab();
+
+ expect(readIngestPreviewSettings().autoOpen).toBe("never");
+
+ await user.click(await screen.findByRole("tab", { name: /every upload/i }));
+
+ await user.click(screen.getByRole("button", { name: /save changes/i }));
+
+ await waitFor(() =>
+ expect(readIngestPreviewSettings().autoOpen).toBe("every"),
+ );
+ });
+});
diff --git a/frontend/app/settings/_components/ingest-preview-settings-section.tsx b/frontend/app/settings/_components/ingest-preview-settings-section.tsx
index 44fd1567b..4dd5abb32 100644
--- a/frontend/app/settings/_components/ingest-preview-settings-section.tsx
+++ b/frontend/app/settings/_components/ingest-preview-settings-section.tsx
@@ -1,7 +1,6 @@
"use client";
import { useMemo, useState } from "react";
-import { toast } from "sonner";
import { IngestPreviewAutoOpenControl } from "@/components/ingest-preview-auto-open-control";
import { IngestReviewDialog } from "@/components/ingest-review";
import { Button } from "@/components/ui/button";
@@ -13,6 +12,7 @@ import {
useIngestPreviewSettings,
} from "@/hooks/use-ingest-preview-settings";
import { createSampleDemoFile } from "@/lib/ingest-preview-demo";
+import { useRegisterSave } from "./ingest-save-context";
const EMPTY_PREVIEW_FILES: File[] = [];
@@ -43,10 +43,15 @@ export function IngestPreviewSettingsSection() {
[previewFile],
);
- const saveChanges = () => {
- updateSettings({ autoOpen: draft.autoOpen });
- toast.success("Ingest preview settings saved");
- };
+ // The tab's single Save button drives this; it reports success for the whole
+ // tab, so this only persists.
+ useRegisterSave("ingest-preview", {
+ isDirty,
+ blocked: false,
+ save: () => {
+ updateSettings({ autoOpen: draft.autoOpen });
+ },
+ });
const runSampleIngest = () => {
setPreviewFile(createSampleDemoFile());
@@ -55,14 +60,12 @@ export function IngestPreviewSettingsSection() {
return (
<div className="space-y-0" data-testid="ingest-preview-settings">
- <div className="flex items-center justify-between gap-4 py-4">
- <div className="flex-1 min-w-0">
- <Label className="text-base font-medium">
+ <div className="flex items-center justify-between gap-12 border-b border-border py-6">
+ <div className="flex-1 min-w-0 space-y-1.5">
+ <Label className="text-base font-semibold">
Auto-open ingest preview
</Label>
- <p className="text-sm text-muted-foreground mt-1">
- {autoOpenDescription}
- </p>
+ <p className="text-sm text-muted-foreground">{autoOpenDescription}</p>
</div>
<IngestPreviewAutoOpenControl
value={draft.autoOpen}
@@ -71,25 +74,20 @@ export function IngestPreviewSettingsSection() {
/>
</div>
- <div className="flex flex-wrap items-center justify-end gap-2 pt-6">
+ <div className="flex items-center justify-between gap-8 py-6">
+ <div className="flex-1 min-w-0 space-y-1.5">
+ <p className="text-base font-semibold">Sample ingest</p>
+ <p className="text-sm text-muted-foreground">
+ Test out the document parser.
+ </p>
+ </div>
<Button
type="button"
variant="outline"
- size="sm"
onClick={runSampleIngest}
data-testid="ingest-preview-run-sample"
>
- Run a sample ingest
- </Button>
- <Button
- type="button"
- size="sm"
- className="min-w-[120px]"
- onClick={saveChanges}
- disabled={!isDirty}
- data-testid="ingest-preview-save"
- >
- Save changes
+ Run sample ingest
</Button>
</div>
diff --git a/frontend/app/settings/_components/ingest-save-context.test.tsx b/frontend/app/settings/_components/ingest-save-context.test.tsx
new file mode 100644
index 000000000..96b1aafea
--- /dev/null
+++ b/frontend/app/settings/_components/ingest-save-context.test.tsx
@@ -0,0 +1,39 @@
+import { render, renderHook } from "@testing-library/react";
+import { describe, expect, it } from "vitest";
+import {
+ IngestSaveProvider,
+ useIngestSave,
+ useRegisterSave,
+} from "./ingest-save-context";
+
+describe("useIngestSave", () => {
+ it("throws when used outside an IngestSaveProvider", () => {
+ expect(() => renderHook(() => useIngestSave())).toThrow(
+ "useIngestSave must be used within IngestSaveProvider",
+ );
+ });
+
+ it("bails out of the flags update when re-registering the same key with an unchanged isDirty/blocked state", () => {
+ // Two sections sharing a key (e.g. a remount racing the old instance's
+ // unmount) both register with identical flags. The second registration's
+ // effect must hit the no-op branch in `register()` rather than scheduling
+ // a redundant flags update.
+ function Section() {
+ useRegisterSave("section", {
+ isDirty: false,
+ blocked: false,
+ save: () => {},
+ });
+ return null;
+ }
+
+ expect(() =>
+ render(
+ <IngestSaveProvider>
+ <Section />
+ <Section />
+ </IngestSaveProvider>,
+ ),
+ ).not.toThrow();
+ });
+});
diff --git a/frontend/app/settings/_components/ingest-save-context.tsx b/frontend/app/settings/_components/ingest-save-context.tsx
new file mode 100644
index 000000000..3e4543abc
--- /dev/null
+++ b/frontend/app/settings/_components/ingest-save-context.tsx
@@ -0,0 +1,146 @@
+"use client";
+
+import {
+ createContext,
+ type ReactNode,
+ use,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
+
+/**
+ * `false` means the section refused to save (validation failed) and the run
+ * should stop without reporting success. Anything else counts as saved.
+ */
+type SaveResult = boolean | void;
+
+interface SaveEntry {
+ /** Whether this section has changes worth persisting. */
+ isDirty: boolean;
+ /** Whether this section is in a state that must not be saved yet. */
+ blocked: boolean;
+ save: () => SaveResult | Promise<SaveResult>;
+}
+
+interface IngestSaveContextValue {
+ register: (key: string, entry: SaveEntry) => void;
+ unregister: (key: string) => void;
+ isDirty: boolean;
+ isBlocked: boolean;
+ isSaving: boolean;
+ saveAll: () => Promise<boolean>;
+}
+
+const IngestSaveContext = createContext<IngestSaveContextValue | null>(null);
+
+/**
+ * Collects the save handlers of every ingest settings section so the tab can
+ * render a single Save button, as the design calls for. Sections stay owners of
+ * their own state and validation; this only sequences their saves.
+ */
+export function IngestSaveProvider({ children }: { children: ReactNode }) {
+ // Handlers live in a ref so re-registering a fresh closure on each render
+ // never triggers a render of its own; only the flags below do that.
+ const entriesRef = useRef<Map<string, SaveEntry>>(new Map());
+ const [flags, setFlags] = useState<
+ Record<string, { isDirty: boolean; blocked: boolean }>
+ >({});
+ const [isSaving, setIsSaving] = useState(false);
+
+ const register = useCallback((key: string, entry: SaveEntry) => {
+ entriesRef.current.set(key, entry);
+ setFlags((prev) => {
+ const current = prev[key];
+ if (
+ current &&
+ current.isDirty === entry.isDirty &&
+ current.blocked === entry.blocked
+ ) {
+ return prev;
+ }
+ return {
+ ...prev,
+ [key]: { isDirty: entry.isDirty, blocked: entry.blocked },
+ };
+ });
+ }, []);
+
+ const unregister = useCallback((key: string) => {
+ entriesRef.current.delete(key);
+ setFlags((prev) => {
+ if (!(key in prev)) return prev;
+ const next = { ...prev };
+ delete next[key];
+ return next;
+ });
+ }, []);
+
+ const isDirty = Object.values(flags).some((flag) => flag.isDirty);
+ const isBlocked = Object.entries(flags).some(
+ ([key, flag]) => flag.blocked && (flags[key]?.isDirty ?? false),
+ );
+
+ const saveAll = useCallback(async () => {
+ setIsSaving(true);
+ try {
+ // Insertion order, so sections save top-to-bottom as they appear.
+ for (const entry of entriesRef.current.values()) {
+ if (!entry.isDirty) continue;
+ if ((await entry.save()) === false) return false;
+ }
+ return true;
+ } finally {
+ setIsSaving(false);
+ }
+ }, []);
+
+ const value = useMemo<IngestSaveContextValue>(
+ () => ({
+ register,
+ unregister,
+ isDirty,
+ isBlocked,
+ isSaving,
+ saveAll,
+ }),
+ [register, unregister, isDirty, isBlocked, isSaving, saveAll],
+ );
+
+ return <IngestSaveContext value={value}>{children}</IngestSaveContext>;
+}
+
+function useIngestSaveContext(): IngestSaveContextValue {
+ const ctx = use(IngestSaveContext);
+ if (!ctx) {
+ throw new Error("useIngestSave must be used within IngestSaveProvider");
+ }
+ return ctx;
+}
+
+/** Hand this section's dirty state and save handler to the shared Save button. */
+export function useRegisterSave(key: string, entry: SaveEntry) {
+ const { register, unregister } = useIngestSaveContext();
+
+ // The handler closes over section state, so it changes every render. Keeping
+ // it behind a ref lets registration depend only on the flags.
+ const saveRef = useRef(entry.save);
+ useEffect(() => {
+ saveRef.current = entry.save;
+ });
+
+ const { isDirty, blocked } = entry;
+ useEffect(() => {
+ register(key, { isDirty, blocked, save: () => saveRef.current() });
+ }, [key, isDirty, blocked, register]);
+
+ useEffect(() => () => unregister(key), [key, unregister]);
+}
+
+/** Read the combined save state — for the tab's single Save button. */
+export function useIngestSave() {
+ const { isDirty, isBlocked, isSaving, saveAll } = useIngestSaveContext();
+ return { isDirty, isBlocked, isSaving, saveAll };
+}
diff --git a/frontend/app/settings/_components/ingest-settings-section.test.tsx b/frontend/app/settings/_components/ingest-settings-section.test.tsx
index eee720a1d..4219c1611 100644
--- a/frontend/app/settings/_components/ingest-settings-section.test.tsx
+++ b/frontend/app/settings/_components/ingest-settings-section.test.tsx
@@ -1,8 +1,8 @@
import type { RequestHandler } from "msw";
import { HttpResponse, http } from "msw";
import { describe, expect, it, vi } from "vitest";
-import { IngestSettingsSection } from "@/app/settings/_components/ingest-settings-section";
-import { authPresets } from "@/test-utils/fixtures/auth";
+import { IngestionTab } from "@/app/settings/_components/ingestion-tab";
+import { authPresets, withAuth } from "@/test-utils/fixtures/auth";
import { makeSettings } from "@/test-utils/fixtures/settings";
import { server } from "@/test-utils/msw/server";
import {
@@ -54,16 +54,18 @@ function baseHandlers(
),
),
http.get("/api/models/catalog", () => HttpResponse.json({ providers: [] })),
+ http.get("/api/models/providers", () => HttpResponse.json({})),
];
}
function renderSection(
extraHandlers: RequestHandler[] = [],
knowledge?: { chunk_size: number; chunk_overlap: number },
+ auth = authPresets.admin,
) {
- return renderWithProviders(<IngestSettingsSection />, {
+ return renderWithProviders(<IngestionTab />, {
providers: ["tooltip", "auth", "unsavedChanges"],
- auth: authPresets.admin,
+ auth,
handlers: [...baseHandlers(knowledge), ...extraHandlers],
});
}
@@ -157,7 +159,7 @@ describe("IngestSettingsSection", () => {
fireEvent.change(input, { target: { value: "0" } });
expect(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
).toBeDisabled();
});
@@ -171,7 +173,7 @@ describe("IngestSettingsSection", () => {
fireEvent.change(overlapInput, { target: { value: "1024" } });
expect(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
).toBeDisabled();
});
@@ -185,7 +187,7 @@ describe("IngestSettingsSection", () => {
await waitFor(() => {
expect(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
).toBeEnabled();
});
});
@@ -197,7 +199,7 @@ describe("IngestSettingsSection", () => {
await screen.findByRole("spinbutton", { name: /chunk size/i });
expect(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
).toBeDisabled();
});
});
@@ -225,7 +227,7 @@ describe("IngestSettingsSection", () => {
fireEvent.change(input, { target: { value: "0" } });
const saveButton = screen.getByRole("button", {
- name: /save ingest settings/i,
+ name: /save changes/i,
});
expect(saveButton).toBeDisabled();
expect(postCalled).toBe(false);
@@ -360,9 +362,7 @@ describe("IngestSettingsSection", () => {
);
// Trigger the save.
- fireEvent.click(
- screen.getByRole("button", { name: /save ingest settings/i }),
- );
+ fireEvent.click(screen.getByRole("button", { name: /save changes/i }));
// After the POST succeeds, userEdited resets to false. The mutation's
// own invalidateQueries then fires another GET, which returns 999. The
@@ -374,11 +374,167 @@ describe("IngestSettingsSection", () => {
});
});
});
+
+ // ── Group 4b: Restore flow persists defaults immediately ──────────────────
+
+ describe("restore flow", () => {
+ it("persists the restored defaults to the server, leaving Save disabled", async () => {
+ // Server state differs from DEFAULT_KNOWLEDGE_SETTINGS so restoring
+ // produces a real diff to persist.
+ // "flows:edit" isn't in the admin preset's permission list, so grant it
+ // directly — otherwise RequirePermission hides the Restore flow button.
+ renderSection(
+ [],
+ { chunk_size: 500, chunk_overlap: 50 },
+ withAuth(authPresets.admin, {
+ usersMe: { permissions: ["flows:edit"] },
+ }),
+ );
+
+ server.use(
+ http.post("/api/reset-flow/ingest", () => HttpResponse.json({})),
+ http.post("/api/settings", () =>
+ HttpResponse.json({
+ message: "ok",
+ settings: makeSettings({
+ knowledge: { chunk_size: 1000, chunk_overlap: 200 },
+ show_vlm_settings: false,
+ }),
+ }),
+ ),
+ http.get("/api/settings", () =>
+ HttpResponse.json(
+ makeSettings({
+ knowledge: { chunk_size: 1000, chunk_overlap: 200 },
+ show_vlm_settings: false,
+ }),
+ ),
+ ),
+ );
+
+ const input = await screen.findByRole("spinbutton", {
+ name: /chunk size/i,
+ });
+ expect(input).toHaveValue(500);
+
+ // The server-sync effect settles a tick after the value appears, so
+ // wait for it rather than asserting disabled against a transient render.
+ await waitFor(() => {
+ expect(
+ screen.getByRole("button", { name: /save changes/i }),
+ ).toBeDisabled();
+ });
+
+ await userEvent.click(
+ await screen.findByRole("button", { name: /restore flow/i }),
+ );
+ await userEvent.click(screen.getByRole("button", { name: /^restore$/i }));
+
+ // Restore writes DEFAULT_KNOWLEDGE_SETTINGS.chunk_size (1000) locally
+ // AND persists it to the server — a refresh right after restoring must
+ // not lose it, so Save settles back to disabled without the user
+ // clicking it.
+ await waitFor(() => {
+ expect(
+ screen.getByRole("spinbutton", { name: /chunk size/i }),
+ ).toHaveValue(1000);
+ });
+ await waitFor(() => {
+ expect(
+ screen.getByRole("button", { name: /save changes/i }),
+ ).toBeDisabled();
+ });
+ });
+ });
+
+ // ── Group 5: chunk steppers and toggle switches ───────────────────────────
+
+ describe("chunk steppers", () => {
+ it("increments and decrements chunk size via the stepper buttons", async () => {
+ renderSection();
+
+ const input = await screen.findByRole("spinbutton", {
+ name: /chunk size/i,
+ });
+ expect(input).toHaveValue(1024);
+
+ const [increaseSize] = screen.getAllByRole("button", {
+ name: /increase value/i,
+ });
+ fireEvent.click(increaseSize);
+ expect(input).toHaveValue(1025);
+
+ const [decreaseSize] = screen.getAllByRole("button", {
+ name: /decrease value/i,
+ });
+ fireEvent.click(decreaseSize);
+ expect(input).toHaveValue(1024);
+ });
+
+ it("increments and decrements chunk overlap via the stepper buttons", async () => {
+ renderSection();
+
+ const overlapInput = await screen.findByRole("spinbutton", {
+ name: /chunk overlap/i,
+ });
+ expect(overlapInput).toHaveValue(50);
+
+ const [, increaseOverlap] = screen.getAllByRole("button", {
+ name: /increase value/i,
+ });
+ fireEvent.click(increaseOverlap);
+ expect(overlapInput).toHaveValue(51);
+
+ const [, decreaseOverlap] = screen.getAllByRole("button", {
+ name: /decrease value/i,
+ });
+ fireEvent.click(decreaseOverlap);
+ expect(overlapInput).toHaveValue(50);
+ });
+ });
+
+ describe("toggle switches", () => {
+ it("toggles Disable Langflow Ingestion, Table Structure, OCR, and Picture Descriptions", async () => {
+ renderSection();
+
+ await screen.findByRole("spinbutton", { name: /chunk size/i });
+
+ const langflowSwitch = screen.getByRole("switch", {
+ name: /disable langflow ingestion/i,
+ });
+ const tableStructureSwitch = screen.getByRole("switch", {
+ name: /table structure/i,
+ });
+ const ocrSwitch = screen.getByRole("switch", { name: /^ocr$/i });
+ const pictureDescriptionsSwitch = screen.getByRole("switch", {
+ name: /picture descriptions/i,
+ });
+
+ expect(langflowSwitch).toHaveAttribute("aria-checked", "false");
+ fireEvent.click(langflowSwitch);
+ expect(langflowSwitch).toHaveAttribute("aria-checked", "true");
+
+ expect(tableStructureSwitch).toHaveAttribute("aria-checked", "true");
+ fireEvent.click(tableStructureSwitch);
+ expect(tableStructureSwitch).toHaveAttribute("aria-checked", "false");
+
+ expect(ocrSwitch).toHaveAttribute("aria-checked", "false");
+ fireEvent.click(ocrSwitch);
+ expect(ocrSwitch).toHaveAttribute("aria-checked", "true");
+
+ expect(pictureDescriptionsSwitch).toHaveAttribute(
+ "aria-checked",
+ "false",
+ );
+ fireEvent.click(pictureDescriptionsSwitch);
+ expect(pictureDescriptionsSwitch).toHaveAttribute("aria-checked", "true");
+ });
+ });
});
describe("IngestSettingsSection OCR languages", () => {
it("shows English last when an existing selection was saved English-first", async () => {
- renderWithProviders(<IngestSettingsSection />, {
+ renderWithProviders(<IngestionTab />, {
providers: ["tooltip", "auth", "brand", "unsavedChanges"],
handlers: [
http.get("/api/settings", () =>
@@ -400,18 +556,20 @@ describe("IngestSettingsSection OCR languages", () => {
);
expect(await screen.findByText("Japanese, English")).toBeInTheDocument();
expect(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
).toBeDisabled();
});
it("saves a newly added Japanese selection before English", async () => {
const save = vi.fn(() => HttpResponse.json({}));
- renderWithProviders(<IngestSettingsSection />, {
+ renderWithProviders(<IngestionTab />, {
providers: ["tooltip", "auth", "brand", "unsavedChanges"],
handlers: [
http.get("/api/settings", () =>
HttpResponse.json(
- makeSettings({ knowledge: { ocr: true, ocr_languages: ["en"] } }),
+ makeSettings({
+ knowledge: { ocr: true, ocr_languages: ["en"] },
+ }),
),
),
http.get("/api/models/catalog", () =>
@@ -434,7 +592,7 @@ describe("IngestSettingsSection OCR languages", () => {
expect(await screen.findByText("Japanese, English")).toBeInTheDocument();
await userEvent.click(
- screen.getByRole("button", { name: /save ingest settings/i }),
+ screen.getByRole("button", { name: /save changes/i }),
);
expect(save).toHaveBeenCalledOnce();
});
diff --git a/frontend/app/settings/_components/ingest-settings-section.tsx b/frontend/app/settings/_components/ingest-settings-section.tsx
index a46313dc3..5931f8708 100644
--- a/frontend/app/settings/_components/ingest-settings-section.tsx
+++ b/frontend/app/settings/_components/ingest-settings-section.tsx
@@ -1,6 +1,6 @@
"use client";
-import { ArrowUpRight, ChevronDown, Loader2, Minus, Plus } from "lucide-react";
+import { ArrowUpRight, ChevronDown, Minus, Plus } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import {
@@ -30,13 +30,6 @@ import {
} from "@/components/models/model-selector";
import { RequirePermission } from "@/components/require-permission";
import { Button } from "@/components/ui/button";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/components/ui/card";
import {
Collapsible,
CollapsibleContent,
@@ -67,6 +60,7 @@ import { allowedLanguages, englishLast } from "@/lib/ocr-languages";
import { resolveLangflowEditUrl } from "@/lib/url-utils";
import { cn } from "@/lib/utils";
import { useUpdateSettingsMutation } from "../../api/mutations/useUpdateSettingsMutation";
+import { useRegisterSave } from "./ingest-save-context";
import { LangflowIcon } from "./langflow-icon";
const DEFAULT_WATSONX_API_VERSION = "2023-05-29";
@@ -267,9 +261,6 @@ export function IngestSettingsSection() {
"";
const updateSettingsMutation = useUpdateSettingsMutation({
- onSuccess: () => {
- toast.success("Settings updated successfully");
- },
onError: (error) => {
toast.error("Failed to update settings", { description: error.message });
},
@@ -292,13 +283,17 @@ export function IngestSettingsSection() {
const handleEmbeddingModelChange = useCallback(
(newModel: string, provider?: string) => {
+ const onSuccess = () => toast.success("Settings updated successfully");
if (newModel && provider) {
- updateSettingsMutation.mutate({
- embedding_model: newModel,
- embedding_provider: provider,
- });
+ updateSettingsMutation.mutate(
+ { embedding_model: newModel, embedding_provider: provider },
+ { onSuccess },
+ );
} else if (newModel) {
- updateSettingsMutation.mutate({ embedding_model: newModel });
+ updateSettingsMutation.mutate(
+ { embedding_model: newModel },
+ { onSuccess },
+ );
}
},
[updateSettingsMutation],
@@ -510,7 +505,7 @@ export function IngestSettingsSection() {
setChunkOverlap(Math.max(0, Number.parseInt(value, 10) || 0));
};
- const handleKnowledgeIngestSave = () => {
+ const handleKnowledgeIngestSave = async (): Promise<boolean> => {
// Only include VLM fields when the VLM UI is enabled; a hidden section
// must not drive backend VLM state or trip its validation.
const vlmPayload = showVlmSettings
@@ -548,7 +543,7 @@ export function IngestSettingsSection() {
toast.error("Could not save ingest settings", {
description: chunkValidationError,
});
- return;
+ return false;
}
if (showVlmSettings && pictureDescriptions) {
@@ -557,18 +552,18 @@ export function IngestSettingsSection() {
"Model name is required when picture descriptions are enabled";
setValidationError(msg);
toast.error("Could not save ingest settings", { description: msg });
- return;
+ return false;
}
if (vlmMaxTokens < 1 || vlmConcurrency < 1 || vlmTimeout < 1) {
const msg = "Max tokens, concurrency, and timeout must be at least 1";
setValidationError(msg);
toast.error("Could not save ingest settings", { description: msg });
- return;
+ return false;
}
}
- updateSettingsMutation.mutate(
- {
+ try {
+ await updateSettingsMutation.mutateAsync({
chunk_size: chunkSize,
chunk_overlap: chunkOverlap,
table_structure: tableStructure,
@@ -577,16 +572,22 @@ export function IngestSettingsSection() {
picture_descriptions: pictureDescriptions,
disable_ingest_with_langflow: disableIngestWithLangflow,
...vlmPayload,
- },
- {
- onSuccess: () => {
- setValidationError(null);
- setUserEdited(false);
- },
- },
- );
+ });
+ } catch {
+ // onError already surfaced the failure; stop the combined save here.
+ return false;
+ }
+ setValidationError(null);
+ setUserEdited(false);
+ return true;
};
+ useRegisterSave("ingest-settings", {
+ isDirty: knowledgeIngestDirty,
+ blocked: vlmModelPending || !!chunkValidationError,
+ save: handleKnowledgeIngestSave,
+ });
+
const handleEditInLangflow = (closeDialog: () => void) => {
trackButton({
CTA: "Edit in Langflow - Ingest",
@@ -627,6 +628,21 @@ export function IngestSettingsSection() {
}
}),
)
+ .then(() =>
+ // The flow reset above only replaces the Langflow graph. The knowledge
+ // settings (chunk size, OCR, etc.) live in a separate store, so restore
+ // must persist the defaults there too, or the form shows defaults that
+ // vanish on refresh while leaving Save stuck enabled against them.
+ updateSettingsMutation.mutateAsync({
+ chunk_size: DEFAULT_KNOWLEDGE_SETTINGS.chunk_size,
+ chunk_overlap: DEFAULT_KNOWLEDGE_SETTINGS.chunk_overlap,
+ table_structure: DEFAULT_KNOWLEDGE_SETTINGS.table_structure,
+ ocr: DEFAULT_KNOWLEDGE_SETTINGS.ocr,
+ ocr_languages: [...DEFAULT_KNOWLEDGE_SETTINGS.ocr_languages],
+ picture_descriptions: DEFAULT_KNOWLEDGE_SETTINGS.picture_descriptions,
+ disable_ingest_with_langflow: false,
+ }),
+ )
.then(() => {
setChunkSize(DEFAULT_KNOWLEDGE_SETTINGS.chunk_size);
setChunkOverlap(DEFAULT_KNOWLEDGE_SETTINGS.chunk_overlap);
@@ -650,19 +666,97 @@ export function IngestSettingsSection() {
};
return (
- <Card>
- <CardHeader>
- <div className="flex items-center justify-between mb-3">
- <CardTitle
- className={cn(
- "text-lg",
- isCloudBrand && "ibm-settings-section-title",
- )}
- >
- Knowledge Ingest
- </CardTitle>
+ <section>
+ <div className="max-w-[685px] space-y-3">
+ <h3
+ className={cn(
+ "text-lg font-semibold leading-tight tracking-tight",
+ isCloudBrand && "ibm-settings-section-title",
+ )}
+ >
+ Knowledge Ingest
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ Select the embedding model used to index your files. It saves as soon
+ as you pick one.
+ </p>
+ </div>
+ <div className="mt-6 space-y-2">
+ <LabelWrapper
+ helperText={
+ needsExplicitEmbeddingModel
+ ? undefined
+ : "Saves immediately when you select a model"
+ }
+ description={
+ needsExplicitEmbeddingModel
+ ? "Select or enter an Azure deployment name before ingesting files"
+ : undefined
+ }
+ id="embedding-model-select"
+ label="Embedding model"
+ required={true}
+ >
+ <ModelSelector
+ groupedOptions={groupedEmbeddingModels}
+ custom
+ noOptionsPlaceholder={
+ isLoadingAnyEmbeddingModels
+ ? "Loading models..."
+ : catalogError
+ ? "Could not load the model catalogue. Retry later."
+ : "No embedding models detected. Configure a provider first."
+ }
+ value={settings.knowledge?.embedding_model || ""}
+ selectedProvider={settings.knowledge?.embedding_provider}
+ onValueChange={handleEmbeddingModelChange}
+ searchPlaceholder={
+ requiresExplicitModelSelection(
+ settings.knowledge?.embedding_provider,
+ )
+ ? "Search models or type Azure deployment name"
+ : undefined
+ }
+ hasError={needsExplicitEmbeddingModel}
+ />
+ </LabelWrapper>
+ {settings.knowledge?.embedding_model && selectedEmbeddingGroup && (
+ <div className="mt-3">
+ <ModelFeatures
+ model={
+ selectedEmbedding?.model ?? {
+ model: settings.knowledge.embedding_model,
+ // Without an explicit mode the panel treats an
+ // off-catalogue embedding model as a language model and
+ // warns that it cannot run the agent tools.
+ mode: "embedding",
+ }
+ }
+ providerName={selectedEmbeddingGroup.group}
+ provider={selectedEmbeddingGroup.provider}
+ />
+ </div>
+ )}
+ </div>
+
+ <div className="mt-8 space-y-6 border-t border-border pt-8">
+ <header className="flex items-start justify-between gap-6">
+ <div className="max-w-[545px] space-y-3">
+ <h3
+ className={cn(
+ "text-lg font-semibold leading-tight tracking-tight",
+ isCloudBrand && "ibm-settings-section-title",
+ )}
+ >
+ Langflow configuration
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ Configure how files are chunked and parsed during ingest. These
+ options use Save changes. Edit in Langflow for full control.
+ </p>
+ </div>
<RequirePermission perm="flows:edit">
- <div className="flex gap-2">
+ <div className="flex shrink-0 gap-2">
<ConfirmationDialog
trigger={
<Button ignoreTitleCase={true} variant="outline">
@@ -706,512 +800,413 @@ export function IngestSettingsSection() {
/>
</div>
</RequirePermission>
- </div>
- <CardDescription>
- Configure how files are ingested and stored for retrieval. The
- embedding model saves as soon as you pick one; chunk and ingest
- options use Save ingest settings. Edit in Langflow for full control.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <div className="space-y-6">
+ </header>
+ <div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
- <LabelWrapper
- helperText={
- needsExplicitEmbeddingModel
- ? undefined
- : "Saves immediately when you select a model"
- }
- description={
- needsExplicitEmbeddingModel
- ? "Select or enter an Azure deployment name before ingesting files"
- : undefined
- }
- id="embedding-model-select"
- label="Embedding model"
- required={true}
- >
- <ModelSelector
- groupedOptions={groupedEmbeddingModels}
- custom
- noOptionsPlaceholder={
- isLoadingAnyEmbeddingModels
- ? "Loading models..."
- : catalogError
- ? "Could not load the model catalogue. Retry later."
- : "No embedding models detected. Configure a provider first."
- }
- value={settings.knowledge?.embedding_model || ""}
- selectedProvider={settings.knowledge?.embedding_provider}
- onValueChange={handleEmbeddingModelChange}
- searchPlaceholder={
- requiresExplicitModelSelection(
- settings.knowledge?.embedding_provider,
- )
- ? "Search models or type Azure deployment name"
- : undefined
- }
- hasError={needsExplicitEmbeddingModel}
- />
- </LabelWrapper>
- {settings.knowledge?.embedding_model && selectedEmbeddingGroup && (
- <div className="mt-3">
- <ModelFeatures
- model={
- selectedEmbedding?.model ?? {
- model: settings.knowledge.embedding_model,
- // Without an explicit mode the panel treats an
- // off-catalogue embedding model as a language model and
- // warns that it cannot run the agent tools.
- mode: "embedding",
- }
- }
- providerName={selectedEmbeddingGroup.group}
- provider={selectedEmbeddingGroup.provider}
+ <LabelWrapper id="chunk-size" label="Chunk size">
+ <div className="relative [&:has(input:hover):not(:has(input:focus))_button]:border-muted-foreground [&:has(input:focus)_button]:border-foreground">
+ <Input
+ id="chunk-size"
+ type="number"
+ min="1"
+ value={chunkSize}
+ onChange={(e) => handleChunkSizeChange(e.target.value)}
+ className={`w-full pr-20 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none${chunkValidationError ? " border-destructive" : ""}`}
/>
- </div>
- )}
- </div>
- <div className="grid grid-cols-2 gap-4">
- <div className="space-y-2">
- <LabelWrapper id="chunk-size" label="Chunk size">
- <div className="relative [&:has(input:hover):not(:has(input:focus))_button]:border-muted-foreground [&:has(input:focus)_button]:border-foreground">
- <Input
- id="chunk-size"
- type="number"
- min="1"
- value={chunkSize}
- onChange={(e) => handleChunkSizeChange(e.target.value)}
- className={`w-full pr-20 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none${chunkValidationError ? " border-destructive" : ""}`}
- />
- <div className="absolute inset-y-0 right-0 flex items-center">
- <span className="text-sm text-placeholder-foreground mr-4 pointer-events-none">
- characters
- </span>
- <div className="flex flex-col">
- <Button
- aria-label="Increase value"
- className="h-5 rounded-l-none rounded-br-none border-input border-b-[0.5px] focus-visible:relative transition-colors"
- variant="outline"
- size="iconSm"
- onClick={() =>
- handleChunkSizeChange((chunkSize + 1).toString())
- }
- >
- <Plus className="text-muted-foreground" size={8} />
- </Button>
- <Button
- aria-label="Decrease value"
- className="h-5 rounded-l-none rounded-tr-none border-input border-t-[0.5px] focus-visible:relative transition-colors"
- variant="outline"
- size="iconSm"
- onClick={() =>
- handleChunkSizeChange((chunkSize - 1).toString())
- }
- >
- <Minus className="text-muted-foreground" size={8} />
- </Button>
- </div>
+ <div className="absolute inset-y-0 right-0 flex items-center">
+ <span className="text-sm text-placeholder-foreground mr-4 pointer-events-none">
+ characters
+ </span>
+ <div className="flex flex-col">
+ <Button
+ aria-label="Increase value"
+ className="h-5 rounded-l-none rounded-br-none border-input border-b-[0.5px] focus-visible:relative transition-colors"
+ variant="outline"
+ size="iconSm"
+ onClick={() =>
+ handleChunkSizeChange((chunkSize + 1).toString())
+ }
+ >
+ <Plus className="text-muted-foreground" size={8} />
+ </Button>
+ <Button
+ aria-label="Decrease value"
+ className="h-5 rounded-l-none rounded-tr-none border-input border-t-[0.5px] focus-visible:relative transition-colors"
+ variant="outline"
+ size="iconSm"
+ onClick={() =>
+ handleChunkSizeChange((chunkSize - 1).toString())
+ }
+ >
+ <Minus className="text-muted-foreground" size={8} />
+ </Button>
</div>
</div>
- </LabelWrapper>
- </div>
- <div className="space-y-2">
- <LabelWrapper id="chunk-overlap" label="Chunk overlap">
- <div className="relative [&:has(input:hover):not(:has(input:focus))_button]:border-muted-foreground [&:has(input:focus)_button]:border-foreground">
- <Input
- id="chunk-overlap"
- type="number"
- min="0"
- value={chunkOverlap}
- onChange={(e) => handleChunkOverlapChange(e.target.value)}
- className={`w-full pr-20 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none${chunkValidationError ? " border-destructive" : ""}`}
- />
- <div className="absolute inset-y-0 right-0 flex items-center">
- <span className="text-sm text-placeholder-foreground mr-4 pointer-events-none">
- characters
- </span>
- <div className="flex flex-col">
- <Button
- aria-label="Increase value"
- className="h-5 rounded-l-none rounded-br-none border-input border-b-[0.5px] focus-visible:relative transition-colors"
- variant="outline"
- size="iconSm"
- onClick={() =>
- handleChunkOverlapChange(
- (chunkOverlap + 1).toString(),
- )
- }
- >
- <Plus className="text-muted-foreground" size={8} />
- </Button>
- <Button
- aria-label="Decrease value"
- className="h-5 rounded-l-none rounded-tr-none border-input border-t-[0.5px] focus-visible:relative transition-colors"
- variant="outline"
- size="iconSm"
- onClick={() =>
- handleChunkOverlapChange(
- (chunkOverlap - 1).toString(),
- )
- }
- >
- <Minus className="text-muted-foreground" size={8} />
- </Button>
- </div>
+ </div>
+ </LabelWrapper>
+ </div>
+ <div className="space-y-2">
+ <LabelWrapper id="chunk-overlap" label="Chunk overlap">
+ <div className="relative [&:has(input:hover):not(:has(input:focus))_button]:border-muted-foreground [&:has(input:focus)_button]:border-foreground">
+ <Input
+ id="chunk-overlap"
+ type="number"
+ min="0"
+ value={chunkOverlap}
+ onChange={(e) => handleChunkOverlapChange(e.target.value)}
+ className={`w-full pr-20 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none${chunkValidationError ? " border-destructive" : ""}`}
+ />
+ <div className="absolute inset-y-0 right-0 flex items-center">
+ <span className="text-sm text-placeholder-foreground mr-4 pointer-events-none">
+ characters
+ </span>
+ <div className="flex flex-col">
+ <Button
+ aria-label="Increase value"
+ className="h-5 rounded-l-none rounded-br-none border-input border-b-[0.5px] focus-visible:relative transition-colors"
+ variant="outline"
+ size="iconSm"
+ onClick={() =>
+ handleChunkOverlapChange((chunkOverlap + 1).toString())
+ }
+ >
+ <Plus className="text-muted-foreground" size={8} />
+ </Button>
+ <Button
+ aria-label="Decrease value"
+ className="h-5 rounded-l-none rounded-tr-none border-input border-t-[0.5px] focus-visible:relative transition-colors"
+ variant="outline"
+ size="iconSm"
+ onClick={() =>
+ handleChunkOverlapChange((chunkOverlap - 1).toString())
+ }
+ >
+ <Minus className="text-muted-foreground" size={8} />
+ </Button>
</div>
</div>
- </LabelWrapper>
- {chunkValidationError && (
- <p className="text-sm text-destructive mt-1" role="alert">
- {chunkValidationError}
- </p>
- )}
+ </div>
+ </LabelWrapper>
+ {chunkValidationError && (
+ <p className="text-sm text-destructive mt-1" role="alert">
+ {chunkValidationError}
+ </p>
+ )}
+ </div>
+ </div>
+ {/* Toggles read as one panel in the design: a filled, rounded card
+ whose rows are split by hairlines that stop short of the card edge
+ (hence last:border-b-0). */}
+ <div className="rounded-lg bg-muted/50 px-5">
+ <div className="flex items-center justify-between gap-6 border-b border-border py-6 last:border-b-0">
+ <div className="flex-1 space-y-2 pl-3">
+ <Label
+ htmlFor="disable-ingest-with-langflow"
+ className="text-base font-semibold cursor-pointer"
+ >
+ Disable Langflow Ingestion
+ </Label>
+ <div className="text-sm text-muted-foreground">
+ Bypass Langflow for document ingestion and use traditional
+ processing.
+ </div>
</div>
+ <Switch
+ id="disable-ingest-with-langflow"
+ checked={disableIngestWithLangflow}
+ onCheckedChange={(v) => {
+ setUserEdited(true);
+ setDisableIngestWithLangflow(v);
+ }}
+ />
</div>
- <div>
- <div className="flex items-center justify-between py-3 border-b border-border">
- <div className="flex-1">
- <Label
- htmlFor="disable-ingest-with-langflow"
- className="text-base font-medium cursor-pointer pb-3"
- >
- Disable Langflow Ingestion
- </Label>
- <div className="text-sm text-muted-foreground">
- Bypass Langflow for document ingestion and use traditional
- processing.
- </div>
+ <div className="flex items-center justify-between gap-6 border-b border-border py-6 last:border-b-0">
+ <div className="flex-1 space-y-2 pl-3">
+ <Label
+ htmlFor="table-structure"
+ className="text-base font-semibold cursor-pointer"
+ >
+ Table Structure
+ </Label>
+ <div className="text-sm text-muted-foreground">
+ Capture table structure during ingest.
</div>
- <Switch
- id="disable-ingest-with-langflow"
- checked={disableIngestWithLangflow}
- onCheckedChange={(v) => {
- setUserEdited(true);
- setDisableIngestWithLangflow(v);
- }}
- />
</div>
- <div className="flex items-center justify-between py-3 border-b border-border">
- <div className="flex-1">
+ <Switch
+ id="table-structure"
+ checked={tableStructure}
+ onCheckedChange={(v) => {
+ setUserEdited(true);
+ setTableStructure(v);
+ }}
+ />
+ </div>
+ <div className="border-b border-border last:border-b-0">
+ <div className="flex items-center justify-between gap-6 py-6">
+ <div className="flex-1 space-y-2 pl-3">
<Label
- htmlFor="table-structure"
- className="text-base font-medium cursor-pointer pb-3"
+ htmlFor="ocr"
+ className="text-base font-semibold cursor-pointer"
>
- Table Structure
+ OCR
</Label>
<div className="text-sm text-muted-foreground">
- Capture table structure during ingest.
+ Extracts text from images/PDFs. Ingest is slower when enabled.
</div>
</div>
<Switch
- id="table-structure"
- checked={tableStructure}
+ id="ocr"
+ checked={ocr}
onCheckedChange={(v) => {
setUserEdited(true);
- setTableStructure(v);
+ setOcr(v);
}}
/>
</div>
- <div className="border-b border-border">
- <div className="flex items-center justify-between py-3">
- <div className="flex-1">
- <Label
- htmlFor="ocr"
- className="text-base font-medium cursor-pointer pb-3"
+ <Collapsible
+ open={ocrOpen}
+ onOpenChange={setOcrOpen}
+ className={cn(
+ "pl-3 pb-6 transition-all duration-200",
+ !ocr && "opacity-50",
+ )}
+ >
+ <CollapsibleTrigger className="flex w-full items-center justify-between py-2 text-sm font-medium text-foreground hover:text-foreground/80">
+ Advanced OCR Settings
+ <ChevronDown
+ className={cn(
+ "h-4 w-4 mr-4 text-muted-foreground transition-transform duration-200",
+ ocrOpen && "rotate-180",
+ )}
+ />
+ </CollapsibleTrigger>
+ <CollapsibleContent className="pt-4 space-y-6">
+ <div className="space-y-2">
+ <LabelWrapper
+ id="ocr-languages"
+ label="OCR languages"
+ helperText="Languages are prioritized in this order; English stays last when combined with others"
+ disabled={!ocr}
+ flex
>
- OCR
- </Label>
- <div className="text-sm text-muted-foreground">
- Extracts text from images/PDFs. Ingest is slower when
- enabled.
- </div>
+ <MultiSelect
+ options={ocrLanguageOptions}
+ value={ocrLanguages}
+ onValueChange={(v) => {
+ setUserEdited(true);
+ // An empty selection would make docling fall back to its
+ // English-only default without saying so; keep English.
+ setOcrLanguages(englishLast(v.length > 0 ? v : ["en"]));
+ }}
+ showAllOption={false}
+ placeholder="Select languages..."
+ searchPlaceholder="Search languages..."
+ className="w-64"
+ inlineLabelLimit={2}
+ disabled={!ocr}
+ />
+ </LabelWrapper>
+ <p className="text-sm text-muted-foreground">
+ Most languages can only be combined with English, so
+ incompatible options are disabled once you choose one.
+ </p>
</div>
- <Switch
- id="ocr"
- checked={ocr}
- onCheckedChange={(v) => {
- setUserEdited(true);
- setOcr(v);
- }}
- />
+ </CollapsibleContent>
+ </Collapsible>
+ </div>
+ <div className="flex items-center justify-between gap-6 border-b border-border py-6 last:border-b-0">
+ <div className="flex-1 space-y-2 pl-3">
+ <Label
+ htmlFor="picture-descriptions"
+ className="text-base font-semibold cursor-pointer"
+ >
+ Picture Descriptions
+ </Label>
+ <div className="text-sm text-muted-foreground">
+ Adds captions for images. Ingest is slower when enabled.
</div>
- <Collapsible
- open={ocrOpen}
- onOpenChange={setOcrOpen}
+ </div>
+ <Switch
+ id="picture-descriptions"
+ checked={pictureDescriptions}
+ onCheckedChange={(v) => {
+ setUserEdited(true);
+ setPictureDescriptions(v);
+ }}
+ />
+ </div>
+ </div>
+ {showVlmSettings && (
+ <Collapsible
+ open={vlmOpen}
+ onOpenChange={setVlmOpen}
+ className={cn(
+ "px-4 transition-all duration-200",
+ !pictureDescriptions && "opacity-50",
+ )}
+ >
+ <CollapsibleTrigger className="flex w-full items-center justify-between py-2 text-sm font-medium text-foreground hover:text-foreground/80">
+ Advanced Vision Model (VLM) Settings
+ <ChevronDown
className={cn(
- "pl-4 pb-3 transition-all duration-200",
- !ocr && "opacity-50",
+ "h-4 w-4 text-muted-foreground transition-transform duration-200",
+ vlmOpen && "rotate-180",
)}
- >
- <CollapsibleTrigger className="flex w-full items-center justify-between py-2 text-sm font-medium text-foreground hover:text-foreground/80">
- Advanced OCR Settings
- <ChevronDown
- className={cn(
- "h-4 w-4 mr-4 text-muted-foreground transition-transform duration-200",
- ocrOpen && "rotate-180",
- )}
- />
- </CollapsibleTrigger>
- <CollapsibleContent className="pt-4 space-y-6">
- <div className="space-y-2">
- <LabelWrapper
- id="ocr-languages"
- label="OCR languages"
- helperText="Languages are prioritized in this order; English stays last when combined with others"
- disabled={!ocr}
- flex
- >
- <MultiSelect
- options={ocrLanguageOptions}
- value={ocrLanguages}
- onValueChange={(v) => {
- setUserEdited(true);
- // An empty selection would make docling fall back to its
- // English-only default without saying so; keep English.
- setOcrLanguages(
- englishLast(v.length > 0 ? v : ["en"]),
- );
- }}
- showAllOption={false}
- placeholder="Select languages..."
- searchPlaceholder="Search languages..."
- className="w-64"
- inlineLabelLimit={2}
- disabled={!ocr}
- />
- </LabelWrapper>
- <p className="text-sm text-muted-foreground">
- Most languages can only be combined with English, so
- incompatible options are disabled once you choose one.
- </p>
- </div>
- </CollapsibleContent>
- </Collapsible>
- </div>
- <div className="flex items-center justify-between py-3">
- <div className="flex-1">
- <Label
- htmlFor="picture-descriptions"
- className="text-base font-medium cursor-pointer pb-3"
- >
- Picture Descriptions
- </Label>
- <div className="text-sm text-muted-foreground">
- Adds captions for images. Ingest is slower when enabled.
- </div>
- </div>
- <Switch
- id="picture-descriptions"
- checked={pictureDescriptions}
- onCheckedChange={(v) => {
- setUserEdited(true);
- setPictureDescriptions(v);
- }}
/>
- </div>
- {showVlmSettings && (
- <>
- <hr className="mt-4 border-border" />
- <Collapsible
- open={vlmOpen}
- onOpenChange={setVlmOpen}
- className={cn(
- "mt-4 pl-4 transition-all duration-200",
- !pictureDescriptions && "opacity-50",
- )}
+ </CollapsibleTrigger>
+ <CollapsibleContent className="pt-4 space-y-6">
+ <div className="space-y-2">
+ <LabelWrapper
+ id="vlm-model"
+ label="Vision model"
+ helperText="Pick a vision-capable model; the provider is set from your selection"
+ required={pictureDescriptions}
>
- <CollapsibleTrigger className="flex w-full items-center justify-between py-2 text-sm font-medium text-foreground hover:text-foreground/80">
- Advanced Vision Model (VLM) Settings
- <ChevronDown
- className={cn(
- "h-4 w-4 mr-4 text-muted-foreground transition-transform duration-200",
- vlmOpen && "rotate-180",
- )}
- />
- </CollapsibleTrigger>
- <CollapsibleContent className="pt-4 space-y-6">
- <div className="space-y-2">
- <LabelWrapper
- id="vlm-model"
- label="Vision model"
- helperText="Pick a vision-capable model; the provider is set from your selection"
- required={pictureDescriptions}
- >
- <ModelSelector
- groupedOptions={groupedVlmModels}
- custom
- noOptionsPlaceholder={
- isLoadingAnyVlmModels
- ? "Loading models..."
- : catalogError
- ? "Could not load the model catalogue. Retry later."
- : "No models detected. Configure a model provider with vision-capable models first."
- }
- value={vlmModel}
- selectedProvider={effectiveVlmProvider}
- onValueChange={handleVlmModelChange}
- hasError={!!validationError}
- disabled={!pictureDescriptions}
- />
- </LabelWrapper>
- {providerWarning && (
- <p className="text-sm text-destructive" role="alert">
- Configure a provider with vision-capable models in
- Settings &gt; Providers first.
- </p>
- )}
- </div>
+ <ModelSelector
+ groupedOptions={groupedVlmModels}
+ custom
+ noOptionsPlaceholder={
+ isLoadingAnyVlmModels
+ ? "Loading models..."
+ : catalogError
+ ? "Could not load the model catalogue. Retry later."
+ : "No models detected. Configure a model provider with vision-capable models first."
+ }
+ value={vlmModel}
+ selectedProvider={effectiveVlmProvider}
+ onValueChange={handleVlmModelChange}
+ hasError={!!validationError}
+ disabled={!pictureDescriptions}
+ />
+ </LabelWrapper>
+ {providerWarning && (
+ <p className="text-sm text-destructive" role="alert">
+ Configure a provider with vision-capable models in Settings
+ &gt; Providers first.
+ </p>
+ )}
+ </div>
- {effectiveVlmProvider === "watsonx" && (
- <div className="space-y-2">
- <LabelWrapper
- id="vlm-watsonx-api-version"
- label="watsonx API version"
- helperText="API version date sent to watsonx.ai"
- >
- <Input
- id="vlm-watsonx-api-version"
- type="text"
- placeholder={DEFAULT_WATSONX_API_VERSION}
- value={vlmWatsonxApiVersion}
- onChange={(e) => {
- setUserEdited(true);
- setVlmWatsonxApiVersion(e.target.value);
- }}
- disabled={!pictureDescriptions}
- />
- </LabelWrapper>
- </div>
- )}
+ {effectiveVlmProvider === "watsonx" && (
+ <div className="space-y-2">
+ <LabelWrapper
+ id="vlm-watsonx-api-version"
+ label="watsonx API version"
+ helperText="API version date sent to watsonx.ai"
+ >
+ <Input
+ id="vlm-watsonx-api-version"
+ type="text"
+ placeholder={DEFAULT_WATSONX_API_VERSION}
+ value={vlmWatsonxApiVersion}
+ onChange={(e) => {
+ setUserEdited(true);
+ setVlmWatsonxApiVersion(e.target.value);
+ }}
+ disabled={!pictureDescriptions}
+ />
+ </LabelWrapper>
+ </div>
+ )}
- <div className="space-y-2">
- <LabelWrapper
- id="vlm-prompt"
- label="Prompt"
- helperText="Sent to the VLM for every page"
- >
- <Textarea
- id="vlm-prompt"
- rows={3}
- value={vlmPrompt}
- onChange={(e) => {
- setUserEdited(true);
- setVlmPrompt(e.target.value);
- }}
- disabled={!pictureDescriptions}
- />
- </LabelWrapper>
- </div>
+ <div className="space-y-2">
+ <LabelWrapper
+ id="vlm-prompt"
+ label="Prompt"
+ helperText="Sent to the VLM for every page"
+ >
+ <Textarea
+ id="vlm-prompt"
+ rows={3}
+ value={vlmPrompt}
+ onChange={(e) => {
+ setUserEdited(true);
+ setVlmPrompt(e.target.value);
+ }}
+ disabled={!pictureDescriptions}
+ />
+ </LabelWrapper>
+ </div>
- <div className="space-y-2">
- <LabelWrapper
- id="vlm-response-format"
- label="Response format"
- helperText="Per-page VLM output. Markdown is compatible with the existing pipeline; the final document is always Docling JSON."
- >
- <Select
- value={vlmResponseFormat}
- onValueChange={(v) => {
- setUserEdited(true);
- setVlmResponseFormat(v);
- }}
- disabled={!pictureDescriptions}
- >
- <SelectTrigger
- id="vlm-response-format"
- disabled={!pictureDescriptions}
- >
- <SelectValue placeholder="Select a format" />
- </SelectTrigger>
- <SelectContent>
- {RESPONSE_FORMATS.map((format) => (
- <SelectItem
- key={format.value}
- value={format.value}
- >
- {format.label}
- </SelectItem>
- ))}
- </SelectContent>
- </Select>
- </LabelWrapper>
- </div>
+ <div className="space-y-2">
+ <LabelWrapper
+ id="vlm-response-format"
+ label="Response format"
+ helperText="Per-page VLM output. Markdown is compatible with the existing pipeline; the final document is always Docling JSON."
+ >
+ <Select
+ value={vlmResponseFormat}
+ onValueChange={(v) => {
+ setUserEdited(true);
+ setVlmResponseFormat(v);
+ }}
+ disabled={!pictureDescriptions}
+ >
+ <SelectTrigger
+ id="vlm-response-format"
+ disabled={!pictureDescriptions}
+ >
+ <SelectValue placeholder="Select a format" />
+ </SelectTrigger>
+ <SelectContent>
+ {RESPONSE_FORMATS.map((format) => (
+ <SelectItem key={format.value} value={format.value}>
+ {format.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </LabelWrapper>
+ </div>
- <div className="grid grid-cols-3 gap-4">
- <NumberInput
- id="vlm-max-tokens"
- label="Max tokens per page"
- value={vlmMaxTokens}
- onChange={(value) => {
- setUserEdited(true);
- setVlmMaxTokens(Math.max(1, value));
- }}
- unit="tokens"
- min={1}
- disabled={!pictureDescriptions}
- />
- <NumberInput
- id="vlm-concurrency"
- label="Concurrency"
- value={vlmConcurrency}
- onChange={(value) => {
- setUserEdited(true);
- setVlmConcurrency(Math.max(1, value));
- }}
- unit="requests"
- min={1}
- disabled={!pictureDescriptions}
- />
- <NumberInput
- id="vlm-timeout"
- label="API timeout"
- value={vlmTimeout}
- onChange={(value) => {
- setUserEdited(true);
- setVlmTimeout(Math.max(1, value));
- }}
- unit="seconds"
- min={1}
- disabled={!pictureDescriptions}
- />
- </div>
+ <div className="grid grid-cols-3 gap-4">
+ <NumberInput
+ id="vlm-max-tokens"
+ label="Max tokens per page"
+ value={vlmMaxTokens}
+ onChange={(value) => {
+ setUserEdited(true);
+ setVlmMaxTokens(Math.max(1, value));
+ }}
+ unit="tokens"
+ min={1}
+ disabled={!pictureDescriptions}
+ />
+ <NumberInput
+ id="vlm-concurrency"
+ label="Concurrency"
+ value={vlmConcurrency}
+ onChange={(value) => {
+ setUserEdited(true);
+ setVlmConcurrency(Math.max(1, value));
+ }}
+ unit="requests"
+ min={1}
+ disabled={!pictureDescriptions}
+ />
+ <NumberInput
+ id="vlm-timeout"
+ label="API timeout"
+ value={vlmTimeout}
+ onChange={(value) => {
+ setUserEdited(true);
+ setVlmTimeout(Math.max(1, value));
+ }}
+ unit="seconds"
+ min={1}
+ disabled={!pictureDescriptions}
+ />
+ </div>
- {validationError && (
- <p className="text-sm text-destructive" role="alert">
- {validationError}
- </p>
- )}
- </CollapsibleContent>
- </Collapsible>
- </>
- )}
- </div>
- <div className="flex justify-end pt-2">
- <Button
- onClick={handleKnowledgeIngestSave}
- disabled={
- updateSettingsMutation.isPending ||
- !knowledgeIngestDirty ||
- vlmModelPending ||
- !!chunkValidationError
- }
- className="min-w-[120px]"
- size="sm"
- variant="outline"
- >
- {updateSettingsMutation.isPending ? (
- <>
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
- Saving...
- </>
- ) : (
- "Save ingest settings"
+ {validationError && (
+ <p className="text-sm text-destructive" role="alert">
+ {validationError}
+ </p>
)}
- </Button>
- </div>
- </div>
- </CardContent>
- </Card>
+ </CollapsibleContent>
+ </Collapsible>
+ )}
+ </div>
+ </section>
);
}
diff --git a/frontend/app/settings/_components/ingestion-tab.tsx b/frontend/app/settings/_components/ingestion-tab.tsx
index 20b4c337b..6451b721f 100644
--- a/frontend/app/settings/_components/ingestion-tab.tsx
+++ b/frontend/app/settings/_components/ingestion-tab.tsx
@@ -1,25 +1,97 @@
"use client";
+import { ChevronDown, Loader2 } from "lucide-react";
+import { useState } from "react";
+import { toast } from "sonner";
+import { Button } from "@/components/ui/button";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
import { useAuth } from "@/contexts/auth-context";
import { useIsCloudBrand } from "@/contexts/brand-context";
import { isIngestPreviewEnabled } from "@/lib/ingest-preview";
+import { cn } from "@/lib/utils";
import { IngestPreviewSettingsSection } from "./ingest-preview-settings-section";
+import { IngestSaveProvider, useIngestSave } from "./ingest-save-context";
import { IngestSettingsSection } from "./ingest-settings-section";
+function IngestSaveBar() {
+ const { isDirty, isBlocked, isSaving, saveAll } = useIngestSave();
+
+ return (
+ <div className="flex justify-end pt-2">
+ <Button
+ type="button"
+ size="sm"
+ className="min-w-[120px]"
+ disabled={!isDirty || isBlocked || isSaving}
+ data-testid="ingest-save"
+ onClick={async () => {
+ if (await saveAll()) toast.success("Ingest settings saved");
+ }}
+ >
+ {isSaving ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ Saving...
+ </>
+ ) : (
+ "Save changes"
+ )}
+ </Button>
+ </div>
+ );
+}
+
export function IngestionTab() {
const { runMode } = useAuth();
const isCloudBrand = useIsCloudBrand();
const showPreview = isIngestPreviewEnabled(runMode, { isCloudBrand });
+ const [previewOpen, setPreviewOpen] = useState(true);
return (
- <div className="space-y-6">
- <IngestSettingsSection />
- {showPreview ? (
- <div className="space-y-4">
- <h2 className="text-lg font-medium">Ingest preview</h2>
- <IngestPreviewSettingsSection />
- </div>
- ) : null}
- </div>
+ <IngestSaveProvider>
+ <div className="space-y-8">
+ <IngestSettingsSection />
+ {showPreview ? (
+ <Collapsible
+ asChild
+ open={previewOpen}
+ onOpenChange={setPreviewOpen}
+ className="border-t border-border pt-8"
+ >
+ <section>
+ <CollapsibleTrigger className="group flex w-full items-start justify-between gap-6 text-left">
+ <div className="max-w-[545px] space-y-3">
+ <h3 className="text-lg font-semibold leading-tight tracking-tight">
+ Ingest preview
+ </h3>
+ <p className="text-sm text-muted-foreground">
+ Check parser output before committing changes, or run a
+ sample ingest of your documents.
+ </p>
+ </div>
+ <ChevronDown
+ aria-hidden="true"
+ className={cn(
+ "mt-1 h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 group-hover:text-foreground",
+ previewOpen && "rotate-180",
+ )}
+ />
+ </CollapsibleTrigger>
+ <CollapsibleContent
+ forceMount
+ className="pt-4 data-[state=closed]:hidden"
+ >
+ <IngestPreviewSettingsSection />
+ </CollapsibleContent>
+ </section>
+ </Collapsible>
+ ) : null}
+ <IngestSaveBar />
+ </div>
+ </IngestSaveProvider>
);
}
diff --git a/frontend/app/settings/_components/model-fallback-selection.test.tsx b/frontend/app/settings/_components/model-fallback-selection.test.tsx
index 28c657a71..a1afc9be9 100644
--- a/frontend/app/settings/_components/model-fallback-selection.test.tsx
+++ b/frontend/app/settings/_components/model-fallback-selection.test.tsx
@@ -5,6 +5,7 @@ import { describe, expect, it } from "vitest";
import { makeSettings } from "@/test-utils/fixtures/settings";
import { renderWithProviders } from "@/test-utils/render";
import { AgentSettingsSection } from "./agent-settings-section";
+import { IngestSaveProvider } from "./ingest-save-context";
import { IngestSettingsSection } from "./ingest-settings-section";
const catalog = {
@@ -80,10 +81,15 @@ describe("Azure fallback model selection", () => {
it("asks for an explicit embedding deployment instead of saving a catalog model", async () => {
const updates: unknown[] = [];
const user = userEvent.setup();
- renderWithProviders(<IngestSettingsSection />, {
- providers: [...providers],
- handlers: handlers(updates),
- });
+ renderWithProviders(
+ <IngestSaveProvider>
+ <IngestSettingsSection />
+ </IngestSaveProvider>,
+ {
+ providers: [...providers],
+ handlers: handlers(updates),
+ },
+ );
const selector = await screen.findByRole("combobox");
await user.click(selector);
diff --git a/frontend/components/chat-renderer.tsx b/frontend/components/chat-renderer.tsx
index 6cc7ae55e..c962a3a66 100644
--- a/frontend/components/chat-renderer.tsx
+++ b/frontend/components/chat-renderer.tsx
@@ -446,7 +446,7 @@ export function ChatRenderer({
<main
className={cn(
- "overflow-hidden flex-1 min-w-0 flex items-center justify-center relative",
+ "overflow-auto flex-1 min-w-0 flex items-center justify-center relative",
isSelectingChats && "relative",
)}
>
@@ -525,7 +525,7 @@ export function ChatRenderer({
: { 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 overflow-x-hidden",
+ "flex h-full w-full max-w-full max-h-full items-center justify-center overflow-auto",
!showLayout &&
"max-h-[calc(100vh-190px)] shadow-[0px_2px_4px_-2px_#0000001A,0px_4px_6px_-1px_#0000001A]",
showLayout && !isOnChatPage && "bg-background",
@@ -533,7 +533,7 @@ export function ChatRenderer({
>
<div
className={cn(
- "h-full bg-background w-full min-w-0 overflow-x-hidden",
+ "h-full bg-background w-full min-w-0",
showLayout && !isOnChatPage && "p-6 container",
showLayout && isSmallWidthPath && "max-w-content mx-auto",
!showLayout && "p-0 py-2",
diff --git a/frontend/tests/core/restore_flow.spec.ts b/frontend/tests/core/restore_flow.spec.ts
index 9f046c88d..9899fcbf7 100644
--- a/frontend/tests/core/restore_flow.spec.ts
+++ b/frontend/tests/core/restore_flow.spec.ts
@@ -41,10 +41,9 @@ test.describe("Restore Flow", () => {
logger.info(
"\n🔧 Non-default settings detected during setup, restoring defaults...",
);
- const restoreFlowButton = page
- .locator("text=Knowledge Ingest")
- .locator("..")
- .getByRole("button", { name: /restore flow/i });
+ const restoreFlowButton = page.getByRole("button", {
+ name: /restore flow/i,
+ });
await restoreFlowButton.scrollIntoViewIfNeeded();
await restoreFlowButton.click();
@@ -130,10 +129,9 @@ test.describe("Restore Flow", () => {
// Click on "Restore flow" button
logger.info("\n🔄 Restoring default settings...");
await page.waitForTimeout(500);
- const restoreFlowButton = page
- .locator("text=Knowledge Ingest")
- .locator("..")
- .getByRole("button", { name: /restore flow/i });
+ const restoreFlowButton = page.getByRole("button", {
+ name: /restore flow/i,
+ });
await restoreFlowButton.scrollIntoViewIfNeeded();
await expect(restoreFlowButton).toBeVisible();
await restoreFlowButton.click();
@@ -259,10 +257,9 @@ test.describe("Restore Flow", () => {
// Click on "Restore flow" button even though settings are already default
logger.info("\n🔄 Clicking restore on already default settings...");
await page.waitForTimeout(500);
- const restoreFlowButton = page
- .locator("text=Knowledge Ingest")
- .locator("..")
- .getByRole("button", { name: /restore flow/i });
+ const restoreFlowButton = page.getByRole("button", {
+ name: /restore flow/i,
+ });
await restoreFlowButton.scrollIntoViewIfNeeded();
await expect(restoreFlowButton).toBeVisible();
await restoreFlowButton.click();
diff --git a/frontend/tests/pages/Settings.ts b/frontend/tests/pages/Settings.ts
index e44991860..d2ac88af1 100644
--- a/frontend/tests/pages/Settings.ts
+++ b/frontend/tests/pages/Settings.ts
@@ -19,9 +19,11 @@ export class Settings {
private readonly settingsLink = () =>
this.page.getByRole("link", { name: "Settings" });
private readonly saveIngestSettingsButton = () =>
- this.page.getByRole("button", { name: /save ingest settings/i });
+ this.page.getByTestId("ingest-save");
private readonly settingsUpdatedToast = () =>
this.page.getByText(/settings updated successfully/i).first();
+ private readonly ingestSettingsSavedToast = () =>
+ this.page.getByText(/ingest settings saved/i).first();
private readonly pictureDescriptionsToggle = () =>
this.page.getByRole("switch", { name: /picture descriptions/i });
private readonly tableStructureToggle = () =>
@@ -232,7 +234,9 @@ export class Settings {
// (vlmModelPending gate). 10s was too short on slow CI runners.
await expect(saveButton).toBeEnabled({ timeout: 30000 });
await saveButton.click();
- await expect(this.settingsUpdatedToast()).toBeVisible({ timeout: 120000 });
+ await expect(this.ingestSettingsSavedToast()).toBeVisible({
+ timeout: 120000,
+ });
}
async setPictureDescriptions(enabled: boolean) {