🪢 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(sessions): persist header detail visibility (#16779)
Nimaree532f7aef7d
diff --git a/web/src/components/session/ModernSessionHeader.clienttest.tsx b/web/src/components/session/ModernSessionHeader.clienttest.tsxnew file mode 100644index 0000000000..b2f0861423--- /dev/null+++ b/web/src/components/session/ModernSessionHeader.clienttest.tsx@@ -0,0 +1,224 @@+import { fireEvent, render, screen } from "@testing-library/react";+import { type ReactNode } from "react";+import { afterEach, describe, expect, it, vi } from "vitest";++import { ModernSessionHeader } from "@/src/components/session/ModernSessionHeader";+import { sessionHeaderVisibilityStorageKey } from "@/src/components/session/sessionHeaderVisibility";++const capture = vi.hoisted(() => vi.fn());++vi.mock("@/src/features/posthog-analytics/usePostHogClientCapture", () => ({+ usePostHogClientCapture: () => capture,+}));++vi.mock("@/src/components/SingleLineOverflowList", () => ({+ SingleLineOverflowList: ({+ items,+ additionalOverflowCount,+ getKey,+ renderItem,+ renderOverflow,+ trailingContent,+ }: {+ items: readonly { key: string }[];+ additionalOverflowCount: number;+ getKey: (item: { key: string }) => string;+ renderItem: (item: { key: string }) => ReactNode;+ renderOverflow: (props: {+ hiddenItems: readonly { key: string }[];+ overflowItemCount: number;+ }) => ReactNode;+ trailingContent?: ReactNode;+ }) => (+ <div>+ {items.map((item) => (+ <div key={getKey(item)}>{renderItem(item)}</div>+ ))}+ {additionalOverflowCount > 0+ ? renderOverflow({+ hiddenItems: [],+ overflowItemCount: additionalOverflowCount,+ })+ : null}+ {trailingContent}+ </div>+ ),+}));++const defaultProps = {+ projectId: "project-1",+ countTraces: 3,+ traces: {+ state: "loaded" as const,+ data: [{ latencyMs: null, observationCount: 7 }],+ },+ tokensIn: 0,+ tokensOut: 0,+ totalTokens: 0,+ totalCost: 0.12,+ environment: null,+ users: [],+ metadataJsonPaths: {+ paths: [],+ source: { state: "idle" as const },+ onEditorOpenChange: vi.fn(),+ onSave: vi.fn(),+ onRemove: vi.fn(),+ },+ scores: [],+};++describe("ModernSessionHeader", () => {+ afterEach(() => {+ capture.mockClear();+ localStorage.clear();+ });++ it("hides and reveals a detail while persisting the preference", () => {+ render(<ModernSessionHeader {...defaultProps} />);++ fireEvent.click(+ screen.getByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ );++ expect(+ screen.queryByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ ).not.toBeInTheDocument();+ expect(+ localStorage.getItem(sessionHeaderVisibilityStorageKey("project-1")),+ ).toBe(JSON.stringify(["traces"]));+ expect(capture).toHaveBeenCalledWith(+ "session_detail:header_detail_visibility_changed",+ {+ action: "hide",+ detailType: "traces",+ storedHiddenDetailCount: 1,+ isV4: true,+ },+ );++ fireEvent.click(+ screen.getByRole("button", {+ name: "Show 1 hidden session details",+ }),+ );+ fireEvent.click(+ screen.getByRole("button", {+ name: "Show trace and span counts in session header",+ }),+ );++ expect(+ screen.getByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ ).toBeInTheDocument();+ expect(+ localStorage.getItem(sessionHeaderVisibilityStorageKey("project-1")),+ ).toBe(JSON.stringify([]));+ expect(capture).toHaveBeenCalledTimes(2);+ expect(capture).toHaveBeenLastCalledWith(+ "session_detail:header_detail_visibility_changed",+ {+ action: "show",+ detailType: "traces",+ storedHiddenDetailCount: 0,+ isV4: true,+ },+ );+ });++ it("restores hidden details from project-scoped local storage", () => {+ localStorage.setItem(+ sessionHeaderVisibilityStorageKey("project-1"),+ JSON.stringify(["traces"]),+ );+ render(<ModernSessionHeader {...defaultProps} />);++ expect(+ screen.queryByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ ).not.toBeInTheDocument();+ fireEvent.click(+ screen.getByRole("button", {+ name: "Show 1 hidden session details",+ }),+ );+ expect(+ screen.getByRole("button", {+ name: "Show trace and span counts in session header",+ }),+ ).toBeInTheDocument();+ });++ it("does not persist customer identifiers in dynamic detail keys", () => {+ const userId = "[email protected]";+ render(<ModernSessionHeader {...defaultProps} users={[userId]} />);++ fireEvent.click(+ screen.getByRole("button", {+ name: "Hide user 1 in session header",+ }),+ );++ const storedValue = localStorage.getItem(+ sessionHeaderVisibilityStorageKey("project-1"),+ );+ expect(storedValue).not.toContain(userId);+ expect(JSON.parse(storedValue ?? "[]")).toHaveLength(1);+ });++ it("preserves preferences for details that are temporarily unavailable", () => {+ const storageKey = sessionHeaderVisibilityStorageKey("project-1");+ localStorage.setItem(storageKey, JSON.stringify(["latency"]));+ render(+ <ModernSessionHeader {...defaultProps} traces={{ state: "loading" }} />,+ );++ fireEvent.click(+ screen.getByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ );++ expect(JSON.parse(localStorage.getItem(storageKey) ?? "[]")).toEqual([+ "latency",+ "traces",+ ]);+ });++ it("lets overflow-only users participate in visibility preferences", () => {+ const users = [+ "[email protected]",+ "[email protected]",+ "[email protected]",+ "[email protected]",+ ];+ render(<ModernSessionHeader {...defaultProps} users={users} />);++ fireEvent.click(+ screen.getByRole("button", {+ name: "Show 1 hidden session details",+ }),+ );+ const hideOverflowUser = screen.getByRole("button", {+ name: "Hide user 4 in session header",+ });+ hideOverflowUser.focus();+ fireEvent.click(hideOverflowUser);++ const showOverflowUser = screen.getByRole("button", {+ name: "Show user 4 in session header",+ });+ expect(showOverflowUser).toBeInTheDocument();+ expect(showOverflowUser).toHaveFocus();+ expect(+ localStorage.getItem(sessionHeaderVisibilityStorageKey("project-1")),+ ).not.toContain(users[3]);+ });+});diff --git a/web/src/components/session/ModernSessionHeader.stories.tsx b/web/src/components/session/ModernSessionHeader.stories.tsxindex 0e81b82fed..8442b69fdb 100644--- a/web/src/components/session/ModernSessionHeader.stories.tsx+++ b/web/src/components/session/ModernSessionHeader.stories.tsx@@ -3,6 +3,7 @@ import { expect, fn, userEvent, waitFor, within } from "storybook/test";import preview from "../../../.storybook/preview";import { ModernSessionHeader } from "@/src/components/session/ModernSessionHeader";+import { sessionHeaderVisibilityStorageKey } from "@/src/components/session/sessionHeaderVisibility";const scores = [{@@ -330,3 +331,80 @@ export const TestCompactsTokenCounts = meta.story({);},});++export const TestHidesAndRevealsDetails = meta.story({+ name: "(Test) Hides and reveals details",+ args: {+ ...defaultArgs,+ projectId: "project-header-visibility-story",+ },+ play: async ({ canvasElement }) => {+ const storageKey = sessionHeaderVisibilityStorageKey(+ "project-header-visibility-story",+ );+ const storedValue = JSON.stringify([]);+ localStorage.setItem(storageKey, storedValue);+ window.dispatchEvent(+ new CustomEvent("localStorageChange", {+ detail: { key: storageKey, newValue: storedValue },+ }),+ );++ const canvas = within(canvasElement);+ const hideTraceDetail = await canvas.findByRole("button", {+ name: "Hide trace and span counts in session header",+ });+ const visibleTraceDetail = hideTraceDetail.closest(+ "[data-overflow-visible-item='true']",+ );+ await expect(visibleTraceDetail).toBeInTheDocument();+ hideTraceDetail.focus();+ await waitFor(() => expect(hideTraceDetail).toBeVisible());+ await expect(+ hideTraceDetail.getBoundingClientRect().width,+ ).toBeGreaterThanOrEqual(24);+ await expect(+ hideTraceDetail.getBoundingClientRect().height,+ ).toBeGreaterThanOrEqual(24);+ await userEvent.click(hideTraceDetail);+ await expect(+ canvas.queryByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ ).not.toBeInTheDocument();+ await expect(+ JSON.parse(localStorage.getItem(storageKey) ?? "[]"),+ ).toContain("traces");++ const overflowButton = canvas.getByRole("button", {+ name: /show \d+ hidden session details/i,+ });+ await waitFor(() => expect(overflowButton).toHaveFocus());+ await userEvent.click(overflowButton);+ const body = within(canvasElement.ownerDocument.body);+ const overflowSearchInput = await body.findByRole("textbox", {+ name: "Search session details",+ });+ const showTraceDetail = await body.findByRole("button", {+ name: "Show trace and span counts in session header",+ });+ showTraceDetail.focus();+ await waitFor(() => expect(showTraceDetail).toBeVisible());+ await userEvent.click(showTraceDetail);++ await expect(+ canvas.getByRole("button", {+ name: "Hide trace and span counts in session header",+ }),+ ).toBeInTheDocument();+ await expect(localStorage.getItem(storageKey)).toBe(JSON.stringify([]));+ const metadataEditorButton = canvas.getByRole("button", {+ name: "Add metadata JSONPath",+ });+ await waitFor(() =>+ expect([overflowSearchInput, metadataEditorButton]).toContain(+ canvasElement.ownerDocument.activeElement,+ ),+ );+ },+});diff --git a/web/src/components/session/ModernSessionHeader.tsx b/web/src/components/session/ModernSessionHeader.tsxindex e9702704df..6420176906 100644--- a/web/src/components/session/ModernSessionHeader.tsx+++ b/web/src/components/session/ModernSessionHeader.tsx@@ -1,9 +1,15 @@import { percentile, type ScoreDomain } from "@langfuse/shared";-import { ArrowUpRight, Plus, Search, X } from "lucide-react";-import { type ReactNode, type SyntheticEvent, useState } from "react";+import { ArrowUpRight, Eye, EyeOff, Plus, Search, X } from "lucide-react";+import { type ReactNode, type SyntheticEvent, useRef, useState } from "react";import { SingleLineOverflowList } from "@/src/components/SingleLineOverflowList";import { ModernSessionHeaderPill } from "@/src/components/session/ModernSessionHeaderPill";+import {+ MAX_STORED_HIDDEN_SESSION_HEADER_DETAILS,+ parseStoredHiddenSessionHeaderDetails,+ sessionHeaderDynamicDetailKey,+ sessionHeaderVisibilityStorageKey,+} from "@/src/components/session/sessionHeaderVisibility";import {getMetadataJsonPathLabel,resolveMetadataJsonPath,@@ -22,6 +28,7 @@ import {PopoverContent,PopoverTrigger,} from "@/src/components/ui/popover";+import useLocalStorage from "@/src/components/useLocalStorage";import { formatIntervalSeconds } from "@/src/utils/dates";import { type WithStringifiedMetadata } from "@/src/utils/clientSideDomainTypes";import {@@ -29,6 +36,7 @@ import {numberFormatter,usdFormatter,} from "@/src/utils/numbers";+import { cn } from "@/src/utils/tailwind";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";type ModernSessionHeaderProps = {@@ -58,6 +66,28 @@ type ModernSessionHeaderProps = {>;};+type SessionHeaderDetailType =+ | "cost"+ | "environment"+ | "latency"+ | "metadata"+ | "score"+ | "tokens"+ | "traces"+ | "user";++type SessionHeaderDetail = {+ key: string;+ searchText: string;+ visibilityLabel: string;+ type: SessionHeaderDetailType;+ content: ReactNode;+};++type SessionHeaderDetailControlLocation = "header" | "overflow";++const EMPTY_HIDDEN_SESSION_HEADER_DETAILS: readonly string[] = [];+const ChipValue = ({ children }: { children: React.ReactNode }) => (<span className="text-foreground">{children}</span>);@@ -93,6 +123,50 @@ const UserChip = ({ projectId, user }: { projectId: string; user: string }) => (</ModernSessionHeaderPill>);+const SessionHeaderDetailWithVisibilityControl = ({+ detail,+ isHidden,+ location,+ onVisibilityChange,+}: {+ detail: SessionHeaderDetail;+ isHidden: boolean;+ location: SessionHeaderDetailControlLocation;+ onVisibilityChange: (+ detail: SessionHeaderDetail,+ isHidden: boolean,+ location: SessionHeaderDetailControlLocation,+ control: HTMLButtonElement,+ ) => void;+}) => {+ const action = isHidden ? "Show" : "Hide";+ return (+ <span+ className={cn(+ "group relative flex items-center",+ detail.type === "metadata" ? "pr-6" : "[@media(hover:none)]:pr-6",+ )}+ >+ {detail.content}+ <button+ type="button"+ aria-label={`${action} ${detail.visibilityLabel} in session header`}+ title={`${action} in session header`}+ className="bg-header hover:bg-muted focus-visible:ring-ring absolute right-0 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-sm border opacity-0 shadow-sm transition-opacity group-focus-within:opacity-100 group-hover:opacity-100 focus-visible:ring-1 focus-visible:outline-none [@media(hover:none)]:opacity-100"+ onClick={(event) =>+ onVisibilityChange(detail, !isHidden, location, event.currentTarget)+ }+ >+ {isHidden ? (+ <Eye aria-hidden="true" className="h-3 w-3" />+ ) : (+ <EyeOff aria-hidden="true" className="h-3 w-3" />+ )}+ </button>+ </span>+ );+};+const resolveAgainstSource = (source: FirstVisibleObservationMetadataState,path: string,@@ -271,6 +345,17 @@ export function ModernSessionHeader({scores,}: ModernSessionHeaderProps) {const capture = usePostHogClientCapture();+ const [rawHiddenDetailKeys, setRawHiddenDetailKeys] =+ useLocalStorage<unknown>(+ sessionHeaderVisibilityStorageKey(projectId),+ EMPTY_HIDDEN_SESSION_HEADER_DETAILS,+ );+ const hiddenDetailKeys =+ parseStoredHiddenSessionHeaderDetails(rawHiddenDetailKeys);+ const hiddenDetailKeySet = new Set(hiddenDetailKeys);+ const overflowButtonRef = useRef<HTMLButtonElement>(null);+ const metadataEditorButtonRef = useRef<HTMLButtonElement>(null);+ const overflowSearchInputRef = useRef<HTMLInputElement>(null);const [search, setSearch] = useState("");const [visibleUserCount, setVisibleUserCount] = useState(SESSION_USERS_PER_PAGE,@@ -311,33 +396,36 @@ export function ModernSessionHeader({const p50LatencyMs = latencies.length > 0 ? percentile(latencies, 0.5) : null;const p95LatencyMs =latencies.length > 0 ? percentile(latencies, 0.95) : null;- const pills: Array<{ key: string; searchText: string; content: ReactNode }> =- [- {- key: "traces",- searchText: `traces ${countTraces} spans ${spanCount ?? ""}`,- content: (- <ModernSessionHeaderPill variant="display">- <span>- <ChipValue>{numberFormatter(countTraces, 0)}</ChipValue> traces- </span>- {spanCount !== null ? (- <>- <ChipDot />- <span>- <ChipValue>{numberFormatter(spanCount, 0)}</ChipValue> spans- </span>- </>- ) : null}- </ModernSessionHeaderPill>- ),- },- ];+ const pills: SessionHeaderDetail[] = [+ {+ key: "traces",+ searchText: `traces ${countTraces} spans ${spanCount ?? ""}`,+ visibilityLabel: "trace and span counts",+ type: "traces",+ content: (+ <ModernSessionHeaderPill variant="display">+ <span>+ <ChipValue>{numberFormatter(countTraces, 0)}</ChipValue> traces+ </span>+ {spanCount !== null ? (+ <>+ <ChipDot />+ <span>+ <ChipValue>{numberFormatter(spanCount, 0)}</ChipValue> spans+ </span>+ </>+ ) : null}+ </ModernSessionHeaderPill>+ ),+ },+ ];if (p50LatencyMs !== null) {pills.push({key: "latency",searchText: `latency p50 ${p50LatencyMs} p95 ${p95LatencyMs ?? ""}`,+ visibilityLabel: "latency percentiles",+ type: "latency",content: (<ModernSessionHeaderPill variant="display"><span>@@ -365,6 +453,8 @@ export function ModernSessionHeader({pills.push({key: "tokens",searchText: `tokens ${tokensIn} ${tokensOut} ${totalTokens}`,+ visibilityLabel: "token usage",+ type: "tokens",content: (<ModernSessionHeaderPillvariant="display"@@ -386,6 +476,8 @@ export function ModernSessionHeader({pills.push({key: "cost",searchText: `cost ${totalCost}`,+ visibilityLabel: "cost",+ type: "cost",content: (<ModernSessionHeaderPillvariant="display"@@ -398,7 +490,7 @@ export function ModernSessionHeader({),});- scores.forEach((score) => {+ scores.forEach((score, index) => {const value = scoreChipValue(score);const isFraction =score.dataType === "NUMERIC" &&@@ -407,8 +499,10 @@ export function ModernSessionHeader({score.value >= 0 &&score.value <= 1;pills.push({- key: `score-${score.id}`,+ key: sessionHeaderDynamicDetailKey("score", score.id),searchText: `score ${score.name} ${value}`,+ visibilityLabel: `score ${index + 1}`,+ type: "score",content: (<ModernSessionHeaderPill variant="display" title={score.name}>{isFraction ? (@@ -427,6 +521,8 @@ export function ModernSessionHeader({pills.push({key: "environment",searchText: `environment env ${environment}`,+ visibilityLabel: "environment",+ type: "environment",content: (<ModernSessionHeaderPill variant="display"><span>@@ -437,23 +533,36 @@ export function ModernSessionHeader({});}- users.slice(0, INITIAL_SESSION_USERS_DISPLAY_COUNT).forEach((user) => {- pills.push({- key: `user-${user}`,+ const userDetails = users.map(+ (user, index): SessionHeaderDetail => ({+ key: sessionHeaderDynamicDetailKey("user", user),searchText: `user ${user}`,+ visibilityLabel: `user ${index + 1}`,+ type: "user",content: <UserChip projectId={projectId} user={user} />,- });- });- const remainingUsers = users.slice(INITIAL_SESSION_USERS_DISPLAY_COUNT);+ }),+ );+ const visibleUserDetails = userDetails+ .filter((detail) => !hiddenDetailKeySet.has(detail.key))+ .slice(0, INITIAL_SESSION_USERS_DISPLAY_COUNT);+ visibleUserDetails.forEach((detail) => pills.push(detail));+ const visibleUserDetailKeySet = new Set(+ visibleUserDetails.map((detail) => detail.key),+ );+ const overflowUserDetails = userDetails.filter(+ (detail) => !visibleUserDetailKeySet.has(detail.key),+ );- metadataJsonPaths.paths.forEach((path) => {+ metadataJsonPaths.paths.forEach((path, index) => {const display = getConfiguredMetadataDisplay(path,metadataJsonPaths.source,);pills.push({- key: `metadata-${path}`,+ key: sessionHeaderDynamicDetailKey("metadata", path),searchText: `metadata ${display.path} ${display.label} ${display.displayValue}`,+ visibilityLabel: `metadata ${index + 1}`,+ type: "metadata",content: (<MetadataJsonPathPilldisplay={display}@@ -462,14 +571,68 @@ export function ModernSessionHeader({),});});+ const visiblePills = pills.filter(+ (pill) => !hiddenDetailKeySet.has(pill.key),+ );+ const manuallyHiddenPills = pills.filter((pill) =>+ hiddenDetailKeySet.has(pill.key),+ );+ const changeDetailVisibility = (+ detail: SessionHeaderDetail,+ isHidden: boolean,+ location: SessionHeaderDetailControlLocation,+ control: HTMLButtonElement,+ ) => {+ if (hiddenDetailKeySet.has(detail.key) === isHidden) return;++ setRawHiddenDetailKeys((current: unknown) => {+ const currentKeys = parseStoredHiddenSessionHeaderDetails(current);+ return isHidden+ ? currentKeys+ .concat(detail.key)+ .slice(-MAX_STORED_HIDDEN_SESSION_HEADER_DETAILS)+ : currentKeys.filter((key) => key !== detail.key);+ });+ capture("session_detail:header_detail_visibility_changed", {+ action: isHidden ? "hide" : "show",+ detailType: detail.type,+ storedHiddenDetailCount: Math.min(+ Math.max(hiddenDetailKeys.length + (isHidden ? 1 : -1), 0),+ MAX_STORED_HIDDEN_SESSION_HEADER_DETAILS,+ ),+ isV4: true,+ });+ window.requestAnimationFrame(() => {+ if (control.isConnected) return;++ const preferredTarget =+ location === "overflow"+ ? overflowSearchInputRef.current+ : overflowButtonRef.current;+ (+ preferredTarget ??+ overflowButtonRef.current ??+ metadataEditorButtonRef.current+ )?.focus();+ });+ };return (<div className="bg-header border-b px-4 py-2"><SingleLineOverflowList- items={pills}- additionalOverflowCount={remainingUsers.length}+ items={visiblePills}+ additionalOverflowCount={+ overflowUserDetails.length + manuallyHiddenPills.length+ }getKey={(pill) => pill.key}- renderItem={(pill) => pill.content}+ renderItem={(pill) => (+ <SessionHeaderDetailWithVisibilityControl+ detail={pill}+ isHidden={false}+ location="header"+ onVisibilityChange={changeDetailVisibility}+ />+ )}trailingContent={<Popoveropen={isMetadataEditorOpen}@@ -479,6 +642,7 @@ export function ModernSessionHeader({<ModernSessionHeaderPillvariant="button"ariaLabel="Add metadata JSONPath"+ ref={metadataEditorButtonRef}><Plus className="h-3 w-3" /></ModernSessionHeaderPill>@@ -494,17 +658,27 @@ export function ModernSessionHeader({}renderOverflow={({ hiddenItems: hiddenPills, overflowItemCount }) => {const normalizedSearch = search.trim().toLocaleLowerCase();+ const overflowPillKeys = new Set(+ hiddenPills+ .map((pill) => pill.key)+ .concat(manuallyHiddenPills.map((pill) => pill.key)),+ );+ const overflowPills = pills.filter((pill) =>+ overflowPillKeys.has(pill.key),+ );const filteredPills = normalizedSearch- ? hiddenPills.filter((pill) =>+ ? overflowPills.filter((pill) =>pill.searchText.toLocaleLowerCase().includes(normalizedSearch),)- : hiddenPills;- const filteredUsers = normalizedSearch- ? remainingUsers.filter((user) =>- user.toLocaleLowerCase().includes(normalizedSearch),+ : overflowPills;+ const filteredUserDetails = normalizedSearch+ ? overflowUserDetails.filter((detail) =>+ detail.searchText+ .toLocaleLowerCase()+ .includes(normalizedSearch),)- : remainingUsers;- const visibleUsers = filteredUsers.slice(0, visibleUserCount);+ : overflowUserDetails;+ const visibleUsers = filteredUserDetails.slice(0, visibleUserCount);const hasResults =filteredPills.length > 0 || visibleUsers.length > 0;@@ -520,6 +694,7 @@ export function ModernSessionHeader({<ModernSessionHeaderPillvariant="button"ariaLabel={`Show ${overflowItemCount} hidden session details`}+ ref={overflowButtonRef}>+{overflowItemCount}</ModernSessionHeaderPill>@@ -532,6 +707,7 @@ export function ModernSessionHeader({<div className="relative border-b p-2"><Search className="text-muted-foreground absolute top-1/2 left-4 h-3.5 w-3.5 -translate-y-1/2" /><Input+ ref={overflowSearchInputRef}value={search}onChange={(event) => {setSearch(event.target.value);@@ -557,7 +733,7 @@ export function ModernSessionHeader({setVisibleUserCount((current) =>Math.min(current + SESSION_USERS_PER_PAGE,- filteredUsers.length,+ filteredUserDetails.length,),);}}@@ -565,13 +741,21 @@ export function ModernSessionHeader({{hasResults ? (<>{filteredPills.map((pill) => (- <div key={pill.key}>{pill.content}</div>+ <SessionHeaderDetailWithVisibilityControl+ key={pill.key}+ detail={pill}+ isHidden={hiddenDetailKeySet.has(pill.key)}+ location="overflow"+ onVisibilityChange={changeDetailVisibility}+ />))}- {visibleUsers.map((user) => (- <UserChip- key={user}- projectId={projectId}- user={user}+ {visibleUsers.map((detail) => (+ <SessionHeaderDetailWithVisibilityControl+ key={detail.key}+ detail={detail}+ isHidden={hiddenDetailKeySet.has(detail.key)}+ location="overflow"+ onVisibilityChange={changeDetailVisibility}/>))}</>diff --git a/web/src/components/session/sessionHeaderVisibility.ts b/web/src/components/session/sessionHeaderVisibility.tsnew file mode 100644index 0000000000..51700f0105--- /dev/null+++ b/web/src/components/session/sessionHeaderVisibility.ts@@ -0,0 +1,36 @@+import { z } from "zod";++export const MAX_STORED_HIDDEN_SESSION_HEADER_DETAILS = 1_000;++const storedHiddenSessionHeaderDetailsSchema = z+ .array(z.string().min(1).max(2_000))+ .max(MAX_STORED_HIDDEN_SESSION_HEADER_DETAILS)+ .transform((keys) => Array.from(new Set(keys)));++export type StoredHiddenSessionHeaderDetails = z.infer<+ typeof storedHiddenSessionHeaderDetailsSchema+>;++export const sessionHeaderVisibilityStorageKey = (projectId: string) =>+ `modern-session:hidden-header-details:v1:${projectId}`;++export const sessionHeaderDynamicDetailKey = (+ type: "metadata" | "score" | "user",+ identity: string,+) => {+ let firstFingerprint = 2_166_136_261;+ let secondFingerprint = 2_654_435_769;+ for (let index = 0; index < identity.length; index += 1) {+ const codeUnit = identity.charCodeAt(index);+ firstFingerprint = Math.imul(firstFingerprint ^ codeUnit, 16_777_619);+ secondFingerprint = Math.imul(secondFingerprint ^ codeUnit, 2_246_822_519);+ }+ return `${type}-${(firstFingerprint >>> 0).toString(36)}-${(secondFingerprint >>> 0).toString(36)}`;+};++export const parseStoredHiddenSessionHeaderDetails = (+ raw: unknown,+): StoredHiddenSessionHeaderDetails => {+ const result = storedHiddenSessionHeaderDetailsSchema.safeParse(raw);+ return result.success ? result.data : [];+};diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.tsindex 07a6743929..11ea82c25b 100644--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts@@ -150,6 +150,7 @@ const events = {"inline_tools_toggled","system_prompt_toggled","metadata_jsonpath_config_changed",+ "header_detail_visibility_changed",],eval_config: ["new_form_submit",