Skip to content

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

feat(mobile): compact shared page header on trace/session detail (LFE-11067) (#15410)

Nikita Kabardinc33fc9ff83f5
diff --git a/web/src/components/layouts/mobile-page-title.tsx b/web/src/components/layouts/mobile-page-title.tsx
index aa8169c4b2..b4dfc9dc8b 100644
--- a/web/src/components/layouts/mobile-page-title.tsx
+++ b/web/src/components/layouts/mobile-page-title.tsx
@@ -4,20 +4,27 @@ import DocPopup from "@/src/components/layouts/doc-popup";
import { PageHeaderControlsSlotTarget } from "@/src/components/layouts/page-header-controls-slot";
import { PageTabs } from "@/src/components/layouts/page-tabs";
import { type PageHeaderProps } from "@/src/components/layouts/page-header";
+import { Button } from "@/src/components/ui/button";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/src/components/ui/popover";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/src/components/ui/tooltip";
+import { MoreHorizontal } from "lucide-react";
/**
* The page-specific block for the minimal-chrome mobile shell. Rendered between
* the slim sticky chrome and the page content (not inside the sticky bar), so
* the title reads as part of the page and scrolls with it. Holds the
- * org/project context switcher, the large page title, page actions, the hoisted
- * controls slot (time range / refresh), the agent launcher, and the section
- * tabs.
+ * org/project context switcher, the compact page title (type icon + heading)
+ * with its page actions collapsed into a single `⋯` overflow popover, the
+ * hoisted controls slot (time range / refresh), and the section tabs.
*
* Takes the same `headerProps` the desktop PageHeader gets, so any Page-style
* wrapper renders it consistently. Controls + agent live here for now; they
@@ -36,6 +43,7 @@ export const MobilePageTitle = ({
itemType,
actionButtonsLeft,
actionButtonsRight,
+ actionButtonsMenu,
titleBadges,
breadcrumb,
breadcrumbBadges,
@@ -51,16 +59,16 @@ export const MobilePageTitle = ({
{breadcrumbBadges}
</div>
- {/* Title on its own full-width line. On desktop the PageHeader packs the
- title and its action clusters onto one justified row, but at phone
- width there is no room: a `shrink-0` action cluster sharing the row
- crushes the `min-w-0` title (a fixed-width search input, or a
- dashboard selector + edit + setup, would overlap the heading). So the
- mobile title owns its line and every action cluster wraps onto its
- own row below — matching how the controls/agent row already behaves. */}
- <div className="mt-1.5 flex min-w-0 items-center gap-2">
- {itemType && <ItemBadge type={itemType} showLabel />}
- <h1 className="text-primary text-2xl leading-tight font-bold wrap-break-word">
+ {/* Title row. On desktop the PageHeader packs the title and its action
+ clusters onto one justified row; at phone width the compact mobile
+ header keeps the type icon + title on the left and collapses every
+ action cluster into a single `⋯` overflow popover pinned to the right,
+ so the header top block stays ~2 rows instead of the 4–5 it used to
+ take (a big labelled type chip, a text-2xl title, then each action
+ cluster wrapping onto its own row). */}
+ <div className="mt-1 flex min-w-0 items-center gap-2">
+ {itemType && <ItemBadge type={itemType} />}
+ <h1 className="text-primary text-base leading-tight font-bold wrap-break-word">
{titleContent ? (
titleContent
) : titleTooltip ? (
@@ -91,23 +99,39 @@ export const MobilePageTitle = ({
{titleBadges && (
<div className="flex items-center gap-1">{titleBadges}</div>
)}
+ {/* Actions collapse into a single right-aligned overflow popover of
+ full-width labeled rows (icon + label) — the same pattern the table
+ peek uses. Pages pass `actionButtonsMenu` (a `layout="menu"` variant
+ of their actions) for proper menu rows; when they don't, we fall
+ back to folding the inline `actionButtonsRight`/`actionButtonsLeft`
+ nodes as-is. Either way the actions' own dialogs/drawers portal
+ through the layer system, so they keep working from the popover. */}
+ {(actionButtonsMenu || actionButtonsRight || actionButtonsLeft) && (
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ size="icon"
+ aria-label="More actions"
+ className="ml-auto shrink-0"
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-auto min-w-44 p-1">
+ <div className="flex flex-col items-stretch gap-0.5">
+ {actionButtonsMenu ?? (
+ <>
+ {actionButtonsRight}
+ {actionButtonsLeft}
+ </>
+ )}
+ </div>
+ </PopoverContent>
+ </Popover>
+ )}
</div>
- {/* Page actions live on ONE horizontally-scrollable row. Detail pages
- (e.g. a session) hand us 6-9 buttons across both clusters; at phone
- width, wrapping them stacks 200-300px of chrome above the content and
- starves the actual page. `flex-nowrap` + `[&>*]:shrink-0` keeps each
- action its natural size and lets the row scroll sideways within its
- own `min-w-0`/`overflow-x-auto` box instead of wrapping or forcing
- page-level horizontal overflow. Pages with a couple of actions never
- need to scroll. */}
- {(actionButtonsRight || actionButtonsLeft) && (
- <div className="mt-2 flex min-w-0 flex-nowrap items-center gap-1 overflow-x-auto [&>*]:shrink-0">
- {actionButtonsRight}
- {actionButtonsLeft}
- </div>
- )}
-
{/* Hoisted page controls (time range, auto-refresh). The assistant
launcher lives in the sticky MobileTopBar now (prominent + always
reachable), not here where it wrapped onto its own line and shrank to
diff --git a/web/src/components/layouts/page-header.tsx b/web/src/components/layouts/page-header.tsx
index b29e62bc7b..deb00863b6 100644
--- a/web/src/components/layouts/page-header.tsx
+++ b/web/src/components/layouts/page-header.tsx
@@ -32,6 +32,13 @@ export type PageHeaderProps = {
breadcrumb?: { name: string; href?: string }[];
actionButtonsLeft?: React.ReactNode; // Right-side actions (buttons, etc.)
actionButtonsRight?: React.ReactNode; // Right-side actions (buttons, etc.)
+ /** Mobile-only: the same actions rendered as full-width labeled menu rows
+ * (icon + label), for the compact header's `⋯` overflow. Pages pass a
+ * `layout="menu"` variant of their actions here (mirrors the table peek's
+ * `actionsMenu`). When omitted, the mobile header falls back to folding the
+ * inline `actionButtonsRight`/`actionButtonsLeft` nodes as-is. Desktop
+ * `PageHeader` ignores this. */
+ actionButtonsMenu?: React.ReactNode;
help?: { description: React.ReactNode; href?: string; className?: string };
titleTooltip?: string;
itemType?: LangfuseItemType;
diff --git a/web/src/components/publish-object-switch.tsx b/web/src/components/publish-object-switch.tsx
index 85d601ca76..057779293f 100644
--- a/web/src/components/publish-object-switch.tsx
+++ b/web/src/components/publish-object-switch.tsx
@@ -134,6 +134,8 @@ export const PublishSessionSwitch = (props: {
projectId: string;
isPublic: boolean;
size?: "icon" | "icon-xs";
+ /** When set, render as a full-width labeled menu item instead of an icon. */
+ label?: string;
}) => {
const capture = usePostHogClientCapture();
const hasAccess = useHasProjectAccess({
@@ -155,6 +157,7 @@ export const PublishSessionSwitch = (props: {
itemName="session"
isPublic={props.isPublic}
size={props.size}
+ label={props.label}
onChange={(val) => {
capture("session_detail:publish_button_click");
return mut.mutateAsync({
diff --git a/web/src/components/session/index.tsx b/web/src/components/session/index.tsx
index 654f4457d3..537d6dda1b 100644
--- a/web/src/components/session/index.tsx
+++ b/web/src/components/session/index.tsx
@@ -293,9 +293,36 @@ const SessionScores = ({
};
const CopySessionIdButton: React.FC<{
sessionId: string;
-}> = ({ sessionId }) => {
+ /** "menu" renders a full-width labeled row for the mobile ⋯ overflow;
+ * default "toolbar" keeps the inline icon-only button. */
+ layout?: "toolbar" | "menu";
+}> = ({ sessionId, layout = "toolbar" }) => {
const capture = usePostHogClientCapture();
const { copy, isCopied } = useCopyToClipboard();
+ const isMenu = layout === "menu";
+ const onCopy = async () => {
+ capture("session_detail:copy_session_id_click");
+ await copy(sessionId);
+ };
+
+ if (isMenu) {
+ return (
+ <Button
+ variant="ghost"
+ size="sm"
+ aria-label="Copy session ID"
+ className="w-full justify-start gap-2 font-normal"
+ onClick={onCopy}
+ >
+ {isCopied ? (
+ <CheckIcon className="text-muted-green h-4 w-4" />
+ ) : (
+ <CopyIcon className="h-4 w-4" />
+ )}
+ <span className="text-sm">Copy session ID</span>
+ </Button>
+ );
+ }
return (
<Button
@@ -303,10 +330,7 @@ const CopySessionIdButton: React.FC<{
size="icon-xs"
title="Copy session ID"
aria-label="Copy session ID"
- onClick={async () => {
- capture("session_detail:copy_session_id_click");
- await copy(sessionId);
- }}
+ onClick={onCopy}
>
{isCopied ? (
<CheckIcon className="text-muted-green h-4 w-4" />
@@ -563,6 +587,79 @@ export const SessionPage: React.FC<{
</div>
</>
),
+ // Mobile compact header: the same session actions as full-width
+ // labeled menu rows for the `⋯` overflow popover, instead of the
+ // inline icon toolbar. Session-to-session nav stays desktop-only.
+ actionButtonsMenu: (
+ <>
+ <StarSessionToggle
+ projectId={projectId}
+ sessionId={sessionId}
+ value={session.data?.bookmarked ?? false}
+ showLabel
+ />
+ <PublishSessionSwitch
+ projectId={projectId}
+ sessionId={sessionId}
+ isPublic={session.data?.public ?? false}
+ label="Share"
+ />
+ <CopySessionIdButton sessionId={sessionId} layout="menu" />
+ <CommentDrawerButton
+ variant="outline"
+ projectId={projectId}
+ objectId={sessionId}
+ objectType="SESSION"
+ count={getNumberFromMap(sessionCommentCounts.data, sessionId)}
+ layout="menu"
+ />
+ <AnnotateDrawer
+ projectId={projectId}
+ scoreTarget={{
+ type: "session",
+ sessionId,
+ }}
+ scores={session.data?.scores ?? []}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: session.data?.environment,
+ }}
+ buttonVariant="outline"
+ layout="menu"
+ />
+ <CreateNewAnnotationQueueItem
+ projectId={projectId}
+ objectId={sessionId}
+ objectType="SESSION"
+ variant="outline"
+ layout="menu"
+ />
+ <WebCalloutButton
+ projectId={projectId}
+ traceId={null}
+ observationId={null}
+ sessionId={sessionId}
+ layout="menu"
+ />
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={onDownloadSessionAsJson}
+ className="w-full justify-start gap-2 font-normal"
+ >
+ <Download className="h-4 w-4" />
+ <span className="text-sm">Download JSON</span>
+ </Button>
+ <label className="hover:bg-accent flex w-full items-center justify-between gap-4 rounded-md px-2 py-1.5">
+ <span className="text-sm">Show corrections</span>
+ <Switch
+ checked={showCorrections}
+ onCheckedChange={setShowCorrectionsForSession}
+ size="sm"
+ />
+ </label>
+ </>
+ ),
}}
>
<div className="flex h-full flex-col overflow-auto">
@@ -1413,6 +1510,86 @@ const LoadedSessionEventsPage: React.FC<{
) : null}
</>
),
+ // Mobile compact header: the same session actions as full-width
+ // labeled menu rows for the `⋯` overflow popover, instead of the
+ // inline icon toolbar. Session-to-session nav stays desktop-only.
+ actionButtonsMenu: (
+ <>
+ <StarSessionToggle
+ projectId={projectId}
+ sessionId={sessionId}
+ value={session.bookmarked}
+ showLabel
+ />
+ <PublishSessionSwitch
+ projectId={projectId}
+ sessionId={sessionId}
+ isPublic={session.public}
+ label="Share"
+ />
+ <CopySessionIdButton sessionId={sessionId} layout="menu" />
+ <CommentDrawerButton
+ variant="outline"
+ projectId={projectId}
+ objectId={sessionId}
+ objectType="SESSION"
+ count={getNumberFromMap(sessionCommentCounts.data, sessionId)}
+ layout="menu"
+ />
+ <AnnotateDrawer
+ projectId={projectId}
+ scoreTarget={{
+ type: "session",
+ sessionId,
+ }}
+ scores={session.scores}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: session.environment,
+ }}
+ buttonVariant="outline"
+ layout="menu"
+ />
+ <CreateNewAnnotationQueueItem
+ projectId={projectId}
+ objectId={sessionId}
+ objectType="SESSION"
+ variant="outline"
+ layout="menu"
+ />
+ <WebCalloutButton
+ projectId={projectId}
+ traceId={null}
+ observationId={null}
+ sessionId={sessionId}
+ layout="menu"
+ />
+ {isModernSessionEnabled ? (
+ displayOptions.map(({ label, checked, onCheckedChange }) => (
+ <label
+ key={label}
+ className="hover:bg-accent flex w-full items-center justify-between gap-4 rounded-md px-2 py-1.5"
+ >
+ <span className="text-sm capitalize">{label}</span>
+ <Switch
+ checked={checked}
+ onCheckedChange={onCheckedChange}
+ size="sm"
+ />
+ </label>
+ ))
+ ) : (
+ <label className="hover:bg-accent flex w-full items-center justify-between gap-4 rounded-md px-2 py-1.5">
+ <span className="text-sm">Show corrections</span>
+ <Switch
+ checked={showCorrections}
+ onCheckedChange={setShowCorrectionsForSession}
+ size="sm"
+ />
+ </label>
+ )}
+ </>
+ ),
}}
>
<div
diff --git a/web/src/components/star-toggle.tsx b/web/src/components/star-toggle.tsx
index 708535f1af..faf54eba13 100644
--- a/web/src/components/star-toggle.tsx
+++ b/web/src/components/star-toggle.tsx
@@ -237,11 +237,14 @@ export function StarSessionToggle({
sessionId,
value,
size = "icon",
+ showLabel = false,
}: {
projectId: string;
sessionId: string;
value: boolean;
size?: "icon" | "icon-xs";
+ /** Render as a full-width labeled menu item (label tracks the state). */
+ showLabel?: boolean;
}) {
const utils = api.useUtils();
const hasAccess = useHasProjectAccess({
@@ -259,6 +262,7 @@ export function StarSessionToggle({
<StarToggle
value={value}
size={size}
+ showLabel={showLabel}
isLoading={mutBookmarkSession.isPending}
disabled={!hasAccess}
onClick={(value) => {
diff --git a/web/src/components/trace/TracePage.tsx b/web/src/components/trace/TracePage.tsx
index 22512fde49..5e65bdd17e 100644
--- a/web/src/components/trace/TracePage.tsx
+++ b/web/src/components/trace/TracePage.tsx
@@ -156,6 +156,21 @@ export function TracePage({
/>
</>
),
+ // Mobile compact header: the same trace actions as full-width labeled
+ // menu rows (Bookmark / Share / Delete) for the `⋯` overflow, instead
+ // of the inline icon toolbar. Trace-to-trace nav is desktop-only.
+ actionButtonsMenu: (
+ <TraceDetailActions
+ traceId={trace.data.id}
+ projectId={trace.data.projectId}
+ bookmarked={trace.data.bookmarked}
+ isPublic={trace.data.public}
+ name={trace.data.name}
+ timestamp={timestamp}
+ deleteRedirectUrl={`/project/${router.query.projectId as string}/traces`}
+ layout="menu"
+ />
+ ),
}}
>
<div className="flex max-h-full min-h-0 flex-1 overflow-hidden">
diff --git a/web/src/components/trace/components/ObservationDetailView/ObservationDetailViewHeader.tsx b/web/src/components/trace/components/ObservationDetailView/ObservationDetailViewHeader.tsx
index c69f7b819c..5ec9289e2f 100644
--- a/web/src/components/trace/components/ObservationDetailView/ObservationDetailViewHeader.tsx
+++ b/web/src/components/trace/components/ObservationDetailView/ObservationDetailViewHeader.tsx
@@ -52,14 +52,22 @@ import { useViewPreferences } from "@/src/components/trace/contexts/ViewPreferen
import { useV4Beta } from "@/src/features/events/hooks/useV4Beta";
import { useTraceData } from "@/src/components/trace/contexts/TraceDataContext";
import { Button } from "@/src/components/ui/button";
-import { LockIcon, SquarePen } from "lucide-react";
+import { LockIcon, MoreHorizontal, SquarePen } from "lucide-react";
import {
Drawer,
DrawerContent,
DrawerTrigger,
} from "@/src/components/ui/drawer";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/src/components/ui/popover";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { DualAnnotationContent } from "@/src/features/scores/components/DualAnnotationContent";
+import { CollapsibleBadgeRow } from "@/src/components/trace/components/_shared/CollapsibleBadgeRow";
+import { useIsMobile } from "@/src/hooks/use-mobile";
+import { cn } from "@/src/utils/tailwind";
export interface ObservationDetailViewHeaderProps {
observation: ObservationReturnTypeWithMetadata;
@@ -102,6 +110,7 @@ export const ObservationDetailViewHeader = memo(
treeNodeTotalCost,
}: ObservationDetailViewHeaderProps) {
const { isAnnotationMode } = useViewPreferences();
+ const isMobile = useIsMobile();
const { isBetaEnabled: isV4Enabled } = useV4Beta();
const { trace, serverScores } = useTraceData();
@@ -129,7 +138,12 @@ export const ObservationDetailViewHeader = memo(
<div className="grid w-full grid-cols-1 items-start gap-2 @2xl:grid-cols-[auto_auto] @2xl:justify-between">
<div className="flex w-full flex-row items-center gap-1">
<ItemBadge type={observation.type as ObservationType} isSmall />
- <span className="mb-0 line-clamp-2 min-w-0 font-bold break-all md:break-normal md:wrap-break-word">
+ <span
+ className={cn(
+ "mb-0 line-clamp-2 min-w-0 font-bold break-all md:break-normal md:wrap-break-word",
+ isMobile && "flex-1",
+ )}
+ >
{observation.name || observation.id}
</span>
<DetailHeaderActionsMenu
@@ -146,98 +160,217 @@ export const ObservationDetailViewHeader = memo(
sessionId: observation.sessionId ?? null,
}}
/>
- </div>
- {/* Action buttons */}
- <div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
- {observationWithIO && (
- <NewDatasetItemFromExistingObject
- traceId={traceId}
- observationId={observation.id}
- projectId={projectId}
- input={observationWithIO.input}
- output={observationWithIO.output}
- metadata={observationWithIO.metadata}
- key={observation.id}
- size="sm"
- />
- )}
- {/* Hide annotation buttons in annotation mode (panel shown separately) */}
- {!isAnnotationMode && (
- <div className="flex items-start">
- {isV4Enabled ? (
- <Drawer key={"annotation-drawer-" + observation.id}>
- <DrawerTrigger asChild>
- <Button
- variant="secondary"
- size="sm"
- disabled={!hasAnnotationAccess}
- className="rounded-r-none"
- >
- {!hasAnnotationAccess ? (
- <LockIcon className="mr-1.5 h-3 w-3" />
- ) : (
- <SquarePen className="mr-1.5 h-3.5 w-3.5" />
- )}
- <span>Annotate</span>
- </Button>
- </DrawerTrigger>
- <DrawerContent className="p-3">
- <DualAnnotationContent
+ {/* Mobile: collapse the action-button cluster into a `⋯` overflow of
+ full-width labeled rows, next to the `â‹®` utility menu. */}
+ {isMobile && (
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ size="icon"
+ aria-label="More actions"
+ className="ml-auto shrink-0"
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent
+ align="end"
+ // forceMount + hide-when-closed: CommentDrawerButton lives in
+ // here, and its deep-link auto-open effect (?comments=open) and
+ // controlled inline-selection flow only work while mounted. A
+ // default Popover unmounts its content when closed (the default
+ // state), silently breaking both. Keep it mounted, just hidden.
+ forceMount
+ className="flex w-auto min-w-44 flex-col gap-0.5 p-1 data-[state=closed]:hidden"
+ >
+ {observationWithIO && (
+ <NewDatasetItemFromExistingObject
+ traceId={traceId}
+ observationId={observation.id}
+ projectId={projectId}
+ input={observationWithIO.input}
+ output={observationWithIO.output}
+ metadata={observationWithIO.metadata}
+ layout="menu"
+ />
+ )}
+ {!isAnnotationMode && (
+ <>
+ {isV4Enabled ? (
+ <Drawer
+ key={"annotation-drawer-menu-" + observation.id}
+ >
+ <DrawerTrigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={!hasAnnotationAccess}
+ className="w-full justify-start gap-2 font-normal"
+ >
+ {!hasAnnotationAccess ? (
+ <LockIcon className="h-3 w-3" />
+ ) : (
+ <SquarePen className="h-4 w-4" />
+ )}
+ <span className="text-sm">Annotate</span>
+ </Button>
+ </DrawerTrigger>
+ <DrawerContent className="p-3">
+ <DualAnnotationContent
+ projectId={projectId}
+ traceId={traceId}
+ observationId={observation.id}
+ traceEnvironment={trace.environment}
+ observationEnvironment={observation.environment}
+ observationScores={observationScores}
+ traceScores={traceScores}
+ />
+ </DrawerContent>
+ </Drawer>
+ ) : (
+ <AnnotateDrawer
+ key={"annotation-drawer-menu-" + observation.id}
+ projectId={projectId}
+ scoreTarget={{
+ type: "trace",
+ traceId: traceId,
+ observationId: observation.id,
+ }}
+ scores={observationScores}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: observation.environment,
+ }}
+ layout="menu"
+ />
+ )}
+ <CreateNewAnnotationQueueItem
projectId={projectId}
- traceId={traceId}
- observationId={observation.id}
- traceEnvironment={trace.environment}
- observationEnvironment={observation.environment}
- observationScores={observationScores}
- traceScores={traceScores}
+ objectId={observation.id}
+ objectType={AnnotationQueueObjectType.OBSERVATION}
+ layout="menu"
+ />
+ </>
+ )}
+ {observationWithIO &&
+ isGenerationLike(observationWithIO.type) && (
+ <JumpToPlaygroundButton
+ source="generation"
+ generation={observationWithIO}
+ analyticsEventName="trace_detail:test_in_playground_button_click"
+ layout="menu"
/>
- </DrawerContent>
- </Drawer>
- ) : (
- <AnnotateDrawer
- key={"annotation-drawer-" + observation.id}
+ )}
+ <CommentDrawerButton
projectId={projectId}
- scoreTarget={{
- type: "trace",
- traceId: traceId,
- observationId: observation.id,
- }}
- scores={observationScores}
- scoreMetadata={{
- projectId: projectId,
- environment: observation.environment,
- }}
- size="sm"
+ objectId={observation.id}
+ objectType="OBSERVATION"
+ count={commentCount}
+ layout="menu"
+ pendingSelection={pendingSelection}
+ onSelectionUsed={onSelectionUsed}
+ isOpen={isCommentDrawerOpen}
+ onOpenChange={onCommentDrawerOpenChange}
/>
- )}
- <CreateNewAnnotationQueueItem
+ </PopoverContent>
+ </Popover>
+ )}
+ </div>
+ {/* Action buttons (desktop inline cluster) */}
+ {!isMobile && (
+ <div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
+ {observationWithIO && (
+ <NewDatasetItemFromExistingObject
+ traceId={traceId}
+ observationId={observation.id}
projectId={projectId}
- objectId={observation.id}
- objectType={AnnotationQueueObjectType.OBSERVATION}
+ input={observationWithIO.input}
+ output={observationWithIO.output}
+ metadata={observationWithIO.metadata}
+ key={observation.id}
size="sm"
/>
- </div>
- )}
- {observationWithIO && isGenerationLike(observationWithIO.type) && (
- <JumpToPlaygroundButton
- source="generation"
- generation={observationWithIO}
- analyticsEventName="trace_detail:test_in_playground_button_click"
+ )}
+ {/* Hide annotation buttons in annotation mode (panel shown separately) */}
+ {!isAnnotationMode && (
+ <div className="flex items-start">
+ {isV4Enabled ? (
+ <Drawer key={"annotation-drawer-" + observation.id}>
+ <DrawerTrigger asChild>
+ <Button
+ variant="secondary"
+ size="sm"
+ disabled={!hasAnnotationAccess}
+ className="rounded-r-none"
+ >
+ {!hasAnnotationAccess ? (
+ <LockIcon className="mr-1.5 h-3 w-3" />
+ ) : (
+ <SquarePen className="mr-1.5 h-3.5 w-3.5" />
+ )}
+ <span>Annotate</span>
+ </Button>
+ </DrawerTrigger>
+ <DrawerContent className="p-3">
+ <DualAnnotationContent
+ projectId={projectId}
+ traceId={traceId}
+ observationId={observation.id}
+ traceEnvironment={trace.environment}
+ observationEnvironment={observation.environment}
+ observationScores={observationScores}
+ traceScores={traceScores}
+ />
+ </DrawerContent>
+ </Drawer>
+ ) : (
+ <AnnotateDrawer
+ key={"annotation-drawer-" + observation.id}
+ projectId={projectId}
+ scoreTarget={{
+ type: "trace",
+ traceId: traceId,
+ observationId: observation.id,
+ }}
+ scores={observationScores}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: observation.environment,
+ }}
+ size="sm"
+ />
+ )}
+ <CreateNewAnnotationQueueItem
+ projectId={projectId}
+ objectId={observation.id}
+ objectType={AnnotationQueueObjectType.OBSERVATION}
+ size="sm"
+ />
+ </div>
+ )}
+ {observationWithIO &&
+ isGenerationLike(observationWithIO.type) && (
+ <JumpToPlaygroundButton
+ source="generation"
+ generation={observationWithIO}
+ analyticsEventName="trace_detail:test_in_playground_button_click"
+ size="sm"
+ />
+ )}
+ <CommentDrawerButton
+ projectId={projectId}
+ objectId={observation.id}
+ objectType="OBSERVATION"
+ count={commentCount}
size="sm"
+ pendingSelection={pendingSelection}
+ onSelectionUsed={onSelectionUsed}
+ isOpen={isCommentDrawerOpen}
+ onOpenChange={onCommentDrawerOpenChange}
/>
- )}
- <CommentDrawerButton
- projectId={projectId}
- objectId={observation.id}
- objectType="OBSERVATION"
- count={commentCount}
- size="sm"
- pendingSelection={pendingSelection}
- onSelectionUsed={onSelectionUsed}
- isOpen={isCommentDrawerOpen}
- onOpenChange={onCommentDrawerOpenChange}
- />
- </div>
+ </div>
+ )}
</div>
{/* Metadata badges */}
@@ -254,7 +387,7 @@ export const ObservationDetailViewHeader = memo(
{/* Other badges */}
{!isAnnotationMode && (
- <div className="flex flex-wrap items-center gap-1">
+ <CollapsibleBadgeRow>
<LatencyBadge latencySeconds={latencySeconds} />
<TimeToFirstTokenBadge
timeToFirstToken={observation.timeToFirstToken}
@@ -317,7 +450,7 @@ export const ObservationDetailViewHeader = memo(
projectId={projectId}
/>
)}
- </div>
+ </CollapsibleBadgeRow>
)}
</div>
</div>
diff --git a/web/src/components/trace/components/TraceDetailView/TraceDetailViewHeader.tsx b/web/src/components/trace/components/TraceDetailView/TraceDetailViewHeader.tsx
index cde86c3d88..d2f593c23b 100644
--- a/web/src/components/trace/components/TraceDetailView/TraceDetailViewHeader.tsx
+++ b/web/src/components/trace/components/TraceDetailView/TraceDetailViewHeader.tsx
@@ -42,6 +42,16 @@ import {
import { aggregateTraceMetrics } from "@/src/components/trace/lib/trace-aggregation";
import { resolveEvalExecutionMetadata } from "@/src/components/trace/lib/resolve-metadata";
import { useViewPreferences } from "@/src/components/trace/contexts/ViewPreferencesContext";
+import { CollapsibleBadgeRow } from "@/src/components/trace/components/_shared/CollapsibleBadgeRow";
+import { useIsMobile } from "@/src/hooks/use-mobile";
+import { Button } from "@/src/components/ui/button";
+import { MoreHorizontal } from "lucide-react";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/src/components/ui/popover";
+import { cn } from "@/src/utils/tailwind";
export interface TraceDetailViewHeaderProps {
trace: Omit<WithStringifiedMetadata<TraceDomain>, "input" | "output"> & {
@@ -74,6 +84,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
onCommentDrawerOpenChange,
}: TraceDetailViewHeaderProps) {
const { isAnnotationMode } = useViewPreferences();
+ const isMobile = useIsMobile();
const aggregatedMetrics = useMemo(
() => aggregateTraceMetrics(observations),
[observations],
@@ -90,7 +101,12 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
<div className="grid w-full grid-cols-1 items-start gap-2 @2xl:grid-cols-[auto_auto] @2xl:justify-between">
<div className="flex w-full flex-row items-center gap-1">
<ItemBadge type="TRACE" isSmall />
- <span className="line-clamp-2 min-w-0 font-bold break-all md:break-normal md:wrap-break-word">
+ <span
+ className={cn(
+ "line-clamp-2 min-w-0 font-bold break-all md:break-normal md:wrap-break-word",
+ isMobile && "flex-1",
+ )}
+ >
{trace.name || trace.id}
</span>
<DetailHeaderActionsMenu
@@ -101,55 +117,126 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
sessionId: trace.sessionId ?? null,
}}
/>
- </div>
- {/* Action buttons */}
- <div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
- <NewDatasetItemFromExistingObject
- traceId={trace.id}
- projectId={projectId}
- input={trace.input}
- output={trace.output}
- metadata={trace.metadata}
- key={trace.id}
- size="sm"
- />
- {/* Hide annotation buttons in annotation mode (panel shown separately) */}
- {!isAnnotationMode && (
- <div className="flex items-start">
- <AnnotateDrawer
- key={"annotation-drawer-" + trace.id}
- projectId={projectId}
- scoreTarget={{
- type: "trace",
- traceId: trace.id,
- }}
- scores={traceScores}
- scoreMetadata={{
- projectId: projectId,
- environment: trace.environment,
- }}
- size="sm"
- />
- <CreateNewAnnotationQueueItem
- projectId={projectId}
- objectId={trace.id}
- objectType={AnnotationQueueObjectType.TRACE}
- size="sm"
- />
- </div>
+ {/* Mobile: collapse the action-button cluster into a `⋯` overflow of
+ full-width labeled rows, next to the `â‹®` utility menu. */}
+ {isMobile && (
+ <Popover>
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ size="icon"
+ aria-label="More actions"
+ className="ml-auto shrink-0"
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent
+ align="end"
+ // forceMount + hide-when-closed: CommentDrawerButton lives in
+ // here, and its deep-link auto-open effect (?comments=open) and
+ // controlled inline-selection flow only work while mounted. A
+ // default Popover unmounts its content when closed (the default
+ // state), silently breaking both. Keep it mounted, just hidden.
+ forceMount
+ className="flex w-auto min-w-44 flex-col gap-0.5 p-1 data-[state=closed]:hidden"
+ >
+ <NewDatasetItemFromExistingObject
+ traceId={trace.id}
+ projectId={projectId}
+ input={trace.input}
+ output={trace.output}
+ metadata={trace.metadata}
+ layout="menu"
+ />
+ {!isAnnotationMode && (
+ <>
+ <AnnotateDrawer
+ projectId={projectId}
+ scoreTarget={{
+ type: "trace",
+ traceId: trace.id,
+ }}
+ scores={traceScores}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: trace.environment,
+ }}
+ layout="menu"
+ />
+ <CreateNewAnnotationQueueItem
+ projectId={projectId}
+ objectId={trace.id}
+ objectType={AnnotationQueueObjectType.TRACE}
+ layout="menu"
+ />
+ </>
+ )}
+ <CommentDrawerButton
+ projectId={projectId}
+ objectId={trace.id}
+ objectType="TRACE"
+ count={commentCount}
+ layout="menu"
+ pendingSelection={pendingSelection}
+ onSelectionUsed={onSelectionUsed}
+ isOpen={isCommentDrawerOpen}
+ onOpenChange={onCommentDrawerOpenChange}
+ />
+ </PopoverContent>
+ </Popover>
)}
- <CommentDrawerButton
- projectId={projectId}
- objectId={trace.id}
- objectType="TRACE"
- count={commentCount}
- size="sm"
- pendingSelection={pendingSelection}
- onSelectionUsed={onSelectionUsed}
- isOpen={isCommentDrawerOpen}
- onOpenChange={onCommentDrawerOpenChange}
- />
</div>
+ {/* Action buttons (desktop inline cluster) */}
+ {!isMobile && (
+ <div className="flex h-full flex-wrap content-start items-start justify-start gap-0.5 @2xl:mr-1 @2xl:justify-end">
+ <NewDatasetItemFromExistingObject
+ traceId={trace.id}
+ projectId={projectId}
+ input={trace.input}
+ output={trace.output}
+ metadata={trace.metadata}
+ key={trace.id}
+ size="sm"
+ />
+ {/* Hide annotation buttons in annotation mode (panel shown separately) */}
+ {!isAnnotationMode && (
+ <div className="flex items-start">
+ <AnnotateDrawer
+ key={"annotation-drawer-" + trace.id}
+ projectId={projectId}
+ scoreTarget={{
+ type: "trace",
+ traceId: trace.id,
+ }}
+ scores={traceScores}
+ scoreMetadata={{
+ projectId: projectId,
+ environment: trace.environment,
+ }}
+ size="sm"
+ />
+ <CreateNewAnnotationQueueItem
+ projectId={projectId}
+ objectId={trace.id}
+ objectType={AnnotationQueueObjectType.TRACE}
+ size="sm"
+ />
+ </div>
+ )}
+ <CommentDrawerButton
+ projectId={projectId}
+ objectId={trace.id}
+ objectType="TRACE"
+ count={commentCount}
+ size="sm"
+ pendingSelection={pendingSelection}
+ onSelectionUsed={onSelectionUsed}
+ isOpen={isCommentDrawerOpen}
+ onOpenChange={onCommentDrawerOpenChange}
+ />
+ </div>
+ )}
</div>
{/* Metadata badges */}
@@ -165,7 +252,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
{/* Other badges */}
{!isAnnotationMode && (
- <div className="flex flex-wrap items-center gap-1">
+ <CollapsibleBadgeRow>
<LatencyBadge latencySeconds={trace.latency ?? null} />
<SessionBadge sessionId={trace.sessionId} projectId={projectId} />
<UserIdBadge userId={trace.userId} projectId={projectId} />
@@ -190,7 +277,7 @@ export const TraceDetailViewHeader = memo(function TraceDetailViewHeader({
usageDetails={aggregatedMetrics.usageDetails}
/>
)}
- </div>
+ </CollapsibleBadgeRow>
)}
</div>
</div>
diff --git a/web/src/components/trace/components/_shared/CollapsibleBadgeRow.tsx b/web/src/components/trace/components/_shared/CollapsibleBadgeRow.tsx
new file mode 100644
index 0000000000..59f589649a
--- /dev/null
+++ b/web/src/components/trace/components/_shared/CollapsibleBadgeRow.tsx
@@ -0,0 +1,68 @@
+/**
+ * CollapsibleBadgeRow - metadata-badge row wrapper shared by the trace and
+ * observation detail headers.
+ *
+ * Desktop: renders the full `flex flex-wrap` badge set exactly as before.
+ * Mobile: clips the badges to a single line and adds a chevron toggle that
+ * expands to the full wrapped set (and collapses back). Uses local state only;
+ * no effects.
+ */
+
+import { useState } from "react";
+import { ChevronDown, ChevronUp } from "lucide-react";
+import { Button } from "@/src/components/ui/button";
+import { cn } from "@/src/utils/tailwind";
+import { useIsMobile } from "@/src/hooks/use-mobile";
+
+export function CollapsibleBadgeRow({
+ children,
+ className,
+}: {
+ children: React.ReactNode;
+ className?: string;
+}) {
+ const isMobile = useIsMobile();
+ const [expanded, setExpanded] = useState(false);
+
+ // Desktop: unchanged full wrapped badge row.
+ if (!isMobile) {
+ return (
+ <div className={cn("flex flex-wrap items-center gap-1", className)}>
+ {children}
+ </div>
+ );
+ }
+
+ // Mobile: default to a single clipped line with an expand/collapse chevron.
+ return (
+ <div className="flex items-start gap-1">
+ <div
+ className={cn(
+ "flex min-w-0 flex-1 items-center gap-1",
+ // Collapsed: one clipped line. `[&>*]:shrink-0` stops flex from
+ // squeezing badges below their content width (which made long ones
+ // like "Time to first token" wrap vertically into a multi-line row);
+ // badges keep their natural width and overflow-hidden clips the rest.
+ expanded ? "flex-wrap" : "flex-nowrap overflow-hidden [&>*]:shrink-0",
+ )}
+ >
+ {children}
+ </div>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-xs"
+ aria-label={expanded ? "Show fewer details" : "Show more details"}
+ aria-expanded={expanded}
+ className="mt-0.5 shrink-0"
+ onClick={() => setExpanded((prev) => !prev)}
+ >
+ {expanded ? (
+ <ChevronUp className="h-4 w-4" />
+ ) : (
+ <ChevronDown className="h-4 w-4" />
+ )}
+ </Button>
+ </div>
+ );
+}
diff --git a/web/src/components/ui/popover.tsx b/web/src/components/ui/popover.tsx
index 2d655d015b..3e4586d4ab 100644
--- a/web/src/components/ui/popover.tsx
+++ b/web/src/components/ui/popover.tsx
@@ -13,26 +13,37 @@ const PopoverTrigger = PopoverPrimitive.Trigger;
const PopoverContent = React.forwardRef<
React.ComponentRef<typeof PopoverPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
->(({ className, align = "center", sideOffset = 4, ...props }, ref) => {
- // Route into the `popover` overlay layer (above `modal`, so popovers opened
- // inside a dialog render above it). null until mounted → falls back to
- // <body>, SSR-parity. Layer order, not z-index, stacks it.
- const container = useLayerContainer("popover");
- return (
- <PopoverPrimitive.Portal container={container}>
- <PopoverPrimitive.Content
- ref={ref}
- align={align}
- sideOffset={sideOffset}
- className={cn(
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-[calc(var(--radix-popover-content-available-height)-1rem)] max-w-[max(var(--radix-popover-trigger-width),fit-content)] min-w-72 overflow-y-auto rounded-md border p-3 shadow-md outline-hidden",
- className,
- )}
- {...props}
- />
- </PopoverPrimitive.Portal>
- );
-});
+>(
+ (
+ { className, align = "center", sideOffset = 4, forceMount, ...props },
+ ref,
+ ) => {
+ // Route into the `popover` overlay layer (above `modal`, so popovers opened
+ // inside a dialog render above it). null until mounted → falls back to
+ // <body>, SSR-parity. Layer order, not z-index, stacks it.
+ const container = useLayerContainer("popover");
+ // Forward `forceMount` to BOTH the Portal and the Content: Radix's Portal
+ // also gates on open state, so keeping the Content mounted while closed
+ // requires both. Callers pair this with `data-[state=closed]:hidden` when they
+ // need mounted-but-hidden content (e.g. a child whose effect must keep running
+ // while the popover is closed). Undefined for everyone else → default behavior.
+ return (
+ <PopoverPrimitive.Portal container={container} forceMount={forceMount}>
+ <PopoverPrimitive.Content
+ ref={ref}
+ align={align}
+ sideOffset={sideOffset}
+ forceMount={forceMount}
+ className={cn(
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 max-h-[calc(var(--radix-popover-content-available-height)-1rem)] max-w-[max(var(--radix-popover-trigger-width),fit-content)] min-w-72 overflow-y-auto rounded-md border p-3 shadow-md outline-hidden",
+ className,
+ )}
+ {...props}
+ />
+ </PopoverPrimitive.Portal>
+ );
+ },
+);
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
const PopoverClose = PopoverPrimitive.Close;
diff --git a/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx b/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
index a3756248d2..29a4ce6a2d 100644
--- a/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
+++ b/web/src/features/annotation-queues/components/CreateNewAnnotationQueueItem.tsx
@@ -12,7 +12,7 @@ import {
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { api } from "@/src/utils/api";
import { type AnnotationQueueObjectType } from "@langfuse/shared";
-import { ChevronDown, ExternalLink } from "lucide-react";
+import { ChevronDown, ExternalLink, ListPlus } from "lucide-react";
import { useSession } from "next-auth/react";
import Link from "next/link";
import { useState, useCallback } from "react";
@@ -23,13 +23,21 @@ export const CreateNewAnnotationQueueItem = ({
objectType,
variant = "secondary",
size = "default",
+ layout = "toolbar",
}: {
projectId: string;
objectId: string;
objectType: AnnotationQueueObjectType;
variant?: ButtonProps["variant"];
size?: ButtonProps["size"];
+ /**
+ * "toolbar" (default) is the inline split-button chevron; "menu" renders the
+ * same dropdown trigger as a full-width labeled row ("Add to queue") for the
+ * mobile header overflow popover.
+ */
+ layout?: "toolbar" | "menu";
}) => {
+ const isMenu = layout === "menu";
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const session = useSession();
const hasAccess = useHasProjectAccess({
@@ -93,14 +101,25 @@ export const CreateNewAnnotationQueueItem = ({
if (session.status !== "authenticated" || queues.isLoading) {
return (
<Button
- variant={variant}
- size={size}
+ variant={isMenu ? "ghost" : variant}
+ size={isMenu ? "sm" : size}
disabled={session.status !== "authenticated"}
- className="rounded-l-none rounded-r-md border-l-2"
+ className={
+ isMenu
+ ? "w-full justify-start gap-2 font-normal"
+ : "rounded-l-none rounded-r-md border-l-2"
+ }
>
- <span className="relative mr-1 text-xs">
- <ChevronDown className="h-3 w-3" />
- </span>
+ {isMenu ? (
+ <>
+ <ListPlus className="h-4 w-4" />
+ <span className="text-sm">Add to queue</span>
+ </>
+ ) : (
+ <span className="relative mr-1 text-xs">
+ <ChevronDown className="h-3 w-3" />
+ </span>
+ )}
</Button>
);
}
@@ -117,12 +136,26 @@ export const CreateNewAnnotationQueueItem = ({
>
<DropdownMenuTrigger asChild>
<Button
- variant={variant}
- size={size}
+ variant={isMenu ? "ghost" : variant}
+ size={isMenu ? "sm" : size}
disabled={!hasAccess}
- className="rounded-l-none rounded-r-md border-l-2"
+ className={
+ isMenu
+ ? "w-full justify-start gap-2 font-normal"
+ : "rounded-l-none rounded-r-md border-l-2"
+ }
>
- {queues.data?.totalCount ? (
+ {isMenu ? (
+ <>
+ <ListPlus className="h-4 w-4" />
+ <span className="text-sm">Add to queue</span>
+ {!!queues.data?.totalCount && (
+ <span className="bg-primary/50 text-primary-foreground ml-auto flex h-3.5 w-fit items-center justify-center rounded-sm px-1 text-xs shadow-xs">
+ {queues.data.totalCount > 99 ? "99+" : queues.data.totalCount}
+ </span>
+ )}
+ </>
+ ) : queues.data?.totalCount ? (
<span className="relative mr-1 text-xs">
<ChevronDown className="text-secondary-foreground h-3 w-3" />
<span className="bg-primary text-primary-foreground absolute -top-1 left-2.5 flex h-3 min-w-3 items-center justify-center rounded-sm px-0.5 text-[8px] font-bold shadow-xs">
diff --git a/web/src/features/comments/CommentDrawerButton.tsx b/web/src/features/comments/CommentDrawerButton.tsx
index 4240a4226f..b1bb92c359 100644
--- a/web/src/features/comments/CommentDrawerButton.tsx
+++ b/web/src/features/comments/CommentDrawerButton.tsx
@@ -31,6 +31,7 @@ export function CommentDrawerButton({
onCommentChange,
isOpen: controlledIsOpen,
onOpenChange: controlledOnOpenChange,
+ layout = "toolbar",
}: {
projectId: string;
objectId: string;
@@ -44,7 +45,13 @@ export function CommentDrawerButton({
onCommentChange?: () => void | Promise<void>;
isOpen?: boolean;
onOpenChange?: (open: boolean) => void;
+ /**
+ * "toolbar" (default) is the inline button; "menu" renders the same drawer
+ * trigger as a full-width labeled row for the mobile header overflow popover.
+ */
+ layout?: "toolbar" | "menu";
}) {
+ const isMenu = layout === "menu";
const router = useRouter();
const [isMentionDropdownOpen, setIsMentionDropdownOpen] = useState(false);
const [internalIsDrawerOpen, setInternalIsDrawerOpen] = useState(false);
@@ -111,18 +118,23 @@ export function CommentDrawerButton({
return (
<Button
type="button"
- variant="secondary"
- size={size}
- className={className}
+ variant={isMenu ? "ghost" : "secondary"}
+ size={isMenu ? "sm" : size}
+ className={
+ isMenu ? "w-full justify-start gap-2 font-normal" : className
+ }
disabled
>
<MessageSquareOff
className={
- size === "sm"
- ? "text-muted-foreground h-3.5 w-3.5"
- : "text-muted-foreground h-4 w-4"
+ isMenu
+ ? "text-muted-foreground h-4 w-4"
+ : size === "sm"
+ ? "text-muted-foreground h-3.5 w-3.5"
+ : "text-muted-foreground h-4 w-4"
}
/>
+ {isMenu ? <span className="text-sm">Add comment</span> : null}
</Button>
);
@@ -160,29 +172,30 @@ export function CommentDrawerButton({
<DrawerTrigger asChild>
<Button
type="button"
- variant={variant}
- size={size}
- className={className}
+ variant={isMenu ? "ghost" : variant}
+ size={isMenu ? "sm" : size}
+ className={
+ isMenu ? "w-full justify-start gap-2 font-normal" : className
+ }
id="comment-drawer-button"
>
- {!!count ? (
- <div className="flex items-center gap-1">
- <MessageSquare
- className={size === "sm" ? "h-3.5 w-3.5" : "h-4 w-4"}
- />
- <span>Add comment</span>
+ <div
+ className={
+ isMenu ? "flex items-center gap-2" : "flex items-center gap-1"
+ }
+ >
+ <MessageSquare
+ className={
+ isMenu ? "h-4 w-4" : size === "sm" ? "h-3.5 w-3.5" : "h-4 w-4"
+ }
+ />
+ <span className={isMenu ? "text-sm" : undefined}>Add comment</span>
+ {!!count ? (
<span className="bg-primary/50 text-primary-foreground flex h-3.5 w-fit items-center justify-center rounded-sm px-1 text-xs shadow-xs">
{count > 99 ? "99+" : count}
</span>
- </div>
- ) : (
- <div className="flex items-center gap-1">
- <MessageSquare
- className={size === "sm" ? "h-3.5 w-3.5" : "h-4 w-4"}
- />
- <span>Add comment</span>
- </div>
- )}
+ ) : null}
+ </div>
</Button>
</DrawerTrigger>
<DrawerContent
diff --git a/web/src/features/datasets/components/NewDatasetItemFromExistingObject.tsx b/web/src/features/datasets/components/NewDatasetItemFromExistingObject.tsx
index 529e57d26c..666235c721 100644
--- a/web/src/features/datasets/components/NewDatasetItemFromExistingObject.tsx
+++ b/web/src/features/datasets/components/NewDatasetItemFromExistingObject.tsx
@@ -46,7 +46,13 @@ export const NewDatasetItemFromExistingObject = (props: {
isCopyItem?: boolean;
buttonVariant?: ButtonProps["variant"];
size?: ButtonProps["size"];
+ /**
+ * "toolbar" (default) is the inline button; "menu" renders the same trigger
+ * as a full-width labeled row for the mobile header overflow popover.
+ */
+ layout?: "toolbar" | "menu";
}) => {
+ const isMenu = props.layout === "menu";
const normalizePrefillValue = (
value: Prisma.JsonValue | null,
): Prisma.JsonValue | null => {
@@ -109,12 +115,22 @@ export const NewDatasetItemFromExistingObject = (props: {
<DropdownMenu open={hasAccess ? undefined : false}>
<DropdownMenuTrigger asChild>
<Button
- variant="secondary"
- size={buttonSize}
+ variant={isMenu ? "ghost" : "secondary"}
+ size={isMenu ? "sm" : buttonSize}
disabled={!hasAccess}
+ className={
+ isMenu ? "w-full justify-start gap-2 font-normal" : undefined
+ }
>
- <span>{`In ${observationInDatasets.data.length} dataset(s)`}</span>
- <ChevronDown className="ml-2 h-3 w-3" />
+ {isMenu ? (
+ <PlusIcon className="h-4 w-4" aria-hidden="true" />
+ ) : null}
+ <span className={isMenu ? "text-sm" : undefined}>
+ {`In ${observationInDatasets.data.length} dataset(s)`}
+ </span>
+ <ChevronDown
+ className={isMenu ? "ml-auto h-3 w-3" : "ml-2 h-3 w-3"}
+ />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
@@ -154,22 +170,36 @@ export const NewDatasetItemFromExistingObject = (props: {
object: props.observationId ? "observation" : "trace",
});
}}
- variant={buttonVariant}
- size={buttonSize}
+ variant={isMenu ? "ghost" : buttonVariant}
+ size={isMenu ? "sm" : buttonSize}
disabled={!hasAccess}
+ className={
+ isMenu ? "w-full justify-start gap-2 font-normal" : undefined
+ }
>
{hasAccess ? (
<PlusIcon
className={cn(
- "mr-1.5 -ml-0.5",
- buttonSize === "sm" ? "h-3.5 w-3.5" : "h-4 w-4",
+ isMenu
+ ? "h-4 w-4"
+ : cn(
+ "mr-1.5 -ml-0.5",
+ buttonSize === "sm" ? "h-3.5 w-3.5" : "h-4 w-4",
+ ),
)}
aria-hidden="true"
/>
) : null}
- Add to datasets
+ {isMenu ? (
+ <span className="text-sm">Add to datasets</span>
+ ) : (
+ "Add to datasets"
+ )}
{!hasAccess ? (
- <LockIcon className="ml-1.5 h-3 w-3" aria-hidden="true" />
+ <LockIcon
+ className={isMenu ? "ml-auto h-3 w-3" : "ml-1.5 h-3 w-3"}
+ aria-hidden="true"
+ />
) : null}
</Button>
)}
diff --git a/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx b/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx
index 12bd045112..276c599c74 100644
--- a/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx
+++ b/web/src/features/playground/page/components/JumpToPlaygroundButton.tsx
@@ -68,6 +68,12 @@ type JumpToPlaygroundButtonProps = (
variant?: ButtonProps["variant"];
className?: string;
size?: ButtonProps["size"];
+ /**
+ * "toolbar" (default) is the inline button; "menu" renders the same dropdown
+ * trigger as a full-width labeled row ("Test in playground") for the mobile
+ * header overflow popover.
+ */
+ layout?: "toolbar" | "menu";
};
export const JumpToPlaygroundButton: React.FC<JumpToPlaygroundButtonProps> = (
@@ -189,26 +195,42 @@ export const JumpToPlaygroundButton: React.FC<JumpToPlaygroundButtonProps> = (
? "Test in LLM playground"
: "Test in LLM playground is not available since messages are not in valid ChatML format or tool calls have been used. If you think this is not correct, please open a GitHub issue.";
+ const isMenu = props.layout === "menu";
+
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
- variant={props.variant ?? "secondary"}
- size={props.size ?? "default"}
+ variant={isMenu ? "ghost" : (props.variant ?? "secondary")}
+ size={isMenu ? "sm" : (props.size ?? "default")}
disabled={!isAvailable}
title={tooltipMessage}
className={cn(
- "flex items-center gap-1",
+ isMenu
+ ? "w-full justify-start gap-2 font-normal"
+ : "flex items-center gap-1",
!isAvailable ? "cursor-not-allowed opacity-50" : "cursor-pointer",
)}
>
<Terminal
- className={props.size === "sm" ? "h-3.5 w-3.5" : "h-4 w-4"}
+ className={
+ isMenu
+ ? "h-4 w-4"
+ : props.size === "sm"
+ ? "h-3.5 w-3.5"
+ : "h-4 w-4"
+ }
/>
- <span className={cn("hidden md:inline", props.className)}>
- Playground
- </span>
- <ChevronDown className="h-3 w-3" />
+ {isMenu ? (
+ <span className="text-sm">Test in playground</span>
+ ) : (
+ <>
+ <span className={cn("hidden md:inline", props.className)}>
+ Playground
+ </span>
+ <ChevronDown className="h-3 w-3" />
+ </>
+ )}
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
diff --git a/web/src/features/scores/components/AnnotateDrawer.tsx b/web/src/features/scores/components/AnnotateDrawer.tsx
index f31fc90eca..d455abebea 100644
--- a/web/src/features/scores/components/AnnotateDrawer.tsx
+++ b/web/src/features/scores/components/AnnotateDrawer.tsx
@@ -23,9 +23,16 @@ export function AnnotateDrawer<Target extends ScoreTarget>({
scoreMetadata,
buttonVariant = "secondary",
size = "default",
+ layout = "toolbar",
}: AnnotateDrawerProps<Target> & {
size?: "default" | "sm" | "xs" | "lg" | "icon" | "icon-xs" | "icon-sm";
+ /**
+ * "toolbar" (default) is the inline button; "menu" renders the same drawer
+ * trigger as a full-width labeled row for the mobile header overflow popover.
+ */
+ layout?: "toolbar" | "menu";
}) {
+ const isMenu = layout === "menu";
const capture = usePostHogClientCapture();
const hasAccess = useHasProjectAccess({
projectId,
@@ -40,10 +47,12 @@ export function AnnotateDrawer<Target extends ScoreTarget>({
<Drawer>
<DrawerTrigger asChild>
<Button
- variant={buttonVariant}
- size={size}
+ variant={isMenu ? "ghost" : buttonVariant}
+ size={isMenu ? "sm" : size}
disabled={!hasAccess}
- className="rounded-r-none"
+ className={
+ isMenu ? "w-full justify-start gap-2 font-normal" : "rounded-r-none"
+ }
onClick={() => {
capture(
Boolean(scores.length)
@@ -54,15 +63,19 @@ export function AnnotateDrawer<Target extends ScoreTarget>({
}}
>
{!hasAccess ? (
- <LockIcon className="mr-1.5 h-3 w-3" />
+ <LockIcon className={isMenu ? "h-3 w-3" : "mr-1.5 h-3 w-3"} />
) : (
<SquarePen
className={
- size === "sm" ? "mr-1.5 h-3.5 w-3.5" : "mr-1.5 h-4 w-4"
+ isMenu
+ ? "h-4 w-4"
+ : size === "sm"
+ ? "mr-1.5 h-3.5 w-3.5"
+ : "mr-1.5 h-4 w-4"
}
/>
)}
- <span>Annotate</span>
+ <span className={isMenu ? "text-sm" : undefined}>Annotate</span>
</Button>
</DrawerTrigger>
<DrawerContent className="p-3">
diff --git a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
index 60b6fc1c90..bbbd4c9644 100644
--- a/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
+++ b/web/src/features/web-callouts/components/WebCalloutMenuItem.tsx
@@ -115,7 +115,16 @@ export function WebCalloutButton({
traceId,
observationId,
sessionId,
-}: WebCalloutTarget) {
+ layout = "toolbar",
+}: WebCalloutTarget & {
+ /**
+ * "toolbar" (default) is the inline icon button; "menu" renders the same
+ * action as a full-width labeled row for the mobile header overflow popover.
+ * (WebCalloutMenuItem is a Radix DropdownMenuItem and only works inside a
+ * DropdownMenu, so the plain-popover mobile menu uses this row instead.)
+ */
+ layout?: "toolbar" | "menu";
+}) {
const action = useWebCalloutAction({
projectId,
traceId,
@@ -129,6 +138,26 @@ export function WebCalloutButton({
const label = `Call ${action.endpointName}`;
+ if (layout === "menu") {
+ return (
+ <Button
+ aria-label={label}
+ variant="ghost"
+ size="sm"
+ loading={action.isLoading}
+ className="w-full justify-start gap-2 font-normal"
+ onClick={() => {
+ action.invokeCallout().catch(() => undefined);
+ }}
+ >
+ <Webhook className="h-4 w-4 shrink-0" />
+ <span className="min-w-0 truncate text-sm" title={label}>
+ {label}
+ </span>
+ </Button>
+ );
+ }
+
return (
<Tooltip>
<TooltipTrigger asChild>