Skip to content

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

Python

chore: ui simplification / QoL Fixes (#2423)

Jason Dong6d50461eb05e
diff --git a/frontend/app/chat/_components/message.tsx b/frontend/app/chat/_components/message.tsx
index c526d98ea..49ee390dc 100644
--- a/frontend/app/chat/_components/message.tsx
+++ b/frontend/app/chat/_components/message.tsx
@@ -21,7 +21,7 @@ export function Message({
<div
className={
isAssistant && !unstyledContent
- ? "px-5 py-4 bg-secondary/20 rounded-2xl flex-1"
+ ? "px-5 py-4 bg-muted rounded-2xl flex-1"
: "flex-1 flex w-full overflow-hidden"
}
>
diff --git a/frontend/app/chat/_components/nudges.tsx b/frontend/app/chat/_components/nudges.tsx
index 8326d7e66..200eb319c 100644
--- a/frontend/app/chat/_components/nudges.tsx
+++ b/frontend/app/chat/_components/nudges.tsx
@@ -39,7 +39,7 @@ export default function Nudges({
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",
+ "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 text-left",
)}
>
{suggestion}
diff --git a/frontend/app/knowledge/chunks/page.test.tsx b/frontend/app/knowledge/chunks/page.test.tsx
index 5cc035bdc..153d0bfda 100644
--- a/frontend/app/knowledge/chunks/page.test.tsx
+++ b/frontend/app/knowledge/chunks/page.test.tsx
@@ -164,3 +164,69 @@ describe("ChunksPage — highlight wiring", () => {
expect(container.querySelector("mark")?.textContent).toBe("fox");
});
});
+
+/**
+ * Serve a minimal /api/search response carrying per-chunk access-control
+ * fields. The query aggregates these onto the File object, making them visible
+ * in the detail panel when chunkCount > 0.
+ */
+function serveFile(chunkOverrides: Partial<ChunkResult>) {
+ const baseChunk: ChunkResult = {
+ filename: "access-test.pdf",
+ mimetype: "application/pdf",
+ page: 1,
+ text: "Sample content",
+ score: 1,
+ chunk_id: "c1",
+ };
+ server.use(
+ http.post("/api/search", () =>
+ HttpResponse.json({
+ results: [{ ...baseChunk, ...chunkOverrides }],
+ warnings: [],
+ }),
+ ),
+ );
+}
+
+describe("ChunksPage — access-control sections", () => {
+ it("renders every allowed_users entry (line 224)", async () => {
+ setMockLocation({
+ pathname: "/knowledge/chunks",
+ searchParams: { filename: "access-test.pdf" },
+ });
+ serveFile({
+ allowed_users: ["[email protected]", "[email protected]"],
+ filename: "access-test.pdf",
+ });
+
+ renderWithProviders(<ProtectedChunksPage />, {
+ providers: ["tooltip", "auth", "knowledgeFilter"],
+ auth: authPresets.admin,
+ });
+
+ await screen.findByText("[email protected]", {}, { timeout: 5000 });
+ expect(screen.getByText("[email protected]")).toBeTruthy();
+ expect(screen.getByText("Allowed users")).toBeTruthy();
+ });
+
+ it("renders every allowed_groups entry (line 256)", async () => {
+ setMockLocation({
+ pathname: "/knowledge/chunks",
+ searchParams: { filename: "access-test.pdf" },
+ });
+ serveFile({
+ allowed_groups: ["admins", "editors"],
+ filename: "access-test.pdf",
+ });
+
+ renderWithProviders(<ProtectedChunksPage />, {
+ providers: ["tooltip", "auth", "knowledgeFilter"],
+ auth: authPresets.admin,
+ });
+
+ await screen.findByText("admins", {}, { timeout: 5000 });
+ expect(screen.getByText("editors")).toBeTruthy();
+ expect(screen.getByText("Allowed groups")).toBeTruthy();
+ });
+});
diff --git a/frontend/app/knowledge/chunks/page.tsx b/frontend/app/knowledge/chunks/page.tsx
index 40644a765..bfe641c0c 100644
--- a/frontend/app/knowledge/chunks/page.tsx
+++ b/frontend/app/knowledge/chunks/page.tsx
@@ -121,134 +121,155 @@ function ChunksPageContent() {
{chunkCount > 0 && (
<div className="min-w-[200px]">
- <div className="mb-8">
- <h2 className="text-xl font-semibold mb-4">Technical details</h2>
- <dl>
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
+ {/* Heading row — on narrow view the owner sits flush right */}
+ <div className="flex items-center mb-4">
+ <h2 className="text-xl font-semibold">Document Details</h2>
+ {fileData?.owner && (
+ <span className="lg:hidden flex items-center gap-1.5 text-sm text-muted-foreground ps-3 min-w-0">
+ Owned by:{" "}
+ <span className="inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900">
+ <span className="text-xs font-medium text-amber-800 dark:text-amber-200">
+ {String(fileData.owner).charAt(0).toUpperCase()}
+ </span>
+ </span>
+ <span className="text-foreground truncate">
+ {fileData.owner_name ||
+ fileData.owner_email ||
+ fileData.owner}
+ </span>
+ </span>
+ )}
+ </div>
+
+ {/*
+ Narrow (< lg): unified 2-col grid, cells flush together (no gap-y).
+ Wide (≥ lg): single-column stacked label/value list.
+ */}
+ <dl className="grid grid-cols-2 gap-x-4 gap-y-0 lg:grid-cols-1">
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">
+ Total chunks
+ </dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {chunkCount}
+ </dd>
+ </div>
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">Avg length</dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {averageChunkLength.toFixed(0)} chars
+ </dd>
+ </div>
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">Type</dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {fileData ? getFileTypeLabel(fileData.mimetype) : "Unknown"}
+ </dd>
+ </div>
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">Size</dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {fileData?.size ? formatFileSize(fileData.size) : "Unknown"}
+ </dd>
+ </div>
+ {fileData?.embedding_model && (
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
<dt className="text-sm/6 text-muted-foreground">
- Total chunks
+ Embedding model
</dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- {chunkCount}
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {fileData.embedding_model}
</dd>
</div>
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
+ )}
+ {typeof fileData?.embedding_dimensions === "number" && (
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
<dt className="text-sm/6 text-muted-foreground">
- Avg length
+ Dimensions
</dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- {averageChunkLength.toFixed(0)} chars
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ {fileData.embedding_dimensions}
</dd>
</div>
- </dl>
- </div>
- <div className="mb-4">
- <h2 className="text-xl font-semibold mt-2 mb-3">
- Original document
- </h2>
- <dl>
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
- <dt className="text-sm/6 text-muted-foreground">Type</dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- {fileData ? getFileTypeLabel(fileData.mimetype) : "Unknown"}
- </dd>
- </div>
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
- <dt className="text-sm/6 text-muted-foreground">Size</dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- {fileData?.size ? formatFileSize(fileData.size) : "Unknown"}
+ )}
+
+ {/* Owner — wide view only (narrow shows it in the heading row) */}
+ {fileData?.owner && (
+ <div className="hidden lg:grid lg:grid-cols-3 lg:gap-4 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">Owned by</dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ <div className="flex items-center gap-2">
+ <span className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900">
+ <span className="text-xs font-medium text-amber-800 dark:text-amber-200">
+ {String(fileData.owner).charAt(0).toUpperCase()}
+ </span>
+ </span>
+ <span className="text-sm break-all truncate">
+ {fileData.owner_name ||
+ fileData.owner_email ||
+ fileData.owner}
+ </span>
+ </div>
</dd>
</div>
- </dl>
- </div>
- {hasAccessControl && (
- <div className="mb-4">
- <h2 className="text-xl font-semibold mt-2 mb-3">
- Access Control
- </h2>
- <dl>
- {fileData?.owner && (
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
- <dt className="text-sm/6 text-muted-foreground">Owner</dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- <div className="flex items-center gap-2">
- <span className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-amber-100 dark:bg-amber-900">
- <span className="text-xs font-medium text-amber-800 dark:text-amber-200">
- {String(fileData.owner).charAt(0).toUpperCase()}
+ )}
+ {fileData?.allowed_users && fileData.allowed_users.length > 0 && (
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">
+ Allowed users
+ </dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ <div className="space-y-2">
+ {fileData.allowed_users.map((user, idx) => (
+ <div
+ key={user ?? idx}
+ className="flex items-center gap-2 overflow-hidden w-full"
+ >
+ <span className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900">
+ <span className="text-xs font-medium text-blue-800 dark:text-blue-200">
+ {user?.charAt(0).toUpperCase()}
</span>
</span>
- <span className="text-sm break-all">
- {fileData.owner_name ||
- fileData.owner_email ||
- fileData.owner}
- </span>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="text-sm break-all truncate">
+ {user}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>{user}</TooltipContent>
+ </Tooltip>
</div>
- </dd>
+ ))}
</div>
- )}
- {fileData?.allowed_users &&
- fileData.allowed_users.length > 0 && (
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
- <dt className="text-sm/6 text-muted-foreground">
- Allowed users
- </dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- <div className="space-y-2">
- {fileData.allowed_users.map((user, idx) => (
- <div
- key={user ?? idx}
- className="flex items-center gap-2 overflow-hidden w-full"
- >
- <span className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900">
- <span className="text-xs font-medium text-blue-800 dark:text-blue-200">
- {user?.charAt(0).toUpperCase()}
- </span>
- </span>
- <Tooltip>
- <TooltipTrigger asChild>
- <span className="text-sm break-all truncate">
- {user}
- </span>
- </TooltipTrigger>
- <TooltipContent>{user}</TooltipContent>
- </Tooltip>
- </div>
- ))}
- </div>
- </dd>
- </div>
- )}
-
- {fileData?.allowed_groups &&
- fileData.allowed_groups.length > 0 && (
- <div className="sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0 mb-2.5">
- <dt className="text-sm/6 text-muted-foreground">
- Allowed groups
- </dt>
- <dd className="mt-1 text-sm/6 text-gray-800 dark:text-gray-100 sm:col-span-2 sm:mt-0">
- <div className="space-y-1">
- {fileData.allowed_groups.map((group, idx) => (
- <div
- key={group ?? idx}
- className="flex items-center gap-2"
- >
- <span className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-green-100 dark:bg-green-900">
- <span className="text-xs font-medium text-green-800 dark:text-green-200">
- {group?.charAt(0).toUpperCase()}
- </span>
- </span>
- <span className="text-sm break-all">
- {group}
- </span>
- </div>
- ))}
+ </dd>
+ </div>
+ )}
+ {fileData?.allowed_groups &&
+ fileData.allowed_groups.length > 0 && (
+ <div className="pb-2.5 lg:grid lg:grid-cols-3 lg:gap-4 lg:pb-0 lg:mb-2.5">
+ <dt className="text-sm/6 text-muted-foreground">
+ Allowed groups
+ </dt>
+ <dd className="text-sm/6 text-foreground lg:col-span-2">
+ <div className="space-y-1">
+ {fileData.allowed_groups.map((group, idx) => (
+ <div
+ key={group ?? idx}
+ className="flex items-center gap-2"
+ >
+ <span className="inline-flex h-6 w-6 items-center justify-center rounded-full bg-green-100 dark:bg-green-900">
+ <span className="text-xs font-medium text-green-800 dark:text-green-200">
+ {group?.charAt(0).toUpperCase()}
+ </span>
+ </span>
+ <span className="text-sm break-all">{group}</span>
</div>
- </dd>
+ ))}
</div>
- )}
- </dl>
- </div>
- )}
+ </dd>
+ </div>
+ )}
+ </dl>
</div>
)}
</div>
diff --git a/frontend/app/knowledge/page.test.tsx b/frontend/app/knowledge/page.test.tsx
index 2e5c3e0c1..1f7bed36d 100644
--- a/frontend/app/knowledge/page.test.tsx
+++ b/frontend/app/knowledge/page.test.tsx
@@ -1,21 +1,47 @@
/**
* Unit tests for pure helpers extracted from knowledge/page.tsx.
*
- * Covers the lines added / changed in #2388:
- * getStatusSortRank — all branches including "skipped" (4) and "hidden" (7)
+ * getStatusSortRank — all branches including "skipped" (4) and "hidden" (7)
* getSkippedWarningText — provided warning vs default fallback
* isSkippedStatus — skipped detection used by the cell renderer
* SkippedStatusCell — renders the amber "Duplicate" badge with tooltip
+ * buildChunksUrl — URL construction for the chunks navigation link
+ * getOwnerLabel — owner display label preference order
+ * formatAvgScoreLabel — avg-score cell number / dash formatting
+ * formatChunkCountLabel — chunk-count cell number / dash formatting
+ * resolveDisplayStatus — failed→cancelled promotion for cancelled files
+ *
+ * SearchPage render smoke-test — exercises the column-definition object
+ * construction (colOwner, colChunks, colAvgScore, colStatus, colActions, …)
+ * which runs every time the component mounts.
*/
+
import { render, screen } from "@testing-library/react";
-import { describe, expect, it } from "vitest";
+import { HttpResponse, http } from "msw";
+import { describe, expect, it, vi } from "vitest";
+import type { File } from "@/app/api/queries/useGetSearchQuery";
import { TooltipProvider } from "@/components/ui/tooltip";
-import {
+import { authPresets } from "@/test-utils/fixtures/auth";
+import { renderWithProviders, userEvent, waitFor } from "@/test-utils/render";
+import { setMockLocation } from "@/test-utils/router";
+import ProtectedSearchPage, {
+ AvgScoreCellContent,
buildChunksUrl,
+ compareAvgScore,
+ compareStatusRank,
+ formatAvgScoreLabel,
+ formatChunkCountLabel,
+ formatSizeLabel,
+ getFileStatus,
+ getOwnerLabel,
getSkippedWarningText,
getStatusSortRank,
isSkippedStatus,
+ resolveActionsVariant,
+ resolveDisplayStatus,
SkippedStatusCell,
+ StatusCellContent,
+ serverSideComparator,
} from "./page";
describe("getStatusSortRank", () => {
@@ -124,3 +150,364 @@ describe("buildChunksUrl", () => {
expect(url).toContain("q=cost%2Fbenefit");
});
});
+
+describe("getOwnerLabel", () => {
+ // Minimal File-shaped stubs — only the fields getOwnerLabel reads.
+ const f = (partial: Partial<File>) => partial as File;
+
+ it("prefers owner_name when present", () => {
+ expect(
+ getOwnerLabel(
+ f({ owner_name: "Alice", owner_email: "[email protected]" }),
+ ),
+ ).toBe("Alice");
+ });
+
+ it("falls back to owner_email when owner_name is absent", () => {
+ expect(getOwnerLabel(f({ owner_email: "[email protected]" }))).toBe(
+ );
+ });
+
+ it("returns an em-dash when both are absent", () => {
+ expect(getOwnerLabel(f({}))).toBe("—");
+ expect(getOwnerLabel(undefined)).toBe("—");
+ });
+
+ it("trims whitespace from owner_name", () => {
+ expect(getOwnerLabel(f({ owner_name: " Bob " }))).toBe("Bob");
+ });
+});
+
+describe("formatAvgScoreLabel", () => {
+ it("formats a number to two decimal places", () => {
+ expect(formatAvgScoreLabel(0.8765)).toBe("0.88");
+ expect(formatAvgScoreLabel(1)).toBe("1.00");
+ });
+
+ it("returns a dash for non-numeric values", () => {
+ expect(formatAvgScoreLabel(undefined)).toBe("-");
+ expect(formatAvgScoreLabel(null)).toBe("-");
+ expect(formatAvgScoreLabel("0.9")).toBe("-");
+ });
+});
+
+describe("formatChunkCountLabel", () => {
+ it("converts a defined count to its string representation", () => {
+ expect(formatChunkCountLabel(42)).toBe("42");
+ expect(formatChunkCountLabel(0)).toBe("0");
+ });
+
+ it("returns a dash when chunkCount is undefined", () => {
+ expect(formatChunkCountLabel(undefined)).toBe("-");
+ });
+});
+
+describe("resolveDisplayStatus", () => {
+ it("promotes failed to cancelled when the file is cancelled", () => {
+ expect(resolveDisplayStatus("failed", true)).toBe("cancelled");
+ });
+
+ it("keeps failed when the file is not cancelled", () => {
+ expect(resolveDisplayStatus("failed", false)).toBe("failed");
+ });
+
+ it("passes through any other status unchanged regardless of cancellation flag", () => {
+ expect(resolveDisplayStatus("active", false)).toBe("active");
+ expect(resolveDisplayStatus("processing", true)).toBe("processing");
+ expect(resolveDisplayStatus("skipped", true)).toBe("skipped");
+ });
+});
+
+describe("formatSizeLabel", () => {
+ it("formats a truthy numeric value via formatFileSize", () => {
+ // formatFileSize converts bytes to human-readable; we just check it
+ // returns something non-dash for a positive number.
+ expect(formatSizeLabel(1024)).not.toBe("-");
+ expect(formatSizeLabel(1024)).toBeTruthy();
+ });
+
+ it("returns a dash for falsy values", () => {
+ expect(formatSizeLabel(0)).toBe("-");
+ expect(formatSizeLabel(undefined)).toBe("-");
+ expect(formatSizeLabel(null)).toBe("-");
+ });
+});
+
+describe("compareAvgScore", () => {
+ it("returns a positive number when valueA > valueB", () => {
+ expect(compareAvgScore(0.9, 0.5)).toBeGreaterThan(0);
+ });
+
+ it("returns a negative number when valueA < valueB", () => {
+ expect(compareAvgScore(0.3, 0.8)).toBeLessThan(0);
+ });
+
+ it("returns 0 for equal values", () => {
+ expect(compareAvgScore(0.5, 0.5)).toBe(0);
+ });
+
+ it("treats undefined as 0", () => {
+ expect(compareAvgScore(undefined, 0)).toBe(0);
+ expect(compareAvgScore(0.5, undefined)).toBeGreaterThan(0);
+ });
+});
+
+describe("getFileStatus", () => {
+ it("returns the status when present", () => {
+ expect(getFileStatus("active")).toBe("active");
+ expect(getFileStatus("failed")).toBe("failed");
+ });
+
+ it("defaults to 'active' when status is undefined", () => {
+ expect(getFileStatus(undefined)).toBe("active");
+ });
+});
+
+describe("resolveActionsVariant", () => {
+ it("returns 'cancel' for a processing row with taskId and filePath", () => {
+ expect(resolveActionsVariant("processing", "task-1", "file.pdf")).toBe(
+ "cancel",
+ );
+ });
+
+ it("returns null for a processing row without taskId", () => {
+ expect(resolveActionsVariant("processing", null, "file.pdf")).toBeNull();
+ expect(
+ resolveActionsVariant("processing", undefined, "file.pdf"),
+ ).toBeNull();
+ });
+
+ it("returns null for a processing row without filePath", () => {
+ expect(resolveActionsVariant("processing", "task-1", "")).toBeNull();
+ });
+
+ it("returns 'dropdown' for an active row", () => {
+ expect(resolveActionsVariant("active", undefined, "")).toBe("dropdown");
+ });
+
+ it("returns null for any other status", () => {
+ expect(resolveActionsVariant("failed", undefined, "")).toBeNull();
+ expect(resolveActionsVariant("cancelled", undefined, "")).toBeNull();
+ expect(resolveActionsVariant("skipped", undefined, "")).toBeNull();
+ });
+});
+
+describe("StatusCellContent", () => {
+ const f = (partial: Partial<File>) => partial as File;
+ const noop = () => {};
+
+ const baseProps = {
+ isCloudBrand: false,
+ isOpenragDocsRow: () => false,
+ hasOpenragRefreshCue: false,
+ selectTask: noop,
+ getTaskIdForRow: () => null as null,
+ openTaskMenu: noop,
+ setRecentTasksExpanded: noop,
+ };
+
+ it("renders a StatusBadge for an active file", () => {
+ render(
+ <TooltipProvider>
+ <StatusCellContent {...baseProps} data={f({ status: "active" })} />
+ </TooltipProvider>,
+ );
+ // active StatusBadge renders an "Active" or similar label — just check it
+ // doesn't crash and renders something.
+ expect(document.body.firstChild).toBeTruthy();
+ });
+
+ it("renders the cancelled StatusBadge for a cancelled file", () => {
+ const { container } = render(
+ <TooltipProvider>
+ <StatusCellContent {...baseProps} data={f({ status: "cancelled" })} />
+ </TooltipProvider>,
+ );
+ expect(container.textContent?.toLowerCase()).toContain("cancel");
+ });
+
+ it("renders the Refreshing indicator when hasOpenragRefreshCue and isOpenragDocsRow", () => {
+ render(
+ <TooltipProvider>
+ <StatusCellContent
+ {...baseProps}
+ isOpenragDocsRow={() => true}
+ hasOpenragRefreshCue={true}
+ isCloudBrand={false}
+ data={f({ status: "active", connector_type: "openrag_docs" })}
+ />
+ </TooltipProvider>,
+ );
+ // The non-cloud variant renders an aria-label "OpenRAG doc is refreshing".
+ expect(
+ document.querySelector('[aria-label="OpenRAG doc is refreshing"]'),
+ ).not.toBeNull();
+ });
+
+ it("renders the cloud Refreshing label when isCloudBrand is true", () => {
+ const { container } = render(
+ <TooltipProvider>
+ <StatusCellContent
+ {...baseProps}
+ isOpenragDocsRow={() => true}
+ hasOpenragRefreshCue={true}
+ isCloudBrand={true}
+ data={f({ status: "active", connector_type: "openrag_docs" })}
+ />
+ </TooltipProvider>,
+ );
+ expect(container.textContent).toContain("Refreshing");
+ });
+
+ it("renders the failed button trigger for a failed file", () => {
+ render(
+ <TooltipProvider>
+ <StatusCellContent {...baseProps} data={f({ status: "failed" })} />
+ </TooltipProvider>,
+ );
+ expect(
+ document.querySelector('[data-testid="failed-status-cell-trigger"]'),
+ ).not.toBeNull();
+ });
+
+ it("calls selectTask/openTaskMenu/setRecentTasksExpanded on click of the failed trigger", async () => {
+ const user = userEvent.setup();
+ const selectTask = vi.fn();
+ const openTaskMenu = vi.fn();
+ const setRecentTasksExpanded = vi.fn();
+ render(
+ <TooltipProvider>
+ <StatusCellContent
+ {...baseProps}
+ data={f({ status: "failed", task_id: "t1" })}
+ selectTask={selectTask}
+ getTaskIdForRow={() => "t1"}
+ openTaskMenu={openTaskMenu}
+ setRecentTasksExpanded={setRecentTasksExpanded}
+ />
+ </TooltipProvider>,
+ );
+ await user.click(
+ document.querySelector('[data-testid="failed-status-cell-trigger"]')!,
+ );
+ expect(selectTask).toHaveBeenCalledWith("t1");
+ expect(openTaskMenu).toHaveBeenCalled();
+ expect(setRecentTasksExpanded).toHaveBeenCalledWith(true);
+ });
+
+ it("wraps the failed button in a tooltip when data.error is set", () => {
+ render(
+ <TooltipProvider>
+ <StatusCellContent
+ {...baseProps}
+ data={f({ status: "failed", error: "Upload timed out" })}
+ />
+ </TooltipProvider>,
+ );
+ // Tooltip wraps the trigger — button is still in the DOM.
+ expect(
+ document.querySelector('[data-testid="failed-status-cell-trigger"]'),
+ ).not.toBeNull();
+ });
+
+ it("renders the Duplicate badge for a skipped duplicate-content file", () => {
+ render(
+ <TooltipProvider>
+ <StatusCellContent
+ {...baseProps}
+ data={f({ status: "skipped", skip_reason: "duplicate_content" })}
+ />
+ </TooltipProvider>,
+ );
+ expect(screen.getByText("Duplicate")).toBeTruthy();
+ });
+});
+
+describe("serverSideComparator", () => {
+ it("always returns 0 regardless of arguments", () => {
+ expect(serverSideComparator()).toBe(0);
+ });
+});
+
+describe("compareStatusRank", () => {
+ it("sorts active before failed", () => {
+ expect(compareStatusRank("active", "failed")).toBeLessThan(0);
+ });
+
+ it("sorts failed before cancelled", () => {
+ expect(compareStatusRank("failed", "cancelled")).toBeLessThan(0);
+ });
+
+ it("returns 0 for equal statuses", () => {
+ expect(compareStatusRank("active", "active")).toBe(0);
+ });
+});
+
+describe("AvgScoreCellContent", () => {
+ it("renders a formatted score label", () => {
+ const { container } = render(
+ <TooltipProvider>
+ <AvgScoreCellContent value={0.875} />
+ </TooltipProvider>,
+ );
+ expect(container.textContent).toContain("0.88");
+ });
+
+ it("renders a dash when value is not a number", () => {
+ const { container } = render(
+ <TooltipProvider>
+ <AvgScoreCellContent value={undefined} />
+ </TooltipProvider>,
+ );
+ expect(container.textContent).toContain("-");
+ });
+});
+
+describe("SearchPage — column-definition smoke-test", () => {
+ /**
+ * Rendering the page (even with no data) exercises the body of SearchPage,
+ * which creates all column-definition objects (colSource, colSize, colType,
+ * colOwner, colChunks, colAvgScore, colStatus, colActions, columnDefs).
+ * That's enough to hit the property-declaration lines that V8 tracks as
+ * executable. Cell-renderer closure bodies run only when ag-grid paints a
+ * real cell, which jsdom cannot do — those branches are covered by the pure-
+ * helper tests above.
+ */
+ it("mounts without crashing and renders the search heading", async () => {
+ setMockLocation({ pathname: "/knowledge" });
+
+ renderWithProviders(<ProtectedSearchPage />, {
+ providers: "all",
+ auth: authPresets.admin,
+ handlers: [
+ http.get("/api/files", () =>
+ HttpResponse.json({
+ files: [],
+ total: 0,
+ is_approximate: false,
+ page: 1,
+ page_size: 20,
+ after_key: null,
+ }),
+ ),
+ http.post("/api/search", () =>
+ HttpResponse.json({ files: [], warnings: [] }),
+ ),
+ // Side-effect fetches triggered by KnowledgeDropdown / connector queries.
+ http.get("/api/upload_options", () => HttpResponse.json({})),
+ http.get("/api/connectors", () =>
+ HttpResponse.json({ connectors: [] }),
+ ),
+ http.get("/api/connectors/:name/defaults", () => HttpResponse.json({})),
+ ],
+ });
+
+ // The heading is always rendered once SearchPage mounts.
+ await waitFor(() =>
+ expect(
+ screen.queryByRole("heading", { name: /knowledge/i }),
+ ).not.toBeNull(),
+ );
+ });
+});
diff --git a/frontend/app/knowledge/page.tsx b/frontend/app/knowledge/page.tsx
index fa971c750..52a4cfceb 100644
--- a/frontend/app/knowledge/page.tsx
+++ b/frontend/app/knowledge/page.tsx
@@ -130,8 +130,6 @@ const AG_FIELD_TO_SORT_BY: Record<string, string> = {
mimetype: "mimetype",
owner: "owner",
chunkCount: "chunk_count",
- embedding_model: "embedding_model",
- embedding_dimensions: "embedding_dimensions",
status: "status",
};
@@ -156,7 +154,6 @@ function buildFilterPageResetKey(
});
}
-/** Pure helper — exported for unit tests, used by the status column comparator. */
export function getStatusSortRank(status?: File["status"]): number {
switch (status) {
case "active":
@@ -180,19 +177,11 @@ export function getStatusSortRank(status?: File["status"]): number {
}
}
-/**
- * Pure helper — exported for unit tests, used by the status column cell renderer.
- * Returns the warning text for a skipped (duplicate-content) file.
- */
export function getSkippedWarningText(warning?: string): string {
return warning ?? "Duplicate content — already exists in the knowledge base.";
}
-/**
- * Pure helper — exported for unit tests, used by the status column cell renderer.
- * Returns true only for skipped rows that are content duplicates.
- * Other skip reasons (e.g. deleted_at_source) fall through to the normal StatusBadge.
- */
+/** Returns true only for skipped+duplicate_content rows; other skip reasons use the normal StatusBadge. */
export function isSkippedStatus(
rawStatus?: string,
skipReason?: string,
@@ -200,10 +189,6 @@ export function isSkippedStatus(
return rawStatus === "skipped" && skipReason === "duplicate_content";
}
-/**
- * Exported for unit tests — renders the amber "Duplicate" badge with tooltip
- * used by the status column cell renderer when a file was skipped.
- */
export function SkippedStatusCell({ warning }: { warning?: string }) {
const warningText = getSkippedWarningText(warning);
return (
@@ -224,8 +209,53 @@ export function SkippedStatusCell({ warning }: { warning?: string }) {
);
}
-/** Builds the URL for navigating from a knowledge search result to its chunks page.
- * Exported for unit testing; the click handler in SearchPage calls this directly. */
+export function getOwnerLabel(file?: File): string {
+ return file?.owner_name?.trim() || file?.owner_email?.trim() || "—";
+}
+
+export function formatAvgScoreLabel(value: unknown): string {
+ return typeof value === "number" ? value.toFixed(2) : "-";
+}
+
+export function formatChunkCountLabel(chunkCount?: number): string {
+ return chunkCount?.toString() ?? "-";
+}
+
+/** Promotes "failed" to "cancelled" when the file's task was cancelled. */
+export function resolveDisplayStatus(
+ rawStatus: string,
+ isCancelled: boolean,
+): string {
+ return rawStatus === "failed" && isCancelled ? "cancelled" : rawStatus;
+}
+
+export function formatSizeLabel(value: unknown): string {
+ return value ? formatFileSize(value as number) : "-";
+}
+
+/** Always returns 0 — passed to ag-grid columns whose ordering is server-side. */
+export function serverSideComparator(): number {
+ return 0;
+}
+
+export function compareStatusRank(
+ valueA?: File["status"],
+ valueB?: File["status"],
+): number {
+ return getStatusSortRank(valueA) - getStatusSortRank(valueB);
+}
+
+export function compareAvgScore(
+ valueA: number | undefined,
+ valueB: number | undefined,
+): number {
+ return (valueA || 0) - (valueB || 0);
+}
+
+export function getFileStatus(status?: File["status"]): string {
+ return status || "active";
+}
+
export function buildChunksUrl(
filename: string,
effectiveSearchText: string,
@@ -238,8 +268,152 @@ export function buildChunksUrl(
return `/knowledge/chunks?${params.toString()}`;
}
+const AVG_SCORE_TOOLTIP =
+ "Average relevance score across the matched chunks of this file. Higher means a stronger match — sort by this column to rank results by relevance.";
+
+export function AvgScoreCellContent({ value }: { value: unknown }) {
+ const label = formatAvgScoreLabel(value);
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span className="text-xs text-accent-emerald-foreground bg-accent-emerald px-2 py-1 rounded cursor-default">
+ {label}
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="top" className="max-w-56 text-center">
+ {AVG_SCORE_TOOLTIP}
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
+export function StatusCellContent({
+ data,
+ isCloudBrand,
+ isOpenragDocsRow,
+ hasOpenragRefreshCue,
+ selectTask,
+ getTaskIdForRow,
+ openTaskMenu,
+ setRecentTasksExpanded,
+}: {
+ data?: File;
+ isCloudBrand: boolean;
+ isOpenragDocsRow: (file?: File) => boolean;
+ hasOpenragRefreshCue: boolean;
+ selectTask: (taskId: string | null) => void;
+ getTaskIdForRow: (data?: File) => string | null;
+ openTaskMenu: () => void;
+ setRecentTasksExpanded: (v: boolean) => void;
+}) {
+ const rawStatus = data?.status || "active";
+ const status = resolveDisplayStatus(
+ rawStatus,
+ data != null && isFileCancelled(data),
+ );
+ const showOpenragRefreshCue = isOpenragDocsRow(data) && hasOpenragRefreshCue;
+
+ if (showOpenragRefreshCue) {
+ if (isCloudBrand) {
+ return (
+ <div className="inline-flex items-center gap-2 text-primary">
+ <RefreshCw className="h-4 w-4 animate-spin" />
+ <span className="text-sm font-medium">Refreshing</span>
+ </div>
+ );
+ }
+ return (
+ <div className="inline-flex items-center justify-center h-5 w-5">
+ <RefreshCw
+ className="h-4 w-4 text-primary animate-spin"
+ aria-label="OpenRAG doc is refreshing"
+ />
+ </div>
+ );
+ }
+
+ if (status === "failed") {
+ const button = (
+ <button
+ type="button"
+ className={cn(
+ "inline-flex items-center h-full transition",
+ isCloudBrand
+ ? "text-destructive hover:opacity-80"
+ : "w-full text-red-500 hover:text-red-400",
+ )}
+ aria-label={
+ data?.error
+ ? `View ingestion error: ${data.error}`
+ : "View ingestion error"
+ }
+ data-testid="failed-status-cell-trigger"
+ onClick={() => {
+ selectTask(getTaskIdForRow(data));
+ openTaskMenu();
+ setRecentTasksExpanded(true);
+ }}
+ >
+ <StatusBadge status={status} className="pointer-events-none" />
+ </button>
+ );
+
+ if (!data?.error) {
+ return button;
+ }
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>{button}</TooltipTrigger>
+ <TooltipContent
+ side="top"
+ align="end"
+ className="max-w-80 whitespace-pre-wrap break-words"
+ >
+ {data.error}
+ </TooltipContent>
+ </Tooltip>
+ );
+ }
+
+ if (status === "cancelled") {
+ return <StatusBadge status="cancelled" />;
+ }
+
+ if (isSkippedStatus(rawStatus, data?.skip_reason)) {
+ return <SkippedStatusCell warning={data?.warning} />;
+ }
+
+ return (
+ <StatusBadge
+ status={status as import("@/components/ui/status-badge").Status}
+ />
+ );
+}
+
+export function resolveActionsVariant(
+ status: string,
+ taskId: string | null | undefined,
+ filePath: string,
+): "cancel" | "dropdown" | null {
+ if (status === "processing") {
+ if (!taskId || !filePath) return null;
+ return "cancel";
+ }
+ if (status !== "active") return null;
+ return "dropdown";
+}
+
function SearchPage() {
const isCloudBrand = useIsCloudBrand();
+ const [isNarrow, setIsNarrow] = useState(false);
+ useEffect(() => {
+ const mq = window.matchMedia("(max-width: 640px)");
+ setIsNarrow(mq.matches);
+ const handler = (e: MediaQueryListEvent) => setIsNarrow(e.matches);
+ mq.addEventListener("change", handler);
+ return () => mq.removeEventListener("change", handler);
+ }, []);
const queryClient = useQueryClient();
const router = useRouter();
const {
@@ -528,10 +702,6 @@ function SearchPage() {
[effectiveData],
);
- const getOwnerLabel = useCallback((file?: File): string => {
- return file?.owner_name?.trim() || file?.owner_email?.trim() || "—";
- }, []);
-
const hasOpenragRefreshCueFromTasks = tasks.some((task) => {
const isTaskActive =
task.status === "pending" ||
@@ -652,12 +822,13 @@ function SearchPage() {
);
}, [gridRowsSelectionKey, isDeletableKnowledgeRow, getGridApi]);
- const columnDefs: ColDef<File>[] = [
- {
+ // ── Shared column fragments ──────────────────────────────────────────────
+ const colSource: ColDef<File> = useMemo(
+ () => ({
field: "filename",
headerName: "Source",
sortable: true,
- comparator: () => 0,
+ comparator: serverSideComparator,
checkboxSelection: (params: CheckboxSelectionCallbackParams<File>) =>
isDeletableKnowledgeRow(params?.data),
headerCheckboxSelection: true,
@@ -715,235 +886,151 @@ function SearchPage() {
</div>
);
},
- },
- {
- field: "size",
- headerName: "Size",
- ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),
- sortable: true,
- comparator: () => 0,
- valueFormatter: (params: ValueFormatterParams<File>) =>
- params.value ? formatFileSize(params.value) : "-",
- cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
- },
- {
- field: "mimetype",
- headerName: "Type",
- ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),
- cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
- sortable: true,
- },
- {
- field: "owner",
- headerName: "Owner",
- ...(isCloudBrand ? { flex: 1.4, minWidth: 180 } : {}),
- valueFormatter: (params: ValueFormatterParams<File>) =>
- params.data?.owner_name || params.data?.owner_email || "—",
- cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
- sortable: true,
- valueGetter: (params: ValueGetterParams<File>) =>
- getOwnerLabel(params.data),
- comparator: () => 0,
- },
- {
- field: "chunkCount",
- headerName: "Chunks",
- ...(isCloudBrand ? { flex: 0.9, minWidth: 95 } : {}),
- sortable: true,
- comparator: () => 0,
- valueFormatter: (params: ValueFormatterParams<File>) =>
- params.data?.chunkCount?.toString() || "-",
- cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
- },
- {
- field: "avgScore",
- headerName: "Avg score",
- ...(isCloudBrand ? { flex: 1, minWidth: 120 } : {}),
- sortable: true,
- comparator: (valueA?: number, valueB?: number) =>
- (valueA || 0) - (valueB || 0),
- cellRenderer: ({ value }: CustomCellRendererProps<File>) => {
- if (isCloudBrand) {
- return (
- <span className="text-muted-foreground">
- {typeof value === "number" ? value.toFixed(2) : "-"}
- </span>
- );
- }
- return (
- <span className="text-xs text-accent-emerald-foreground bg-accent-emerald px-2 py-1 rounded">
- {value?.toFixed(2) ?? "-"}
- </span>
- );
- },
- },
- {
- field: "embedding_model",
- headerName: "Embedding model",
- ...(isCloudBrand ? { flex: 1.4 } : {}),
- sortable: true,
- minWidth: 200,
- cellRenderer: ({ data }: CustomCellRendererProps<File>) => (
- <span className="text-xs text-muted-foreground">
- {data?.embedding_model || "—"}
- </span>
- ),
- },
- {
- field: "embedding_dimensions",
- headerName: "Dimensions",
- ...(isCloudBrand ? { flex: 0.9, minWidth: 110 } : { width: 110 }),
- sortable: true,
- comparator: () => 0,
- cellRenderer: ({ data }: CustomCellRendererProps<File>) => (
- <span className="text-xs text-muted-foreground">
- {typeof data?.embedding_dimensions === "number"
- ? data.embedding_dimensions.toString()
- : "—"}
- </span>
- ),
- },
- {
- field: "status",
- headerName: "Status",
- ...(isCloudBrand ? { flex: 1, minWidth: 130 } : {}),
- sortable: true,
- valueGetter: (params: ValueGetterParams<File>) =>
- params.data?.status || "active",
- comparator: (valueA?: File["status"], valueB?: File["status"]) =>
- getStatusSortRank(valueA) - getStatusSortRank(valueB),
- cellRenderer: ({ data }: CustomCellRendererProps<File>) => {
- const rawStatus = data?.status || "active";
- // Use centralized cancellation detection
- const status =
- rawStatus === "failed" && data && isFileCancelled(data)
- ? "cancelled"
- : rawStatus;
- const showOpenragRefreshCue =
- isOpenragDocsRow(data) && hasOpenragRefreshCue;
+ }),
+ [
+ isCloudBrand,
+ isDeletableKnowledgeRow,
+ isOpenragDocsRow,
+ hasOpenragRefreshCue,
+ effectiveSearchText,
+ router,
+ ],
+ );
- if (showOpenragRefreshCue) {
- if (isCloudBrand) {
- return (
- <div className="inline-flex items-center gap-2 text-primary">
- <RefreshCw className="h-4 w-4 animate-spin" />
- <span className="text-sm font-medium">Refreshing</span>
- </div>
- );
- }
- return (
- <div className="inline-flex items-center justify-center h-5 w-5">
- <RefreshCw
- className="h-4 w-4 text-primary animate-spin"
- aria-label="OpenRAG doc is refreshing"
- />
- </div>
- );
- }
+ const colSize: ColDef<File> = {
+ field: "size",
+ headerName: "Size",
+ ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),
+ sortable: true,
+ comparator: serverSideComparator,
+ valueFormatter: (params: ValueFormatterParams<File>) =>
+ formatSizeLabel(params.value),
+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
+ };
- if (status === "failed") {
- const button = (
- <button
- type="button"
- className={cn(
- "inline-flex items-center h-full transition",
- isCloudBrand
- ? "text-destructive hover:opacity-80"
- : "w-full text-red-500 hover:text-red-400",
- )}
- aria-label={
- data?.error
- ? `View ingestion error: ${data.error}`
- : "View ingestion error"
- }
- data-testid="failed-status-cell-trigger"
- onClick={() => {
- selectTask(getTaskIdForRow(data));
- openTaskMenu();
- setRecentTasksExpanded(true);
- }}
- >
- <StatusBadge status={status} className="pointer-events-none" />
- </button>
- );
-
- if (!data?.error) {
- return button;
- }
-
- return (
- <Tooltip>
- <TooltipTrigger asChild>{button}</TooltipTrigger>
- <TooltipContent
- side="top"
- align="end"
- className="max-w-80 whitespace-pre-wrap break-words"
- >
- {data.error}
- </TooltipContent>
- </Tooltip>
- );
- }
+ const colType: ColDef<File> = {
+ field: "mimetype",
+ headerName: "Type",
+ ...(isCloudBrand ? { flex: 1, minWidth: 110 } : {}),
+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
+ sortable: true,
+ };
- if (status === "cancelled") {
- return <StatusBadge status="cancelled" />;
- }
+ const colOwner: ColDef<File> = {
+ field: "owner",
+ headerName: "Owner",
+ ...(isCloudBrand ? { flex: 1.4, minWidth: 180 } : {}),
+ valueFormatter: (params: ValueFormatterParams<File>) =>
+ getOwnerLabel(params.data),
+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
+ sortable: true,
+ valueGetter: (params: ValueGetterParams<File>) =>
+ getOwnerLabel(params.data),
+ comparator: serverSideComparator,
+ };
- if (isSkippedStatus(rawStatus, data?.skip_reason)) {
- return <SkippedStatusCell warning={data?.warning} />;
- }
+ const colChunks: ColDef<File> = {
+ field: "chunkCount",
+ headerName: "Chunks",
+ ...(isCloudBrand ? { flex: 0.9, minWidth: 95 } : { width: 95 }),
+ sortable: true,
+ comparator: serverSideComparator,
+ headerClass: "ag-center-header",
+ cellStyle: { textAlign: "center" },
+ cellClass: isCloudBrand ? "text-muted-foreground" : undefined,
+ valueFormatter: (params: ValueFormatterParams<File>) =>
+ formatChunkCountLabel(params.data?.chunkCount),
+ };
+
+ const colAvgScore: ColDef<File> = {
+ field: "avgScore",
+ headerName: "Avg score",
+ hide: isWildcardQuery,
+ ...(isCloudBrand ? { flex: 1, minWidth: 120 } : { width: 120 }),
+ sortable: true,
+ comparator: compareAvgScore,
+ cellRenderer: ({ value }: CustomCellRendererProps<File>) => (
+ <AvgScoreCellContent value={value} />
+ ),
+ };
+
+ const colStatus: ColDef<File> = {
+ field: "status",
+ headerName: "Status",
+ ...(isCloudBrand ? { flex: 1, minWidth: 130 } : { width: 130 }),
+ sortable: true,
+ valueGetter: (params: ValueGetterParams<File>) =>
+ getFileStatus(params.data?.status),
+ comparator: compareStatusRank,
+ cellRenderer: ({ data }: CustomCellRendererProps<File>) => (
+ <StatusCellContent
+ data={data}
+ isCloudBrand={isCloudBrand}
+ isOpenragDocsRow={isOpenragDocsRow}
+ hasOpenragRefreshCue={hasOpenragRefreshCue}
+ selectTask={selectTask}
+ getTaskIdForRow={getTaskIdForRow}
+ openTaskMenu={openTaskMenu}
+ setRecentTasksExpanded={setRecentTasksExpanded}
+ />
+ ),
+ };
+ const colActions: ColDef<File> = {
+ colId: "actions",
+ headerName: "",
+ width: 56,
+ minWidth: 56,
+ ...(isCloudBrand ? { maxWidth: 56 } : { initialFlex: 0 }),
+ sortable: false,
+ filter: false,
+ resizable: false,
+ suppressMovable: true,
+ cellRenderer: ({ data }: CustomCellRendererProps<File>) => {
+ const status = getFileStatus(data?.status);
+ const taskId = getTaskIdForRow(data);
+ const filePath = data?.source_url || data?.filename || "";
+ const variant = resolveActionsVariant(status, taskId, filePath);
+ if (variant === "cancel" && data && taskId) {
return (
- <StatusBadge
- status={status as import("@/components/ui/status-badge").Status}
+ <CancelIngestionButton
+ taskId={taskId}
+ filePath={filePath}
+ onCancel={cancelFile}
/>
);
- },
- },
- {
- colId: "actions",
- headerName: "",
- width: 56,
- minWidth: 56,
- ...(isCloudBrand ? { maxWidth: 56 } : { initialFlex: 0 }),
- sortable: false,
- filter: false,
- resizable: false,
- suppressMovable: true,
- cellRenderer: ({ data }: CustomCellRendererProps<File>) => {
- const status = data?.status || "active";
- if (status === "processing") {
- const taskId = getTaskIdForRow(data);
- if (!taskId || !data) return null;
-
- // Get file path for this row - use source_url or filename
- const filePath = data.source_url || data.filename || "";
- if (!filePath) return null;
-
- return (
- <CancelIngestionButton
- taskId={taskId}
- filePath={filePath}
- onCancel={cancelFile}
- />
- );
- }
- if (status !== "active") return null;
+ }
+ if (variant === "dropdown") {
return (
<KnowledgeActionsDropdown
filename={data?.filename || ""}
connectorType={data?.connector_type}
/>
);
- },
- cellStyle: {
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- padding: 0,
- },
+ }
+ return null;
+ },
+ cellStyle: {
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ padding: 0,
},
- ];
+ };
+
+ // ── Layout-aware column sets ─────────────────────────────────────────────
+ const columnDefs: ColDef<File>[] = isNarrow
+ ? [colSource, colChunks, colAvgScore, colStatus, colActions]
+ : [
+ colSource,
+ colSize,
+ colType,
+ colOwner,
+ colChunks,
+ colAvgScore,
+ colStatus,
+ colActions,
+ ];
const defaultColDef: ColDef<File> = {
resizable: false,
@@ -1059,8 +1146,14 @@ function SearchPage() {
isCloudBrand && "ibm-section-title",
)}
>
- Project knowledge
+ Project Knowledge
</h2>
+ {!isCloudBrand && isNarrow && (
+ <KnowledgeSearchInput
+ placeholder="Search..."
+ className="max-w-[180px]"
+ />
+ )}
</div>
{isCloudBrand ? (
<div className="relative overflow-hidden h-12 shrink-0">
@@ -1095,7 +1188,9 @@ function SearchPage() {
) : (
/* Search Input Area */
<div className="flex items-center flex-shrink-0 flex-wrap-reverse gap-3 mb-6">
- <KnowledgeSearchInput />
+ {!isNarrow && (
+ <KnowledgeSearchInput placeholder="Search your documents..." />
+ )}
<Button
type="button"
diff --git a/frontend/components/AgGrid/agGridStyles.css b/frontend/components/AgGrid/agGridStyles.css
index b5d8b0775..fd4dcaff0 100644
--- a/frontend/components/AgGrid/agGridStyles.css
+++ b/frontend/components/AgGrid/agGridStyles.css
@@ -1,3 +1,7 @@
+.ag-center-header .ag-header-cell-label {
+ justify-content: center;
+}
+
body {
--ag-text-color: hsl(var(--muted-foreground));
--ag-background-color: hsl(var(--background));
diff --git a/frontend/components/knowledge-search-input.tsx b/frontend/components/knowledge-search-input.tsx
index f7972ba55..46a38f5e8 100644
--- a/frontend/components/knowledge-search-input.tsx
+++ b/frontend/components/knowledge-search-input.tsx
@@ -33,7 +33,7 @@ export function KnowledgeSearchInput({
value,
onSearch,
onClear,
- placeholder = "Search your documents...",
+ placeholder,
hideFilterChip = false,
hideSubmit = false,
className,
@@ -125,7 +125,7 @@ export function KnowledgeSearchInput({
name="search-query"
id="search-query"
type="text"
- placeholder={placeholder}
+ placeholder={placeholder ?? "Search your documents..."}
value={inputValue}
onChange={(e: ChangeEvent<HTMLInputElement>) => {
const next = e.target.value;
diff --git a/frontend/lib/greeting.ts b/frontend/lib/greeting.ts
index eed6df291..a90e220bc 100644
--- a/frontend/lib/greeting.ts
+++ b/frontend/lib/greeting.ts
@@ -16,10 +16,10 @@ function getTimeSlot(hour: number): TimeSlot {
const GREETING_MESSAGES: Record<TimeSlot, string[]> = {
morning: [
"Good morning{name}! How can I assist you today?",
- "Morning{name}! How can I help?",
+ "Good morning{name}! How can I help?",
"Good morning{name}! What can I help you with?",
"Good morning{name}! How may I help you today?",
- "Morning{name}! What are we working on today?",
+ "Good morning{name}! What are we working on today?",
],
afternoon: [
"Good afternoon{name}! How can I assist?",
@@ -30,7 +30,7 @@ const GREETING_MESSAGES: Record<TimeSlot, string[]> = {
],
evening: [
"Good evening{name}! How can I assist?",
- "Evening{name}! How can I help you?",
+ "Good evening{name}! How can I help you?",
"Good evening{name}! What can I do for you?",
"Good evening{name}! How may I assist you?",
"Evening{name}! What are we working on tonight?",