🪢 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(topics): move time selector and restore tabs (#18532)
Nimar3dd21f2018d3
diff --git a/web/src/features/topics/TopicPipelineForm.tsx b/web/src/features/topics/TopicPipelineForm.tsxindex 0649ecac72..bd8531aad0 100644--- a/web/src/features/topics/TopicPipelineForm.tsx+++ b/web/src/features/topics/TopicPipelineForm.tsx@@ -179,7 +179,7 @@ export function useTopicPipelineForm({const values = (() => {if (operation === "update") {if (!timeRange)- throw new Error("Select a time range of at most 93 days.");+ throw new Error("Select a time range of at most 90 days.");return {...base,operation,diff --git a/web/src/features/topics/TopicsActionsMenu.tsx b/web/src/features/topics/TopicsActionsMenu.tsxindex c5e1455ba0..c2cd379b7c 100644--- a/web/src/features/topics/TopicsActionsMenu.tsx+++ b/web/src/features/topics/TopicsActionsMenu.tsx@@ -60,7 +60,7 @@ export function TopicsActionsMenu({}type TopicsActionsMenuProps = {- children: ReactNode;+ children?: ReactNode;hasFacets: boolean;triggerAction: {label: string;diff --git a/web/src/features/topics/TopicsFilters.stories.tsx b/web/src/features/topics/TopicsFilters.stories.tsxindex d2f29b8099..8d35f6aa84 100644--- a/web/src/features/topics/TopicsFilters.stories.tsx+++ b/web/src/features/topics/TopicsFilters.stories.tsx@@ -10,24 +10,18 @@ const filterArgs = {{ facetId: "issues", name: "Issues" },],selectedFacetId: undefined,- timeWindow: "7",onSelectFacet: fn(),- onSelectTimeWindow: fn(),};const meta = preview.meta({ component: TopicsFilters });-export const Header = meta.story({- args: { ...filterArgs, layout: "header" },-});--export const Menu = meta.story({- args: { ...filterArgs, layout: "menu" },+export const Default = meta.story({+ args: filterArgs,});export const RetainsSelectionThroughRefresh = meta.story({name: "(Test) Retains selection through refresh and falls back after removal",- args: { ...filterArgs, layout: "header" },+ args: filterArgs,render: (args) => {const [facets, setFacets] = useState(args.facets);const [selectedFacetId, setSelectedFacetId] = useState(@@ -60,48 +54,19 @@ export const RetainsSelectionThroughRefresh = meta.story({},play: async ({ canvasElement, args }) => {const canvas = within(canvasElement);- const body = within(canvasElement.ownerDocument.body);- const picker = canvas.getByRole("combobox", { name: "Topics facet" });- await expect(picker).toHaveTextContent("Intent");- await userEvent.click(picker);- await userEvent.click(body.getByRole("option", { name: "Issues" }));+ const intent = canvas.getByRole("tab", { name: "Intent" });+ const issues = canvas.getByRole("tab", { name: "Issues" });+ await expect(intent).toHaveAttribute("aria-selected", "true");+ await userEvent.click(issues);await expect(args.onSelectFacet).toHaveBeenCalledWith("issues");- await expect(picker).toHaveTextContent("Issues");+ await expect(issues).toHaveAttribute("aria-selected", "true");await userEvent.click(canvas.getByRole("button", { name: "Refresh facets" }),);- await expect(picker).toHaveTextContent("Issues");+ await expect(issues).toHaveAttribute("aria-selected", "true");await userEvent.click(canvas.getByRole("button", { name: "Remove selected facet" }),);- await expect(picker).toHaveTextContent("Intent");- },-});--export const MenuTimeRangeSelection = meta.story({- name: "(Test) Selects time range from menu controls",- args: { ...filterArgs, layout: "menu" },- render: (args) => {- const [timeWindow, setTimeWindow] = useState(args.timeWindow);- function selectTimeWindow(value: string) {- setTimeWindow(value);- args.onSelectTimeWindow(value);- }- return (- <TopicsFilters- {...args}- timeWindow={timeWindow}- onSelectTimeWindow={selectTimeWindow}- />- );- },- play: async ({ canvasElement, args }) => {- const canvas = within(canvasElement);- const body = within(canvasElement.ownerDocument.body);- const picker = canvas.getByRole("combobox", { name: "Topics time range" });- await userEvent.click(picker);- await userEvent.click(body.getByRole("option", { name: "Last 30 days" }));- await expect(args.onSelectTimeWindow).toHaveBeenCalledWith("30");- await expect(picker).toHaveTextContent("Last 30 days");+ await expect(intent).toHaveAttribute("aria-selected", "true");},});diff --git a/web/src/features/topics/TopicsFilters.tsx b/web/src/features/topics/TopicsFilters.tsxindex d7e9918d98..304d93b30a 100644--- a/web/src/features/topics/TopicsFilters.tsx+++ b/web/src/features/topics/TopicsFilters.tsx@@ -1,79 +1,41 @@-import { SelectInput } from "@/src/components/design-system/SelectInput/SelectInput";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/src/components/ui/select";+import { type ReactNode } from "react";+import { Tabs } from "@/src/components/design-system/Tabs/Tabs";import { resolveTopicFacetId } from "./topic-facet-selection";-import { topicTimeRangePresets } from "./time-range";--const layouts = {- header: {- root: "ph-no-capture flex min-w-0 flex-wrap items-center gap-2",- facet: "w-44",- range: "w-36",- },- menu: {- root: "ph-no-capture flex flex-col gap-3 p-1",- facet: "flex w-full flex-col gap-1",- range: "flex w-full flex-col gap-1",- },-};export function TopicsFilters({- layout,facets,selectedFacetId,- timeWindow,onSelectFacet,- onSelectTimeWindow,+ children,}: TopicsFiltersProps) {const selectedFacet = resolveTopicFacetId(facets, selectedFacetId);- const classes = layouts[layout];+ if (!selectedFacet) return children;+return (- <div className={classes.root}>- {facets.length > 0 && selectedFacet && (- <div className={classes.facet}>- {layout === "menu" && (- <span className="text-muted-foreground text-xs">Facet</span>- )}- <Select value={selectedFacet} onValueChange={onSelectFacet}>- <SelectTrigger aria-label="Topics facet" className="h-8">- <SelectValue placeholder="Facet" />- </SelectTrigger>- <SelectContent className="ph-no-capture">- {facets.map((facet) => (- <SelectItem key={facet.facetId} value={facet.facetId}>- {facet.name}- </SelectItem>- ))}- </SelectContent>- </Select>+ <div className="ph-no-capture flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden">+ <Tabs value={selectedFacet} onValueChange={onSelectFacet} layout="fill">+ <div className="shrink-0 overflow-x-auto">+ <Tabs.List variant="underline" aria-label="Topics facets">+ {facets.map((facet) => (+ <Tabs.Trigger+ key={facet.facetId}+ value={facet.facetId}+ label={facet.name}+ />+ ))}+ </Tabs.List></div>- )}- <div className={classes.range}>- {layout === "menu" && (- <span className="text-muted-foreground text-xs">Time range</span>- )}- <SelectInput- aria-label="Topics time range"- placeholder="Topics time range"- value={timeWindow}- options={topicTimeRangePresets}- onValueChange={onSelectTimeWindow}- />- </div>+ <Tabs.Content value={selectedFacet} layout="fill">+ <div className="flex min-h-0 flex-1 flex-col pt-2">{children}</div>+ </Tabs.Content>+ </Tabs></div>);}type TopicsFiltersProps = {- layout: "header" | "menu";facets: readonly { facetId: string; name: string }[];selectedFacetId: string | undefined;- timeWindow: string;onSelectFacet: (facetId: string) => void;- onSelectTimeWindow: (value: string) => void;+ children?: ReactNode;};diff --git a/web/src/features/topics/TopicsPage.clienttest.tsx b/web/src/features/topics/TopicsPage.clienttest.tsxindex edc0ba8f0a..f6716d8f68 100644--- a/web/src/features/topics/TopicsPage.clienttest.tsx+++ b/web/src/features/topics/TopicsPage.clienttest.tsx@@ -2,6 +2,8 @@ import type { ReactNode } from "react";import { fireEvent, render, screen, within } from "@testing-library/react";import { afterEach, beforeEach, expect, it, vi } from "vitest";import TopicsPage from "./TopicsPage";+import { useGlobalDateRangeStore } from "@/src/features/global-time-range/globalDateRangeStore";+import { rangeToString, type TimeRange } from "@/src/utils/date-range-utils";const state = vi.hoisted(() => ({status: "failed",@@ -9,11 +11,37 @@ const state = vi.hoisted(() => ({updatedAt: "2026-09-23T12:00:00Z",retry: vi.fn(),refetchExecution: vi.fn(),+ dateRange: undefined as string | undefined,+ executionId: undefined as string | undefined,+ setQueryParams: vi.fn(),+ currentTopics: vi.fn(),+ pipeline: vi.fn(),+ picker: vi.fn(),}));+vi.mock("use-query-params", () => ({+ StringParam: {},+ useQueryParams: () => [{ dateRange: state.dateRange }, state.setQueryParams],+}));+vi.mock("@/src/components/layouts/page-header-controls-slot", () => ({+ PageHeaderControlsPortal: ({ children }: { children: ReactNode }) => children,+}));+vi.mock("@/src/components/date-picker", () => ({+ TimeRangePicker: (props: {+ timeRange: TimeRange;+ onTimeRangeChange: (range: TimeRange) => void;+ }) => {+ state.picker(props.timeRange);+ return (+ <button onClick={() => props.onTimeRangeChange({ range: "last30Days" })}>+ Select last 30 days+ </button>+ );+ },+}));vi.mock("next/router", () => ({useRouter: () => ({- query: { projectId: "project", executionId: "execution" },+ query: { projectId: "project", executionId: state.executionId },}),}));vi.mock("@/src/components/layouts/page", () => ({@@ -32,20 +60,24 @@ vi.mock("@/src/features/feature-flags/hooks/useIsFeatureEnabled", () => ({default: () => true,}));vi.mock("./TopicPipelineForm", () => ({- useTopicPipelineForm: () => ({- primaryAction: null,- openConfiguration: vi.fn(),- configuration: null,- }),+ useTopicPipelineForm: (input: unknown) => {+ state.pipeline(input);+ return {+ primaryAction: null,+ openConfiguration: vi.fn(),+ configuration: null,+ };+ },}));vi.mock("./CurrentTopics", () => ({- useCurrentTopics: ({- running,- refreshAfter,- }: {+ useCurrentTopics: (input: {running: boolean;refreshAfter: number;- }) => ({ running, refreshAfter, data: [] }),+ timeRange: { from: Date; to: Date };+ }) => {+ state.currentTopics(input);+ return { ...input, data: [] };+ },CurrentTopics: ({result,}: {@@ -103,6 +135,8 @@ vi.mock("@/src/utils/api", () => ({beforeEach(() => {vi.clearAllMocks();+ vi.useFakeTimers({ toFake: ["Date"] });+ vi.setSystemTime(new Date("2026-10-09T12:00:00Z"));vi.stubGlobal("ResizeObserver",class {@@ -114,11 +148,165 @@ beforeEach(() => {state.status = "failed";state.executionUpdatedAt = 110;state.updatedAt = "2026-09-23T12:00:00Z";+ state.dateRange = undefined;+ state.executionId = undefined;+ state.setQueryParams.mockImplementation(+ ({ dateRange }: { dateRange: string }) => {+ state.dateRange = dateRange;+ },+ );+ useGlobalDateRangeStore.persist.setOptions({+ storage: { getItem: () => null, setItem: vi.fn(), removeItem: vi.fn() },+ });+ useGlobalDateRangeStore.setState({ defaultsByProject: {} });+});++afterEach(() => {+ vi.unstubAllGlobals();+ vi.useRealTimers();});-afterEach(() => vi.unstubAllGlobals());+it.each([+ ["30d", 30 * 24 * 60],+ ["5m", 5],+ ["6h", 6 * 60],+])(+ "uses the shared project range %s for results and processing",+ (token, minutes) => {+ useGlobalDateRangeStore+ .getState()+ .actions.setProjectDefault("project", token);+ render(<TopicsPage />);+ const { timeRange } = state.currentTopics.mock.lastCall![0];+ expect(timeRange.to.getTime() - timeRange.from.getTime()).toBe(+ minutes * 60_000,+ );+ expect(state.pipeline).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange }),+ );++ fireEvent.click(+ screen.getByRole("button", { name: "Select last 30 days" }),+ );+ expect(state.dateRange).toBe("30d");+ expect(useGlobalDateRangeStore.getState().defaultsByProject.project).toBe(+ "30d",+ );+ },+);++it("keeps a URL custom range fixed when an execution completes", () => {+ const timeRange = {+ from: new Date("2026-09-01T12:34:00Z"),+ to: new Date("2026-09-02T15:45:00Z"),+ };+ state.dateRange = rangeToString(timeRange);+ state.status = "running";+ const view = render(<TopicsPage />);+ expect(state.currentTopics).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange }),+ );++ state.status = "completed";+ view.rerender(<TopicsPage />);+ expect(state.currentTopics).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange }),+ );+});++it.each(["stored", "URL"])(+ "caps an inherited one-year %s range without changing the shared selection",+ (source) => {+ useGlobalDateRangeStore+ .getState()+ .actions.setProjectDefault("project", "1y");+ state.dateRange = source === "URL" ? "1y" : undefined;+ render(<TopicsPage />);++ const { timeRange } = state.currentTopics.mock.lastCall![0];+ expect(timeRange).toEqual({+ from: new Date(Date.now() - 90 * 86_400_000),+ to: new Date(),+ });+ expect(state.picker).toHaveBeenLastCalledWith({ range: "last90Days" });+ expect(state.pipeline).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange }),+ );+ expect(screen.getByTestId("current-topics")).toBeInTheDocument();+ expect(screen.getByRole("status")).toHaveTextContent(+ "Your selection is preserved on other pages.",+ );+ expect(state.setQueryParams).not.toHaveBeenCalled();+ expect(state.dateRange).toBe(source === "URL" ? "1y" : undefined);+ expect(useGlobalDateRangeStore.getState().defaultsByProject.project).toBe(+ "1y",+ );++ fireEvent.click(+ screen.getByRole("button", { name: "Select last 30 days" }),+ );+ expect(state.dateRange).toBe("30d");+ expect(useGlobalDateRangeStore.getState().defaultsByProject.project).toBe(+ "30d",+ );+ expect(state.picker).toHaveBeenLastCalledWith({ range: "last30Days" });+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ },+);++it("caps a custom range at its original end and preserves its URL through completion", () => {+ const requested = {+ from: new Date("2026-03-01T12:34:00Z"),+ to: new Date("2026-09-02T15:45:00Z"),+ };+ const expected = {+ from: new Date(requested.to.getTime() - 90 * 86_400_000),+ to: requested.to,+ };+ state.dateRange = rangeToString(requested);+ state.status = "running";+ const view = render(<TopicsPage />);+ expect(state.currentTopics).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange: expected }),+ );+ expect(state.picker).toHaveBeenLastCalledWith(expected);+ expect(state.pipeline).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange: expected }),+ );+ expect(screen.getByRole("status")).toHaveTextContent(+ "final 90 days of your selected range",+ );++ state.status = "completed";+ view.rerender(<TopicsPage />);+ expect(state.currentTopics).toHaveBeenLastCalledWith(+ expect.objectContaining({ timeRange: expected }),+ );+ expect(state.setQueryParams).not.toHaveBeenCalled();+ expect(state.dateRange).toBe(rangeToString(requested));+ expect(useGlobalDateRangeStore.getState().defaultsByProject).toEqual({});+});++it.each([+ { range: "last90Days" },+ {+ from: new Date("2026-04-01T15:45:00Z"),+ to: new Date(new Date("2026-04-01T15:45:00Z").getTime() + 90 * 86_400_000),+ },+] satisfies TimeRange[])(+ "leaves an exact 90-day range unchanged: %j",+ (timeRange) => {+ state.dateRange = rangeToString(timeRange);+ render(<TopicsPage />);+ expect(state.picker).toHaveBeenLastCalledWith(timeRange);+ expect(screen.queryByRole("status")).not.toBeInTheDocument();+ expect(state.setQueryParams).not.toHaveBeenCalled();+ expect(screen.getByTestId("current-topics")).toBeInTheDocument();+ },+);it("refreshes current results through retry and completion for a selected run outside history", () => {+ state.executionId = "execution";const view = render(<TopicsPage />);const status = screen.getByRole("dialog", { name: "Run status" });fireEvent.click(@@ -149,3 +337,21 @@ it("refreshes current results through retry and completion for a selected run ouview.rerender(<TopicsPage />);expect(current).toHaveAttribute("data-refresh-after", completedAt);});++it("holds relative bounds between renders and advances them after completion", () => {+ state.status = "running";+ const view = render(<TopicsPage />);+ const initialRange = state.currentTopics.mock.lastCall![0].timeRange;++ vi.setSystemTime(new Date("2026-10-09T12:01:00Z"));+ view.rerender(<TopicsPage />);+ expect(state.currentTopics.mock.lastCall![0].timeRange).toEqual(initialRange);++ state.status = "completed";+ state.updatedAt = "2026-10-09T12:01:00Z";+ view.rerender(<TopicsPage />);+ expect(state.currentTopics.mock.lastCall![0].timeRange).toEqual({+ from: new Date("2026-10-02T12:01:00Z"),+ to: new Date("2026-10-09T12:01:00Z"),+ });+});diff --git a/web/src/features/topics/TopicsPage.tsx b/web/src/features/topics/TopicsPage.tsxindex 96c093b728..9741121d66 100644--- a/web/src/features/topics/TopicsPage.tsx+++ b/web/src/features/topics/TopicsPage.tsx@@ -1,5 +1,4 @@-import { useState } from "react";-import { format } from "date-fns";+import { useMemo, useState } from "react";import { MoreHorizontal } from "lucide-react";import { type UseQueryResult } from "@tanstack/react-query";import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";@@ -7,6 +6,14 @@ import { TablePeekViewTraceDetail } from "@/src/components/table/peek/peek-traceimport { useRouter } from "next/router";import { TextLink } from "@/src/components/design-system/TextLink/TextLink";import Page from "@/src/components/layouts/page";+import { PageHeaderControlsPortal } from "@/src/components/layouts/page-header-controls-slot";+import { TimeRangePicker } from "@/src/components/date-picker";+import { useGlobalDateRange } from "@/src/features/global-time-range/useGlobalDateRange";+import {+ DASHBOARD_AGGREGATION_OPTIONS,+ TABLE_AGGREGATION_OPTIONS,+ TIME_RANGES,+} from "@/src/utils/date-range-utils";import { ErrorPage } from "@/src/components/error-page";import { Button } from "@/src/components/design-system/Button/Button";import { Button as PopoverButton } from "@/src/components/ui/button";@@ -21,7 +28,6 @@ import {import { Input } from "@/src/components/design-system/Input/Input";import { DropdownMenu } from "@/src/components/design-system/DropdownMenu/DropdownMenu";import { IconButton } from "@/src/components/design-system/IconButton/IconButton";-import { DateRangeInput } from "@/src/features/evals/v2/components/Evaluators/EvaluatorBackfillSettings/components/DateRangeInput/DateRangeInput";import { Textarea } from "@/src/components/ui/textarea";import { PopoverController } from "@/src/components/ui/popover";import { Badge } from "@/src/components/design-system/Badge/Badge";@@ -47,12 +53,15 @@ import { TopicsFilters } from "./TopicsFilters";import { TopicsActionsMenu } from "./TopicsActionsMenu";import { TopicsWorkspaceGate } from "./TopicsWorkspaceGate";import { resolveTopicFacetId } from "./topic-facet-selection";-import {- isValidTopicTimeRange,- relativeTopicTimeRange,- topicCalendarDates,- topicCalendarRange,-} from "./time-range";+import { isValidTopicTimeRange } from "./time-range";++const maxTimeRangeMs = TIME_RANGES.last90Days.minutes * 60_000;+const sharedTimeRangePresets = [+ ...new Set([...TABLE_AGGREGATION_OPTIONS, ...DASHBOARD_AGGREGATION_OPTIONS]),+].sort((a, b) => TIME_RANGES[a].minutes - TIME_RANGES[b].minutes);+const topicsTimeRangePresets = sharedTimeRangePresets.filter(+ (range) => TIME_RANGES[range].minutes * 60_000 <= maxTimeRangeMs,+);const operationLabels: Record<TopicOperation, string> = {process: "Process traces",@@ -128,11 +137,13 @@ function TopicsWorkspaceView({facets: UseQueryResult<TopicFacet[], { message: string }>;}) {const [historyOpen, setHistoryOpen] = useState(false);- const [timeWindow, setTimeWindow] = useState("7");- const [timeRange, setTimeRange] = useState(() => relativeTopicTimeRange(7));+ const { timeRange, setTimeRange } = useGlobalDateRange({+ allowedRanges: sharedTimeRangePresets,+ fallback: "last7Days",+ });+ const [refreshedAt, setRefreshedAt] = useState(Date.now);const [selectedFacetId, setSelectedFacetId] = useState<string>();const [tracePanel, setTracePanel] = useState<HTMLElement | null>(null);- const validTimeRange = isValidTopicTimeRange(timeRange);const peekNavigation = usePeekNavigation({tableName: "topics-traces",isV4: false,@@ -175,11 +186,40 @@ function TopicsWorkspaceView({: [],),);- const rangeEnd = Math.max(timeRange.to.getTime(), completedAt);- const currentTimeRange =- timeWindow === "custom" || !Number.isFinite(rangeEnd)- ? timeRange- : relativeTopicTimeRange(Number(timeWindow), new Date(rangeEnd));+ const { currentTimeRange, effectiveTimeRange, isTimeRangeCapped } =+ useMemo(() => {+ const to =+ "from" in timeRange+ ? timeRange.to+ : new Date(Math.max(Date.now(), completedAt, refreshedAt));+ const from =+ "from" in timeRange+ ? timeRange.from+ : new Date(+ to.getTime() -+ (TIME_RANGES[timeRange.range as keyof typeof TIME_RANGES]+ .minutes ?? TIME_RANGES.last7Days.minutes) *+ 60_000,+ );+ const isTimeRangeCapped = to.getTime() - from.getTime() > maxTimeRangeMs;+ const currentTimeRange = {+ from: isTimeRangeCapped+ ? new Date(to.getTime() - maxTimeRangeMs)+ : from,+ to,+ };+ let effectiveTimeRange = timeRange;+ if (isTimeRangeCapped) {+ effectiveTimeRange =+ "from" in timeRange ? currentTimeRange : { range: "last90Days" };+ }+ return {+ currentTimeRange,+ effectiveTimeRange,+ isTimeRangeCapped,+ };+ }, [timeRange, completedAt, refreshedAt]);+ const validTimeRange = isValidTopicTimeRange(currentTimeRange);const running =Boolean(executions.data?.some((execution) => busy(execution.status))) ||busy(selectedExecution.data?.status ?? "");@@ -194,8 +234,7 @@ function TopicsWorkspaceView({selectedFacetId,);const refreshResults = () => {- if (timeWindow !== "custom")- setTimeRange(relativeTopicTimeRange(Number(timeWindow)));+ setRefreshedAt(Date.now());utils.topics.currentResults.invalidate({ projectId });};const openExecution = (id: string) => {@@ -221,19 +260,6 @@ function TopicsWorkspaceView({function openHistory() {setHistoryOpen(true);}- function selectTimeWindow(value: string) {- setTimeWindow(value);- setTimeRange(- value === "custom"- ? topicCalendarRange(topicCalendarDates(currentTimeRange))- : relativeTopicTimeRange(Number(value)),- );- }- function selectCalendarRange(- value: Parameters<typeof topicCalendarRange>[0],- ) {- setTimeRange(topicCalendarRange(value));- }const {primaryAction,triggerAction,@@ -251,13 +277,6 @@ function TopicsWorkspaceView({<FacetEditor projectId={projectId} facets={facets.data ?? []} />) : null,});- const filterProps = {- facets: results.data ?? [],- selectedFacetId,- timeWindow,- onSelectFacet: setSelectedFacetId,- onSelectTimeWindow: selectTimeWindow,- };const actions = (<div className="ph-no-capture flex items-center justify-end gap-1">{primaryAction}@@ -309,7 +328,6 @@ function TopicsWorkspaceView({"Explore recurring themes across traces, one facet at a time.",},actionButtonsRight: actions,- actionButtonsLeft: <TopicsFilters {...filterProps} layout="header" />,actionButtonsMenu: ({ closeMenu }) => (<TopicsActionsMenuhasFacets={(facets.data?.length ?? 0) > 0}@@ -318,26 +336,31 @@ function TopicsWorkspaceView({onOpenConfiguration={openConfiguration}onOpenHistory={openHistory}onRefresh={refreshResults}- >- <TopicsFilters {...filterProps} layout="menu" />- </TopicsActionsMenu>+ />),}}>+ <PageHeaderControlsPortal>+ <TimeRangePicker+ timeRange={effectiveTimeRange}+ onTimeRangeChange={setTimeRange}+ timeRangePresets={topicsTimeRangePresets}+ maxRangeMs={maxTimeRangeMs}+ className="my-0 max-w-full overflow-x-auto"+ triggerClassName="px-2"+ />+ </PageHeaderControlsPortal><div className="ph-no-capture flex min-h-0 flex-1 flex-col gap-2 overflow-hidden p-2">- {timeWindow === "custom" && (- <div className="flex shrink-0 flex-wrap items-center gap-2">- <DateRangeInput- value={topicCalendarDates(timeRange)}- max={format(new Date(), "yyyy-MM-dd")}- fromAriaLabel="Topics start date"- toAriaLabel="Topics end date"- onValueChange={selectCalendarRange}- />- </div>+ {isTimeRangeCapped && (+ <p role="status" className="text-muted-foreground shrink-0 text-xs">+ {"from" in timeRange+ ? "Showing the final 90 days of your selected range."+ : "Showing the last 90 days."}{" "}+ Your selection is preserved on other pages.+ </p>)}{!validTimeRange && (- <ErrorMessage message="Select a time range of at most 93 days." />+ <ErrorMessage message="Select a time range of at most 90 days." />)}{error && <ErrorMessage message={error} />}{configuration}@@ -420,13 +443,19 @@ function TopicsWorkspaceView({widthStorageKey="topicsPeekViewWidthFraction"/>{validTimeRange && (- <CurrentTopics- projectId={projectId}- timeRange={currentTimeRange}- result={results}- selectedFacetId={selectedFacet}- tracePanelRef={setTracePanel}- />+ <TopicsFilters+ facets={results.data ?? []}+ selectedFacetId={selectedFacetId}+ onSelectFacet={setSelectedFacetId}+ >+ <CurrentTopics+ projectId={projectId}+ timeRange={currentTimeRange}+ result={results}+ selectedFacetId={selectedFacet}+ tracePanelRef={setTracePanel}+ />+ </TopicsFilters>)}{facets.isLoading && <p>Loading facets…</p>}{facets.error && <ErrorMessage message={facets.error.message} />}diff --git a/web/src/features/topics/TopicsWorkspaceGate.stories.tsx b/web/src/features/topics/TopicsWorkspaceGate.stories.tsxindex 4d238debbf..f4253cfa6c 100644--- a/web/src/features/topics/TopicsWorkspaceGate.stories.tsx+++ b/web/src/features/topics/TopicsWorkspaceGate.stories.tsx@@ -7,12 +7,9 @@ import { TopicsWorkspaceGate } from "./TopicsWorkspaceGate";const controls = (<TopicsFilters- layout="header"facets={[{ facetId: "intent", name: "Intent" }]}selectedFacetId="intent"- timeWindow="7"onSelectFacet={fn()}- onSelectTimeWindow={fn()}/>);@@ -57,14 +54,15 @@ export const WaitsForInitialFacets = meta.story({const canvas = within(canvasElement);await expect(canvas.getByText("Loading topics…")).toBeVisible();await expect(- canvas.queryByRole("combobox", { name: "Topics facet" }),+ canvas.queryByRole("tab", { name: "Intent" }),).not.toBeInTheDocument();await userEvent.click(canvas.getByRole("button", { name: "Finish loading" }),);await expect(canvas.queryByText("Loading topics…")).not.toBeInTheDocument();- await expect(- canvas.getByRole("combobox", { name: "Topics facet" }),- ).toHaveTextContent("Intent");+ await expect(canvas.getByRole("tab", { name: "Intent" })).toHaveAttribute(+ "aria-selected",+ "true",+ );},});