+
{m.role}:
+ {m.parts.map((part, i) => {
+ if (part.type === 'text') {
+ return
{part.text};
+ }
+ if (part.type === 'tool-invocation') {
+ // Find the latest data part for this tool call // [!code highlight]
+ const dataPart = m.parts.findLast( // [!code highlight]
+ (p) => p.type === 'data' && p.id === part.toolInvocation.toolCallId // [!code highlight]
+ ); // [!code highlight]
+ const status = dataPart?.type === 'data' ? dataPart.data : null; // [!code highlight]
+ return (
+
+ {status?.status === 'fetching' // [!code highlight]
+ ? `Fetching ${status.url}...` // [!code highlight]
+ : `Called ${part.toolInvocation.toolName}`} // [!code highlight]
+
+ );
+ }
+ return null;
+ })}
+