Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(filters): block filter-sidebar facets unavailable in chart view (LFE-11040) (#15203)

Nikita Kabardin1cb1bbcf6b26
diff --git a/web/src/components/table/data-table-controls.clienttest.tsx b/web/src/components/table/data-table-controls.clienttest.tsx
index bb84ea70eb..5da56c31d3 100644
--- a/web/src/components/table/data-table-controls.clienttest.tsx
+++ b/web/src/components/table/data-table-controls.clienttest.tsx
@@ -599,3 +599,121 @@ describe("DataTableControls facet ordering", () => {
expect(screen.getByText("All")).toBeInTheDocument();
});
});
+
+describe("DataTableControls blocked facets (LFE-11040)", () => {
+ const categoricalFilter = (
+ column: string,
+ label: string,
+ isActive: boolean,
+ ): CategoricalUIFilter => ({
+ type: "categorical",
+ column,
+ label,
+ loading: false,
+ expanded: false,
+ isActive,
+ isDisabled: false,
+ onReset: () => {},
+ value: isActive ? ["x"] : [],
+ options: ["x", "y"],
+ counts: new Map(),
+ onChange: () => {},
+ });
+
+ const queryFilter = (
+ filters: UIFilter[],
+ expanded: string[] = [],
+ ): QueryFilter => ({
+ filters,
+ expanded,
+ onExpandedChange: () => {},
+ clearAll: () => {},
+ isFiltered: filters.some((f) => f.isActive),
+ setFilterState: () => {},
+ });
+
+ const REASON = "Charts can't filter by this field at the moment.";
+
+ it("blocks an INACTIVE facet whose column the surface can't honour, while leaving a forwardable one live", () => {
+ // The core of LFE-11040: previously only an ACTIVE filter deactivated, so
+ // an empty facet on an unavailable column stayed usable. Now a column the
+ // surface can't honour blocks regardless of whether it holds a value.
+ const { container } = render(
+ <TooltipProvider>
+ <DataTableControls
+ queryFilter={queryFilter(
+ [
+ categoricalFilter("blocked", "Blocked", false),
+ categoricalFilter("forwardable", "Forwardable", false),
+ ],
+ // Expand both so each facet's fieldset is mounted and observable.
+ ["blocked", "forwardable"],
+ )}
+ blockedColumnReason={(column) =>
+ column === "blocked" ? REASON : null
+ }
+ />
+ </TooltipProvider>,
+ );
+
+ // The inactive-but-blocked facet's inputs are disabled (fieldset) even
+ // though it carries no value…
+ expect(
+ container.querySelector('[data-facet-column="blocked"] fieldset'),
+ ).toBeDisabled();
+ // …and its header reads blocked (dimmed + not-allowed cursor).
+ expect(screen.getByRole("button", { name: /Blocked/ }).className).toContain(
+ "cursor-not-allowed",
+ );
+
+ // A forwardable inactive facet (resolver returns null) stays interactive.
+ expect(
+ container.querySelector('[data-facet-column="forwardable"] fieldset'),
+ ).not.toBeDisabled();
+ expect(
+ screen.getByRole("button", { name: /Forwardable/ }).className,
+ ).not.toContain("cursor-not-allowed");
+ });
+
+ it("makes a blocked column non-addable in the Add-filter picker, carrying the reason as its title", () => {
+ // Active-only mode surfaces the rest of the catalog behind "Add filter".
+ localStorage.setItem("data-table-controls-active-only", "true");
+ try {
+ render(
+ <TooltipProvider>
+ <DataTableControls
+ queryFilter={queryFilter([
+ // One active facet so active-only mode has something to show
+ // and the picker (addable = the inactive rest) renders.
+ categoricalFilter("active", "Active", true),
+ categoricalFilter("blocked", "Blocked", false),
+ categoricalFilter("forwardable", "Forwardable", false),
+ ])}
+ blockedColumnReason={(column) =>
+ column === "blocked" ? REASON : null
+ }
+ />
+ </TooltipProvider>,
+ );
+
+ // Open the Add-filter dropdown. Radix opens the menu on the trigger's
+ // pointer-down, which jsdom doesn't synthesize reliably; the keyboard
+ // path (Enter) opens it without depending on PointerEvent support.
+ const addButton = screen.getByRole("button", { name: /Add filter/ });
+ fireEvent.keyDown(addButton, { key: "Enter" });
+
+ const blockedItem = screen.getByRole("menuitem", { name: "Blocked" });
+ const forwardableItem = screen.getByRole("menuitem", {
+ name: "Forwardable",
+ });
+ // Blocked column stays visible but is disabled, with the reason on hover.
+ expect(blockedItem).toHaveAttribute("aria-disabled", "true");
+ expect(blockedItem).toHaveAttribute("title", REASON);
+ // Forwardable column is addable as usual.
+ expect(forwardableItem).not.toHaveAttribute("aria-disabled", "true");
+ expect(forwardableItem).not.toHaveAttribute("title");
+ } finally {
+ localStorage.removeItem("data-table-controls-active-only");
+ }
+ });
+});
diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsx
index 14009ea115..4e33ddad6d 100644
--- a/web/src/components/table/data-table-controls.tsx
+++ b/web/src/components/table/data-table-controls.tsx
@@ -152,12 +152,14 @@ interface DataTableControlsProps {
queryFilter: QueryFilter;
filterWithAI?: boolean;
/**
- * Given a filter column, the reason an active filter on it is NOT applied on
- * the current surface (e.g. the chart view can't filter on it), or null. When
- * it returns a reason, that active facet renders deactivated (dimmed + the
- * reason on hover); Clearing still works. Undefined leaves every filter live.
+ * Given a filter column, the reason a filter on it is blocked on the current
+ * surface (active or not) — e.g. the chart view can't filter on it (#15187 /
+ * #15049), and later an OR/bracket a surface can't honour — or null. When it
+ * returns a reason, that facet renders blocked (dimmed + the reason on hover)
+ * whether or not it holds a value; Clearing still works. Undefined leaves
+ * every filter live.
*/
- deactivatedColumnReason?: (column: string) => string | null;
+ blockedColumnReason?: (column: string) => string | null;
}
// Module-stable initial value: a fresh {} per render would re-subscribe
@@ -167,7 +169,7 @@ const EMPTY_RECENCY: Record<string, number> = {};
export function DataTableControls({
queryFilter,
filterWithAI,
- deactivatedColumnReason,
+ blockedColumnReason,
}: DataTableControlsProps) {
const { isLangfuseCloud } = useLangfuseCloudRegion();
const { setOpen, tableName } = useDataTableControls();
@@ -339,15 +341,16 @@ export function DataTableControls({
const promotedFacetCount = displayedFilters.filter(isPromoted).length;
const renderFacet = (filter: UIFilter) => {
- // "Not applied on this surface" (e.g. the chart can't filter on this
- // column — #15187). Only an ACTIVE filter deactivates — an empty facet
- // stays usable. Overrides isDisabled/disabledReason so the facet dims
- // and explains on hover while Clear still works.
- const deactivatedReason = filter.isActive
- ? (deactivatedColumnReason?.(filter.column) ?? null)
- : null;
- const facetDisabled = filter.isDisabled || deactivatedReason !== null;
- const facetDisabledReason = deactivatedReason ?? filter.disabledReason;
+ // A column the current surface can't honour blocks the facet whether or
+ // not it holds a value: the chart view can't filter on it (#15187 /
+ // #15049), and later an OR/bracket a surface can't apply. (An empty facet
+ // used to stay usable; blocking it regardless is the point of LFE-11040 —
+ // adding a value it can't honour would only mislead.) Overrides
+ // isDisabled/disabledReason so the facet dims and explains on hover while
+ // Clear still works.
+ const blockedReason = blockedColumnReason?.(filter.column) ?? null;
+ const facetDisabled = filter.isDisabled || blockedReason !== null;
+ const facetDisabledReason = blockedReason ?? filter.disabledReason;
if (filter.type === "categorical") {
const summaryValue = getFacetSummaryValue(filter);
return (
@@ -837,15 +840,25 @@ export function DataTableControls({
align="start"
className="max-h-72 w-56 overflow-y-auto"
>
- {addableFilters.map((filter) => (
- <DropdownMenuItem
- key={filter.column}
- onClick={() => handleAddFilter(filter.column)}
- className="cursor-pointer"
- >
- {filter.label}
- </DropdownMenuItem>
- ))}
+ {addableFilters.map((filter) => {
+ // A column the surface can't honour stays visible but is
+ // not addable — adding it would only land a facet that
+ // immediately reads blocked (chart view — #15187 /
+ // #15049). Same reason on hover.
+ const reason =
+ blockedColumnReason?.(filter.column) ?? null;
+ return (
+ <DropdownMenuItem
+ key={filter.column}
+ disabled={!!reason}
+ title={reason ?? undefined}
+ onClick={() => handleAddFilter(filter.column)}
+ className="cursor-pointer"
+ >
+ {filter.label}
+ </DropdownMenuItem>
+ );
+ })}
</DropdownMenuContent>
</DropdownMenu>
</div>
diff --git a/web/src/features/events/components/EventsTable.tsx b/web/src/features/events/components/EventsTable.tsx
index cc5bbcf106..1d604c9d38 100644
--- a/web/src/features/events/components/EventsTable.tsx
+++ b/web/src/features/events/components/EventsTable.tsx
@@ -2050,9 +2050,10 @@ export default function ObservationsEventsTable({
// In bar mode AI filtering lives in the search bar; only offer the
// sidebar wand on non-bar surfaces (embedded scoped tables).
filterWithAI={!searchBarMode}
- // In chart mode, dim active filters the chart can't apply (+ hover
- // reason). Stateless per-column resolver — matches the search bar.
- deactivatedColumnReason={
+ // In chart mode, block filters the chart can't apply — active or
+ // not — dimmed + hover reason. Stateless per-column resolver,
+ // matching the search bar.
+ blockedColumnReason={
chartActive ? chartFilterExclusionReason : undefined
}
/>