🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(events): show "select all across pages" banner on v4 events table (LFE-10733) (#14859)
Nikita Kabardin9f5a5c443e66
diff --git a/web/src/components/table/data-table-toolbar.clienttest.tsx b/web/src/components/table/data-table-toolbar.clienttest.tsxnew file mode 100644index 0000000000..ea298955ec--- /dev/null+++ b/web/src/components/table/data-table-toolbar.clienttest.tsx@@ -0,0 +1,182 @@+import { fireEvent, render, screen } from "@testing-library/react";+import { vi } from "vitest";+import {+ DataTableToolbar,+ type MultiSelect,+} from "@/src/components/table/data-table-toolbar";++const baseMultiSelect = (overrides: Partial<MultiSelect>): MultiSelect => ({+ selectAll: false,+ setSelectAll: vi.fn(),+ selectedRowIds: [],+ setRowSelection: vi.fn(),+ pageSize: 50,+ pageIndex: 0,+ totalCount: null,+ ...overrides,+});++const selectedIds = (count: number) =>+ Array.from({ length: count }, (_, i) => `row-${i}`);++describe("DataTableToolbar select-all banner gate", () => {+ describe("exact-count tables (v3)", () => {+ it("shows the exact-count banner when the full first page is selected", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: 500,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(+ screen.getByRole("button", {+ name: "Select all 500 items across 10 pages",+ }),+ ).toBeInTheDocument();+ });++ it("shows no banner while the count is unknown and no more-pages signal is provided", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: null,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(+ screen.queryByText(/items on this page are selected/),+ ).not.toBeInTheDocument();+ });++ it("shows no banner when all rows fit on one page", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: 30,+ selectedRowIds: selectedIds(30),+ })}+ />,+ );++ expect(+ screen.queryByText(/items on this page are selected/),+ ).not.toBeInTheDocument();+ });+ });++ describe("count-unknown tables with a more-pages signal (v4 events)", () => {+ it("shows the banner and flips select-all when the full first page is selected", () => {+ const setSelectAll = vi.fn();+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: null,+ hasNextPage: true,+ selectedRowIds: selectedIds(50),+ setSelectAll,+ })}+ />,+ );++ const selectAllButton = screen.getByRole("button", {+ name: "Select all matching items",+ });+ fireEvent.click(selectAllButton);+ expect(setSelectAll).toHaveBeenCalledWith(true);+ });++ it("keeps the banner visible while the lazy count is loading after select-all", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ selectAll: true,+ totalCount: null,+ hasNextPage: true,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(screen.getByText(/items are selected/)).toBeInTheDocument();+ });++ it("shows the exact count once the lazy count resolves after select-all", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ selectAll: true,+ totalCount: 823,+ hasNextPage: true,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(screen.getByText("823")).toBeInTheDocument();+ expect(screen.getByText(/items are selected/)).toBeInTheDocument();+ });++ it("shows no banner on the last page (no more matching rows)", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: null,+ hasNextPage: false,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(+ screen.queryByText(/items on this page are selected/),+ ).not.toBeInTheDocument();+ });++ it("shows no banner when the page is only partially selected", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: null,+ hasNextPage: true,+ selectedRowIds: selectedIds(10),+ })}+ />,+ );++ expect(+ screen.queryByText(/items on this page are selected/),+ ).not.toBeInTheDocument();+ });++ it("shows no banner beyond the first page", () => {+ render(+ <DataTableToolbar+ columns={[]}+ multiSelect={baseMultiSelect({+ totalCount: null,+ hasNextPage: true,+ pageIndex: 1,+ selectedRowIds: selectedIds(50),+ })}+ />,+ );++ expect(+ screen.queryByText(/items on this page are selected/),+ ).not.toBeInTheDocument();+ });+ });+});diff --git a/web/src/components/table/data-table-toolbar.tsx b/web/src/components/table/data-table-toolbar.tsxindex c46ad5bee0..79e43d395e 100644--- a/web/src/components/table/data-table-toolbar.tsx+++ b/web/src/components/table/data-table-toolbar.tsx@@ -66,6 +66,10 @@ export interface MultiSelect {pageSize: number;pageIndex: number;totalCount: number | null;+ // Tables that only compute totalCount lazily (e.g. v4 events, where counting+ // is expensive and runs once select-all is active) pass this keyset-pagination+ // signal instead, so the select-all banner can show while the count is unknown.+ hasNextPage?: boolean;// When the displayed row count does not equal the number of affected entities// (e.g. datasets where a folder row expands to many datasets on delete), the// select-all banner drops the precise number and says "matching" instead.@@ -224,12 +228,14 @@ export function DataTableToolbar<TData, TValue>({);const allVisibleRowsSelected = Boolean(multiSelect &&- multiSelect.totalCount !== null &&- multiSelect.totalCount > multiSelect.pageSize &&multiSelect.pageIndex === 0 &&multiSelect.selectedRowIds.length > 0 &&- multiSelect.selectedRowIds.length ===- Math.min(multiSelect.pageSize, multiSelect.totalCount),+ (multiSelect.totalCount !== null+ ? multiSelect.totalCount > multiSelect.pageSize &&+ multiSelect.selectedRowIds.length ===+ Math.min(multiSelect.pageSize, multiSelect.totalCount)+ : multiSelect.hasNextPage === true &&+ multiSelect.selectedRowIds.length === multiSelect.pageSize),);const submitSearch = (query: string) => {diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsxindex d2d2e51326..5eda820220 100644--- a/web/src/features/events/components/EventsTable.tsx+++ b/web/src/features/events/components/EventsTable.tsx@@ -1709,6 +1709,10 @@ export default function ObservationsEventsTable({selectedRowIds: selectedObservationIds,setRowSelection: setSelectedRows,totalCount,+ // totalCount stays null until select-all triggers the lazy+ // count query; hasNextPage lets the select-all banner show+ // without an eager count over the events table.+ hasNextPage: hasMore,pageSize: paginationState.limit,pageIndex: paginationState.page - 1,}}