From 9fc4532c0a6b13f757d3ba79cb92e9b2c6ce20fd Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Sun, 11 Jan 2026 02:08:33 +1000 Subject: [PATCH] fix: render embedded tool calls from ASSISTANT messages on page refresh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, tool calls only rendered during streaming. Now they also render when loading conversation history from the database, where tool calls are embedded in ASSISTANT messages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../agents/[id]/chat/[chatId]/page.tsx | 90 +++++++++++++------ 1 file changed, 64 insertions(+), 26 deletions(-) diff --git a/apps/web/src/app/dashboard/agents/[id]/chat/[chatId]/page.tsx b/apps/web/src/app/dashboard/agents/[id]/chat/[chatId]/page.tsx index 7842c18..8735a60 100644 --- a/apps/web/src/app/dashboard/agents/[id]/chat/[chatId]/page.tsx +++ b/apps/web/src/app/dashboard/agents/[id]/chat/[chatId]/page.tsx @@ -17,6 +17,12 @@ interface Agent { modelId: string; } +interface MessageToolCall { + toolCallId: string; + toolName: string; + args?: Record; +} + interface Message { id: string; role: 'USER' | 'ASSISTANT' | 'TOOL'; @@ -24,6 +30,7 @@ interface Message { toolName?: string; toolCallId?: string; toolResult?: unknown; + toolCalls?: MessageToolCall[] | null; createdAt: string; } @@ -608,35 +615,66 @@ export default function AgentChatPage(): React.ReactElement { } }; + // Check if this ASSISTANT message has embedded tool calls + const hasEmbeddedToolCalls = + message.role === 'ASSISTANT' && + message.toolCalls && + Array.isArray(message.toolCalls) && + message.toolCalls.length > 0; + return ( -
- {message.role === 'TOOL' ? ( -
- toggleToolCall(message.toolCallId || message.id)} - /> -
- ) : ( -
-

{message.content}

+
+ {/* Render embedded tool calls from ASSISTANT messages */} + {hasEmbeddedToolCalls && ( +
+ {message.toolCalls!.map((tc) => ( +
+
+ toggleToolCall(tc.toolCallId)} + /> +
+
+ ))}
)} + + {/* Render the message content */} +
+ {message.role === 'TOOL' ? ( +
+ toggleToolCall(message.toolCallId || message.id)} + /> +
+ ) : ( +
+

{message.content}

+
+ )} +
); })}