πͺ’ 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(web): collapse the trace-table facet list behind a Show N more control (#16071)
Trang Nguyen966889b2b8fb
diff --git a/web/src/components/table/data-table-controls.clienttest.tsx b/web/src/components/table/data-table-controls.clienttest.tsxindex 4e0c1f44cc..c6b96488da 100644--- a/web/src/components/table/data-table-controls.clienttest.tsx+++ b/web/src/components/table/data-table-controls.clienttest.tsx@@ -829,6 +829,239 @@ describe("DataTableControls blocked facets (LFE-11040)", () => {});});+describe("DataTableControls facet fold", () => {+ 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[],+ commonFacets?: string[],+ ): QueryFilter => ({+ filters,+ expanded: [],+ onExpandedChange: () => {},+ clearAll: () => {},+ isFiltered: filters.some((f) => f.isActive),+ setFilterState: () => {},+ commonFacets,+ });++ // The fold preference is session-scoped and (without a provider) shares one+ // key across tests; the used-facet recency map is localStorage-backed the+ // same way. (Guarded: this vitest environment lacks localStorage on some+ // Node versions, where the hook falls back to plain state.)+ beforeEach(() => {+ sessionStorage.clear();+ globalThis.localStorage?.clear?.();+ captureSpy.mockClear();+ });++ // Config order deliberately interleaves a tail facet (Release) between the+ // common ones, so the append-below-the-fold ordering is distinguishable+ // from plain catalog order.+ const CATALOG = [+ categoricalFilter("environment", "Environment", false),+ categoricalFilter("release", "Release", false),+ categoricalFilter("name", "Name", false),+ categoricalFilter("version", "Version", false),+ ];++ const labelOrder = (first: string, second: string) => {+ const a = screen.getByText(first);+ const b = screen.getByText(second);+ return Boolean(+ a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING,+ );+ };++ it("folds uncommon facets behind 'Show N more' with the real hidden count", () => {+ render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(CATALOG, ["environment", "name"])}+ />+ </TooltipProvider>,+ );++ expect(screen.getByText("Environment")).toBeVisible();+ expect(screen.getByText("Name")).toBeVisible();+ expect(screen.getByText("Release")).not.toBeVisible();+ expect(screen.getByText("Version")).not.toBeVisible();+ expect(+ screen.getByRole("button", { name: "Show 2 more" }),+ ).toBeInTheDocument();+ });++ it("expands to the full catalog and collapses back, capturing the toggle", () => {+ render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(CATALOG, ["environment", "name"])}+ />+ </TooltipProvider>,+ );++ fireEvent.click(screen.getByRole("button", { name: "Show 2 more" }));+ expect(screen.getByText("Release")).toBeVisible();+ expect(screen.getByText("Version")).toBeVisible();+ // Revealed facets APPEND below the common block β the facets already on+ // screen keep their positions, so Release (config-ordered between+ // Environment and Name) lands after Name, not between them.+ expect(labelOrder("Environment", "Name")).toBe(true);+ expect(labelOrder("Name", "Release")).toBe(true);+ expect(labelOrder("Release", "Version")).toBe(true);+ const toggled = captureSpy.mock.calls.filter(+ ([event]) => event === "filters:facet_fold_toggled",+ );+ expect(toggled).toHaveLength(1);+ expect(toggled[0][1]).toMatchObject({+ expanded: true,+ foldedCount: 2,+ isV4: false,+ });++ fireEvent.click(screen.getByRole("button", { name: "Show fewer" }));+ expect(screen.getByText("Release")).not.toBeVisible();+ expect(screen.getByText("Version")).not.toBeVisible();+ });++ it("never folds a facet with an active filter, even outside the common set", () => {+ render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(+ [+ categoricalFilter("environment", "Environment", false),+ categoricalFilter("name", "Name", false),+ categoricalFilter("release", "Release", true),+ categoricalFilter("version", "Version", false),+ ],+ ["environment", "name"],+ )}+ />+ </TooltipProvider>,+ );++ // Active Release stays reachable; only inactive Version counts as folded.+ expect(screen.getByText("Release")).toBeVisible();+ expect(screen.getByText("Version")).not.toBeVisible();+ expect(+ screen.getByRole("button", { name: "Show 1 more" }),+ ).toBeInTheDocument();+ });++ it("renders the full catalog with no fold control when the table declares no common set", () => {+ render(+ <TooltipProvider>+ <DataTableControls queryFilter={queryFilter(CATALOG)} />+ </TooltipProvider>,+ );++ expect(screen.getByText("Release")).toBeVisible();+ expect(screen.getByText("Version")).toBeVisible();+ expect(+ screen.queryByRole("button", { name: /Show \d+ more/ }),+ ).not.toBeInTheDocument();+ });++ it("keeps a facet the user has filtered on visible after the filter clears", () => {+ const withReleaseActive = [+ categoricalFilter("environment", "Environment", false),+ categoricalFilter("release", "Release", true),+ categoricalFilter("name", "Name", false),+ categoricalFilter("version", "Version", false),+ ];+ const { rerender } = render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(CATALOG, ["environment", "name"])}+ />+ </TooltipProvider>,+ );+ expect(screen.getByText("Release")).not.toBeVisible();++ // A filter lands on Release: it surfaces and is recorded as used.+ rerender(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(withReleaseActive, ["environment", "name"])}+ />+ </TooltipProvider>,+ );+ expect(screen.getByText("Release")).toBeVisible();++ // Clearing the filter no longer folds it away: a used facet stays+ // visible, and the fold count only covers the never-used tail.+ rerender(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(CATALOG, ["environment", "name"])}+ />+ </TooltipProvider>,+ );+ expect(screen.getByText("Release")).toBeVisible();+ expect(+ screen.getByRole("button", { name: "Show 1 more" }),+ ).toBeInTheDocument();+ });++ it("expand-all expands only the facets on screen while folded", () => {+ const onExpandedChange = vi.fn();+ render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={{+ ...queryFilter(CATALOG, ["environment", "name"]),+ onExpandedChange,+ }}+ />+ </TooltipProvider>,+ );++ fireEvent.click(screen.getByRole("button", { name: "Expand all filters" }));+ // Folded tail facets must not expand: that would fire their option+ // loads with no visible effect.+ expect(onExpandedChange).toHaveBeenCalledWith(["environment", "name"]);+ });++ it("hides the fold control when every tail facet is promoted (nothing left to fold)", () => {+ render(+ <TooltipProvider>+ <DataTableControls+ queryFilter={queryFilter(+ [+ categoricalFilter("environment", "Environment", false),+ categoricalFilter("release", "Release", true),+ ],+ ["environment"],+ )}+ />+ </TooltipProvider>,+ );++ expect(screen.getByText("Release")).toBeVisible();+ expect(+ screen.queryByRole("button", { name: /Show \d+ more|Show fewer/ }),+ ).not.toBeInTheDocument();+ });+});+describe("DataTableControls facet-name search", () => {// A catalog long enough to earn the search box (the traces sidebar's shape).const CATALOG: [column: string, label: string][] = [diff --git a/web/src/components/table/data-table-controls.tsx b/web/src/components/table/data-table-controls.tsxindex e921429eab..05f4be426d 100644--- a/web/src/components/table/data-table-controls.tsx+++ b/web/src/components/table/data-table-controls.tsx@@ -33,6 +33,7 @@ import {} from "@/src/features/filters/lib/facet-order";import { useMediaQuery } from "react-responsive";import useLocalStorage from "@/src/components/useLocalStorage";+import useSessionStorage from "@/src/components/useSessionStorage";import { cn } from "@/src/utils/tailwind";import { compactNumberFormatter } from "@/src/utils/numbers";import { Accordion } from "@/src/components/ui/accordion";@@ -178,6 +179,12 @@ export interface QueryFilter {setFilterState: (filters: FilterState) => void;/** v3-vs-v4 analytics dimension of the surface (see useSidebarFilterState). */isV4?: boolean;+ /**+ * Curated default-visible facet set from the table's FilterConfig+ * When present, facets outside it fold behind "Show N more";+ * absent = the whole catalog stays visible.+ */+ commonFacets?: string[];}interface DataTableControlsProps {@@ -258,7 +265,19 @@ export function DataTableControls({facetInteractionRef.current,);facetOrderRef.current = facetOrder;- const noteFacetInteraction = () => {+ // No event = a programmatic in-list action (Add filter), which is always a+ // deliberate interaction.+ const noteFacetInteraction = (event?: React.SyntheticEvent) => {+ // The fold toggle never changes promotion, so it must not arm the+ // attribution token: a dangling token would wrongly hold the order+ // through the next external filter change (search bar, saved view).+ if (+ event &&+ event.target instanceof Element &&+ event.target.closest("[data-facet-fold-toggle]")+ ) {+ return;+ }facetInteractionRef.current += 1;};// Boundaries the sidebar owns itself (Clear all, AI apply): the change they@@ -275,6 +294,18 @@ export function DataTableControls({? orderedFilters.filter(isPromoted): orderedFilters;+ // Fold the uncommon tail of the catalog behind "Show N more",+ // on tables that declare a curated `commonFacets` set. Session-scoped like+ // the per-facet expanded state: a mid-session "show all" survives+ // navigation, a fresh session starts folded again. Active-only mode is a+ // stricter collapse already, so the fold only applies outside it.+ const [showAllFacets, setShowAllFacets] = useSessionStorage(+ `${storagePrefix}-facets-show-all`,+ false,+ );+ const commonFacetSet = new Set(queryFilter.commonFacets ?? []);+ const facetFoldEnabled = commonFacetSet.size > 0 && !showOnlyActive;+// Facet-NAME search over a long catalog. Two surfaces search the same names:// this list, and the active-only "Add filter" picker below.const [facetSearch, setFacetSearch] = useState("");@@ -287,33 +318,81 @@ export function DataTableControls({// must never narrow the list behind the user's back.const facetSearchQuery = showFacetSearch ? facetSearch.trim() : "";- // The name search FILTERS, it does not reorder: the settled promoted block- // and config order still own every position. A facet whose name misses the- // query goes whether or not it is filtering β what is in force stays on show- // above the list (the header's active count, plus the search bar's tokens- // where there is one), so the sidebar need not repeat it mid-search.- //- // Non-matching facets are HIDDEN, never unmounted. Every facet holds+ // Matching facet columns, or null when not searching. The name search+ // FILTERS, it does not reorder: the settled promoted block and render order+ // still own every position. A facet whose name misses the query goes whether+ // or not it is filtering β what is in force stays on show above the list+ // (the header's active count, plus the search bar's tokens where there is+ // one), so the sidebar need not repeat it mid-search. The match set is also+ // what tells "nothing matched" apart from an unsearched list.+ const facetSearchMatches = facetSearchQuery+ ? new Set(+ displayedFilters+ .filter((filter) => facetNameRank(filter, facetSearchQuery) !== null)+ .map((filter) => filter.column),+ )+ : null;++ // Facet-usage recency: every facet the user has filtered on, on this table,+ // in this browser (localStorage; written by the activity effect below).+ // Feeds the "Add filter" dropdown's ordering, and keeps used facets out of+ // the fold β once someone filters on a facet, it stays visible for them.+ const [recentColumns, setRecentColumns] = useLocalStorage<+ Record<string, number>+ >(`${storagePrefix}-recent-facets`, EMPTY_RECENCY);+ // Two groups, both in settled order: the top group is the curated common+ // set, every facet this user has ever filtered on, and the SETTLED promoted+ // block; everything else is the tail. Expanding APPENDS the tail below the+ // top group (never interleaves it back into catalog order), so the facets+ // already on screen keep their exact positions when the button is clicked.+ // Group membership uses the settled promotion β not the live one β so a+ // facet activated in place stays in place until the next settle. A+ // live-active tail facet still never hides: when folded it renders at the+ // end of the top group, right above the button.+ const inTopFoldGroup = (filter: UIFilter) =>+ commonFacetSet.has(filter.column) ||+ recentColumns[filter.column] !== undefined ||+ facetOrder.promoted.has(filter.column);+ const topFoldGroup = facetFoldEnabled+ ? displayedFilters.filter(inTopFoldGroup)+ : displayedFilters;+ const tailFoldGroup = facetFoldEnabled+ ? displayedFilters.filter((filter) => !inTopFoldGroup(filter))+ : [];+ const foldedFacetCount = tailFoldGroup.filter(+ (filter) => !isPromoted(filter),+ ).length;+ // The one render order: top group first, tail appended below β expanding+ // the fold never interleaves the tail back into catalog order, so facets+ // already on screen keep their exact positions. Reordering a single keyed+ // array moves elements without remounting them.+ const renderOrderedFilters = facetFoldEnabled+ ? [...topFoldGroup, ...tailFoldGroup]+ : displayedFilters;+ const foldVisibleFilters = facetFoldEnabled+ ? [+ ...topFoldGroup,+ ...(showAllFacets ? tailFoldGroup : tailFoldGroup.filter(isPromoted)),+ ]+ : displayedFilters;+ // Search and fold COMPOSE: an active search suspends the fold (a match in+ // the folded tail must be findable), otherwise the fold decides what is on+ // screen. Either way rows are HIDDEN, never unmounted: every facet holds// uncommitted local state β a typed-but-not-added text filter, a metadata// condition mid-build, a "show more" expansion, a debounced numeric draft β// and unmounting throws all of it away with nothing said. Now that an ACTIVE// facet can be hidden too, that matters more, not less: hiding is// presentation only and must never touch the filter state.- const visibleFilters = facetSearchQuery- ? displayedFilters.filter(- (filter) => facetNameRank(filter, facetSearchQuery) !== null,+ const visibleFilters = facetSearchMatches+ ? renderOrderedFilters.filter((filter) =>+ facetSearchMatches.has(filter.column),)- : displayedFilters;+ : foldVisibleFilters;const visibleColumns = new Set(visibleFilters.map((filter) => filter.column));const expandedVisibleCount = queryFilter.expanded.filter((column) =>visibleColumns.has(column),).length;- // Facet-usage recency, feeding the "Add filter" dropdown's ordering so the- // filters someone actually uses on this table surface first.- const [recentColumns, setRecentColumns] = useLocalStorage<- Record<string, number>- >(`${storagePrefix}-recent-facets`, EMPTY_RECENCY);const addableFilters = showOnlyActive? orderedFilters.filter(@@ -491,7 +570,8 @@ export function DataTableControls({: visibleFilters.filter((filter) => facetOrder.promoted.has(filter.column)).length;// Anchored to the first VISIBLE catalog facet rather than to an index: rows- // hidden by a search stay in the list, so an index would count them.+ // hidden by a search or the fold stay in the list, so an index would count+ // them.const firstCatalogColumn = visibleFilters.find((filter) => !facetOrder.promoted.has(filter.column),)?.column;@@ -726,11 +806,11 @@ export function DataTableControls({the promoted/rest boundary would REMOUNT (wiping inputfocus and draft state) instead of moving.- Every facet renders; a search only sets `hidden` on the rows- it excludes. The wrapper is always present for the same- reason the array is single: swapping the element around a- facet would remount it and lose its draft state. */}- {displayedFilters.flatMap((filter) => {+ Every facet renders; a search or the fold only sets `hidden`+ on the rows they exclude. The wrapper is always present for+ the same reason the array is single: swapping the element+ around a facet would remount it and lose its draft state. */}+ {renderOrderedFilters.flatMap((filter) => {const nodes = [];if (showPromotedSeparator && filter.column === firstCatalogColumn) {nodes.push(@@ -763,6 +843,46 @@ export function DataTableControls({</p>)}+ {/* The fold control: the uncommon tail of the catalog sits+ behind an accurate "Show N more"; expanding reveals every remaining+ facet, so nothing is unreachable. Hidden while nothing is foldable+ (e.g. every tail facet currently carries an active filter) and while+ a search owns visibility. */}+ {facetFoldEnabled && foldedFacetCount > 0 && !facetSearchQuery && (+ <div className="px-2 pt-1">+ <Button+ variant="ghost"+ size="sm"+ data-facet-fold-toggle+ onClick={() => {+ const next = !showAllFacets;+ setShowAllFacets(next);+ capture("filters:facet_fold_toggled", {+ tableName,+ expanded: next,+ foldedCount: foldedFacetCount,+ isV4: queryFilter.isV4 ?? false,+ });+ }}+ // Reads like a facet header row: same muted color, size, and+ // chevron treatment (> folded, v expanded), same left inset.+ className="text-muted-foreground hover:text-foreground h-auto w-full justify-start gap-1.5 px-2 py-1 text-xs font-normal"+ >+ {showAllFacets ? (+ <>+ <ChevronDown className="h-3.5 w-3.5 shrink-0" />+ Show fewer+ </>+ ) : (+ <>+ <ChevronRight className="h-3.5 w-3.5 shrink-0" />+ Show {foldedFacetCount} more+ </>+ )}+ </Button>+ </div>+ )}+{/* Active-only mode: surface the rest of the catalog behind anexplicit "Add filter" picker, most-recently-used first, sothe filters someone actually works with are one click away. */}diff --git a/web/src/features/events/config/filter-config.ts b/web/src/features/events/config/filter-config.tsindex 84f166c7c7..b4342d1062 100644--- a/web/src/features/events/config/filter-config.ts+++ b/web/src/features/events/config/filter-config.ts@@ -88,13 +88,42 @@ export const observationEventsFilterConfig: FilterConfig = {defaultExpanded: ["environment", "name", "isRootObservation", "type"],+ // Top 15 facets by real usage β 60 days of PostHog `filters:applied` on+ // this table: they cover ~98% of sidebar filter applies per project on+ // average, ~95% at the 10th percentile. The rest folds behind+ // "Show N more".+ commonFacets: [+ "isRootObservation",+ "name",+ "type",+ "environment",+ "traceName",+ "metadata",+ "traceTags",+ "sessionId",+ "userId",+ "traceId",+ "level",+ "providedModelName",+ "promptName",+ "latency",+ "scores_avg",+ ],+migrateFilterState: migrateLegacyRootObservationFilters,facets: [+ {+ type: "boolean" as const,+ column: "isRootObservation",+ label: "Is Root Observation",+ tooltip:+ "A root observation is top-level in a trace or marked as an app root by the SDK. Filter to 'True' to see root-level observations.",+ },{type: "categorical" as const,- column: "environment",- label: getEventsColumnName("environment"),+ column: "name",+ label: getEventsColumnName("name"),},{type: "categorical" as const,@@ -108,11 +137,9 @@ export const observationEventsFilterConfig: FilterConfig = {renderIcon: renderFilterIcon,},{- type: "boolean" as const,- column: "isRootObservation",- label: "Is Root Observation",- tooltip:- "A root observation is top-level in a trace or marked as an app root by the SDK. Filter to 'True' to see root-level observations.",+ type: "categorical" as const,+ column: "environment",+ label: getEventsColumnName("environment"),},{type: "categorical" as const,@@ -120,9 +147,9 @@ export const observationEventsFilterConfig: FilterConfig = {label: getEventsColumnName("traceName"),},{- type: "categorical" as const,- column: "name",- label: getEventsColumnName("name"),+ type: "stringKeyValue" as const,+ column: "metadata",+ label: getEventsColumnName("metadata"),},{// Tags are a primary, user-defined filter β keep them near the identity@@ -131,6 +158,21 @@ export const observationEventsFilterConfig: FilterConfig = {column: "traceTags",label: getEventsColumnName("traceTags"),},+ {+ type: "categorical" as const,+ column: "sessionId",+ label: getEventsColumnName("sessionId"),+ },+ {+ type: "categorical" as const,+ column: "userId",+ label: getEventsColumnName("userId"),+ },+ {+ type: "string" as const,+ column: "traceId",+ label: getEventsColumnName("traceId"),+ },{// Display name comes from eventsTableCols so the sidebar and table// column stay aligned. Column id stays `level`.@@ -144,20 +186,28 @@ export const observationEventsFilterConfig: FilterConfig = {column: "providedModelName",label: getEventsColumnName("providedModelName"),},- {- type: "categorical" as const,- column: "modelId",- label: getEventsColumnName("modelId"),- },{type: "categorical" as const,column: "promptName",label: getEventsColumnName("promptName"),},{- type: "stringKeyValue" as const,- column: "metadata",- label: getEventsColumnName("metadata"),+ type: "numeric" as const,+ column: "latency",+ label: getEventsColumnName("latency"),+ min: 0,+ max: 60,+ unit: "s",+ },+ {+ type: "numericKeyValue" as const,+ column: "scores_avg",+ label: "Numeric Scores",+ },+ {+ type: "categorical" as const,+ column: "modelId",+ label: getEventsColumnName("modelId"),},{type: "categorical" as const,@@ -174,21 +224,6 @@ export const observationEventsFilterConfig: FilterConfig = {column: "statusMessage",label: getEventsColumnName("statusMessage"),},- {- type: "string" as const,- column: "traceId",- label: getEventsColumnName("traceId"),- },- {- type: "categorical" as const,- column: "sessionId",- label: getEventsColumnName("sessionId"),- },- {- type: "categorical" as const,- column: "userId",- label: getEventsColumnName("userId"),- },{type: "categorical" as const,column: "ingestionApiKey",@@ -224,14 +259,6 @@ export const observationEventsFilterConfig: FilterConfig = {column: "experimentName",label: getEventsColumnName("experimentName"),},- {- type: "numeric" as const,- column: "latency",- label: getEventsColumnName("latency"),- min: 0,- max: 60,- unit: "s",- },{type: "numeric" as const,column: "timeToFirstToken",@@ -309,22 +336,11 @@ export const observationEventsFilterConfig: FilterConfig = {min: 0,max: 25,},- // The "Scores" facets are level-agnostic: their filter matches a score at- // observation OR trace level (LFE-10596), and their options list all score- // names. The trace-only `trace_scores_avg` / `trace_score_categories` /- // `trace_score_booleans` columns stay valid (search bar `traceScores.` +- // existing saved views) but are no longer offered as separate sidebar- // facets β one "Scores" group.{type: "keyValue" as const,column: "score_categories",label: "Categorical Scores",},- {- type: "numericKeyValue" as const,- column: "scores_avg",- label: "Numeric Scores",- },{type: "booleanKeyValue" as const,column: "score_booleans",diff --git a/web/src/features/filters/hooks/useSidebarFilterState.tsx b/web/src/features/filters/hooks/useSidebarFilterState.tsxindex 612e75c092..93ece9b355 100644--- a/web/src/features/filters/hooks/useSidebarFilterState.tsx+++ b/web/src/features/filters/hooks/useSidebarFilterState.tsx@@ -1991,6 +1991,9 @@ export function useSidebarFilterPresentation(// Exposed so view-layer captures (DataTableControls) carry the same// v3-vs-v4 dimension as the hook's own events.isV4: isV4Surface,+ // The curated default-visible facet set; DataTableControls folds the+ // rest behind "Show N more".+ commonFacets: config.commonFacets,};}diff --git a/web/src/features/filters/lib/facet-order.clienttest.ts b/web/src/features/filters/lib/facet-order.clienttest.tsindex 564a947922..fd54f8653b 100644--- a/web/src/features/filters/lib/facet-order.clienttest.ts+++ b/web/src/features/filters/lib/facet-order.clienttest.ts@@ -50,18 +50,32 @@ describe("facet order", () => {expect(shown(order)).toEqual(["alpha", "gamma", "beta"]);});- it("never holds a stale block: an outstanding interaction cannot survive an empty set or a boundary", () => {- // beta settled on top, then three in-list edits that changed values but not- // promotion: none of them consumed its token, so one is still outstanding.+ it("holds the block when the user clears the sole remaining facet in-list", () => {+ // beta is the only promoted facet; the user clears it inside the list.const order = settleFacetOrder(["beta"]);- const token = 3;- // Clearing everything settles regardless β no block to hold, no separator.- expect(shown(advanceFacetOrder(order, [], token))).toEqual([+ // Attributed to an in-list interaction: beta keeps its place until the+ // next settle instead of vanishing behind the fold mid-gesture.+ expect(shown(advanceFacetOrder(order, [], 1))).toEqual([+ "beta",+ "alpha",+ "gamma",+ ]);++ // An external empty (cleared search bar) carries no new interaction and+ // falls back to plain config order.+ expect(shown(advanceFacetOrder(order, [], 0))).toEqual(["alpha","beta","gamma",]);+ });++ it("a boundary the sidebar owns drops outstanding attribution before the next change", () => {+ // beta settled on top, then in-list edits that changed values but not+ // promotion: none of them consumed the token, so one is still outstanding.+ const order = settleFacetOrder(["beta"]);+ const token = 3;// Left outstanding, the attribution would hold the old blockβ¦expect(shown(advanceFacetOrder(order, ["gamma"], token))).toEqual([diff --git a/web/src/features/filters/lib/facet-order.ts b/web/src/features/filters/lib/facet-order.tsindex e1128ee15e..d1114dde83 100644--- a/web/src/features/filters/lib/facet-order.ts+++ b/web/src/features/filters/lib/facet-order.ts@@ -56,11 +56,12 @@ export function advanceFacetOrder(): FacetOrder {const key = orderKey(promotedColumns);if (key === order.key) return order;- // Nothing promoted means there is no block to protect, so never hold a stale- // one: whatever emptied the filters (Clear all, a cleared search bar) must- // fall back to plain config order.- const holdOrder =- promotedColumns.length > 0 && interactionToken !== order.interactionToken;+ // Attribution alone decides: clearing the sole remaining facet in-list must+ // hold its place until the next settle, exactly like any other in-list+ // clear. External empties (a cleared search bar) carry no new interaction+ // and the owned boundaries (Clear all, AI apply) consume outstanding tokens+ // via settleOnNextChange, so both still fall back to plain config order.+ const holdOrder = interactionToken !== order.interactionToken;return holdOrder? { promoted: order.promoted, key, interactionToken }: settleFacetOrder(promotedColumns, interactionToken);diff --git a/web/src/features/filters/lib/filter-config.ts b/web/src/features/filters/lib/filter-config.tsindex 846cca01ae..7d40c2ab90 100644--- a/web/src/features/filters/lib/filter-config.ts+++ b/web/src/features/filters/lib/filter-config.ts@@ -79,6 +79,14 @@ export interface FilterConfig {columnDefinitions: ColumnDefinition[];defaultExpanded?: string[];defaultSidebarCollapsed?: boolean;+ /**+ * The facets most sessions actually use (curated from PostHog+ * `filters:applied` data). When set, the sidebar shows only+ * these by default and folds the rest behind a "Show N more" control.+ * A facet with an active filter is always shown regardless of this list.+ * Unset = every facet stays visible (tables that haven't opted in).+ */+ commonFacets?: string[];facets: Facet[];/** Runs after display-name normalization and before filter validation. */migrateFilterState?: FilterStateMigration;@@ -106,6 +114,9 @@ export function omitFilterFacets(defaultExpanded: config.defaultExpanded?.filter((column) => !omittedColumnSet.has(column),),+ commonFacets: config.commonFacets?.filter(+ (column) => !omittedColumnSet.has(column),+ ),facets: config.facets.filter((facet) => !omittedColumnSet.has(facet.column),),diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex b711c298c0..05c5819a4d 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -395,6 +395,7 @@ export const events = {"facet_operator_toggled","active_only_toggled","facet_added",+ "facet_fold_toggled","facet_search","facet_mode_switched","sidebar_toggled",