@agentiffai/design 1.3.12 → 1.3.13

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.
@@ -1395,20 +1395,30 @@ var AssistantMessageAdapterBase = ({
1395
1395
  // markdownTagRenderers,
1396
1396
  // ImageRenderer,
1397
1397
  }) => {
1398
- if (isLoading || isGenerating && !message?.content) {
1399
- return /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." });
1400
- }
1398
+ const lastGenerativeUIRef = useRef(null);
1401
1399
  const rawContent = message?.content || "";
1402
1400
  const content = stripToolCallMarkers(rawContent);
1403
1401
  let generativeUIOutput = null;
1404
1402
  const msgWithUI = message;
1405
1403
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1406
1404
  try {
1407
- generativeUIOutput = msgWithUI.generativeUI();
1405
+ const newOutput = msgWithUI.generativeUI();
1406
+ if (newOutput !== null && newOutput !== void 0) {
1407
+ generativeUIOutput = newOutput;
1408
+ lastGenerativeUIRef.current = newOutput;
1409
+ }
1408
1410
  } catch (e) {
1409
1411
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1410
1412
  }
1411
1413
  }
1414
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1415
+ generativeUIOutput = lastGenerativeUIRef.current;
1416
+ }
1417
+ const hasGenerativeUI = generativeUIOutput !== null;
1418
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1419
+ if (showThinking) {
1420
+ return /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." });
1421
+ }
1412
1422
  const attachments = [];
1413
1423
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1414
1424
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
@@ -1427,35 +1437,39 @@ var AssistantMessageAdapterBase = ({
1427
1437
  };
1428
1438
  var AssistantMessageAdapter = memo(AssistantMessageAdapterBase);
1429
1439
  AssistantMessageAdapter.displayName = "AssistantMessageAdapter";
1430
- function createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) {
1440
+ function createAssistantMessageAdapter(ThinkingIndicator, _ToolCallsComponent) {
1431
1441
  const CustomAssistantMessageAdapter = ({
1432
1442
  message,
1433
1443
  isLoading,
1434
- isGenerating,
1435
- isCurrentMessage
1444
+ isGenerating
1445
+ // isCurrentMessage and ToolCallsComponent are no longer used but kept for backwards compat
1436
1446
  }) => {
1437
- const showThinking = isLoading || isGenerating && !message?.content;
1438
- const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1447
+ const lastGenerativeUIRef = useRef(null);
1439
1448
  const rawContent = message?.content || "";
1440
1449
  const content = stripToolCallMarkers(rawContent);
1441
1450
  let generativeUIOutput = null;
1442
1451
  const msgWithUI = message;
1443
1452
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1444
1453
  try {
1445
- generativeUIOutput = msgWithUI.generativeUI();
1454
+ const newOutput = msgWithUI.generativeUI();
1455
+ if (newOutput !== null && newOutput !== void 0) {
1456
+ generativeUIOutput = newOutput;
1457
+ lastGenerativeUIRef.current = newOutput;
1458
+ }
1446
1459
  } catch (e) {
1447
1460
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1448
1461
  }
1449
1462
  }
1463
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1464
+ generativeUIOutput = lastGenerativeUIRef.current;
1465
+ }
1450
1466
  const attachments = [];
1467
+ const hasGenerativeUI = generativeUIOutput !== null;
1468
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1451
1469
  if (showThinking) {
1452
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1453
- ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1454
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1455
- ] });
1470
+ return /* @__PURE__ */ jsx(Fragment, { children: ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }) });
1456
1471
  }
1457
1472
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1458
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1459
1473
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1460
1474
  content && /* @__PURE__ */ jsx(
1461
1475
  AssistantMessage,
@@ -1473,16 +1487,15 @@ function createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) {
1473
1487
  CustomAssistantMessageAdapter.displayName = "CustomAssistantMessageAdapter";
1474
1488
  return memo(CustomAssistantMessageAdapter);
1475
1489
  }
1476
- function createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) {
1490
+ function createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, _ToolCallsComponent) {
1477
1491
  const ErrorReportingAssistantMessageAdapter = ({
1478
1492
  message,
1479
1493
  isLoading,
1480
- isGenerating,
1481
- isCurrentMessage
1494
+ isGenerating
1495
+ // isCurrentMessage and ToolCallsComponent are no longer used but kept for backwards compat
1482
1496
  }) => {
1497
+ const lastGenerativeUIRef = useRef(null);
1483
1498
  const { visibleMessages } = useCopilotChat();
1484
- const showThinking = isLoading || isGenerating && !message?.content;
1485
- const shouldShowToolCalls = isCurrentMessage && ToolCallsComponent;
1486
1499
  const rawContent = message?.content || "";
1487
1500
  const content = stripToolCallMarkers(rawContent);
1488
1501
  const errorContext = useMemo(() => detectErrorInMessage(content), [content]);
@@ -1530,20 +1543,25 @@ function createAssistantMessageAdapterWithErrorReporting(onReportIssue, Thinking
1530
1543
  const msgWithUI = message;
1531
1544
  if (msgWithUI && typeof msgWithUI.generativeUI === "function") {
1532
1545
  try {
1533
- generativeUIOutput = msgWithUI.generativeUI();
1546
+ const newOutput = msgWithUI.generativeUI();
1547
+ if (newOutput !== null && newOutput !== void 0) {
1548
+ generativeUIOutput = newOutput;
1549
+ lastGenerativeUIRef.current = newOutput;
1550
+ }
1534
1551
  } catch (e) {
1535
1552
  console.warn("[AssistantMessageAdapter] Error rendering generativeUI:", e);
1536
1553
  }
1537
1554
  }
1555
+ if (!generativeUIOutput && lastGenerativeUIRef.current) {
1556
+ generativeUIOutput = lastGenerativeUIRef.current;
1557
+ }
1538
1558
  const attachments = [];
1559
+ const hasGenerativeUI = generativeUIOutput !== null;
1560
+ const showThinking = (isLoading || isGenerating && !content) && !hasGenerativeUI;
1539
1561
  if (showThinking) {
1540
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1541
- ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }),
1542
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {})
1543
- ] });
1562
+ return /* @__PURE__ */ jsx(Fragment, { children: ThinkingIndicator ? /* @__PURE__ */ jsx(ThinkingIndicator, { isLoading, isGenerating }) : /* @__PURE__ */ jsx(AssistantThinking, { message: "Thinking..." }) });
1544
1563
  }
1545
1564
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1546
- shouldShowToolCalls && /* @__PURE__ */ jsx(ToolCallsComponent, {}),
1547
1565
  generativeUIOutput && /* @__PURE__ */ jsx(GenerativeUIContainer, { children: generativeUIOutput }),
1548
1566
  content && /* @__PURE__ */ jsx(
1549
1567
  AssistantMessage,
@@ -3172,7 +3190,7 @@ function CustomCopilotSidebar2({
3172
3190
  [disabled, disabledReason, onSetOpen]
3173
3191
  );
3174
3192
  const AssistantMessageAdapterMemo = useMemo(
3175
- () => onReportIssue ? createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator, ToolCallsComponent) : ThinkingIndicator || ToolCallsComponent ? createAssistantMessageAdapter(ThinkingIndicator, ToolCallsComponent) : AssistantMessageAdapter,
3193
+ () => onReportIssue ? createAssistantMessageAdapterWithErrorReporting(onReportIssue, ThinkingIndicator) : ThinkingIndicator || ToolCallsComponent ? createAssistantMessageAdapter(ThinkingIndicator) : AssistantMessageAdapter,
3176
3194
  [ThinkingIndicator, ToolCallsComponent, onReportIssue]
3177
3195
  );
3178
3196
  return /* @__PURE__ */ jsxs(Fragment, { children: [