From 6dee7cf11dfc1b7d43a8406c2235d358f9b0f61f Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 26 Mar 2026 17:07:36 +0000 Subject: [PATCH] perf(site/src/pages/AgentsPage): convert renderBlockList to BlockList component (#23673) --- .../ConversationTimeline.stories.tsx | 2 +- .../AgentDetail/ConversationTimeline.tsx | 398 ++++++++---------- 2 files changed, 185 insertions(+), 215 deletions(-) diff --git a/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.stories.tsx b/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.stories.tsx index c05ded9b69..effc4a1d4f 100644 --- a/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.stories.tsx +++ b/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.stories.tsx @@ -348,7 +348,7 @@ export const UserMessageTextOnly: Story = { }, }; -/** Assistant-side images go through renderBlockList, not the user path. */ +/** Assistant-side images go through BlockList, not the user path. */ export const AssistantMessageWithImage: Story = { args: { ...defaultArgs, diff --git a/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.tsx b/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.tsx index 4291b171cd..7ae42dede2 100644 --- a/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.tsx +++ b/site/src/pages/AgentsPage/components/AgentDetail/ConversationTimeline.tsx @@ -3,7 +3,6 @@ import { type FC, Fragment, memo, - type ReactNode, useEffect, useLayoutEffect, useRef, @@ -88,22 +87,6 @@ const ReasoningDisclosure = memo<{ ); }); -// Shared block renderer used by both ChatMessageItem (historical -// messages) and StreamingOutput (live stream). Encapsulates the -// response / thinking / tool switch so the two consumers stay in sync. -type RenderBlockListParams = { - blocks: readonly RenderBlock[]; - toolByID: ReadonlyMap; - keyPrefix: string; - isStreaming?: boolean; - subagentTitles?: Map; - subagentStatusOverrides?: Map; - mcpServers?: readonly TypesGen.MCPServerConfig[]; - onImageClick?: (src: string) => void; - onTextFileClick?: (content: string) => void; - urlTransform?: UrlTransform; -}; - // Wrapper that runs the smooth-streaming jitter buffer on a single // response block. Only used during live streaming — historical // messages render through directly. @@ -207,24 +190,15 @@ const TextAttachmentButton: FC<{ type FileRenderBlock = Extract; -type RenderFileBlockParams = { +const FileBlock: FC<{ block: FileRenderBlock; - key: string; onImageClick?: (src: string) => void; onTextFileClick?: (content: string) => void; -}; - -const renderFileBlock = ({ - block, - key, - onImageClick, - onTextFileClick, -}: RenderFileBlockParams): ReactNode => { +}> = ({ block, onImageClick, onTextFileClick }) => { if (block.media_type === "text/plain") { if (block.file_id) { return ( @@ -233,7 +207,6 @@ const renderFileBlock = ({ if (block.data != null) { return ( @@ -248,7 +221,6 @@ const renderFileBlock = ({ : `data:${block.media_type};base64,${block.data}`; return (