@caupulican/pi-adaptative 0.80.0 → 0.80.1

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.
@@ -1346,15 +1346,38 @@ export class InteractiveMode {
1346
1346
  }
1347
1347
  this.chatContainer.addChild(component);
1348
1348
  }
1349
+ detachToolExecutionComponent(component) {
1350
+ const children = this.chatContainer.children;
1351
+ const directIndex = children.indexOf(component);
1352
+ if (directIndex !== -1) {
1353
+ children.splice(directIndex, 1);
1354
+ return;
1355
+ }
1356
+ for (let i = 0; i < children.length; i++) {
1357
+ const child = children[i];
1358
+ if (!(child instanceof ToolGroupComponent) || !child.removeTool(component))
1359
+ continue;
1360
+ const remaining = child.getToolCount();
1361
+ if (remaining === 0) {
1362
+ children.splice(i, 1);
1363
+ }
1364
+ else if (remaining === 1) {
1365
+ const onlyTool = child.getOnlyTool();
1366
+ if (onlyTool)
1367
+ children[i] = onlyTool;
1368
+ }
1369
+ return;
1370
+ }
1371
+ }
1349
1372
  attachToolExecutionComponent(toolName, toolCallId, args) {
1350
1373
  const actionKey = getToolPanelActionKey(this.getToolPanelScope(), toolName, args);
1351
1374
  const toolDefinition = this.getRegisteredToolDefinition(toolName);
1352
1375
  const existing = this.toolPanels.getReusable(actionKey);
1353
1376
  if (existing) {
1354
- this.chatContainer.removeChild(existing);
1377
+ this.detachToolExecutionComponent(existing);
1355
1378
  existing.resetInvocation(toolName, toolCallId, args, toolDefinition);
1356
1379
  existing.setExpanded(this.toolOutputExpanded);
1357
- this.chatContainer.addChild(existing);
1380
+ this.appendToolExecutionComponent(existing, true);
1358
1381
  this.toolPanels.register(toolCallId, existing, actionKey);
1359
1382
  return existing;
1360
1383
  }
@@ -1363,7 +1386,7 @@ export class InteractiveMode {
1363
1386
  imageWidthCells: this.settingsManager.getImageWidthCells(),
1364
1387
  }, toolDefinition, this.ui, this.sessionManager.getCwd());
1365
1388
  component.setExpanded(this.toolOutputExpanded);
1366
- this.appendToolExecutionComponent(component, !actionKey);
1389
+ this.appendToolExecutionComponent(component, true);
1367
1390
  this.toolPanels.register(toolCallId, component, actionKey);
1368
1391
  return component;
1369
1392
  }