Skip to content

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

feat(assistant): polish the assistant window header and composer (#16136)

Nikita Kabardine87c468999ac
diff --git a/web/src/components/movable-resizable-panel.clienttest.tsx b/web/src/components/movable-resizable-panel.clienttest.tsx
index 86cffc126d..58b4e1bad3 100644
--- a/web/src/components/movable-resizable-panel.clienttest.tsx
+++ b/web/src/components/movable-resizable-panel.clienttest.tsx
@@ -17,6 +17,7 @@ type TestPanelProps = {
minSize?: MovableResizablePanelSize;
ignoreOutsideInteraction?: boolean;
onActionClick?: () => void;
+ onDragHandleDoubleClick?: () => void;
onGeometryChange?: (geometry: MovableResizablePanelGeometry) => void;
};
@@ -28,6 +29,7 @@ function TestPanel({
maxSize,
minSize = { width: 200, height: 160 },
onActionClick,
+ onDragHandleDoubleClick,
onGeometryChange,
}: TestPanelProps) {
const handle = useMovableResizablePanelControl({
@@ -52,6 +54,7 @@ function TestPanel({
},
}}
ignoreOutsideInteraction={ignoreOutsideInteraction}
+ onDragHandleDoubleClick={onDragHandleDoubleClick}
>
<div className="h-full w-full">
<div data-drag-handle="true" data-testid="drag-handle">
@@ -76,7 +79,7 @@ function TestPanel({
function firePointerEvent(
element: Element,
type: "pointerdown" | "pointermove" | "pointerup",
- init: MouseEventInit & { pointerId: number },
+ init: MouseEventInit & { pointerId: number; timeStamp?: number },
) {
const event = new MouseEvent(type, {
bubbles: true,
@@ -86,6 +89,11 @@ function firePointerEvent(
});
Object.defineProperty(event, "pointerId", { value: init.pointerId });
+
+ if (init.timeStamp !== undefined) {
+ Object.defineProperty(event, "timeStamp", { value: init.timeStamp });
+ }
+
fireEvent(element, event);
}
@@ -128,6 +136,60 @@ describe("MovableResizablePanel", () => {
);
});
+ // Starting a drag has to `preventDefault()` the pointerdown, which suppresses
+ // the browser's own `dblclick`, so the panel detects the pair itself.
+ it("reports a double-click on the drag handle without moving the panel", () => {
+ const onDragHandleDoubleClick = vi.fn();
+ render(<TestPanel onDragHandleDoubleClick={onDragHandleDoubleClick} />);
+
+ const panel = screen.getByTestId("movable-resizable-panel");
+ const handle = screen.getByTestId("drag-handle");
+
+ firePointerEvent(handle, "pointerdown", {
+ pointerId: 1,
+ clientX: 140,
+ clientY: 150,
+ timeStamp: 1_000,
+ });
+ firePointerEvent(panel, "pointerup", { pointerId: 1 });
+ firePointerEvent(handle, "pointerdown", {
+ pointerId: 2,
+ clientX: 141,
+ clientY: 151,
+ timeStamp: 1_120,
+ });
+ firePointerEvent(panel, "pointermove", {
+ pointerId: 2,
+ clientX: 220,
+ clientY: 220,
+ });
+ firePointerEvent(panel, "pointerup", { pointerId: 2 });
+
+ expect(onDragHandleDoubleClick).toHaveBeenCalledTimes(1);
+ expect(screen.getByTestId("panel-state")).toHaveTextContent(
+ "100,100,300,240",
+ );
+
+ // Too slow to be a pair, so it drags instead.
+ firePointerEvent(handle, "pointerdown", {
+ pointerId: 3,
+ clientX: 141,
+ clientY: 151,
+ timeStamp: 3_000,
+ });
+ firePointerEvent(panel, "pointermove", {
+ pointerId: 3,
+ clientX: 161,
+ clientY: 171,
+ });
+ firePointerEvent(panel, "pointerup", { pointerId: 3 });
+
+ expect(onDragHandleDoubleClick).toHaveBeenCalledTimes(1);
+ expect(screen.getByTestId("panel-state")).toHaveTextContent(
+ "120,120,300,240",
+ );
+ });
+
it("resizes from the bottom-right handle", () => {
render(<TestPanel />);
diff --git a/web/src/components/movable-resizable-panel.tsx b/web/src/components/movable-resizable-panel.tsx
index 544e5edde9..c9ad4ef9fb 100644
--- a/web/src/components/movable-resizable-panel.tsx
+++ b/web/src/components/movable-resizable-panel.tsx
@@ -96,10 +96,16 @@ type MovableResizablePanelProps = {
handle: MovableResizablePanelHandle;
dragHandleSelector: string;
ignoreOutsideInteraction?: boolean;
+ /** Title-bar double-click. Starting a drag has to `preventDefault()` the
+ * pointerdown, which suppresses every compat mouse event including
+ * `dblclick`, so a plain `onDoubleClick` on the handle never fires. */
+ onDragHandleDoubleClick?: () => void;
style?: CSSProperties;
};
const DEFAULT_BOUNDS_PADDING = 8;
+const DRAG_HANDLE_DOUBLE_CLICK_MAX_DELAY_MS = 500;
+const DRAG_HANDLE_DOUBLE_CLICK_MAX_DISTANCE_PX = 4;
export function useMovableResizablePanelControl({
boundsPadding = DEFAULT_BOUNDS_PADDING,
@@ -532,12 +538,18 @@ export const MovableResizablePanel = forwardRef<
dragHandleSelector,
handle,
ignoreOutsideInteraction = false,
+ onDragHandleDoubleClick,
style,
},
forwardedRef,
) {
const panelRef = useRef<HTMLDivElement>(null);
const interactionRef = useRef<Interaction | null>(null);
+ const lastHandlePointerDownRef = useRef<{
+ timeStamp: number;
+ clientX: number;
+ clientY: number;
+ } | null>(null);
const [draftPanel, setDraftPanel] =
useState<MovableResizablePanelGeometry | null>(null);
const renderedPanel = draftPanel ?? handle.getGeometry();
@@ -569,6 +581,33 @@ export const MovableResizablePanel = forwardRef<
event.preventDefault();
event.stopPropagation();
+ const previousPointerDown = lastHandlePointerDownRef.current;
+ // A double *tap* is a zoom/select gesture, never a maximize.
+ const isDoubleClick =
+ event.pointerType !== "touch" &&
+ previousPointerDown !== null &&
+ event.timeStamp - previousPointerDown.timeStamp <=
+ DRAG_HANDLE_DOUBLE_CLICK_MAX_DELAY_MS &&
+ Math.abs(coordinates.clientX - previousPointerDown.clientX) <=
+ DRAG_HANDLE_DOUBLE_CLICK_MAX_DISTANCE_PX &&
+ Math.abs(coordinates.clientY - previousPointerDown.clientY) <=
+ DRAG_HANDLE_DOUBLE_CLICK_MAX_DISTANCE_PX;
+
+ // Consume the pair, so a third click starts counting fresh rather than
+ // firing again.
+ lastHandlePointerDownRef.current = isDoubleClick
+ ? null
+ : {
+ timeStamp: event.timeStamp,
+ clientX: coordinates.clientX,
+ clientY: coordinates.clientY,
+ };
+
+ if (isDoubleClick && onDragHandleDoubleClick) {
+ onDragHandleDoubleClick();
+ return;
+ }
+
const { position, size } = renderedPanelRef.current;
interactionRef.current = {
diff --git a/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx b/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx
index 3c446195b4..e5b509ea78 100644
--- a/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx
+++ b/web/src/features/in-app-agent/components/ControlledInAppAgentWindow.tsx
@@ -87,6 +87,7 @@ export function ControlledInAppAgentWindow(
rejectToolCall,
selectConversation,
selectedConversationId,
+ selectedConversationTitle,
selectedConversationIsWriteLocked,
submit,
submitFeedback,
@@ -215,6 +216,7 @@ export function ControlledInAppAgentWindow(
hasMoreConversations={hasMoreConversations}
isLoadingMoreConversations={isLoadingMoreConversations}
selectedConversationId={selectedConversationId}
+ selectedConversationTitle={selectedConversationTitle}
onLoadMoreConversations={loadMoreConversations}
onOpenConversationHistory={invalidateConversations}
onDeleteConversation={props.onDeleteConversation}
diff --git a/web/src/features/in-app-agent/components/InAppAgentWindow.clienttest.tsx b/web/src/features/in-app-agent/components/InAppAgentWindow.clienttest.tsx
index 877e967d61..c084dcf4f7 100644
--- a/web/src/features/in-app-agent/components/InAppAgentWindow.clienttest.tsx
+++ b/web/src/features/in-app-agent/components/InAppAgentWindow.clienttest.tsx
@@ -44,6 +44,7 @@ const controlledAgent = vi.hoisted(() => ({
approveToolCall: vi.fn(),
rejectToolCall: vi.fn(),
selectedConversationId: undefined,
+ selectedConversationTitle: null,
selectedConversationIsWriteLocked: false,
submit: vi.fn(),
submitFeedback: vi.fn(),
@@ -108,6 +109,7 @@ function windowElement(
quickActionResetKey: "/project/project-1/traces",
screenContextDescription: { type: "trace-list" },
selectedConversationId: undefined,
+ selectedConversationTitle: null,
...overrides,
showCloseButton: false,
};
@@ -250,6 +252,44 @@ describe("InAppAgentWindow conversation history", () => {
});
});
+describe("InAppAgentWindow header", () => {
+ it("titles the window by the conversation, and falls back to the product name", () => {
+ const { rerender } = render(
+ windowElement({
+ selectedConversationId: "conversation-1",
+ selectedConversationTitle: " Latency outliers ",
+ }),
+ );
+
+ expect(screen.getByText("Latency outliers")).toBeInTheDocument();
+ expect(screen.queryByText("Beta")).not.toBeInTheDocument();
+
+ // An unnamed conversation is where the product name and Beta tag belong.
+ rerender(
+ windowElement({
+ selectedConversationId: "conversation-1",
+ selectedConversationTitle: null,
+ }),
+ );
+
+ expect(screen.getByText("Assistant")).toBeInTheDocument();
+ expect(screen.getByText("Beta")).toBeInTheDocument();
+ });
+
+ it("toggles expanded on a header double-click, but not from its actions", () => {
+ const onExpandedChange = vi.fn();
+ render(windowElement({ onExpandedChange }));
+
+ fireEvent.dblClick(screen.getByText("Assistant"));
+ expect(onExpandedChange).toHaveBeenCalledWith(true);
+
+ fireEvent.dblClick(
+ screen.getByRole("button", { name: "Start new conversation" }),
+ );
+ expect(onExpandedChange).toHaveBeenCalledTimes(1);
+ });
+});
+
describe("ControlledInAppAgentWindow composer", () => {
beforeEach(() => {
controlledAgent.value.error = null;
diff --git a/web/src/features/in-app-agent/components/InAppAgentWindow.stories.tsx b/web/src/features/in-app-agent/components/InAppAgentWindow.stories.tsx
index 1d4a7ffe26..743984ab60 100644
--- a/web/src/features/in-app-agent/components/InAppAgentWindow.stories.tsx
+++ b/web/src/features/in-app-agent/components/InAppAgentWindow.stories.tsx
@@ -22,9 +22,11 @@ import { getDrawerMessages } from "./utils/utils";
function InAppAgentWindowStoryShell({
children,
isExpanded,
+ onExpandedChange,
}: {
children: (props: { isHeaderDragHandleEnabled: boolean }) => ReactNode;
isExpanded: boolean;
+ onExpandedChange: (isExpanded: boolean) => void;
}) {
const panelRef = useRef<HTMLDivElement>(null);
const floatingPanelHandle = useInAppAgentWindowShellPanelControl({});
@@ -38,6 +40,7 @@ function InAppAgentWindowStoryShell({
floatingPanelHandle={floatingPanelHandle}
isExpanded={isExpanded}
onClose={() => undefined}
+ onExpandedChange={onExpandedChange}
open
panelRef={panelRef}
>
@@ -48,18 +51,22 @@ function InAppAgentWindowStoryShell({
function StatefulInAppAgentWindow(args: InAppAgentWindowProps) {
const [isExpanded, setIsExpanded] = useState(args.isExpanded);
+ const handleExpandedChange = (isExpanded: boolean) => {
+ setIsExpanded(isExpanded);
+ args.onExpandedChange(isExpanded);
+ };
return (
- <InAppAgentWindowStoryShell isExpanded={isExpanded}>
+ <InAppAgentWindowStoryShell
+ isExpanded={isExpanded}
+ onExpandedChange={handleExpandedChange}
+ >
{({ isHeaderDragHandleEnabled }) => (
<InAppAgentWindow
{...args}
isHeaderDragHandleEnabled={isHeaderDragHandleEnabled}
isExpanded={isExpanded}
- onExpandedChange={(isExpanded) => {
- setIsExpanded(isExpanded);
- args.onExpandedChange(isExpanded);
- }}
+ onExpandedChange={handleExpandedChange}
/>
)}
</InAppAgentWindowStoryShell>
@@ -530,18 +537,23 @@ function StreamingInAppAgentWindow(args: InAppAgentWindowProps) {
};
}, []);
+ const handleExpandedChange = (isExpanded: boolean) => {
+ setIsExpanded(isExpanded);
+ args.onExpandedChange(isExpanded);
+ };
+
return (
- <InAppAgentWindowStoryShell isExpanded={isExpanded}>
+ <InAppAgentWindowStoryShell
+ isExpanded={isExpanded}
+ onExpandedChange={handleExpandedChange}
+ >
{({ isHeaderDragHandleEnabled }) => (
<InAppAgentWindow
{...args}
isHeaderDragHandleEnabled={isHeaderDragHandleEnabled}
isExpanded={isExpanded}
messages={messages}
- onExpandedChange={(isExpanded) => {
- setIsExpanded(isExpanded);
- args.onExpandedChange(isExpanded);
- }}
+ onExpandedChange={handleExpandedChange}
onSubmit={(input) => {
setMessages((currentMessages) => [
...currentMessages,
@@ -684,6 +696,7 @@ const meta = preview.meta({
isLoadingMoreConversations: false,
isAssistantTurnInProgress: false,
selectedConversationId: undefined,
+ selectedConversationTitle: null,
onDeleteConversation: fn(),
onLoadMoreConversations: fn(),
onOpenConversationHistory: fn(),
@@ -1743,9 +1756,16 @@ export const RefocusAfterSubmit = meta.story({
},
},
]);
+ const handleExpandedChange = (isExpanded: boolean) => {
+ setIsExpanded(isExpanded);
+ args.onExpandedChange(isExpanded);
+ };
return (
- <InAppAgentWindowStoryShell isExpanded={isExpanded}>
+ <InAppAgentWindowStoryShell
+ isExpanded={isExpanded}
+ onExpandedChange={handleExpandedChange}
+ >
{({ isHeaderDragHandleEnabled }) => (
<InAppAgentWindow
{...args}
@@ -1755,10 +1775,7 @@ export const RefocusAfterSubmit = meta.story({
isConversationInteractionDisabled
}
messages={messages}
- onExpandedChange={(isExpanded) => {
- setIsExpanded(isExpanded);
- args.onExpandedChange(isExpanded);
- }}
+ onExpandedChange={handleExpandedChange}
onSubmit={(input) => {
setIsConversationInteractionDisabled(true);
window.setTimeout(() => {
@@ -2371,7 +2388,10 @@ export const SendingReattachesAutoFollow = meta.story({
const [messages, setMessages] = useState(args.messages);
return (
- <InAppAgentWindowStoryShell isExpanded={args.isExpanded}>
+ <InAppAgentWindowStoryShell
+ isExpanded={args.isExpanded}
+ onExpandedChange={args.onExpandedChange}
+ >
{({ isHeaderDragHandleEnabled }) => (
<InAppAgentWindow
{...args}
diff --git a/web/src/features/in-app-agent/components/InAppAgentWindow.tsx b/web/src/features/in-app-agent/components/InAppAgentWindow.tsx
index 158c23efcb..94750dbefb 100644
--- a/web/src/features/in-app-agent/components/InAppAgentWindow.tsx
+++ b/web/src/features/in-app-agent/components/InAppAgentWindow.tsx
@@ -761,6 +761,12 @@ function ConversationScroller({
>
{children}
</div>
+ {/* The transcript fades into the composer gutter rather than ending on a
+ hard cut. Above the "Latest" pill in DOM order so the pill stays crisp. */}
+ <div
+ aria-hidden="true"
+ className="from-background pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-linear-to-t to-transparent"
+ />
{!isAtLatest ? (
<Button
type="button"
@@ -859,6 +865,9 @@ export type InAppAgentWindowProps = {
focusedQuickActions?: readonly InAppAgentQuickAction[];
quickActionResetKey: string;
selectedConversationId: string | undefined;
+ /** Titles the window. Null until the server has named the conversation,
+ * which is when the product name and its Beta tag show instead. */
+ selectedConversationTitle: string | null;
} & InAppAgentWindowCloseButtonProps;
function InAppAgentRateLimitError({
@@ -957,6 +966,7 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {
quickActionResetKey,
screenContextDescription,
selectedConversationId,
+ selectedConversationTitle,
} = props;
const screenContextNotice = formatScreenContextNotice(
screenContextDescription,
@@ -996,6 +1006,7 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {
? ` (${historyAttentionCount} ${historyAttentionCount === 1 ? "needs" : "need"} attention)`
: "";
const hasUserMessage = messages.some((message) => message.role === "user");
+ const conversationTitle = selectedConversationTitle?.trim() || null;
const pendingToolCalls = messages.flatMap((message) =>
message.content.type === "toolGroup"
? message.content.tools.filter((tool) => tool.approval)
@@ -1092,16 +1103,47 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {
}
className={cn(
"bg-card flex min-h-11.25 shrink-0 items-center justify-between gap-2 border-b px-3 py-1",
- isHeaderDragHandleEnabled && "cursor-move touch-none select-none",
+ isHeaderDragHandleEnabled && "cursor-move touch-none",
+ // Double-click toggles, so never let it select the title instead.
+ !isHandheld && "select-none",
)}
+ onDoubleClick={
+ isHandheld
+ ? undefined
+ : (event) => {
+ // The action cluster owns its own double-clicks.
+ if (
+ event.target instanceof Element &&
+ event.target.closest("button")
+ ) {
+ return;
+ }
+
+ onExpandedChange(!isExpanded);
+ }
+ }
>
<div className="flex min-w-0 flex-1 items-center gap-2">
- <p className="shrink-0 truncate text-sm font-bold" title="Assistant">
- Assistant
- </p>
- <span className="text-muted-foreground rounded border px-1.5 py-1 text-xs leading-none font-bold">
- Beta
- </span>
+ {conversationTitle ? (
+ <p
+ className="min-w-0 truncate text-sm font-bold"
+ title={conversationTitle}
+ >
+ {conversationTitle}
+ </p>
+ ) : (
+ <>
+ <p
+ className="shrink-0 truncate text-sm font-bold"
+ title="Assistant"
+ >
+ Assistant
+ </p>
+ <span className="text-muted-foreground rounded border px-1.5 py-1 text-xs leading-none font-bold">
+ Beta
+ </span>
+ </>
+ )}
</div>
<div
className="flex shrink-0 items-center gap-0.5"
@@ -1509,16 +1551,14 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {
</div>
</div>
) : null}
- <div
- className={cn(
- "p-1.5",
- isExpanded ? "pt-0" : "bg-card",
- !isExpanded && hasUserMessage && "border-t",
- )}
- >
+ <div className={cn("p-1.5", isExpanded && "pt-0")}>
+ {/* The composer separates from the transcript by elevation, not by a
+ rule: one hairline edge, a lifted surface, and a footer band a
+ step off the input. `overflow-hidden` keeps that band inside the
+ rounded corners. */}
<form
className={cn(
- "border-input bg-background focus-within:ring-muted-foreground relative flex w-full cursor-text flex-col rounded-xl border shadow-xs focus-within:ring-2",
+ "border-border bg-card focus-within:border-border-contrast relative flex w-full cursor-text flex-col overflow-hidden rounded-xl border shadow-sm transition-colors",
isExpanded && "mx-auto max-w-3xl",
)}
onClick={() => {
@@ -1556,9 +1596,9 @@ export function InAppAgentWindow(props: InAppAgentWindowProps) {
: "Let me know what I can do for you..."
}
rows={1}
- className="placeholder:text-foreground-tertiary max-h-40 min-h-9 w-full resize-none overflow-y-auto border-none bg-transparent px-3 pt-2 text-sm leading-5 shadow-none ring-0 outline-none disabled:cursor-not-allowed disabled:opacity-60"
+ className="placeholder:text-foreground-tertiary max-h-40 min-h-9 w-full resize-none overflow-y-auto border-none bg-transparent px-3 pt-2 pb-2 text-sm leading-5 shadow-none ring-0 outline-none disabled:cursor-not-allowed disabled:opacity-60"
/>
- <div className="flex min-h-9 w-full items-center justify-between gap-2 px-2 pb-1.5">
+ <div className="bg-muted flex min-h-9 w-full items-center justify-between gap-2 px-2 py-1.5">
<p className="text-muted-foreground flex min-w-0 items-center gap-1 text-xs">
<Info aria-hidden="true" className="size-3 shrink-0" />
<span className="truncate" title={screenContextNotice}>
diff --git a/web/src/features/in-app-agent/components/InAppAgentWindowHost.tsx b/web/src/features/in-app-agent/components/InAppAgentWindowHost.tsx
index 53173e1a32..f4c626aa8c 100644
--- a/web/src/features/in-app-agent/components/InAppAgentWindowHost.tsx
+++ b/web/src/features/in-app-agent/components/InAppAgentWindowHost.tsx
@@ -98,6 +98,14 @@ export function InAppAgentWindowHost() {
);
}, [isExpanded]);
+ // Captures the outgoing rect so the layout effect above can animate the
+ // floating <-> expanded swap from where the window actually was.
+ const handleExpandedChange = (nextIsExpanded: boolean) => {
+ previousPanelRectRef.current =
+ panelRef.current?.getBoundingClientRect() ?? null;
+ setIsExpanded(nextIsExpanded);
+ };
+
// Geometry follows the open state: cleared on close so every open starts
// from the default placement, initialized on open for the floating panel.
useLayoutEffect(() => {
@@ -143,6 +151,7 @@ export function InAppAgentWindowHost() {
onClose={() => {
setOpen(false);
}}
+ onExpandedChange={handleExpandedChange}
open={open}
panelRef={panelRef}
>
@@ -153,11 +162,7 @@ export function InAppAgentWindowHost() {
onDeleteConversation={(conversation) => {
deleteConversationDialog.open(conversation);
}}
- onExpandedChange={(nextIsExpanded) => {
- previousPanelRectRef.current =
- panelRef.current?.getBoundingClientRect() ?? null;
- setIsExpanded(nextIsExpanded);
- }}
+ onExpandedChange={handleExpandedChange}
onClose={() => {
setOpen(false);
}}
diff --git a/web/src/features/in-app-agent/components/InAppAgentWindowShell.tsx b/web/src/features/in-app-agent/components/InAppAgentWindowShell.tsx
index 8b3ce1fc6b..4db036ced0 100644
--- a/web/src/features/in-app-agent/components/InAppAgentWindowShell.tsx
+++ b/web/src/features/in-app-agent/components/InAppAgentWindowShell.tsx
@@ -65,6 +65,7 @@ type InAppAgentWindowShellProps = {
floatingPanelHandle: MovableResizablePanelHandle;
isExpanded: boolean;
onClose: () => void;
+ onExpandedChange: (isExpanded: boolean) => void;
open: boolean;
panelRef: RefObject<HTMLDivElement | null>;
};
@@ -74,6 +75,7 @@ export function InAppAgentWindowShell({
floatingPanelHandle,
isExpanded,
onClose,
+ onExpandedChange,
open,
panelRef,
}: InAppAgentWindowShellProps) {
@@ -161,6 +163,11 @@ export function InAppAgentWindowShell({
ref={panelRef}
handle={floatingPanelHandle}
className="pointer-events-auto"
+ // The header's own `onDoubleClick` covers every other presentation; only
+ // here is the handle also a drag surface that eats the event.
+ onDragHandleDoubleClick={() => {
+ onExpandedChange(true);
+ }}
>
<div
data-ignore-outside-interaction
diff --git a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx
index 16b0afa3b6..4cad2cce5f 100644
--- a/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx
+++ b/web/src/features/in-app-agent/components/InAppAiAgentProvider.tsx
@@ -144,6 +144,7 @@ const NOOP_CONTEXT: InAppAiAgentContextType = {
activityByConversationId: new Map(),
attentionCount: 0,
selectedConversationId: undefined,
+ selectedConversationTitle: null,
selectedConversationIsWriteLocked: false,
loadMoreConversations: () => undefined,
invalidateConversations: () => undefined,
@@ -205,6 +206,8 @@ type InAppAiAgentContextType = {
/** Conversations the user still owes a look, for the launcher badge. */
attentionCount: number;
selectedConversationId: string | undefined;
+ /** Server-given name of the selected conversation, null until it has one. */
+ selectedConversationTitle: string | null;
selectedConversationIsWriteLocked: boolean;
loadMoreConversations: () => void;
invalidateConversations: () => void;
@@ -453,6 +456,24 @@ function InAppAiAgentProviderInner({
visibleConversationId: open ? selectedConversationId : null,
});
+ // What the window titles itself by. Three sources, because no single one
+ // covers every way a conversation gets selected: the snapshot query is
+ // authoritative and runs for the selected id whatever the list has loaded,
+ // the recent list already holds the title when you pick one out of history,
+ // and the activity poll is the only one warm when a background-run
+ // notification opens a conversation the list has yet to fetch.
+ const selectedConversationTitle =
+ (conversationQuery.data?.conversation.id === selectedConversationId
+ ? conversationQuery.data.conversation.title
+ : null) ??
+ conversations.find(
+ (conversation) => conversation.id === selectedConversationId,
+ )?.title ??
+ (selectedConversationId
+ ? activityByConversationId.get(selectedConversationId)?.title
+ : null) ??
+ null;
+
const effectivePendingToolApprovals = useMemo(() => {
return backgroundExecutionView.pendingToolApprovals.map(
({ runId, approvalRequest, status }): InAppAgentPendingToolApproval => ({
@@ -1500,6 +1521,7 @@ function InAppAiAgentProviderInner({
activityByConversationId,
attentionCount,
selectedConversationId: selectedConversationId ?? undefined,
+ selectedConversationTitle,
selectedConversationIsWriteLocked,
loadMoreConversations,
invalidateConversations,
@@ -1524,6 +1546,7 @@ function InAppAiAgentProviderInner({
isRunning,
isSelectedConversationHydrating,
selectedConversationIsWriteLocked,
+ selectedConversationTitle,
isSubmitting,
isSelectedConversationNotFound,
deleteConversation,