@ant-design/agentic-ui 2.30.19 → 2.30.20

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.
@@ -94,8 +94,8 @@ import { MessagesContext } from "./BubbleContext";
94
94
  * />
95
95
  * ```
96
96
  */ export var MarkdownPreview = function MarkdownPreview(props) {
97
- var _ref, _ref1;
98
- var _props_markdownRenderConfig, _props_markdownRenderConfig1, _props_originData, _props_originData1;
97
+ var _ref, _ref1, _ref2;
98
+ var _props_markdownRenderConfig, _props_markdownRenderConfig1, _props_originData, _props_originData1, _props_originData2;
99
99
  var content = props.content, extra = props.extra, typing = props.typing, htmlRef = props.htmlRef, fncProps = props.fncProps, docListNode = props.docListNode, beforeContent = props.beforeContent, afterContent = props.afterContent;
100
100
  var MarkdownEditorRef = React.useRef(undefined);
101
101
  var hidePadding = (useContext(MessagesContext) || {}).hidePadding;
@@ -105,6 +105,7 @@ import { MessagesContext } from "./BubbleContext";
105
105
  var extraShowOnHover = config === null || config === void 0 ? void 0 : config.extraShowOnHover;
106
106
  var token = theme.useToken().token;
107
107
  var renderMode = (_ref = (_ref1 = (_props_markdownRenderConfig = props.markdownRenderConfig) === null || _props_markdownRenderConfig === void 0 ? void 0 : _props_markdownRenderConfig.renderMode) !== null && _ref1 !== void 0 ? _ref1 : (_props_markdownRenderConfig1 = props.markdownRenderConfig) === null || _props_markdownRenderConfig1 === void 0 ? void 0 : _props_markdownRenderConfig1.renderType) !== null && _ref !== void 0 ? _ref : 'slate';
108
+ var shouldAnimateMarkdown = Boolean(typing) && ((_ref2 = (_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isLast) !== null && _ref2 !== void 0 ? _ref2 : true);
108
109
  var isPaddingHidden = useMemo(function() {
109
110
  return !!extra;
110
111
  }, [
@@ -121,15 +122,15 @@ import { MessagesContext } from "./BubbleContext";
121
122
  renderMode
122
123
  ]);
123
124
  var markdown = useMemo(function() {
124
- var _ref;
125
- var _content_includes, _htmlRef_current, _htmlRef_current1, _props_markdownRenderConfig, _props_originData, _props_originData1, _props_originData2, _props_markdownRenderConfig1, _props_markdownRenderConfig2, _props_markdownRenderConfig3;
125
+ var _ref, _ref1;
126
+ var _content_includes, _htmlRef_current, _htmlRef_current1, _props_markdownRenderConfig, _props_originData, _props_originData1, _props_originData2, _props_markdownRenderConfig1, _props_markdownRenderConfig2, _props_originData3, _props_markdownRenderConfig3;
126
127
  // MarkdownRenderer 渲染路径——轻量,不创建 Slate 实例
127
128
  if (renderMode === 'markdown') {
128
- var _props_originData3, _props_markdownRenderConfig4, _props_markdownRenderConfig5, _props_markdownRenderConfig6, _props_markdownRenderConfig7, _props_markdownRenderConfig8, _props_markdownRenderConfig9, _props_markdownRenderConfig10;
129
+ var _props_originData4, _props_markdownRenderConfig4, _props_markdownRenderConfig5, _props_markdownRenderConfig6, _props_markdownRenderConfig7, _props_markdownRenderConfig8, _props_markdownRenderConfig9, _props_markdownRenderConfig10;
129
130
  return /*#__PURE__*/ React.createElement(MarkdownRenderer, {
130
131
  content: content,
131
- streaming: typing,
132
- isFinished: (_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : _props_originData3.isFinished,
132
+ streaming: shouldAnimateMarkdown,
133
+ isFinished: (_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : _props_originData4.isFinished,
133
134
  plugins: (_props_markdownRenderConfig4 = props.markdownRenderConfig) === null || _props_markdownRenderConfig4 === void 0 ? void 0 : _props_markdownRenderConfig4.plugins,
134
135
  queueOptions: (_props_markdownRenderConfig5 = props.markdownRenderConfig) === null || _props_markdownRenderConfig5 === void 0 ? void 0 : _props_markdownRenderConfig5.queueOptions,
135
136
  streamingParagraphAnimation: (_props_markdownRenderConfig6 = props.markdownRenderConfig) === null || _props_markdownRenderConfig6 === void 0 ? void 0 : _props_markdownRenderConfig6.streamingParagraphAnimation,
@@ -168,7 +169,7 @@ import { MessagesContext } from "./BubbleContext";
168
169
  editorStyle: _object_spread({
169
170
  fontSize: 14
170
171
  }, ((_props_markdownRenderConfig1 = props.markdownRenderConfig) === null || _props_markdownRenderConfig1 === void 0 ? void 0 : _props_markdownRenderConfig1.editorStyle) || {}),
171
- typewriter: (_ref = (_props_markdownRenderConfig2 = props.markdownRenderConfig) === null || _props_markdownRenderConfig2 === void 0 ? void 0 : _props_markdownRenderConfig2.typewriter) !== null && _ref !== void 0 ? _ref : typing,
172
+ typewriter: ((_ref = (_props_markdownRenderConfig2 = props.markdownRenderConfig) === null || _props_markdownRenderConfig2 === void 0 ? void 0 : _props_markdownRenderConfig2.typewriter) !== null && _ref !== void 0 ? _ref : shouldAnimateMarkdown) && ((_ref1 = (_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : _props_originData3.isLast) !== null && _ref1 !== void 0 ? _ref1 : true),
172
173
  style: _object_spread({
173
174
  minWidth: minWidth ? "min(".concat(minWidth, "px,100%)") : undefined,
174
175
  maxWidth: standalone ? '100%' : undefined,
@@ -180,8 +181,8 @@ import { MessagesContext } from "./BubbleContext";
180
181
  }, [
181
182
  hidePadding,
182
183
  typing,
183
- (_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isLast,
184
- (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isFinished,
184
+ (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isLast,
185
+ (_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : _props_originData2.isFinished,
185
186
  isPaddingHidden,
186
187
  content,
187
188
  renderMode,
@@ -222,8 +222,7 @@ var genStyle = function genStyle(token) {
222
222
  '&-typing-hint': {
223
223
  position: 'absolute',
224
224
  left: 'var(--padding-3x)',
225
- top: '50%',
226
- transform: 'translateY(-50%)',
225
+ top: '10%',
227
226
  pointerEvents: 'none',
228
227
  zIndex: 10,
229
228
  display: 'flex',
@@ -139,12 +139,16 @@ export var TaskList = /*#__PURE__*/ memo(function(param) {
139
139
  items,
140
140
  locale
141
141
  ]), summaryStatus = _useMemo.summaryStatus, summaryText = _useMemo.summaryText, progressText = _useMemo.progressText;
142
+ var isCancelled = items.some(function(i) {
143
+ return i.status === 'error';
144
+ });
142
145
  var renderItems = function renderItems() {
143
- return items.map(function(item, index) {
146
+ var visibleItems = isCancelled ? items.slice(-1) : items;
147
+ return visibleItems.map(function(item, index) {
144
148
  return /*#__PURE__*/ React.createElement(TaskListItem, {
145
149
  key: item.key,
146
150
  item: item,
147
- isLast: index === items.length - 1,
151
+ isLast: index === visibleItems.length - 1,
148
152
  prefixCls: prefixCls,
149
153
  hashId: hashId,
150
154
  expandedKeys: internalExpandedKeys,
@@ -105,6 +105,7 @@ import { TableSql } from "./TableSql";
105
105
  import { TitleInfo } from "./TitleInfo";
106
106
  import { ToolCall } from "./ToolCall";
107
107
  import { WebSearch } from "./WebSearch";
108
+ var DETAIL_COLLAPSE_DURATION_MS = 160;
108
109
  /**
109
110
  * ThoughtChainItemDetail 组件 - 思维链项详情组件
110
111
  *
@@ -327,6 +328,7 @@ var ThoughtChainItemMotion = /*#__PURE__*/ React.memo(function(param) {
327
328
  */ export var ThoughtChainListItem = /*#__PURE__*/ React.memo(function(props) {
328
329
  var _props_bubble, _thoughtChainListItem_meta;
329
330
  var _React_useState = _sliced_to_array(React.useState(false), 2), collapse = _React_useState[0], setCollapse = _React_useState[1];
331
+ var _React_useState1 = _sliced_to_array(React.useState(true), 2), shouldRenderDetail = _React_useState1[0], setShouldRenderDetail = _React_useState1[1];
330
332
  var thoughtChainListItem = props.thoughtChainListItem, prefixCls = props.prefixCls, hashId = props.hashId, setDocMeta = props.setDocMeta;
331
333
  var markdownRenderProps = useMemo(function() {
332
334
  return props.markdownRenderProps || {
@@ -352,6 +354,20 @@ var ThoughtChainItemMotion = /*#__PURE__*/ React.memo(function(param) {
352
354
  var handleCollapseChange = React.useCallback(function(change) {
353
355
  setCollapse(change);
354
356
  }, []);
357
+ React.useEffect(function() {
358
+ if (!collapse) {
359
+ setShouldRenderDetail(true);
360
+ return;
361
+ }
362
+ var timer = window.setTimeout(function() {
363
+ setShouldRenderDetail(false);
364
+ }, DETAIL_COLLAPSE_DURATION_MS);
365
+ return function() {
366
+ window.clearTimeout(timer);
367
+ };
368
+ }, [
369
+ collapse
370
+ ]);
355
371
  var titleDom = /*#__PURE__*/ React.createElement(TitleInfo, {
356
372
  title: thoughtChainListItem.info,
357
373
  costMillis: thoughtChainListItem.costMillis,
@@ -393,13 +409,22 @@ var ThoughtChainItemMotion = /*#__PURE__*/ React.memo(function(param) {
393
409
  minWidth: 0,
394
410
  maxWidth: '100%'
395
411
  }
396
- }, props.titleRender ? props.titleRender(thoughtChainListItem, titleDom) : titleDom, /*#__PURE__*/ React.createElement("div", {
412
+ }, props.titleRender ? props.titleRender(thoughtChainListItem, titleDom) : titleDom, shouldRenderDetail ? /*#__PURE__*/ React.createElement("div", {
413
+ style: {
414
+ display: 'grid',
415
+ gridTemplateRows: collapse ? '0fr' : '1fr',
416
+ opacity: collapse ? 0 : 1,
417
+ transition: 'grid-template-rows 0.16s ease, opacity 0.12s ease',
418
+ pointerEvents: collapse ? 'none' : 'auto'
419
+ },
420
+ "aria-hidden": collapse
421
+ }, /*#__PURE__*/ React.createElement("div", {
397
422
  style: {
398
423
  display: 'flex',
399
424
  flexDirection: 'column',
400
- height: !collapse ? 'auto' : '0px',
401
425
  overflow: 'hidden',
426
+ minHeight: 0,
402
427
  gap: 8
403
428
  }
404
- }, !collapse ? props.contentRender ? props.contentRender(thoughtChainListItem, content) : content : null)));
429
+ }, props.contentRender ? props.contentRender(thoughtChainListItem, content) : content)) : null));
405
430
  });
@@ -158,7 +158,7 @@ import dayjs from "dayjs";
158
158
  import duration from "dayjs/plugin/duration";
159
159
  import { motion } from "framer-motion";
160
160
  import { merge } from "lodash-es";
161
- import React, { useContext, useEffect, useMemo } from "react";
161
+ import React, { useContext, useEffect, useMemo, useState } from "react";
162
162
  import { ErrorBoundary } from "react-error-boundary";
163
163
  import { ActionIconBox } from "../Components/ActionIconBox";
164
164
  import { useAutoScroll } from "../Hooks/useAutoScroll";
@@ -168,6 +168,7 @@ import { FlipText } from "./FlipText";
168
168
  import { useStyle } from "./style";
169
169
  import { ThoughtChainListItem } from "./ThoughtChainListItem";
170
170
  import { TitleInfo } from "./TitleInfo";
171
+ var COLLAPSE_ANIMATION_DURATION_MS = 160;
171
172
  // Initialize dayjs plugins
172
173
  try {
173
174
  dayjs.extend(duration);
@@ -258,8 +259,23 @@ var ThoughtChainContent = /*#__PURE__*/ React.memo(function(_0) {
258
259
  var containerRef = useAutoScroll({
259
260
  SCROLL_TOLERANCE: 30
260
261
  }).containerRef;
262
+ var _useState = _sliced_to_array(useState(!collapse), 2), shouldRenderItems = _useState[0], setShouldRenderItems = _useState[1];
263
+ useEffect(function() {
264
+ if (!collapse) {
265
+ setShouldRenderItems(true);
266
+ return;
267
+ }
268
+ var timer = window.setTimeout(function() {
269
+ setShouldRenderItems(false);
270
+ }, COLLAPSE_ANIMATION_DURATION_MS);
271
+ return function() {
272
+ window.clearTimeout(timer);
273
+ };
274
+ }, [
275
+ collapse
276
+ ]);
261
277
  var processedItems = useMemo(function() {
262
- if (collapse) return [];
278
+ if (!shouldRenderItems) return [];
263
279
  return thoughtChainList.map(function(item, index) {
264
280
  var _item_output, _item_output1, _item_output2, _item_output3, _item_output4;
265
281
  var info = item.info;
@@ -288,7 +304,7 @@ var ThoughtChainContent = /*#__PURE__*/ React.memo(function(_0) {
288
304
  }, [
289
305
  thoughtChainList,
290
306
  bubble === null || bubble === void 0 ? void 0 : bubble.isFinished,
291
- collapse
307
+ shouldRenderItems
292
308
  ]);
293
309
  var mergedMarkdownProps = useMemo(function() {
294
310
  return merge(markdownRenderProps || {}, {
@@ -161,7 +161,8 @@ var genStyle = function genStyle(token) {
161
161
  borderRadius: '0px 0px 12px 12px',
162
162
  maxHeight: '566px',
163
163
  padding: '12px 12px',
164
- transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
164
+ opacity: 1,
165
+ transition: 'max-height 0.16s cubic-bezier(0.4, 0, 0.2, 1), padding 0.16s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.12s linear',
165
166
  overflow: 'auto',
166
167
  '&&-compact': {
167
168
  padding: 8
@@ -169,7 +170,8 @@ var genStyle = function genStyle(token) {
169
170
  '&&-collapse': {
170
171
  maxHeight: '0px',
171
172
  padding: '0',
172
- opacity: 0
173
+ opacity: 0,
174
+ overflow: 'hidden'
173
175
  },
174
176
  '&-list': {
175
177
  display: 'flex',
@@ -98,10 +98,11 @@ function _unsupported_iterable_to_array(o, minLen) {
98
98
  }
99
99
  import { Api, ChevronUp, ChevronsDownUp, ChevronsUpDown, X } from "@sofa-design/icons";
100
100
  import classNames from "clsx";
101
- import { AnimatePresence, motion } from "framer-motion";
101
+ import { motion } from "framer-motion";
102
102
  import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
103
103
  import { useRefFunction } from "../../Hooks/useRefFunction";
104
104
  /** 内容超出此高度时自动收起 */ var CONTENT_COLLAPSE_THRESHOLD = 200;
105
+ /** 工具详情收起动画时长(毫秒) */ var TOOL_CONTENT_COLLAPSE_DURATION_MS = 160;
105
106
  var ToolImageComponent = function ToolImageComponent(param) {
106
107
  var tool = param.tool, prefixCls = param.prefixCls, hashId = param.hashId, _param_disableAnimation = param.disableAnimation, disableAnimation = _param_disableAnimation === void 0 ? false : _param_disableAnimation;
107
108
  var toolImageWrapperClassName = useMemo(function() {
@@ -325,6 +326,7 @@ var ToolContentComponent = function ToolContentComponent(param) {
325
326
  var contentInnerRef = useRef(null);
326
327
  var _useState = _sliced_to_array(useState(false), 2), isContentOverflowing = _useState[0], setIsContentOverflowing = _useState[1];
327
328
  var _useState1 = _sliced_to_array(useState(false), 2), contentExpanded = _useState1[0], setContentExpanded = _useState1[1];
329
+ var _useState2 = _sliced_to_array(useState(expanded), 2), shouldRenderContent = _useState2[0], setShouldRenderContent = _useState2[1];
328
330
  var toolContainerClassName = useMemo(function() {
329
331
  return classNames("".concat(prefixCls, "-tool-container"), hashId, _define_property({}, "".concat(prefixCls, "-tool-container-light"), light));
330
332
  }, [
@@ -409,6 +411,25 @@ var ToolContentComponent = function ToolContentComponent(param) {
409
411
  tool.errorMessage,
410
412
  checkOverflow
411
413
  ]);
414
+ useEffect(function() {
415
+ if (!showContent) {
416
+ setShouldRenderContent(false);
417
+ return;
418
+ }
419
+ if (expanded) {
420
+ setShouldRenderContent(true);
421
+ return;
422
+ }
423
+ var timer = window.setTimeout(function() {
424
+ setShouldRenderContent(false);
425
+ }, TOOL_CONTENT_COLLAPSE_DURATION_MS);
426
+ return function() {
427
+ window.clearTimeout(timer);
428
+ };
429
+ }, [
430
+ expanded,
431
+ showContent
432
+ ]);
412
433
  var handleContentExpandToggle = useRefFunction(function() {
413
434
  setContentExpanded(function(prev) {
414
435
  return !prev;
@@ -449,41 +470,6 @@ var ToolContentComponent = function ToolContentComponent(param) {
449
470
  contentExpandClassName,
450
471
  handleContentExpandToggle
451
472
  ]);
452
- var contentVariants = useMemo(function() {
453
- return {
454
- expanded: {
455
- height: 'auto',
456
- opacity: 1
457
- },
458
- collapsed: {
459
- height: 0,
460
- opacity: 0
461
- }
462
- };
463
- }, []);
464
- var contentTransition = useMemo(function() {
465
- return {
466
- height: {
467
- duration: 0.26,
468
- ease: [
469
- 0.4,
470
- 0,
471
- 0.2,
472
- 1
473
- ]
474
- },
475
- opacity: {
476
- duration: 0.2,
477
- ease: 'linear'
478
- }
479
- };
480
- }, []);
481
- var containerStyle = useMemo(function() {
482
- return {
483
- overflow: 'hidden',
484
- willChange: 'height, opacity'
485
- };
486
- }, []);
487
473
  var innerContent = /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
488
474
  ref: contentInnerRef,
489
475
  style: contentInnerStyle
@@ -491,26 +477,17 @@ var ToolContentComponent = function ToolContentComponent(param) {
491
477
  // 禁用动画时使用简单的显示/隐藏
492
478
  if (disableAnimation) {
493
479
  return showContent && expanded ? /*#__PURE__*/ React.createElement("div", {
494
- className: toolContainerClassName,
480
+ className: classNames(toolContainerClassName, _define_property({}, "".concat(prefixCls, "-tool-container-expanded"), true)),
495
481
  "data-testid": "tool-user-item-tool-container",
496
482
  style: {
497
483
  overflow: 'hidden'
498
484
  }
499
485
  }, innerContent) : null;
500
486
  }
501
- return /*#__PURE__*/ React.createElement(AnimatePresence, {
502
- initial: false,
503
- mode: "sync"
504
- }, expanded ? /*#__PURE__*/ React.createElement(motion.div, {
505
- key: "tool-content",
506
- className: toolContainerClassName,
487
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, showContent && shouldRenderContent ? /*#__PURE__*/ React.createElement("div", {
488
+ className: classNames(toolContainerClassName, _define_property({}, "".concat(prefixCls, "-tool-container-expanded"), expanded)),
507
489
  "data-testid": "tool-user-item-tool-container",
508
- variants: contentVariants,
509
- initial: "collapsed",
510
- animate: "expanded",
511
- exit: "collapsed",
512
- transition: contentTransition,
513
- style: containerStyle
490
+ "aria-hidden": !expanded
514
491
  }, innerContent) : null, !showContent ? /*#__PURE__*/ React.createElement("div", {
515
492
  style: {
516
493
  overflow: 'hidden',
@@ -76,7 +76,7 @@ var genStyle = function genStyle(token) {
76
76
  minHeight: '20px',
77
77
  backdropFilter: 'blur(8px)',
78
78
  width: 'max-content',
79
- transition: 'border-radius 0.4s ease',
79
+ transition: 'border-radius 0.16s cubic-bezier(0.4, 0, 0.2, 1)',
80
80
  display: 'flex',
81
81
  alignItems: 'center',
82
82
  flexDirection: 'column',
@@ -307,12 +307,21 @@ var genStyle = function genStyle(token) {
307
307
  display: 'flex',
308
308
  flexDirection: 'column',
309
309
  width: '100%',
310
- maxHeight: 700,
310
+ maxHeight: 0,
311
311
  overflow: 'hidden',
312
- overflowY: 'auto',
312
+ opacity: 0,
313
+ pointerEvents: 'none',
314
+ transition: 'max-height 0.16s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.12s linear',
313
315
  position: 'relative',
314
316
  paddingInline: 4,
315
- paddingBottom: 4,
317
+ paddingBottom: 0,
318
+ '&-expanded': {
319
+ maxHeight: 700,
320
+ opacity: 1,
321
+ pointerEvents: 'auto',
322
+ overflowY: 'auto',
323
+ paddingBottom: 4
324
+ },
316
325
  '&-light': {
317
326
  borderLeft: '1px solid var(--color-gray-border-light)',
318
327
  paddingLeft: 12,
@@ -197,8 +197,7 @@ export var BrowserItemComponent = function BrowserItemComponent(param) {
197
197
  }, /*#__PURE__*/ React.createElement("div", {
198
198
  className: classNames("".concat(prefixCls, "-result-item-title"), hashId)
199
199
  }, item.title)))), /*#__PURE__*/ React.createElement("div", {
200
- className: classNames("".concat(prefixCls, "-result-item-site"), hashId),
201
- onClick: handleOpen
200
+ className: classNames("".concat(prefixCls, "-result-item-site"), hashId)
202
201
  }, renderSiteAvatar(item.site, item.icon), /*#__PURE__*/ React.createElement(Tooltip, {
203
202
  title: item.site,
204
203
  mouseEnterDelay: 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/agentic-ui",
3
- "version": "2.30.19",
3
+ "version": "2.30.20",
4
4
  "description": "面向智能体的 UI 组件库,提供多步推理可视化、工具调用展示、任务执行协同等 Agentic UI 能力",
5
5
  "repository": "git@github.com:ant-design/agentic-ui.git",
6
6
  "license": "MIT",