@assistant-ui/react 0.5.12 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -1198,7 +1198,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
1198
1198
  if (message.content.length === 0 && partIndex === 0) {
1199
1199
  part = EMPTY_CONTENT;
1200
1200
  } else {
1201
- return;
1201
+ return null;
1202
1202
  }
1203
1203
  }
1204
1204
  const status = toContentPartStatus(message, partIndex, part);
@@ -1834,6 +1834,7 @@ var getIsLast = (messages, message) => {
1834
1834
  var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
1835
1835
  const parentId = messages[messageIndex - 1]?.id ?? null;
1836
1836
  const message = messages[messageIndex];
1837
+ if (!message) return null;
1837
1838
  const isLast = getIsLast(messages, message);
1838
1839
  const branches = getBranches(message.id);
1839
1840
  const currentState = useMessage?.getState();
@@ -3604,7 +3605,6 @@ var AUTO_STATUS_COMPLETE = Object.freeze({
3604
3605
  type: "complete",
3605
3606
  reason: "unknown"
3606
3607
  });
3607
- var isAutoStatus = (status) => status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;
3608
3608
  var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;
3609
3609
 
3610
3610
  // src/runtimes/external-store/ThreadMessageLike.tsx
@@ -3688,9 +3688,8 @@ var useExternalStoreSync = (adapter, updateData) => {
3688
3688
  adapterRef.current.messages.at(-1) === m,
3689
3689
  adapterRef.current.isRunning ?? false
3690
3690
  );
3691
- if (cache && (cache.role !== "assistant" || !isAutoStatus(cache.status) || cache.status.type === autoStatus.type))
3691
+ if (cache && (cache.role !== "assistant" || cache.status === autoStatus))
3692
3692
  return cache;
3693
- if (cache) return cache;
3694
3693
  const newMessage = fromThreadMessageLike(
3695
3694
  converter2(m, idx),
3696
3695
  idx.toString(),