Skip to content

πŸͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(trace): fold the playback transport into the header's overflow menu (#16201)

Nikita Kabardineba4eba03d1d
diff --git a/web/src/features/traces/components/PlaybackControls.tsx b/web/src/features/traces/components/PlaybackControls.tsx
index 8b2d20ef57..a82d192a2f 100644
--- a/web/src/features/traces/components/PlaybackControls.tsx
+++ b/web/src/features/traces/components/PlaybackControls.tsx
@@ -18,6 +18,7 @@
import { useEffect, useRef } from "react";
import { Pause, Play, Square } from "lucide-react";
+import { DropdownMenuItem } from "@/src/components/ui/dropdown-menu";
import { StringParam, useQueryParam } from "use-query-params";
import { Button } from "@/src/components/ui/button";
import {
@@ -36,17 +37,43 @@ const RING_STROKE = 2;
const RING_R = (RING_SIZE - RING_STROKE) / 2;
const RING_C = 2 * Math.PI * RING_R;
-export function PlaybackControls() {
+/**
+ * Whether a playback surface exists to drive.
+ *
+ * Shared, because the transport has two homes now: inline in the header, and
+ * folded into its overflow menu when the panel is too narrow for it. One rule for
+ * both β€” a second copy would drift the moment either home changed.
+ *
+ * A playback surface exists in the timeline view (unless a search query has
+ * replaced it with the search list) or when the graph panel renders β€” a
+ * COLLAPSED panel still counts (the surface is one click away; hiding the
+ * transport when the user collapses the panel would make it undiscoverable), and
+ * a pending graph query counts too, so graph-eligible traces don't get a
+ * transport pop-in after first load. An actively-placed playhead keeps its
+ * controls regardless.
+ */
+export function useHasPlayback(): boolean {
const { traceDuration } = useTraceData();
const { isGraphViewAvailable, isLoading: isGraphDataLoading } =
useTraceGraphData();
const { showGraph } = useViewPreferences();
const { searchQuery } = useSearch();
const [viewMode] = useQueryParam("view", StringParam);
- const { play, pause, stop, getPlayheadSec, subscribePosition } =
+ const showPlayhead = useShowPlayhead();
+
+ const isSearching = searchQuery.trim().length > 0;
+ const hasPlaybackSurface =
+ (viewMode === "timeline" && !isSearching) ||
+ (showGraph && (isGraphViewAvailable || isGraphDataLoading));
+ return traceDuration > 0 && (hasPlaybackSurface || showPlayhead);
+}
+
+export function PlaybackControls() {
+ const { traceDuration } = useTraceData();
+ const { play, pause, getPlayheadSec, subscribePosition, stop } =
usePlayhead();
const isPlaying = useIsPlaying();
- const showPlayhead = useShowPlayhead();
+ const hasPlayback = useHasPlayback();
const ringRef = useRef<SVGCircleElement>(null);
// Fill the ring to the current playhead fraction; update imperatively as the
@@ -62,20 +89,7 @@ export function PlaybackControls() {
return subscribePosition(apply);
}, [traceDuration, getPlayheadSec, subscribePosition]);
- // A playback surface exists in the timeline view (unless a search query has
- // replaced it with the search list) or when the graph panel renders β€” a
- // COLLAPSED panel still counts (the surface is one click away; hiding the
- // transport when the user collapses the panel would make it undiscoverable),
- // and a pending graph query counts too, so graph-eligible traces don't get a
- // transport pop-in after first load. An actively-placed playhead keeps its
- // controls regardless.
- const isSearching = searchQuery.trim().length > 0;
- const hasPlaybackSurface =
- (viewMode === "timeline" && !isSearching) ||
- (showGraph && (isGraphViewAvailable || isGraphDataLoading));
- if (traceDuration <= 0 || (!hasPlaybackSurface && !showPlayhead)) {
- return null;
- }
+ if (!hasPlayback) return null;
return (
<div className="ml-1 flex shrink-0 flex-row items-center gap-0.5">
@@ -137,3 +151,36 @@ export function PlaybackControls() {
</div>
);
}
+
+/**
+ * The transport as menu items, for the overflow menu the header folds into below
+ * ~360px. Two 28px buttons plus their ring are what tipped that row over: the
+ * search input collapsed to "Se" and the segmented switch clipped. Play is a
+ * verb, so it reads fine as a menu entry β€” and unlike hiding it, the transport
+ * stays reachable while a playhead is placed.
+ */
+export function PlaybackMenuItems() {
+ const { play, pause, stop } = usePlayhead();
+ const isPlaying = useIsPlaying();
+ const showPlayhead = useShowPlayhead();
+ const hasPlayback = useHasPlayback();
+
+ if (!hasPlayback) return null;
+
+ return (
+ <>
+ <DropdownMenuItem onSelect={() => (isPlaying ? pause() : play())}>
+ {isPlaying ? (
+ <Pause className="mr-2 h-3.5 w-3.5" />
+ ) : (
+ <Play className="mr-2 h-3.5 w-3.5" />
+ )}
+ {isPlaying ? "Pause playback" : "Play trace over time"}
+ </DropdownMenuItem>
+ <DropdownMenuItem onSelect={() => stop()} disabled={!showPlayhead}>
+ <Square className="mr-2 h-3 w-3" />
+ Stop playback
+ </DropdownMenuItem>
+ </>
+ );
+}
diff --git a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx
index 499b2d4df3..867b21974f 100644
--- a/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx
+++ b/web/src/features/traces/components/TracePanelNavigationHeader/TracePanelNavigationHeader.tsx
@@ -45,7 +45,7 @@ import {
downloadServerTraceAsJson,
} from "../../fns/downloadTrace";
import { TracePanelNavigationButton } from "./components/TracePanelNavigationButton";
-import { PlaybackControls } from "../PlaybackControls";
+import { PlaybackControls, PlaybackMenuItems } from "../PlaybackControls";
import { useDesktopLayoutContextOptional } from "../TraceLayoutDesktop";
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useTraceAnalyticsDimensions } from "@/src/features/traces/hooks/useTraceAnalyticsDimensions";
@@ -180,16 +180,21 @@ function TracePanelNavigationHeaderExpanded({
return (
<Command className="flex h-auto shrink-0 flex-col gap-1 overflow-hidden rounded-none border-b">
- {/* Responsive toolbar via container queries on this row's own width β€”
- no JS measurement. The breakpoints are tuned to the row's actual
- content minimums (all fixed-size icon buttons + the search input's
- min-width, so the sums are font-independent): with playback controls
- present the row needs ~434px with switcher labels, ~352px icons-only,
- ~292px with the minor tools folded into "…". Hence: labels < 440px β†’
- hidden; tools < 360px β†’ folded; search < 300px β†’ narrower min-width
- (covers dragging to the 260px panel min). If you ADD anything to this
- row, re-measure and retune all three β€” stale thresholds show up as a
- clipped switcher at default widths (LFE-10729). */}
+ {/* Responsive toolbar via container queries on this row's own width β€” no JS
+ measurement. The breakpoints are tuned to the row's actual content
+ minimums (all fixed-size icon buttons plus the search input's
+ min-width, so the sums are font-independent). Measured states:
+
+ β‰₯ 440px switcher labels, minor tools and transport all inline
+ 360-440 switcher icons-only, tools and transport still inline
+ < 360px tools AND transport folded into the "…" menu; this row
+ first overflows at 188px, well under the 260px panel min
+
+ Hence: labels < 440px β†’ hidden; tools and the transport < 360px β†’
+ folded; search < 300px β†’ narrower min-width (covers dragging to the
+ panel min). If you ADD anything to this row, re-measure and retune all
+ three β€” stale thresholds show up as a clipped switcher at default
+ widths, which is what the folding exists to prevent. */}
<div className="@container/navheader flex flex-row items-center justify-between pr-2 pl-1">
{/* Panel Toggle Button; special p-0.5 offset to pixel align with closed
version. Hidden while the detail panel is closed (nothing useful to
@@ -282,6 +287,7 @@ function TracePanelNavigationHeaderExpanded({
<Download className="mr-2 h-3.5 w-3.5" />
Download trace as JSON
</DropdownMenuItem>
+ <PlaybackMenuItems />
<DropdownMenuSeparator />
<TraceViewOptionsMenuItems
isGraphViewAvailable={isGraphViewAvailable}
@@ -290,8 +296,13 @@ function TracePanelNavigationHeaderExpanded({
</DropdownMenu>
{/* Playback transport + circular time-progress ring. View-agnostic:
- shown in both Tree and Timeline views (see PlaybackControls). */}
- <PlaybackControls />
+ shown in both Tree and Timeline views (see PlaybackControls) β€” and
+ folded into the overflow menu on a narrow panel, like the tools
+ above it. Two more 28px buttons are what tipped this row over: the
+ search input collapsed to "Se" and the switch clipped. */}
+ <div className="hidden flex-row items-center @min-[360px]/navheader:flex">
+ <PlaybackControls />
+ </div>
{/* Tree / Timeline segmented switch (labels collapse to icons when
the panel is narrow β€” see @container/navheader). */}