🪢 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(datatable): allow filtering by empty string in stringOptions filter (#11189)
Michael Fröhlichc4446c87ff31
diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsxindex f533b685a8..95f86be146 100644--- a/web/src/components/table/data-table-controls.tsx+++ b/web/src/components/table/data-table-controls.tsx@@ -1190,6 +1190,10 @@ export function FilterValueCheckbox({// Show "All" when clicking would reverse selection (only one item selected)const labelText = checked && totalSelected === 1 ? "All" : "Only";+ // Display placeholder for empty strings to ensure clickable area+ const displayLabel = label === "" ? "(empty)" : label;+ const displayTitle = label === "" ? "(empty)" : label;+return (<divclassName={cn(@@ -1216,8 +1220,14 @@ export function FilterValueCheckbox({)}onClick={onLabelClick}>- <span className="min-w-0 flex-1 truncate text-xs" title={label}>- {label}+ <span+ className={cn(+ "min-w-0 flex-1 truncate text-xs",+ label === "" && "italic text-muted-foreground",+ )}+ title={displayTitle}+ >+ {displayLabel}</span>{/* "Only" or "All" indicator when hovering label */}diff --git a/web/src/features/filters/components/multi-select.tsx b/web/src/features/filters/components/multi-select.tsxindex 42c2b4dd5a..233dd82ea8 100644--- a/web/src/features/filters/components/multi-select.tsx+++ b/web/src/features/filters/components/multi-select.tsx@@ -155,15 +155,23 @@ export function MultiSelect({{selectedValues.size} selected</Badge>) : (- getSelectedOptions().map((option) => (- <Badge- variant="secondary"- key={option.value}- className="rounded-sm px-1 font-normal"- >- {option.displayValue ?? option.value}- </Badge>- ))+ getSelectedOptions().map((option) => {+ const displayValue =+ option.displayValue ??+ (option.value === "" ? "(empty)" : option.value);+ return (+ <Badge+ variant="secondary"+ key={option.value}+ className={cn(+ "rounded-sm px-1 font-normal",+ option.value === "" && "italic",+ )}+ >+ {displayValue}+ </Badge>+ );+ }))}</div></>@@ -202,6 +210,13 @@ export function MultiSelect({{options.map((option) => {if (option.value.length === 0) return;const isSelected = selectedValues.has(option.value);+ const displayValue =+ option.displayValue ??+ (option.value === "" ? "(empty)" : option.value);+ const displayTitle =+ option.displayValue ??+ (option.value === "" ? "(empty)" : option.value);+const commandItem = (<InputCommandItemkey={option.value}@@ -226,10 +241,13 @@ export function MultiSelect({<Check className={cn("h-4 w-4")} /></div><div- className="overflow-x-hidden text-ellipsis whitespace-nowrap"- title={option.displayValue ?? option.value}+ className={cn(+ "overflow-x-hidden text-ellipsis whitespace-nowrap",+ option.value === "" && "italic text-muted-foreground",+ )}+ title={displayTitle}>- {option.displayValue ?? option.value}+ {displayValue}</div>{option.count !== undefined ? (<span className="ml-auto flex h-4 w-4 items-center justify-center pl-1 font-mono text-xs">@@ -242,7 +260,7 @@ export function MultiSelect({return option.description ? (<PropertyHoverCardkey={option.value}- label={option.displayValue ?? option.value}+ label={displayValue}description={option.description}>{commandItem}diff --git a/web/src/features/filters/lib/filter-query-encoding-decoding.clienttest.ts b/web/src/features/filters/lib/filter-query-encoding-decoding.clienttest.tsindex 852775cbd9..ea7edc5b81 100644--- a/web/src/features/filters/lib/filter-query-encoding-decoding.clienttest.ts+++ b/web/src/features/filters/lib/filter-query-encoding-decoding.clienttest.ts@@ -367,6 +367,19 @@ describe("Filter Query Encoding & Decoding (Legacy Format)", () => {},]);});++ it("should decode stringOptions with empty string value", () => {+ // This URL is generated when filtering for empty trace names (clicking "Only" on empty name)+ const result = decodeFilters("name;stringOptions;;any of;");+ expect(result).toEqual([+ {+ column: "name",+ type: "stringOptions",+ operator: "any of",+ value: [""],+ },+ ]);+ });});describe("Round-trip consistency", () => {@@ -426,6 +439,23 @@ describe("Filter Query Encoding & Decoding (Legacy Format)", () => {expect(deserialized).toEqual(exclusiveFilters);});+ it("should maintain consistency for stringOptions with empty string value", () => {+ // This tests filtering by empty trace names (e.g., clicking "Only" on an empty name)+ const filterWithEmptyString: FilterState = [+ {+ column: "name",+ type: "stringOptions",+ operator: "any of",+ value: [""],+ },+ ];++ const serialized = encodeFilters(filterWithEmptyString);+ const deserialized = decodeFilters(serialized);++ expect(deserialized).toEqual(filterWithEmptyString);+ });+it("should maintain consistency for mixed filter types", () => {const mixedFilters: FilterState = [{diff --git a/web/src/features/filters/lib/filter-query-encoding.ts b/web/src/features/filters/lib/filter-query-encoding.tsindex 3dd72a3dbd..5433d59255 100644--- a/web/src/features/filters/lib/filter-query-encoding.ts+++ b/web/src/features/filters/lib/filter-query-encoding.ts@@ -102,7 +102,11 @@ export function decodeFiltersGeneric(query: string): FilterState {type === "arrayOptions" ||type === "categoryOptions") {- parsedValue = decodedValue ? decodedValue.split("|") : [];+ parsedValue = decodedValue+ ? decodedValue.split("|")+ : decodedValue === ""+ ? [""] // allow empty strings (i.e, filter for empty trace name)+ : [decodedValue];} else if (type === "boolean") {parsedValue = decodedValue === "true";} else {