From da11f44847e710b75497c903de2a317b6c8eaaf9 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Thu, 9 Apr 2026 18:38:55 +0000 Subject: [PATCH] fix: update UI tool call processing to match new unwrapped ToolOutput shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sonarly.com/issue/23566?type=bug AI chat navigate_app tool calls crash in the frontend because commit 563e27831b removed the `ExecuteToolResult` wrapper on the backend but the frontend still reads the old nested `output.result.success` path. Fix: Updated the frontend to match the new backend `ToolOutput` shape after commit 563e27831b removed the `ExecuteToolResult` wrapper from `execute_tool`. **`AgentChatMessageUIToolCallPart.ts`**: Removed the `toolName` field and flattened the `output` type from `{ toolName, result: { success, message, result } }` to `{ success, message, result }` — matching the raw `ToolOutput` the backend now returns. **`useProcessUIToolCallMessage.ts`**: Updated two property access paths: - Line 45: `toolExecutionPart.output.result.success` → `toolExecutionPart.output.success` - Line 54: `toolExecutionPart.output.result.result` → `toolExecutionPart.output.result` These are the only two sites in the codebase that read from the tool execution part output, so the fix is complete. --- .../src/modules/ai/hooks/useProcessUIToolCallMessage.ts | 4 ++-- .../modules/ai/types/AgentChatMessageUIToolCallPart.ts | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts b/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts index c21d4ebd749..b8c5eeb221d 100644 --- a/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts +++ b/packages/twenty-front/src/modules/ai/hooks/useProcessUIToolCallMessage.ts @@ -42,7 +42,7 @@ export const useProcessUIToolCallMessage = () => { continue; } - if (toolExecutionPart.output.result.success !== true) { + if (toolExecutionPart.output.success !== true) { continue; } @@ -51,7 +51,7 @@ export const useProcessUIToolCallMessage = () => { toolExecutionPart.toolCallId, ]); - const navigateAppOutput = toolExecutionPart.output.result.result; + const navigateAppOutput = toolExecutionPart.output.result; switch (navigateAppOutput.action) { case 'navigateToObject': { diff --git a/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts b/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts index 9e6aa1c06dc..0138a94329c 100644 --- a/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts +++ b/packages/twenty-front/src/modules/ai/types/AgentChatMessageUIToolCallPart.ts @@ -5,11 +5,8 @@ export type AgentChatMessageUIToolCallPart = { toolCallId: string; state: string; output: { - toolName: string; - result: { - message: string; - result: NavigateAppToolOutput; - success: boolean; - }; + success: boolean; + message: string; + result: NavigateAppToolOutput; }; };