import { memo, type ReactNode } from "react"; import type { SessionMessage } from "../types/message"; import type { SessionPart } from "../types/parts"; export interface UserMessageProps { /** Session-model input: text is derived from these parts. */ message?: SessionMessage; parts?: SessionPart[]; /** Direct-content input (e.g. AgentTimeline): explicit text + timestamp. */ content?: string; timestamp?: Date; actions?: ReactNode; } function formatTime(date: Date): string { return date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" }); } /** * The single user message bubble — a quiet, right-aligned bordered bubble on the * muted surface (no loud fill, no uppercase label). Used by both the run/message * list (session-model `parts`) and AgentTimeline (direct `content`/`timestamp`). */ export const UserMessage = memo( ({ message: _message, parts, content, timestamp, actions }: UserMessageProps) => { const text = content ?? (parts ?? []) .filter((p) => p.type === "text") .map((p) => (p as { text: string }).text) .join("\n"); if (!text.trim()) return null; return (