🪢 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
feat(scores): add the filter and search bar (#17289)
Nikita Kabardin77f9e4561cec
diff --git a/web/src/__tests__/server/scores-trpc.servertest.ts b/web/src/__tests__/server/scores-trpc.servertest.tsindex 6451fb9b1f..d84d87117e 100644--- a/web/src/__tests__/server/scores-trpc.servertest.ts+++ b/web/src/__tests__/server/scores-trpc.servertest.ts@@ -53,6 +53,8 @@ import {} from "@langfuse/shared/src/server";import { env } from "@/src/env.mjs";import { observationScopeFilter } from "@/src/features/filters/config/scores-config";+import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";+import { planCommit } from "@/src/features/search-bar/lib/commit";import { randomUUID } from "crypto";const maybeEvents =@@ -123,6 +125,57 @@ describe("scores trpc", () => {});describe("scores.all", () => {+ it("applies search-bar name matching and repeated numeric bounds to v4 rows and counts", async () => {+ await createScoresCh(+ [+ { name: "Rouge Score", value: 0.5 },+ { name: "Weighted Rouge Score", value: 0.7 },+ { name: "confidence", value: 0.6 },+ { name: "Rouge Score", value: 0.1 },+ { name: "confidence", value: 0.95 },+ ].map((score) =>+ createTraceScore({+ project_id: projectId,+ data_type: "NUMERIC",+ ...score,+ }),+ ),+ );++ for (const { query, names } of [+ {+ query: "Rouge Score value:>0.2 value:<0.8",+ names: ["Rouge Score", "Weighted Rouge Score"],+ },+ {+ query: 'name:("Rouge Score" OR confidence) value:>0.2 value:<0.8',+ names: ["Rouge Score", "confidence"],+ },+ ]) {+ const committed = planCommit(query, undefined, SCORES_FIELD_REGISTRY);+ expect(committed.status, query).toBe("committed");+ if (committed.status !== "committed") {+ throw new Error(`Invalid score search: ${query}`);+ }++ const payload = { projectId, filter: committed.filters };+ const [rows, count] = await Promise.all([+ caller.scores.allFromEvents({+ ...payload,+ orderBy: { column: "timestamp", order: "DESC" },+ page: 0,+ limit: 50,+ }),+ caller.scores.countAllFromEvents({ ...payload, orderBy: null }),+ ]);++ expect(rows.scores.map((score) => score.name).sort(), query).toEqual(+ names,+ );+ expect(count.totalCount, query).toBe(names.length);+ }+ });+it("returns the recorded evaluator and resolves legacy scores by rule assignment and score name", async () => {const [recordedEvaluator, matchingEvaluator, otherEvaluator] =await Promise.all(diff --git a/web/src/components/table/data-table-controls.clienttest.tsx b/web/src/components/table/data-table-controls.clienttest.tsxindex b23434606d..c702653a77 100644--- a/web/src/components/table/data-table-controls.clienttest.tsx+++ b/web/src/components/table/data-table-controls.clienttest.tsx@@ -171,6 +171,52 @@ describe("delayed sidebar edits and search-bar commits", () => {);});+describe("DataTableControls numeric conditions", () => {+ it("renders strict bounds as removable chips instead of a slider", () => {+ const queryFilter: QueryFilter = {+ filters: [+ {+ type: "numeric",+ column: "latency",+ label: "Latency",+ loading: false,+ expanded: true,+ isActive: true,+ isDisabled: false,+ onReset: () => {},+ value: null,+ conditions: [+ { column: "latency", type: "number", operator: ">", value: 10 },+ { column: "latency", type: "number", operator: "<", value: 80 },+ ],+ min: 0,+ max: 100,+ onChange: () => {},+ onRemoveCondition: () => {},+ },+ ],+ expanded: ["latency"],+ onExpandedChange: () => {},+ clearAll: () => {},+ draftResetKey: 0,+ isFiltered: true,+ setFilterState: () => {},+ };++ render(<DataTableControls queryFilter={queryFilter} />, {+ wrapper: TooltipProvider,+ });++ expect(+ screen.getByRole("button", { name: "Remove Latency > 10" }),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("button", { name: "Remove Latency < 80" }),+ ).toBeInTheDocument();+ expect(screen.queryByLabelText("Min.")).not.toBeInTheDocument();+ });+});+describe("CategoricalFacet", () => {it("uses a custom option hover title", () => {render(diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsxindex 22a986fee0..c9036c21d8 100644--- a/web/src/components/table/data-table-controls.tsx+++ b/web/src/components/table/data-table-controls.tsx@@ -83,6 +83,7 @@ import { Skeleton } from "@/src/components/ui/skeleton";import DocPopup from "@/src/components/layouts/doc-popup";import type {UIFilter,+ NumericUIFilter,KeyScoreLevels,KeyValueFilterEntry,NumericKeyValueFilterEntry,@@ -562,7 +563,7 @@ export function DataTableControls({if (filter.type === "numeric") {return (<NumericFacet- key={filter.column}+ key={`${filter.column}:${filter.value === null ? "conditions" : "range"}`}filterKey={filter.column}label={filter.label}tooltip={filter.tooltip}@@ -573,6 +574,8 @@ export function DataTableControls({min={filter.min}max={filter.max}value={filter.value}+ conditions={filter.conditions}+ onRemoveCondition={filter.onRemoveCondition}onChange={filter.onChange}unit={filter.unit}isActive={filter.isActive}@@ -1311,7 +1314,9 @@ interface CategoricalFacetProps extends BaseFacetProps {interface NumericFacetProps extends BaseFacetProps {min: number;max: number;- value: [number, number];+ value: [number, number] | null;+ conditions: NumericUIFilter["conditions"];+ onRemoveCondition: (index: number) => void;onChange: (value: [number, number]) => void;unit?: string;}@@ -2060,6 +2065,8 @@ function NumericFacet({min,max,value,+ conditions,+ onRemoveCondition,onChange,unit,isActive,@@ -2067,20 +2074,23 @@ function NumericFacet({disabledReason,onReset,}: NumericFacetProps) {- const [localValue, setLocalValue] = useState<[number, number]>(value);+ const [localValue, setLocalValue] = useState<[number, number]>(+ value ?? [min, max],+ );// Adopt external value changes (reset, URL navigation) during render — the// "adjust state when a prop changes" pattern — rather than via a mirror// effect. `lastValue` tracks the last adopted prop so pending local edits// (which lead the prop while the debounce runs) survive unrelated renders.- const [lastValue, setLastValue] = useState<[number, number]>(value);- if (lastValue[0] !== value[0] || lastValue[1] !== value[1]) {+ const [lastValue, setLastValue] = useState(value);+ if (lastValue?.[0] !== value?.[0] || lastValue?.[1] !== value?.[1]) {setLastValue(value);- setLocalValue(value);+ setLocalValue(value ?? [min, max]);}const timeoutRef = useRef<NodeJS.Timeout | null>(null);const onChangeRef = useRef(onChange);onChangeRef.current = onChange;- const [appliedMin, appliedMax] = value;+ const appliedMin = value?.[0];+ const appliedMax = value?.[1];// An external reset or replacement cancels the pending draft.useEffect(() => {@@ -2155,6 +2165,29 @@ function NumericFacet({<div className="px-4 py-2">{loading ? (<div className="text-muted-foreground text-sm">Loading...</div>+ ) : value === null ? (+ <div className="ph-no-capture flex flex-col gap-1">+ {conditions.map((condition, index) => (+ <div+ key={index}+ className="border-border/40 bg-muted/30 flex items-center gap-2 rounded border px-2 py-1 text-xs"+ >+ <span className="min-w-0 flex-1">+ {condition.operator} {condition.value}+ {unit ? ` ${unit}` : ""}+ </span>+ <Button+ size="sm"+ variant="ghost"+ aria-label={`Remove ${label} ${condition.operator} ${condition.value}`}+ onClick={() => onRemoveCondition(index)}+ className="text-muted-foreground hover:text-foreground h-5 w-5 shrink-0 p-0"+ >+ <X className="h-3 w-3" />+ </Button>+ </div>+ ))}+ </div>) : (<div className="grid gap-4"><div className="flex items-center gap-4">diff --git a/web/src/components/table/use-cases/scores.tsx b/web/src/components/table/use-cases/scores.tsxindex a8b62c5adb..c3a82d92c2 100644--- a/web/src/components/table/use-cases/scores.tsx+++ b/web/src/components/table/use-cases/scores.tsx@@ -44,6 +44,7 @@ import {import { transformFiltersForBackend } from "@/src/features/filters/lib/filter-transform";import { sortOptionValues } from "@/src/features/filters/lib/option-sort";import { isNumericDataType } from "@/src/features/scores/lib/helpers";+import { ScoresSearchBar } from "@/src/features/scores/components/ScoresSearchBar";import { getScoreChartTimeRange } from "@/src/features/scores-chart-view/fns/scoreChartConfig";import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";import { useTableDateRange } from "@/src/hooks/useTableDateRange";@@ -272,6 +273,12 @@ export default function ScoresTable({);const chartActive =chartEnabled && chartTimeRange !== undefined && chartViewMode === "chart";+ const searchBarEnabled =+ isV4 &&+ showControlsInPageHeader &&+ chartEnabled &&+ !chartActive &&+ !peekContext;// Drill-in from the outlier strip writes the clicked bucket as an absolute// range. URL-only and deliberately NOT persisted as the project's default@@ -1084,6 +1091,15 @@ export default function ScoresTable({setTimeRange={setTimeRange}/>)}+ {searchBarEnabled && (+ <ScoresSearchBar+ projectId={projectId}+ filterState={queryFilter.searchBarFilterState}+ setFilterState={setFiltersWrapper}+ filterOptions={newFilterOptions}+ isLoading={isSidebarFilterLoading}+ />+ )}{/* Toolbar spanning full width */}<DataTableToolbarcolumns={columns}diff --git a/web/src/features/filters/hooks/useSidebarFilterState.tsx b/web/src/features/filters/hooks/useSidebarFilterState.tsxindex 0d25d691f9..d7f25c2191 100644--- a/web/src/features/filters/hooks/useSidebarFilterState.tsx+++ b/web/src/features/filters/hooks/useSidebarFilterState.tsx@@ -124,28 +124,19 @@ export function decodeAndNormalizeFilters(}function computeNumericRange(- column: string,- filterState: FilterState,+ conditions: NumericUIFilter["conditions"],defaultMin: number,defaultMax: number,-): [number, number] {- const minFilter = filterState.find(- (f) => f.column === column && f.type === "number" && f.operator === ">=",- );- const maxFilter = filterState.find(- (f) => f.column === column && f.type === "number" && f.operator === "<=",- );-- const minValue =- minFilter && typeof minFilter.value === "number"- ? minFilter.value- : defaultMin;- const maxValue =- maxFilter && typeof maxFilter.value === "number"- ? maxFilter.value- : defaultMax;-- return [minValue, maxValue];+): [number, number] | null {+ if (conditions.length === 0) return [defaultMin, defaultMax];+ // The range editor writes exactly one inclusive lower and upper bound.+ // Other shapes must retain their operators and every separate condition.+ if (conditions.length !== 2) return null;+ const minFilter = conditions.find((filter) => filter.operator === ">=");+ const maxFilter = conditions.find((filter) => filter.operator === "<=");+ if (!minFilter || !maxFilter || minFilter.value > maxFilter.value)+ return null;+ return [minFilter.value, maxFilter.value];}interface BaseUIFilter {@@ -228,7 +219,9 @@ export interface CategoricalUIFilter extends BaseUIFilter {export interface NumericUIFilter extends BaseUIFilter {type: "numeric";- value: [number, number];+ value: [number, number] | null;+ conditions: Extract<FilterState[number], { type: "number" }>[];+ onRemoveCondition: (index: number) => void;min: number;max: number;onChange: (value: [number, number]) => void;@@ -1385,9 +1378,14 @@ export function useSidebarFilterPresentation(return config.facets.map((facet): UIFilter | null => {if (facet.type === "numeric") {+ const conditions = filterState.filter(+ (+ filter,+ ): filter is Extract<FilterState[number], { type: "number" }> =>+ filter.column === facet.column && filter.type === "number",+ );const currentRange = computeNumericRange(- facet.column,- filterState,+ conditions,facet.min,facet.max,);@@ -1404,6 +1402,7 @@ export function useSidebarFilterPresentation(help: facet.help,value: currentRange,+ conditions,min: facet.min,max: facet.max,unit: facet.unit,@@ -1414,6 +1413,13 @@ export function useSidebarFilterPresentation(disabledReason: disableState.reason,onChange: (value: [number, number]) =>updateNumericFilter(facet.column, value, facet.min, facet.max),+ onRemoveCondition: (index: number) => {+ const condition = conditions[index];+ if (!condition) return;+ const filterIndex = filterState.indexOf(condition);+ setFilterState(filterState.filter((_, i) => i !== filterIndex));+ emitFacetCleared(facet.column, 1);+ },onReset: () =>updateNumericFilter(facet.column, null, facet.min, facet.max),};diff --git a/web/src/features/filters/lib/facet-display.clienttest.ts b/web/src/features/filters/lib/facet-display.clienttest.tsindex 91b9a238a4..c0e242ff7b 100644--- a/web/src/features/filters/lib/facet-display.clienttest.ts+++ b/web/src/features/filters/lib/facet-display.clienttest.ts@@ -218,6 +218,11 @@ describe("getFacetSummary", () => {type: "numeric",isActive: true,value: [0.5, 30],+ conditions: [+ { column: "col", type: "number", operator: ">=", value: 0.5 },+ { column: "col", type: "number", operator: "<=", value: 30 },+ ],+ onRemoveCondition: () => {},min: 0,max: 60,unit: "s",diff --git a/web/src/features/filters/lib/facet-display.ts b/web/src/features/filters/lib/facet-display.tsindex e2448c287d..1363c6b37b 100644--- a/web/src/features/filters/lib/facet-display.ts+++ b/web/src/features/filters/lib/facet-display.ts@@ -111,6 +111,11 @@ export function getFacetSummary(filter: UIFilter): string | null {if (filter.type === "numeric") {if (!filter.isActive) return null;const unit = filter.unit ? ` ${filter.unit}` : "";+ if (filter.value === null) {+ return filter.conditions+ .map((condition) => `${condition.operator} ${condition.value}${unit}`)+ .join(" · ");+ }return `${filter.value[0]}–${filter.value[1]}${unit}`;}diff --git a/web/src/features/filters/sidebarFilterSessionPersistence.clienttest.tsx b/web/src/features/filters/sidebarFilterSessionPersistence.clienttest.tsxindex c51158e5ce..716ab0eb7c 100644--- a/web/src/features/filters/sidebarFilterSessionPersistence.clienttest.tsx+++ b/web/src/features/filters/sidebarFilterSessionPersistence.clienttest.tsx@@ -1,8 +1,17 @@-import { fireEvent, render, screen, waitFor } from "@testing-library/react";+import {+ act,+ fireEvent,+ render,+ renderHook,+ screen,+ waitFor,+} from "@testing-library/react";import { type FilterState, encodeFiltersGeneric } from "@langfuse/shared";import { useSidebarFilterState } from "./hooks/useSidebarFilterState";import { omitFilterFacets, type FilterConfig } from "./lib/filter-config";import { buildSidebarFilterQueryStorageKey } from "./lib/persistedSidebarFilterQuery";+import { getScoreFilterConfig } from "./config/scores-config";+import { getFacetSummary } from "./lib/facet-display";const queryParamStore = new Map<string, unknown>();// Values placed here are NOT visible on the first render; they are applied on@@ -95,6 +104,102 @@ const TEST_OPTIONS = {name: ["checkout", "search"],};+describe("numeric conditions restored from the URL", () => {+ it("keeps strict bounds visible and removes only the selected condition", () => {+ const filters: FilterState = [+ { column: "value", type: "number", operator: ">", value: 0.2 },+ { column: "value", type: "number", operator: "<", value: 0.8 },+ {+ column: "source",+ type: "stringOptions",+ operator: "any of",+ value: ["API"],+ },+ ];+ queryParamStore.clear();+ deferredQueryParams.clear();+ queryParamStore.set("filter", encodeFiltersGeneric(filters));+ const { result } = renderHook(() =>+ useSidebarFilterState(+ getScoreFilterConfig(),+ {},+ { stateLocation: "url" },+ ),+ );+ const facet = result.current.filters.find(+ (filter) => filter.type === "numeric",+ );+ if (!facet || facet.type !== "numeric")+ throw new Error("numeric facet missing");++ expect(getFacetSummary(facet)).toBe("> 0.2 · < 0.8");+ expect(facet.value).toBeNull();+ act(() => facet.onRemoveCondition(0));+ expect(result.current.explicitFilterState).toEqual(filters.slice(1));+ });++ it.each<{+ conditions: Extract<FilterState[number], { type: "number" }>[];+ range: [number, number] | null;+ summary: string;+ }>([+ {+ conditions: [+ { column: "value", type: "number", operator: "=", value: 0.5 },+ ],+ range: null,+ summary: "= 0.5",+ },+ {+ conditions: [+ { column: "value", type: "number", operator: ">=", value: 0.2 },+ { column: "value", type: "number", operator: ">=", value: 0.4 },+ { column: "value", type: "number", operator: "<=", value: 0.8 },+ ],+ range: null,+ summary: ">= 0.2 · >= 0.4 · <= 0.8",+ },+ {+ conditions: [+ { column: "value", type: "number", operator: "<=", value: 0.8 },+ ],+ range: null,+ summary: "<= 0.8",+ },+ {+ conditions: [+ { column: "value", type: "number", operator: ">=", value: 0.2 },+ { column: "value", type: "number", operator: "<=", value: 0.8 },+ ],+ range: [0.2, 0.8],+ summary: "0.2–0.8",+ },+ ])(+ "projects $summary without adding or collapsing bounds",+ ({ conditions, range, summary }) => {+ queryParamStore.clear();+ deferredQueryParams.clear();+ queryParamStore.set("filter", encodeFiltersGeneric(conditions));+ const { result } = renderHook(() =>+ useSidebarFilterState(+ getScoreFilterConfig(),+ {},+ { stateLocation: "url" },+ ),+ );+ const facet = result.current.filters.find(+ (filter) => filter.type === "numeric",+ );+ if (!facet || facet.type !== "numeric")+ throw new Error("numeric facet missing");++ expect(getFacetSummary(facet)).toBe(summary);+ expect(facet.value).toEqual(range);+ expect(result.current.explicitFilterState).toEqual(conditions);+ },+ );+});+const FILTER_A: FilterState = [{column: "name",diff --git a/web/src/features/scores/README.md b/web/src/features/scores/README.mdnew file mode 100644index 0000000000..8e9fe033fb--- /dev/null+++ b/web/src/features/scores/README.md@@ -0,0 +1,17 @@+# Scores++Score rendering, annotation forms, mutations, and the project Scores search bar.++- `components/ScoresSearchBar.tsx` owns the shared composer's lifecycle. It+ edits the table's existing sidebar filter state; the only local state is the+ shared editor's draft. It uses the table's filter-option response.+- `constants/scoresSearchRegistry.ts` derives the grammar from the Scores+ sidebar's facets. Bare text searches within score names; exact selections,+ numeric ranges, boolean values, and categorical values retain their existing+ filter shapes. There is no independent full-text search or aggregate-score+ namespace.+- `components/table/use-cases/scores.tsx` (under `src/`) owns data fetching,+ URL/saved-view filters, and the table. It mounts the bar only for the full-page+ v4 table; scoped embeds and chart mode have different filter contracts.++The shared grammar and extension contract live in `features/search-bar/README.md`.diff --git a/web/src/features/scores/components/ScoresSearchBar.tsx b/web/src/features/scores/components/ScoresSearchBar.tsxnew file mode 100644index 0000000000..c61335266e--- /dev/null+++ b/web/src/features/scores/components/ScoresSearchBar.tsx@@ -0,0 +1,49 @@+import type { FilterState } from "@langfuse/shared";+import { EventsSearchBarRow } from "@/src/features/search-bar/components/EventsSearchBarRow";+import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";+import { DEFAULT_SEARCH_TYPE } from "@/src/features/search-bar/lib/commit";+import { toObservedOptions } from "@/src/features/search-bar/lib/observed-options";+import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";++const noSearchLane = () => {};++export function ScoresSearchBar({+ projectId,+ filterState,+ setFilterState,+ filterOptions,+ isLoading,+}: {+ projectId: string;+ filterState: FilterState;+ setFilterState: (filters: FilterState) => void;+ filterOptions: Parameters<typeof toObservedOptions>[0];+ isLoading: boolean;+}) {+ const observed = toObservedOptions(filterOptions, isLoading);+ const { store, commit, applyFilters } = useEventsSearchBar({+ projectId,+ tableName: "scores",+ enabled: true,+ filterState,+ searchQuery: null,+ searchType: DEFAULT_SEARCH_TYPE,+ observed,+ setFilterState,+ setSearchQuery: noSearchLane,+ setSearchType: noSearchLane,+ registry: SCORES_FIELD_REGISTRY,+ });++ return (+ <EventsSearchBarRow+ projectId={projectId}+ tableName="scores"+ store={store}+ commit={commit}+ observed={observed}+ onApplyFilters={applyFilters}+ registry={SCORES_FIELD_REGISTRY}+ />+ );+}diff --git a/web/src/features/scores/constants/scoresSearchRegistry.ts b/web/src/features/scores/constants/scoresSearchRegistry.tsnew file mode 100644index 0000000000..24aaa15fbd--- /dev/null+++ b/web/src/features/scores/constants/scoresSearchRegistry.ts@@ -0,0 +1,50 @@+import { getScoreFilterConfig } from "@/src/features/filters/config/scores-config";+import { fieldRegistryFromColumns } from "@/src/features/search-bar/lib/fields";++const config = getScoreFilterConfig();+const facetColumns = new Set(config.facets.map((facet) => facet.column));++export const SCORES_FIELD_REGISTRY = fieldRegistryFromColumns(+ config.columnDefinitions.filter((column) => facetColumns.has(column.id)),+ {+ id: "scores",+ metadata: true,+ scores: false,+ traceScores: false,+ // Scores has no full-text lane. Bare text becomes a visible name filter.+ allowFreeText: false,+ defaultTextField: "name",+ recentSearches: true,+ aiFilterPrompt: false,+ hasExample: "userId",+ searchExamples: [+ "name:helpfulness",+ 'name:("Rouge Score" OR confidence)',+ "source:EVAL",+ "value:<0.5",+ ],+ fields: {+ name: {+ aliases: ["scoreName", "score_name"],+ label: "Score name",+ description: "Search within score names",+ syncMode: "textSearch",+ suggestObservedValues: true,+ },+ environment: { aliases: ["env"] },+ dataType: { aliases: ["type", "data_type"] },+ value: { label: "Numeric value" },+ booleanValue: { aliases: ["boolean_value"] },+ stringValue: {+ aliases: ["category", "string_value"],+ label: "Categorical value",+ },+ traceId: { aliases: ["trace_id"] },+ sessionId: { aliases: ["session_id"] },+ observationId: { aliases: ["observation_id"] },+ traceName: { aliases: ["trace_name"] },+ userId: { aliases: ["user", "user_id"] },+ tags: { aliases: ["tag", "traceTags", "trace_tags"] },+ },+ },+);diff --git a/web/src/features/search-bar/README.md b/web/src/features/search-bar/README.mdindex 0a0bf0faa0..72c8471cf9 100644--- a/web/src/features/search-bar/README.md+++ b/web/src/features/search-bar/README.md@@ -1,7 +1,7 @@# Search BarGrammar-based query bar shared by the observations (v4 events) table,-evaluation-rule observation filters, and the sessions table. On the events table it does NOT replace+evaluation-rule observation filters, sessions, experiments, and scores tables. On the events table it does NOT replacethe facet sidebar — it is an ADDITIONAL keyboard-driven editor that coexistswith the sidebar and stays in sync with it. The facet sidebar's `FilterState`(+ the table's full-text search) remains the single source of truth; the bar@@ -433,7 +433,13 @@ so a new view must check the field dropdown, not just that Enter applies.aliases/macros**, **AI context fields**, **dot-path roots**(`metadata.`, `scores.`/`traceScores.` and their score columns), and**value-parse hints** (datetime ISO, numeric, boolean). Keep it small and- declarative. Three flags are per-view capabilities, not cosmetics:+ declarative.+ A field's `syncMode` can override the column-derived default: Scores uses+ `textSearch` plus `suggestObservedValues` for option-backed score names, so+ bare text searches within names while selected exact values still round-trip.+ The derived `exactMatchUsesOptions` flag keeps singleton exact selections in+ a categorical facet's `stringOptions` shape, so its checkbox stays selected.+ Three flags are per-view capabilities, not cosmetics:- `metadata` / `scores` / `traceScores` — the keyed dot-path roots. Set themfrom the columns the view's BACKEND has, not from what reads well: sessionsaggregates scores at session level and has no `trace_scores_*` columns, sodiff --git a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsxindex 3400c7e269..43ff44a90c 100644--- a/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx+++ b/web/src/features/search-bar/hooks/useEventsSearchBar.clienttest.tsx@@ -5,6 +5,7 @@ import type { FilterState } from "@langfuse/shared";import { DEFAULT_SEARCH_TYPE } from "@/src/features/search-bar/lib/commit";import { useEventsSearchBar } from "@/src/features/search-bar/hooks/useEventsSearchBar";+import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";const NEW_FILTERS: FilterState = [{ type: "string", column: "name", operator: "contains", value: "checkout" },@@ -35,6 +36,36 @@ function setup(}describe("useEventsSearchBar.commit", () => {+ it("preserves a Scores saved-view filter the bar cannot represent", () => {+ const hiddenFilter: FilterState = [+ {+ column: "evaluatorId",+ type: "stringOptions",+ operator: "any of",+ value: ["legacy-evaluator"],+ },+ ];+ const { result, setFilterState } = setup({+ tableName: "scores",+ registry: SCORES_FIELD_REGISTRY,+ filterState: hiddenFilter,+ searchQuery: null,+ });+ act(() => result.current.store.getState().actions.setDraft("Rouge Score"));+ act(() => {+ result.current.commit("enter");+ });+ expect(setFilterState).toHaveBeenCalledWith([+ {+ column: "name",+ type: "string",+ operator: "contains",+ value: "Rouge Score",+ },+ ...hiddenFilter,+ ]);+ });+it("fully replaces hidden filters when a query preset is picked", () => {const hiddenFilter: FilterState = [{diff --git a/web/src/features/search-bar/lib/adapter.ts b/web/src/features/search-bar/lib/adapter.tsindex d5b6170ea1..b2a83f2e96 100644--- a/web/src/features/search-bar/lib/adapter.ts+++ b/web/src/features/search-bar/lib/adapter.ts@@ -419,8 +419,9 @@ function lowerText(// none-of (negated) via stringOptions (string columns accept it). A single// NEGATED exact (`-name:=abc`) is exact-inequality: its only faithful flat// form is stringOptions none-of, since there is no `string !=`. A single- // POSITIVE exact stays the plain `string =`.- if (node.values.length > 1) {+ // POSITIVE exact uses the owning column's shape: categorical facets need+ // stringOptions even for one value so the selected checkbox stays visible.+ if (node.values.length > 1 || field.exactMatchUsesOptions) {out.push({type: "stringOptions",column: field.id,diff --git a/web/src/features/search-bar/lib/fields.ts b/web/src/features/search-bar/lib/fields.tsindex 37800934d1..f224deae45 100644--- a/web/src/features/search-bar/lib/fields.ts+++ b/web/src/features/search-bar/lib/fields.ts@@ -57,6 +57,8 @@ export type FieldDef = {* `exactOption`; only set this on `textSearch` fields that should suggest.*/suggestObservedValues?: boolean;+ /** Preserve exact selections in the owning categorical facet's filter shape. */+ exactMatchUsesOptions?: boolean;/** Canonical FilterState column emitted for this display-oriented field. */filterColumn?: string;/** Display/query value → canonical FilterState value for labeled options. */@@ -74,6 +76,7 @@ export type FieldRegistry = {| "evaluatorSamples"| "ruleSamples"| "sessions"+ | "scores"| "experiments"| "users";fields: readonly FieldDef[];@@ -137,7 +140,10 @@ export type AIContextField = {};export type FieldOverlay = Partial<- Omit<FieldDef, "id" | "kind" | "syncMode" | "label" | "description">+ Omit<+ FieldDef,+ "id" | "kind" | "label" | "description" | "exactMatchUsesOptions"+ >> & {label?: string;description?: string;@@ -193,7 +199,8 @@ export function fieldRegistryFromColumns(id: column.id,aliases: fieldOverlay?.aliases ?? column.aliases ?? [],kind,- syncMode,+ syncMode: fieldOverlay?.syncMode ?? syncMode,+ exactMatchUsesOptions: column.type === "stringOptions",label: fieldOverlay?.label ?? column.name,description: fieldOverlay?.description ?? column.name,nullable: column.nullable,diff --git a/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts b/web/src/features/search-bar/lib/searchBarInvariants.clienttest.tsindex 0a52a78532..fe58056f67 100644--- a/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts+++ b/web/src/features/search-bar/lib/searchBarInvariants.clienttest.ts@@ -16,6 +16,9 @@ import { SESSIONS_FIELD_REGISTRY } from "@/src/features/filters";import { usersEventsFilterConfig } from "@/src/features/filters/config/users-config";import { USERS_FIELD_REGISTRY } from "@/src/features/filters/config/usersSearchRegistry";import { EXPERIMENTS_FIELD_REGISTRY } from "@/src/features/experiments/constants/experimentsSearchRegistry";+import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";+import { getScoreFilterConfig } from "@/src/features/filters/config/scores-config";+import type { FilterState } from "@langfuse/shared";import { validateQuery } from "./validate";import { DEFAULT_SEARCH_TYPE, planCommit } from "./commit";import { filterStateToQueryText } from "./filter-state-to-query";@@ -30,6 +33,202 @@ import {type RegistryUnderTest,} from "./searchBarInvariants";+describe("search bar invariants — Scores registry", () => {+ it("searches within a score name", () => {+ const result = planCommit("Rouge Score", undefined, SCORES_FIELD_REGISTRY);+ expect(result).toMatchObject({+ status: "committed",+ filters: [+ {+ column: "name",+ type: "string",+ operator: "contains",+ value: "Rouge Score",+ },+ ],+ });+ });++ it("round-trips exact names, repeated ranges, values, metadata, and tag filters", () => {+ const sidebarFilters: FilterState[] = [+ [+ {+ column: "name",+ type: "stringOptions",+ operator: "any of",+ value: ["Rouge Score"],+ },+ ],+ [+ {+ column: "name",+ type: "stringOptions",+ operator: "any of",+ value: ["Rouge Score", "confidence"],+ },+ ],+ [+ {+ column: "name",+ type: "stringOptions",+ operator: "none of",+ value: ["Rouge Score"],+ },+ ],+ [+ { column: "value", type: "number", operator: ">=", value: 0.2 },+ { column: "value", type: "number", operator: "<", value: 0.8 },+ ],+ [+ {+ column: "booleanValue",+ type: "stringOptions",+ operator: "any of",+ value: ["true"],+ },+ ],+ [+ {+ column: "stringValue",+ type: "stringOptions",+ operator: "any of",+ value: ["true", "needs review"],+ },+ ],+ [+ {+ column: "metadata",+ type: "stringObject",+ key: "review team",+ operator: "=",+ value: "quality",+ },+ ],+ [+ {+ column: "tags",+ type: "arrayOptions",+ operator: "all of",+ value: ["billing", "urgent"],+ },+ ],+ [+ {+ column: "evaluatorId",+ type: "stringOptions",+ operator: "any of",+ value: ["legacy-evaluator"],+ },+ ],+ ];+ const view: RegistryUnderTest = {+ name: "scores",+ registry: SCORES_FIELD_REGISTRY,+ extraKeys: ["metadata.region", 'metadata."review team"', "has:userId"],+ scoreContexts: [],+ fieldValues: ["x", "true", "false", "0.5", "Rouge Score", "or", "a,b"],+ freeTextValues: [],+ sidebarFilters,+ };+ expect(runSearchBarInvariants(view)).toEqual([]);++ const exactName = filterStateToQueryText(+ sidebarFilters[0],+ {},+ SCORES_FIELD_REGISTRY,+ );+ expect(+ planCommit(exactName.text, undefined, SCORES_FIELD_REGISTRY),+ ).toMatchObject({+ status: "committed",+ filters: [+ {+ column: "name",+ type: "stringOptions",+ operator: "any of",+ value: ["Rouge Score"],+ },+ ],+ });++ for (const filters of sidebarFilters.slice(1, -1)) {+ const projection = filterStateToQueryText(+ filters,+ {},+ SCORES_FIELD_REGISTRY,+ );+ expect(projection.skippedFilters).toEqual([]);+ expect(+ planCommit(projection.text, undefined, SCORES_FIELD_REGISTRY),+ ).toMatchObject({+ status: "committed",+ filters,+ });+ }+ });++ it("keeps boolean score values distinct from categorical text", () => {+ expect(+ planCommit(+ "booleanValue:true stringValue:true",+ undefined,+ SCORES_FIELD_REGISTRY,+ ),+ ).toMatchObject({+ status: "committed",+ filters: [+ {+ column: "booleanValue",+ type: "stringOptions",+ operator: "any of",+ value: ["true"],+ },+ {+ column: "stringValue",+ type: "stringOptions",+ operator: "any of",+ value: ["true"],+ },+ ],+ });+ });++ it("offers only fields owned by the sidebar and rejects aggregate-score namespaces", () => {+ const facets = new Set(+ getScoreFilterConfig().facets.map((facet) => facet.column),+ );+ for (const field of SCORES_FIELD_REGISTRY.fields) {+ expect(facets.has(field.id), field.id).toBe(true);+ }+ for (const query of [+ "scores.accuracy:>0.5",+ "traceScores.grade:A",+ "latency:>2",+ "evaluatorId:abc",+ ]) {+ expect(+ planCommit(query, undefined, SCORES_FIELD_REGISTRY).status,+ query,+ ).toBe("invalid");+ }+ const completion = planInputCompletions(+ {+ input: "name:",+ caret: 5,+ observed: { name: [{ value: "Rouge Score" }] },+ recents: [],+ currentQueryText: "",+ },+ SCORES_FIELD_REGISTRY,+ );+ const options =+ completion?.sections.flatMap((section) => section.options) ?? [];+ expect(options.some((option) => option.label.includes("Rouge Score"))).toBe(+ true,+ );+ });+});+// Per-view wiring of the property harness. A second filterable view adopts the// bar by adding its own block here with its registry — the harness is unchanged.// See README.md "Extending to other views (the universality contract)".diff --git a/web/src/features/search-bar/server/router.ts b/web/src/features/search-bar/server/router.tsindex 66d2043005..45527fe1ca 100644--- a/web/src/features/search-bar/server/router.ts+++ b/web/src/features/search-bar/server/router.ts@@ -55,6 +55,7 @@ import {} from "@/src/features/evals/v2/constants/evaluatorSearchRegistry";import { DATASET_NAME_COLUMN } from "@/src/features/evals/v2/utils/datasetNameFilter";import { SESSIONS_FIELD_REGISTRY } from "@/src/features/filters/config/sessionsSearchRegistry";+import { SCORES_FIELD_REGISTRY } from "@/src/features/scores/constants/scoresSearchRegistry";import { USERS_FIELD_REGISTRY } from "@/src/features/filters/config/usersSearchRegistry";import { EXPERIMENTS_FIELD_REGISTRY } from "@/src/features/experiments/constants/experimentsSearchRegistry";import {@@ -75,6 +76,7 @@ const REGISTRY_IDS = ["evaluatorSamples","ruleSamples","sessions",+ "scores","experiments","users",] as const;@@ -91,6 +93,7 @@ const REGISTRIES_BY_ID: Record<(typeof REGISTRY_IDS)[number], FieldRegistry> = {evaluatorSamples: EVALUATOR_FIELD_REGISTRY,ruleSamples: RULE_SAMPLE_FIELD_REGISTRY,sessions: SESSIONS_FIELD_REGISTRY,+ scores: SCORES_FIELD_REGISTRY,experiments: EXPERIMENTS_FIELD_REGISTRY,users: USERS_FIELD_REGISTRY,};