@sidecar-ai/cli 0.1.0-alpha.13 → 0.1.0-alpha.14

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/dist/index.js CHANGED
@@ -5492,7 +5492,10 @@ async function streamChat(contentEl) {
5492
5492
  } else if (parsed.event === "tool_start") {
5493
5493
  appendToolStart(parsed.data);
5494
5494
  } else if (parsed.event === "tool_result") {
5495
- appendToolResult(parsed.data);
5495
+ const toolArticle = appendToolResult(parsed.data);
5496
+ if (parsed.data.tool?.resourceUri) {
5497
+ moveAssistantAfterToolUi(contentEl, toolArticle);
5498
+ }
5496
5499
  } else if (parsed.event === "error") {
5497
5500
  throw new Error(parsed.data.message || "Sidecar dev chat failed.");
5498
5501
  }
@@ -5562,6 +5565,17 @@ function renderAssistantError(element, message) {
5562
5565
  return text;
5563
5566
  }
5564
5567
 
5568
+ function moveAssistantAfterToolUi(contentEl, toolArticle) {
5569
+ const assistantArticle = contentEl.closest(".message");
5570
+ if (!assistantArticle || !toolArticle?.parentElement || assistantArticle === toolArticle) {
5571
+ return;
5572
+ }
5573
+ if (toolArticle.nextSibling === assistantArticle) {
5574
+ return;
5575
+ }
5576
+ messagesEl.insertBefore(assistantArticle, toolArticle.nextSibling);
5577
+ }
5578
+
5565
5579
  function appendToolStart(tool) {
5566
5580
  const article = document.createElement("article");
5567
5581
  article.className = "tool-card";
@@ -5569,6 +5583,7 @@ function appendToolStart(tool) {
5569
5583
  article.innerHTML = '<div class="tool-head"><div class="tool-title"></div><div class="status">Running</div></div><div class="tool-body"></div>';
5570
5584
  article.querySelector(".tool-title").textContent = tool.title || tool.name;
5571
5585
  messagesEl.append(article);
5586
+ return article;
5572
5587
  }
5573
5588
 
5574
5589
  function appendToolResult(event) {
@@ -5608,6 +5623,7 @@ function appendToolResult(event) {
5608
5623
  body.append(pre);
5609
5624
  }
5610
5625
  article.scrollIntoView({ block: "end" });
5626
+ return article;
5611
5627
  }
5612
5628
 
5613
5629
  function toolText(result) {