@ray-js/t-agent-ui-ray 0.2.0-beta-4 → 0.2.0-beta-5
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/MessageList/index.d.ts +1 -0
- package/dist/MessageList/index.js +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +1 -2
- package/dist/tiles/BubbleTile/index.js +34 -4
- package/dist/tiles/BubbleTile/index.less +19 -1
- package/package.json +2 -2
- package/dist/hooks/useMultiSelect.d.ts +0 -7
- package/dist/hooks/useMultiSelect.js +0 -12
|
@@ -112,7 +112,7 @@ export default function MessageList(props) {
|
|
|
112
112
|
});
|
|
113
113
|
}), historyLimit && historyLimit.count < reversed.length && /*#__PURE__*/React.createElement(View, {
|
|
114
114
|
className: "t-agent-message-list-history-tip"
|
|
115
|
-
}, historyLimit.tipText), /*#__PURE__*/React.createElement(View, {
|
|
115
|
+
}, historyLimit.tipText), props.renderTop, /*#__PURE__*/React.createElement(View, {
|
|
116
116
|
className: "t-agent-message-list-padding-start"
|
|
117
117
|
})));
|
|
118
118
|
}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -3,15 +3,16 @@ import "core-js/modules/esnext.iterator.constructor.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.find.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
5
5
|
import "core-js/modules/esnext.iterator.some.js";
|
|
6
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
6
7
|
import './index.less';
|
|
7
8
|
import { View } from '@ray-js/components';
|
|
8
|
-
import React, { useCallback,
|
|
9
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
9
10
|
import { Image } from '@ray-js/ray';
|
|
10
11
|
import { BubbleTileStatus, ChatMessageStatus } from '@ray-js/t-agent';
|
|
11
12
|
import TileRender from '../../TileRender';
|
|
12
13
|
import noticeSvg from './notice.svg';
|
|
13
14
|
import noticeWarnSvg from './notice-warn.svg';
|
|
14
|
-
import { useChatAgent,
|
|
15
|
+
import { useChatAgent, useLongPress, useRenderOptions, useTranslate } from '../../hooks';
|
|
15
16
|
import RollBack from '../WorkflowTile/RollBack';
|
|
16
17
|
const BubbleTile = props => {
|
|
17
18
|
var _workflowTile$data;
|
|
@@ -73,7 +74,36 @@ const BubbleTile = props => {
|
|
|
73
74
|
const showRollBack = side === 'start' && children.some(child => child.type === 'workflow');
|
|
74
75
|
const workflowTile = children.find(child => child.type === 'workflow');
|
|
75
76
|
const workflowNode = workflowTile === null || workflowTile === void 0 || (_workflowTile$data = workflowTile.data) === null || _workflowTile$data === void 0 ? void 0 : _workflowTile$data.nodeId;
|
|
76
|
-
|
|
77
|
+
const isErrorBubble = useMemo(() => {
|
|
78
|
+
let empty = true;
|
|
79
|
+
for (const child of children) {
|
|
80
|
+
// 如果子元素是文本类型,并且文本不为空,则不是空消息
|
|
81
|
+
if (child.type === 'text') {
|
|
82
|
+
if (child.data.text !== '') {
|
|
83
|
+
empty = false;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
// 如果子元素是其他类型,则不是空消息
|
|
88
|
+
empty = false;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return empty && role === 'assistant' && bubbleStatus === BubbleTileStatus.ERROR && status === ChatMessageStatus.FINISH;
|
|
93
|
+
}, [status, role, bubbleStatus, children]);
|
|
94
|
+
if (isErrorBubble) {
|
|
95
|
+
return /*#__PURE__*/React.createElement(View, _extends({
|
|
96
|
+
className: "t-agent-bubble-tile t-agent-bubble-tile-error-alert",
|
|
97
|
+
"data-testid": "t-agent-bubble-tile"
|
|
98
|
+
}, longPressRes.longPressProps), /*#__PURE__*/React.createElement(Image, {
|
|
99
|
+
src: noticeSvg,
|
|
100
|
+
className: "t-agent-bubble-tile-error",
|
|
101
|
+
"data-testid": "t-agent-bubble-tile-error"
|
|
102
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
103
|
+
className: "t-agent-bubble-tile-error-alert-text"
|
|
104
|
+
}, data.info || t('t-agent.unknown-error')), longPressBlock);
|
|
105
|
+
}
|
|
106
|
+
return /*#__PURE__*/React.createElement(View, _extends({
|
|
77
107
|
className: "t-agent-bubble-tile t-agent-bubble-tile-".concat(side),
|
|
78
108
|
"data-testid": "t-agent-bubble-tile"
|
|
79
109
|
}, longPressRes.longPressProps), side === 'end' && /*#__PURE__*/React.createElement(ErrorNotice, {
|
|
@@ -96,7 +126,7 @@ const BubbleTile = props => {
|
|
|
96
126
|
}, t('t-agent.message.bubble.aborted'))), side === 'start' && /*#__PURE__*/React.createElement(ErrorNotice, {
|
|
97
127
|
bubbleStatus: bubbleStatus,
|
|
98
128
|
showInfo: showInfo
|
|
99
|
-
})
|
|
129
|
+
}), longPressBlock, showRollBack && !isLatestMessage && workflowNode && /*#__PURE__*/React.createElement(RollBack, {
|
|
100
130
|
nodeId: workflowNode
|
|
101
131
|
}));
|
|
102
132
|
};
|
|
@@ -18,6 +18,24 @@
|
|
|
18
18
|
position: relative;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
.t-agent-bubble-tile-error-alert {
|
|
22
|
+
background: var(--app-M2_1);
|
|
23
|
+
border-radius: 32rpx;
|
|
24
|
+
padding: 24rpx;
|
|
25
|
+
|
|
26
|
+
.t-agent-bubble-tile-error {
|
|
27
|
+
margin: 0 12rpx 0 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.t-agent-bubble-tile-error-alert-text {
|
|
31
|
+
flex: 0 1 auto;
|
|
32
|
+
min-width: 0;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
.t-agent-bubble-tile-bubble-loader {
|
|
22
40
|
display: inline-flex;
|
|
23
41
|
|
|
@@ -64,7 +82,7 @@
|
|
|
64
82
|
display: flex;
|
|
65
83
|
justify-content: center;
|
|
66
84
|
align-items: center;
|
|
67
|
-
|
|
85
|
+
|
|
68
86
|
.t-agent-bubble-tile-bubble-loader-ball {
|
|
69
87
|
width: 6px;
|
|
70
88
|
height: 6px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-ui-ray",
|
|
3
|
-
"version": "0.2.0-beta-
|
|
3
|
+
"version": "0.2.0-beta-5",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@types/echarts": "^4.9.22",
|
|
41
41
|
"@types/markdown-it": "^14.1.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "a0beda17c8e1c3ef81c718300c02a23d88a3ee4a"
|
|
44
44
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const useMultiSelectMessage: () => {
|
|
3
|
-
show: boolean;
|
|
4
|
-
select: string[];
|
|
5
|
-
onSelect: import("react").Dispatch<import("react").SetStateAction<string[]>>;
|
|
6
|
-
setShow: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
7
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
export const useMultiSelectMessage = () => {
|
|
4
|
-
const [select, setSelect] = useState([]);
|
|
5
|
-
const [show, setShow] = useState(false);
|
|
6
|
-
return {
|
|
7
|
-
show,
|
|
8
|
-
select,
|
|
9
|
-
onSelect: setSelect,
|
|
10
|
-
setShow
|
|
11
|
-
};
|
|
12
|
-
};
|