devnonla-ui 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devnonla-ui",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "NonlaUI — React controls for Nonla Agents",
6
6
  "author": "devlangla <devlangla0x01@gmail.com>",
@@ -172,6 +172,7 @@ export function useAgentStream({ endpoint, extraBody, headers, fetcher = fetch,
172
172
  let assistantText = "";
173
173
  let currentId = assistantId;
174
174
  let needsNewBubble = false;
175
+ const seenToolCallIds = new Set<string>();
175
176
 
176
177
  const freezeOpen = () => {
177
178
  const freezeId = currentId;
@@ -298,6 +299,34 @@ export function useAgentStream({ endpoint, extraBody, headers, fetcher = fetch,
298
299
  },
299
300
  onToolCall: (event) => {
300
301
  const label = event.toolLabel ? (event.toolLabel.includes(" ") ? event.toolLabel : formatToolName(event.toolLabel)) : formatToolName(event.toolName);
302
+ const alreadySeen = event.toolCallId ? seenToolCallIds.has(event.toolCallId) : false;
303
+ if (event.toolCallId) seenToolCallIds.add(event.toolCallId);
304
+
305
+ if (alreadySeen) {
306
+ setMessages((prev) =>
307
+ prev.map((m) =>
308
+ m.role === "tool-call" && m.toolCallId === event.toolCallId
309
+ ? {
310
+ ...m,
311
+ content: event.toolName,
312
+ toolName: event.toolName,
313
+ toolLabel: label,
314
+ toolInput: event.input !== undefined ? event.input : m.toolInput,
315
+ }
316
+ : m,
317
+ ),
318
+ );
319
+ if (event.input !== undefined) {
320
+ emitCall({
321
+ toolCallId: event.toolCallId,
322
+ toolName: event.toolName,
323
+ toolLabel: label,
324
+ input: event.input,
325
+ });
326
+ }
327
+ return;
328
+ }
329
+
301
330
  freezeOpen();
302
331
  const id = nextId("tc");
303
332
  const call: AgentToolCallEvent = {