Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,13 @@ export const useAssistantChat = ({
},
// send message automatically when there's a frontend tool call
sendAutomaticallyWhen: ({ messages }) => {
const lastMessage = messages[messages.length - 1];
const lastMessagePart =
lastMessage?.parts?.[lastMessage.parts.length - 1];
return (
lastMessagePart?.type?.includes('tool-ui') &&
'output' in lastMessagePart &&
!!lastMessagePart.output
return messages.some((message) =>
message?.parts?.some(
(part) =>
part?.type?.includes('tool-ui') &&
'output' in part &&
!!part.output,
),
);
Comment on lines +284 to 291
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking all messages and all parts on every invocation could be inefficient as the message history grows. Consider tracking tool-ui state separately or limiting the search to recent messages if the intention is to detect new tool-ui outputs rather than any historical ones.

Copilot uses AI. Check for mistakes.
},
});
Expand Down
Loading