@ash-ai/ui 0.0.4 → 0.0.6

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
@@ -347,6 +347,22 @@ ${fileRefs}` : fileRefs;
347
347
  setMessages((prev) => prev.map(
348
348
  (m) => m.id === assistantId ? { ...m, content: fullContent || "(no response)", toolCalls: [...toolCalls], isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
349
349
  ));
350
+ } else if (event.type === "message") {
351
+ const data = event.data;
352
+ if (data.type === "assistant" && Array.isArray(data.message?.content)) {
353
+ let text = "";
354
+ for (const block of data.message.content) {
355
+ if (block.type === "text" && block.text) {
356
+ text += (text ? "\n" : "") + block.text;
357
+ }
358
+ }
359
+ if (text) {
360
+ fullContent = text;
361
+ setMessages((prev) => prev.map(
362
+ (m) => m.id === assistantId ? { ...m, content: fullContent, toolCalls: [...toolCalls], isStreaming: true } : m
363
+ ));
364
+ }
365
+ }
350
366
  } else if (event.type === "error") {
351
367
  const data = event.data;
352
368
  const errText = data.error || "Unknown error";
@@ -355,12 +371,14 @@ ${fileRefs}` : fileRefs;
355
371
  ));
356
372
  }
357
373
  }
358
- for (const tc of toolCalls) {
359
- if (tc.state === "running" || tc.state === "pending") tc.state = "completed";
374
+ if (fullContent || toolCalls.length > 0) {
375
+ for (const tc of toolCalls) {
376
+ if (tc.state === "running" || tc.state === "pending") tc.state = "completed";
377
+ }
378
+ setMessages((prev) => prev.map(
379
+ (m) => m.id === assistantId && m.isStreaming ? { ...m, content: fullContent || "(no response)", toolCalls: toolCalls.length > 0 ? [...toolCalls] : void 0, isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
380
+ ));
360
381
  }
361
- setMessages((prev) => prev.map(
362
- (m) => m.id === assistantId && m.isStreaming ? { ...m, content: fullContent || "(no response)", toolCalls: toolCalls.length > 0 ? [...toolCalls] : void 0, isStreaming: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : m
363
- ));
364
382
  } catch (err) {
365
383
  const errMsg = err instanceof Error ? err.message : "Failed to send";
366
384
  setMessages((prev) => prev.map(
@@ -1214,13 +1232,13 @@ function Terminal2({ logs, connected, onClear, className }) {
1214
1232
  ref: containerRef,
1215
1233
  onScroll: handleScroll,
1216
1234
  className: "flex-1 overflow-auto p-3 font-mono text-xs leading-5 scrollbar-thin min-h-[120px]",
1217
- children: filteredLogs.length === 0 ? /* @__PURE__ */ jsx11("div", { className: "flex h-full items-center justify-center text-white/20 text-xs", children: logs.length === 0 ? "Waiting for sandbox output..." : "No matching lines" }) : filteredLogs.map((entry) => /* @__PURE__ */ jsxs10("div", { className: "flex hover:bg-white/5 rounded px-1 -mx-1", children: [
1235
+ children: filteredLogs.length === 0 ? /* @__PURE__ */ jsx11("div", { className: "flex h-full items-center justify-center text-white/20 text-xs", children: logs.length === 0 ? "Waiting for sandbox output..." : "No matching lines" }) : filteredLogs.map((entry, i) => /* @__PURE__ */ jsxs10("div", { className: "flex hover:bg-white/5 rounded px-1 -mx-1", children: [
1218
1236
  showTimestamps && /* @__PURE__ */ jsx11("span", { className: "mr-3 shrink-0 select-none text-white/20", children: formatTimestamp(entry.ts) }),
1219
1237
  /* @__PURE__ */ jsx11("span", { className: cn(
1220
1238
  "whitespace-pre-wrap break-all",
1221
1239
  levelColors[entry.level] || "text-white/60"
1222
1240
  ), children: entry.text })
1223
- ] }, entry.index))
1241
+ ] }, `${entry.index}-${i}`))
1224
1242
  }
1225
1243
  )
1226
1244
  ] });