@zero-library/chat-copilot 3.1.7 → 3.1.8

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.esm.js CHANGED
@@ -3,7 +3,7 @@ import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeH
3
3
  import { useRefState, useDebounce, createTokenManager, useSyncInput, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
4
  import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Drawer, Empty, Modal, Checkbox, Input, message, List, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
5
5
  import * as React10 from 'react';
6
- import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, useCallback, memo, useState, useContext, useLayoutEffect } from 'react';
6
+ import React10__default, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback, useLayoutEffect } from 'react';
7
7
  import { useSnapshot, proxy } from 'valtio';
8
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
9
9
  import { LexicalComposer } from '@lexical/react/LexicalComposer';
@@ -825,8 +825,8 @@ var ChatSender_default = forwardRef(
825
825
  const isFocusedRef = useRef(false);
826
826
  const commandConfigRef = useRef(commandConfig);
827
827
  commandConfigRef.current = commandConfig;
828
- const inputComponent = useCallback(
829
- (inputProps) => /* @__PURE__ */ jsx(ChatInput_default, { ...inputProps, commandConfig: commandConfigRef.current }),
828
+ const inputComponent = useMemo(
829
+ () => forwardRef((inputProps, ref2) => /* @__PURE__ */ jsx(ChatInput_default, { ...inputProps, ref: ref2, commandConfig: commandConfigRef.current })),
830
830
  []
831
831
  );
832
832
  useEffect(() => {
@@ -3880,6 +3880,15 @@ function extractSurfaceId2(command) {
3880
3880
  function getA2uiRuntimeCommands(state) {
3881
3881
  return [...state.serverCommands, ...state.localCommands];
3882
3882
  }
3883
+ function sanitizeA2uiCommands(commands) {
3884
+ return commands.map((cmd) => {
3885
+ if (!cmd || typeof cmd !== "object" || !cmd.updateDataModel) return cmd;
3886
+ const { path } = cmd.updateDataModel;
3887
+ if (typeof path === "string" && path.trim()) return cmd;
3888
+ const { updateDataModel: _, ...rest } = cmd;
3889
+ return rest;
3890
+ });
3891
+ }
3883
3892
  function diffConversationMessages(messages, prevCursors) {
3884
3893
  if (messages.length < prevCursors.length) {
3885
3894
  return { shouldReplayAll: true, nextCursors: [], pendingItems: [] };
@@ -4077,7 +4086,7 @@ function selectA2uiRuntimeView(state, dismissedSurfaceIds) {
4077
4086
  const mergedDismissedSurfaceIds = Array.from(
4078
4087
  new Set([...dismissedSurfaceIds || [], ...state.optimisticallyDismissedSurfaceIds].filter((surfaceId) => surfaceId?.trim?.()))
4079
4088
  );
4080
- const commands = getA2uiRuntimeCommands(state);
4089
+ const commands = sanitizeA2uiCommands(getA2uiRuntimeCommands(state));
4081
4090
  const visibleSurfaceIds = resolveVisibleSurfaceIds(commands, mergedDismissedSurfaceIds);
4082
4091
  const anchoredSurfaceIdsByMessageIndex = {};
4083
4092
  visibleSurfaceIds.forEach((surfaceId) => {