Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(sessions): Allow resizing sidebar (#19027)

Ben Bachema08b1f33a43b
diff --git a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx
index 7085b3ea13..982e3cb4a6 100644
--- a/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx
+++ b/web/src/features/sessions/components/ConnectedModernSessionBodyTimeline/components/ConnectedSessionConversationTimeline/components/SessionConversationalView/SessionConversationalView.tsx
@@ -1,6 +1,13 @@
import { type ComponentProps, useLayoutEffect, useId, useRef } from "react";
import { Search } from "@langfuse/icons";
import { Input } from "@/src/components/ui/input";
+import {
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+ useDefaultLayout,
+} from "@/src/components/ui/resizable";
+import { useElementSize } from "@/src/hooks/useElementSize";
import { Dialog } from "@/src/components/design-system/Dialog/Dialog";
import { DialogController } from "@/src/components/design-system/DialogController/DialogController";
import { Trigger as DialogTrigger } from "@radix-ui/react-dialog";
@@ -38,6 +45,13 @@ export function SessionConversationalView(
},
) {
const transcriptRef = useRef<HTMLDivElement>(null);
+ const [workspaceRef, workspaceSize] = useElementSize<HTMLDivElement>();
+ const showSidebar = (workspaceSize?.width ?? 0) >= 768;
+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({
+ id: "session-conversation-sidebar",
+ panelIds: ["sidebar", "timeline"],
+ storage: "session",
+ });
const highlightName = `session-transcript-${useId().replace(/[^a-z0-9_-]/gi, "")}`;
const searchQuery = props.state === "loaded" ? props.search.trim() : "";
useLayoutEffect(() => {
@@ -229,91 +243,119 @@ export function SessionConversationalView(
activeTraceId: props.controller.activeItemId ?? undefined,
};
return (
- <div className="bg-background relative grid min-h-0 flex-1 grid-rows-[auto_minmax(0,1fr)] gap-x-4 overflow-hidden @3xl/session-workspace:grid-cols-[clamp(200px,24cqw,296px)_minmax(0,1fr)] @3xl/session-workspace:grid-rows-1">
- <div className="border-b px-2 py-2.5 @3xl/session-workspace:hidden">
- <DialogController
- renderDialog={({ closeDialog }) => (
- <Dialog title="Search session" closeOnInteractionOutside>
- <div className="shrink-0 border-b px-4 pt-0 pb-2">
- <div className="relative min-w-0">
- <Search
- size="base"
- color="tertiary"
- __rawClassName="absolute top-1/2 left-2 -translate-y-1/2"
- />
- <Input
- disabled={props.state === "loading"}
- value={props.state === "loaded" ? props.search : ""}
- onChange={(event) => {
- if (props.state === "loaded")
- props.onSearchChange(event.target.value);
- }}
- aria-label="Search session"
- placeholder="Search session"
- className="h-7 rounded-sm bg-transparent pl-7 font-mono text-xs"
- />
+ <div
+ ref={workspaceRef}
+ className="bg-background relative flex min-h-0 flex-1 flex-col overflow-hidden"
+ >
+ {!showSidebar && (
+ <div className="shrink-0 border-b px-2 py-2.5">
+ <DialogController
+ renderDialog={({ closeDialog }) => (
+ <Dialog title="Search session" closeOnInteractionOutside>
+ <div className="shrink-0 border-b px-4 pt-0 pb-2">
+ <div className="relative min-w-0">
+ <Search
+ size="base"
+ color="tertiary"
+ __rawClassName="absolute top-1/2 left-2 -translate-y-1/2"
+ />
+ <Input
+ disabled={props.state === "loading"}
+ value={props.state === "loaded" ? props.search : ""}
+ onChange={(event) => {
+ if (props.state === "loaded")
+ props.onSearchChange(event.target.value);
+ }}
+ aria-label="Search session"
+ placeholder="Search session"
+ className="h-7 rounded-sm bg-transparent pl-7 font-mono text-xs"
+ />
+ </div>
</div>
- </div>
- <div className="min-h-0 flex-1 sm:h-[60dvh] sm:flex-none">
- {sidebarProps.state === "loading" ? (
- <SessionConversationSidebar
- state="loading"
- searchVisibility="hidden"
- />
- ) : (
- <SessionConversationSidebar
- {...sidebarProps}
- searchVisibility="hidden"
- onSelect={(...args) => {
- sidebarProps.onSelect(...args);
- closeDialog();
- }}
- />
- )}
- </div>
- </Dialog>
- )}
- >
- {({ openDialog }) => (
- <DialogTrigger asChild>
- <button
- type="button"
- disabled={props.state === "loading"}
- onClick={() => openDialog()}
- aria-label="Search session"
- className="border-input text-muted-foreground flex h-7 w-full items-center gap-2 rounded-sm border px-2 text-left font-mono text-xs"
- >
- <Search size="base" />
- <span
- className="truncate"
- title={
- props.state === "loaded" && props.search
- ? props.search
- : "Search session"
- }
+ <div className="min-h-0 flex-1 sm:h-[60dvh] sm:flex-none">
+ {sidebarProps.state === "loading" ? (
+ <SessionConversationSidebar
+ state="loading"
+ searchVisibility="hidden"
+ />
+ ) : (
+ <SessionConversationSidebar
+ {...sidebarProps}
+ searchVisibility="hidden"
+ onSelect={(...args) => {
+ sidebarProps.onSelect(...args);
+ closeDialog();
+ }}
+ />
+ )}
+ </div>
+ </Dialog>
+ )}
+ >
+ {({ openDialog }) => (
+ <DialogTrigger asChild>
+ <button
+ type="button"
+ disabled={props.state === "loading"}
+ onClick={() => openDialog()}
+ aria-label="Search session"
+ className="border-input text-muted-foreground flex h-7 w-full items-center gap-2 rounded-sm border px-2 text-left font-mono text-xs"
>
- {props.state === "loaded" && props.search
- ? props.search
- : "Search session"}
- </span>
- </button>
- </DialogTrigger>
- )}
- </DialogController>
- </div>
- <div className="hidden min-h-0 @3xl/session-workspace:block">
- <SessionConversationSidebar {...sidebarProps} />
- </div>
- <div
- ref={transcriptRef}
- className="bg-card dark:bg-background relative min-h-0 min-w-0"
+ <Search size="base" />
+ <span
+ className="truncate"
+ title={
+ props.state === "loaded" && props.search
+ ? props.search
+ : "Search session"
+ }
+ >
+ {props.state === "loaded" && props.search
+ ? props.search
+ : "Search session"}
+ </span>
+ </button>
+ </DialogTrigger>
+ )}
+ </DialogController>
+ </div>
+ )}
+ <ResizablePanelGroup
+ orientation="horizontal"
+ className="min-h-0 min-w-0 flex-1"
+ defaultLayout={showSidebar ? defaultLayout : undefined}
+ onLayoutChanged={showSidebar ? onLayoutChanged : undefined}
>
- <style>{`::highlight(${highlightName}) { background-color: ${searchQuery ? "hsl(var(--find-match-background))" : "transparent"}; color: ${searchQuery ? "hsl(var(--foreground))" : "inherit"}; }`}</style>
- <SessionConversationTimeline
- traces={timelineItems}
- controller={props.controller}
- />
- </div>
+ {showSidebar && (
+ <ResizablePanel
+ id="sidebar"
+ defaultSize="24%"
+ minSize="200px"
+ maxSize="50%"
+ className="h-full min-h-0"
+ >
+ <SessionConversationSidebar {...sidebarProps} />
+ </ResizablePanel>
+ )}
+ {showSidebar && (
+ <ResizableHandle
+ withHandle
+ aria-label="Resize conversation sidebar"
+ />
+ )}
+ <ResizablePanel id="timeline" minSize={showSidebar ? "300px" : "0%"}>
+ <div
+ ref={transcriptRef}
+ className="bg-card dark:bg-background relative h-full min-h-0 min-w-0"
+ >
+ <style>{`::highlight(${highlightName}) { background-color: ${searchQuery ? "hsl(var(--find-match-background))" : "transparent"}; color: ${searchQuery ? "hsl(var(--foreground))" : "inherit"}; }`}</style>
+ <SessionConversationTimeline
+ traces={timelineItems}
+ controller={props.controller}
+ />
+ </div>
+ </ResizablePanel>
+ </ResizablePanelGroup>
</div>
);
}