🪢 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(topics): make panels resizable (#18903)
Nimarc21afd6bca12
diff --git a/web/src/features/topics/CurrentTopicsView.stories.tsx b/web/src/features/topics/CurrentTopicsView.stories.tsxindex 1057655ca4..b6a0b032a9 100644--- a/web/src/features/topics/CurrentTopicsView.stories.tsx+++ b/web/src/features/topics/CurrentTopicsView.stories.tsx@@ -362,3 +362,82 @@ export const ExistingTopicsWithoutAssignments = meta.story({).toBeVisible();},});++export const PanelSizesPersistAcrossFacetsAndLayouts = meta.story({+ name: "(Test) Panel sizes persist across facets and layouts",+ beforeEach: resetPanelSizes,+ render: function Render(args) {+ const [facetId, setFacetId] = useState("intent");+ function switchFacet() {+ setFacetId((previous) =>+ previous === "intent" ? "sentiment" : "intent",+ );+ }+ return (+ <div className="flex flex-col gap-2">+ <Button text="Switch facet" onClick={switchFacet} />+ <ControlledTopics+ key={facetId}+ {...args}+ facet={{ ...args.facet, facetId }}+ />+ </div>+ );+ },+ play: async ({ canvasElement }) => {+ if (!("__vitest_browser__" in globalThis)) return;++ const { page } = await import("vitest/browser");+ const originalViewport = {+ width: window.innerWidth,+ height: window.innerHeight,+ };+ const canvas = within(canvasElement);+ function panelSizes() {+ return canvas+ .getAllByRole("separator", { name: /^Resize topic/ })+ .map((divider) => divider.getAttribute("aria-valuenow"));+ }+ async function resizePanel(name: string, key: string) {+ canvas.getByRole("separator", { name }).focus();+ await userEvent.keyboard(key);+ }+ async function switchFacet() {+ await userEvent.click(+ canvas.getByRole("button", { name: "Switch facet" }),+ );+ }+ try {+ await page.viewport(1280, 900);+ await resizePanel("Resize topic overview and traces", "{ArrowRight}");+ await resizePanel("Resize topic map and groups", "{ArrowDown}");+ const desktopSizes = panelSizes();+ await switchFacet();+ await waitFor(() => expect(panelSizes()).toEqual(desktopSizes));++ await page.viewport(700, 900);+ await canvas.findByRole("tab", { name: "Topics" });+ await resizePanel("Resize topic map and groups", "{ArrowUp}");+ const narrowSizes = panelSizes();+ await switchFacet();+ await waitFor(() => expect(panelSizes()).toEqual(narrowSizes));++ await page.viewport(1280, 900);+ await waitFor(() => expect(panelSizes()).toEqual(desktopSizes));+ await page.viewport(700, 900);+ await waitFor(() => expect(panelSizes()).toEqual(narrowSizes));+ } finally {+ await page.viewport(originalViewport.width, originalViewport.height);+ }+ },+});++function resetPanelSizes() {+ const keys = [+ "react-resizable-panels:topics-workspace-size:overview:traces",+ "react-resizable-panels:topics-overview-size:map:groups",+ "react-resizable-panels:topics-overview-size-narrow:map:groups",+ ];+ keys.forEach((key) => localStorage.removeItem(key));+ return () => keys.forEach((key) => localStorage.removeItem(key));+}diff --git a/web/src/features/topics/CurrentTopicsView.tsx b/web/src/features/topics/CurrentTopicsView.tsxindex 86c01fa1de..9b04dbff2f 100644--- a/web/src/features/topics/CurrentTopicsView.tsx+++ b/web/src/features/topics/CurrentTopicsView.tsx@@ -1,7 +1,12 @@import { computeSelectedValues, type FilterState } from "@langfuse/shared";-import { useMemo, useState, type ComponentProps, type MouseEvent } from "react";+import {+ useMemo,+ useState,+ type ComponentProps,+ type MouseEvent,+ type ReactNode,+} from "react";import { useMediaQuery } from "react-responsive";-import { cn } from "@/src/utils/tailwind";import { type OnChangeFn, type PaginationState } from "@tanstack/react-table";import { DataTable } from "@/src/components/table/data-table";import { type LangfuseColumnDef } from "@/src/components/table/types";@@ -10,6 +15,12 @@ import { type RouterOutputs } from "@/src/utils/api";import { Button } from "@/src/components/design-system/Button/Button";import { TextLink } from "@/src/components/design-system/TextLink/TextLink";import { Tabs } from "@/src/components/design-system/Tabs/Tabs";+import {+ ResizableHandle,+ ResizablePanel,+ ResizablePanelGroup,+ useDefaultLayout,+} from "@/src/components/ui/resizable";import { useIsMobile } from "@/src/hooks/use-mobile";import { TopicEmbeddingMap } from "./TopicEmbeddingMap";import { TopicGroupCard } from "./TopicGroupCard";@@ -21,6 +32,9 @@ import {} from "./topic-trace-filters";import { TopicsTraceToolbar } from "./TopicsTraceToolbar";+const OVERVIEW_PANEL_IDS = ["map", "groups"];+const WORKSPACE_PANEL_IDS = ["overview", "traces"];+export function CurrentTopicsView({projectId,facet,@@ -89,7 +103,7 @@ export function CurrentTopicsView({const mapPanel = (<sectionaria-label="Topic map"- className="flex min-h-0 min-w-0 flex-col overflow-hidden"+ className="flex h-full min-h-0 min-w-0 flex-col overflow-hidden">{facet.map ? (<TopicEmbeddingMap@@ -132,7 +146,7 @@ export function CurrentTopicsView({const groupsPanel = (<sectionaria-label="Topic groups"- className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-md border"+ className="flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-md border"><div className="flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain p-2"><div className="grid gap-2 sm:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2">@@ -164,10 +178,7 @@ export function CurrentTopicsView({<sectionaria-label="Topic traces"ref={isNarrow ? undefined : tracePanelRef}- className={cn(- "flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-md border lg:col-start-2 lg:row-start-1",- facet.map && "lg:row-span-2",- )}+ className="flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-md border"><TopicsTraceToolbarprojectId={projectId}@@ -192,48 +203,142 @@ export function CurrentTopicsView({/></section>);+ const detailsPanel = isNarrow ? (+ <TopicsDetailsTabs+ value={mobilePanel}+ onValueChange={setMobilePanel}+ tracePanelRef={tracePanelRef}+ groupsPanel={groupsPanel}+ tracesPanel={tracesPanel}+ />+ ) : (+ groupsPanel+ );+ const overviewPanel = (+ <TopicsOverviewSplit+ isNarrow={isNarrow}+ hasMap={facet.map !== null}+ mapPanel={mapPanel}+ >+ {detailsPanel}+ </TopicsOverviewSplit>+ );++ return (+ <TopicsWorkspaceSplit+ isNarrow={isNarrow}+ overviewPanel={overviewPanel}+ tracesPanel={tracesPanel}+ />+ );+}++function TopicsDetailsTabs({+ value,+ onValueChange,+ tracePanelRef,+ groupsPanel,+ tracesPanel,+}: TopicsDetailsTabsProps) {return (- <div- className={cn(- "grid min-h-0 min-w-0 flex-1 gap-2 overflow-hidden lg:grid-cols-2",- facet.map- ? "grid-rows-[minmax(0,9fr)_minmax(0,11fr)] lg:grid-rows-[minmax(0,3fr)_minmax(0,2fr)]"- : "grid-rows-[minmax(0,1fr)]",- )}+ <Tabs+ value={value}+ onValueChange={onValueChange}+ layout="fill"+ ref={tracePanelRef}>- {facet.map && mapPanel}- {isNarrow ? (- <Tabs- value={mobilePanel}- onValueChange={setMobilePanel}- layout="fill"- ref={tracePanelRef}+ <div className="mb-2 shrink-0">+ <Tabs.List+ variant="inset"+ size="sm"+ layout="full"+ aria-label="Topics panels">- <div className="mb-2 shrink-0">- <Tabs.List- variant="inset"- size="sm"- layout="full"- aria-label="Topics panels"- >- <Tabs.Trigger value="topics" label="Topics" />- <Tabs.Trigger value="traces" label="Traces" />- </Tabs.List>- </div>- <Tabs.Content value="topics" layout="fill">- {groupsPanel}- </Tabs.Content>- <Tabs.Content value="traces" layout="fill">- {tracesPanel}- </Tabs.Content>- </Tabs>- ) : (- <>- {groupsPanel}- {tracesPanel}- </>- )}- </div>+ <Tabs.Trigger value="topics" label="Topics" />+ <Tabs.Trigger value="traces" label="Traces" />+ </Tabs.List>+ </div>+ <Tabs.Content value="topics" layout="fill">+ {groupsPanel}+ </Tabs.Content>+ <Tabs.Content value="traces" layout="fill">+ {tracesPanel}+ </Tabs.Content>+ </Tabs>+ );+}++function TopicsOverviewSplit({+ isNarrow,+ hasMap,+ mapPanel,+ children,+}: TopicsOverviewSplitProps) {+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({+ id: isNarrow ? "topics-overview-size-narrow" : "topics-overview-size",+ panelIds: OVERVIEW_PANEL_IDS,+ storage: "local",+ });++ if (!hasMap) return children;++ return (+ <ResizablePanelGroup+ orientation="vertical"+ defaultLayout={defaultLayout}+ onLayoutChanged={onLayoutChanged}+ className="min-h-0 min-w-0 flex-1"+ >+ <ResizablePanel+ id="map"+ defaultSize={isNarrow ? "45%" : "60%"}+ minSize="20%"+ >+ {mapPanel}+ </ResizablePanel>+ <ResizableHandle+ withHandle+ aria-label="Resize topic map and groups"+ className="my-1"+ />+ <ResizablePanel id="groups" minSize="20%">+ {children}+ </ResizablePanel>+ </ResizablePanelGroup>+ );+}++function TopicsWorkspaceSplit({+ isNarrow,+ overviewPanel,+ tracesPanel,+}: TopicsWorkspaceSplitProps) {+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({+ id: "topics-workspace-size",+ panelIds: WORKSPACE_PANEL_IDS,+ storage: "local",+ });+ if (isNarrow) return overviewPanel;++ return (+ <ResizablePanelGroup+ orientation="horizontal"+ defaultLayout={defaultLayout}+ onLayoutChanged={onLayoutChanged}+ className="min-h-0 min-w-0 flex-1"+ >+ <ResizablePanel id="overview" defaultSize="50%" minSize="25%">+ {overviewPanel}+ </ResizablePanel>+ <ResizableHandle+ withHandle+ aria-label="Resize topic overview and traces"+ className="mx-1"+ />+ <ResizablePanel id="traces" minSize="25%">+ {tracesPanel}+ </ResizablePanel>+ </ResizablePanelGroup>);}@@ -381,6 +486,27 @@ function CurrentTraceTable({);}+type TopicsDetailsTabsProps = {+ value: string;+ onValueChange: (value: string) => void;+ tracePanelRef: CurrentTopicsViewProps["tracePanelRef"];+ groupsPanel: ReactNode;+ tracesPanel: ReactNode;+};++type TopicsOverviewSplitProps = {+ isNarrow: boolean;+ hasMap: boolean;+ mapPanel: ReactNode;+ children: ReactNode;+};++type TopicsWorkspaceSplitProps = {+ isNarrow: boolean;+ overviewPanel: ReactNode;+ tracesPanel: ReactNode;+};+type CurrentTraceTableProps = {projectId: string;onOpenTrace: (traceId: string) => void;diff --git a/web/src/features/topics/README.md b/web/src/features/topics/README.mdindex 687dfc21d4..39992012b9 100644--- a/web/src/features/topics/README.md+++ b/web/src/features/topics/README.md@@ -10,8 +10,11 @@ project permissions. Processing additionally requires the project allowlist.picker, time range and processing action on one row; configuration, history andrefresh live in the overflow menu. `CurrentTopics.tsx` owns the map query, tracenavigation and summary inspector; `CurrentTopicsView.tsx` presents the selected- facet in independently scrolling panels: map and groups on the left, traces on- the right. Narrow views keep the map above Topics/Traces tabs, with readable+ facet in independently scrolling, resizable panels: map and groups on the left,+ traces on the right. Both splits use the shared `useDefaultLayout` helper with+ localStorage preferences shared across facets and projects, with separate+ map-height preferences for desktop and narrow layouts. Narrow views keep+ the resizable map above Topics/Traces tabs, with readablesummary rows on phones and all processing controls in the mobile overflowmenu. Selecting a group filters traces without changing the active tab.`useTopicTraceFilters.ts` owns URL-backed facet selection; filters and search