@lobehub/chat 1.31.9 → 1.31.11
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/CHANGELOG.md +42 -0
- package/locales/ar/error.json +1 -0
- package/locales/ar/models.json +3 -9
- package/locales/bg-BG/error.json +1 -0
- package/locales/bg-BG/models.json +3 -9
- package/locales/de-DE/error.json +1 -0
- package/locales/de-DE/models.json +3 -9
- package/locales/en-US/error.json +1 -0
- package/locales/en-US/models.json +3 -9
- package/locales/es-ES/error.json +1 -0
- package/locales/es-ES/models.json +4 -10
- package/locales/fa-IR/error.json +1 -0
- package/locales/fa-IR/models.json +3 -9
- package/locales/fr-FR/error.json +1 -0
- package/locales/fr-FR/models.json +4 -10
- package/locales/it-IT/error.json +1 -0
- package/locales/it-IT/models.json +3 -9
- package/locales/ja-JP/error.json +1 -0
- package/locales/ja-JP/models.json +3 -9
- package/locales/ko-KR/error.json +1 -0
- package/locales/ko-KR/models.json +3 -9
- package/locales/nl-NL/error.json +1 -0
- package/locales/nl-NL/models.json +3 -9
- package/locales/pl-PL/error.json +1 -0
- package/locales/pl-PL/models.json +4 -10
- package/locales/pt-BR/error.json +1 -0
- package/locales/pt-BR/models.json +3 -9
- package/locales/ru-RU/error.json +1 -0
- package/locales/ru-RU/models.json +3 -9
- package/locales/tr-TR/error.json +1 -0
- package/locales/tr-TR/models.json +3 -9
- package/locales/vi-VN/error.json +1 -0
- package/locales/vi-VN/models.json +3 -9
- package/locales/zh-CN/error.json +2 -1
- package/locales/zh-CN/models.json +3 -9
- package/locales/zh-TW/error.json +1 -0
- package/locales/zh-TW/models.json +3 -9
- package/package.json +3 -3
- package/src/{features → app/(main)/chat/(workspace)/@conversation/features}/ChatInput/Desktop/TextArea.test.tsx +13 -13
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +29 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +46 -0
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/index.tsx +2 -1
- package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx +13 -11
- package/src/app/(main)/settings/llm/components/Checker.tsx +9 -2
- package/src/const/message.ts +4 -0
- package/src/features/ChatInput/Desktop/Footer/ShortcutHint.tsx +61 -0
- package/src/features/ChatInput/Desktop/Footer/index.tsx +11 -46
- package/src/features/ChatInput/Desktop/{TextArea.tsx → InputArea/index.tsx} +11 -20
- package/src/features/ChatInput/Desktop/index.tsx +23 -32
- package/src/features/Conversation/Messages/index.ts +11 -11
- package/src/features/Conversation/components/ChatItem/index.tsx +83 -44
- package/src/features/Conversation/components/VirtualizedList/index.tsx +90 -92
- package/src/features/Conversation/index.ts +2 -0
- package/src/libs/agent-runtime/error.ts +2 -0
- package/src/locales/default/error.ts +1 -0
- package/src/types/topic/index.ts +1 -0
- /package/src/types/{topic.ts → topic/topic.ts} +0 -0
@@ -3,116 +3,114 @@
|
|
3
3
|
import { Icon } from '@lobehub/ui';
|
4
4
|
import { useTheme } from 'antd-style';
|
5
5
|
import { Loader2Icon } from 'lucide-react';
|
6
|
-
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
6
|
+
import React, { ReactNode, memo, useCallback, useEffect, useRef, useState } from 'react';
|
7
7
|
import { Center, Flexbox } from 'react-layout-kit';
|
8
8
|
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
9
9
|
|
10
|
-
import { WELCOME_GUIDE_CHAT_ID } from '@/const/session';
|
11
10
|
import { isServerMode } from '@/const/version';
|
12
11
|
import { useChatStore } from '@/store/chat';
|
13
12
|
import { chatSelectors } from '@/store/chat/selectors';
|
14
13
|
|
15
14
|
import AutoScroll from '../AutoScroll';
|
16
15
|
import Item from '../ChatItem';
|
17
|
-
import InboxWelcome from '../InboxWelcome';
|
18
16
|
import SkeletonList from '../SkeletonList';
|
19
17
|
|
20
18
|
interface VirtualizedListProps {
|
21
19
|
dataSource: string[];
|
20
|
+
hideActionBar?: boolean;
|
21
|
+
itemContent?: (index: number, data: any, context: any) => ReactNode;
|
22
22
|
mobile?: boolean;
|
23
23
|
}
|
24
24
|
|
25
|
-
const VirtualizedList = memo<VirtualizedListProps>(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
virtuosoRef.current
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
return <Item id={id} index={index} />;
|
59
|
-
},
|
60
|
-
[mobile],
|
61
|
-
);
|
62
|
-
|
63
|
-
// first time loading or not loaded
|
64
|
-
if (isFirstLoading) return <SkeletonList mobile={mobile} />;
|
65
|
-
|
66
|
-
if (!isCurrentChatLoaded)
|
67
|
-
// use skeleton list when not loaded in server mode due to the loading duration is much longer than client mode
|
68
|
-
return isServerMode ? (
|
69
|
-
<SkeletonList mobile={mobile} />
|
70
|
-
) : (
|
71
|
-
// in client mode and switch page, using the center loading for smooth transition
|
72
|
-
<Center height={'100%'} width={'100%'}>
|
73
|
-
<Icon
|
74
|
-
icon={Loader2Icon}
|
75
|
-
size={{ fontSize: 32 }}
|
76
|
-
spin
|
77
|
-
style={{ color: theme.colorTextTertiary }}
|
78
|
-
/>
|
79
|
-
</Center>
|
25
|
+
const VirtualizedList = memo<VirtualizedListProps>(
|
26
|
+
({ mobile, dataSource, hideActionBar, itemContent }) => {
|
27
|
+
const virtuosoRef = useRef<VirtuosoHandle>(null);
|
28
|
+
const [atBottom, setAtBottom] = useState(true);
|
29
|
+
const [isScrolling, setIsScrolling] = useState(false);
|
30
|
+
|
31
|
+
const [id, isFirstLoading, isCurrentChatLoaded] = useChatStore((s) => [
|
32
|
+
chatSelectors.currentChatKey(s),
|
33
|
+
chatSelectors.currentChatLoadingState(s),
|
34
|
+
chatSelectors.isCurrentChatLoaded(s),
|
35
|
+
]);
|
36
|
+
|
37
|
+
useEffect(() => {
|
38
|
+
if (virtuosoRef.current) {
|
39
|
+
virtuosoRef.current.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
|
40
|
+
}
|
41
|
+
}, [id]);
|
42
|
+
|
43
|
+
const prevDataLengthRef = useRef(dataSource.length);
|
44
|
+
|
45
|
+
const getFollowOutput = useCallback(() => {
|
46
|
+
const newFollowOutput = dataSource.length > prevDataLengthRef.current ? 'auto' : false;
|
47
|
+
prevDataLengthRef.current = dataSource.length;
|
48
|
+
return newFollowOutput;
|
49
|
+
}, [dataSource.length]);
|
50
|
+
|
51
|
+
const theme = useTheme();
|
52
|
+
// overscan should be 3 times the height of the window
|
53
|
+
const overscan = typeof window !== 'undefined' ? window.innerHeight * 3 : 0;
|
54
|
+
|
55
|
+
const defaultItemContent = useCallback(
|
56
|
+
(index: number, id: string) => <Item hideActionBar={hideActionBar} id={id} index={index} />,
|
57
|
+
[mobile, hideActionBar],
|
80
58
|
);
|
81
59
|
|
82
|
-
|
83
|
-
<
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
60
|
+
// first time loading or not loaded
|
61
|
+
if (isFirstLoading) return <SkeletonList mobile={mobile} />;
|
62
|
+
|
63
|
+
if (!isCurrentChatLoaded)
|
64
|
+
// use skeleton list when not loaded in server mode due to the loading duration is much longer than client mode
|
65
|
+
return isServerMode ? (
|
66
|
+
<SkeletonList mobile={mobile} />
|
67
|
+
) : (
|
68
|
+
// in client mode and switch page, using the center loading for smooth transition
|
69
|
+
<Center height={'100%'} width={'100%'}>
|
70
|
+
<Icon
|
71
|
+
icon={Loader2Icon}
|
72
|
+
size={{ fontSize: 32 }}
|
73
|
+
spin
|
74
|
+
style={{ color: theme.colorTextTertiary }}
|
75
|
+
/>
|
76
|
+
</Center>
|
77
|
+
);
|
78
|
+
|
79
|
+
return (
|
80
|
+
<Flexbox height={'100%'}>
|
81
|
+
<Virtuoso
|
82
|
+
atBottomStateChange={setAtBottom}
|
83
|
+
atBottomThreshold={50 * (mobile ? 2 : 1)}
|
84
|
+
computeItemKey={(_, item) => item}
|
85
|
+
data={dataSource}
|
86
|
+
followOutput={getFollowOutput}
|
87
|
+
increaseViewportBy={overscan}
|
88
|
+
initialTopMostItemIndex={dataSource?.length - 1}
|
89
|
+
isScrolling={setIsScrolling}
|
90
|
+
itemContent={itemContent ?? defaultItemContent}
|
91
|
+
overscan={overscan}
|
92
|
+
ref={virtuosoRef}
|
93
|
+
/>
|
94
|
+
<AutoScroll
|
95
|
+
atBottom={atBottom}
|
96
|
+
isScrolling={isScrolling}
|
97
|
+
onScrollToBottom={(type) => {
|
98
|
+
const virtuoso = virtuosoRef.current;
|
99
|
+
switch (type) {
|
100
|
+
case 'auto': {
|
101
|
+
virtuoso?.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
|
102
|
+
break;
|
103
|
+
}
|
104
|
+
case 'click': {
|
105
|
+
virtuoso?.scrollToIndex({ align: 'end', behavior: 'smooth', index: 'LAST' });
|
106
|
+
break;
|
107
|
+
}
|
110
108
|
}
|
111
|
-
}
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
109
|
+
}}
|
110
|
+
/>
|
111
|
+
</Flexbox>
|
112
|
+
);
|
113
|
+
},
|
114
|
+
);
|
117
115
|
|
118
116
|
export default VirtualizedList;
|
@@ -1,2 +1,4 @@
|
|
1
|
+
export { default as ChatItem } from './components/ChatItem';
|
2
|
+
export { default as InboxWelcome } from './components/InboxWelcome';
|
1
3
|
export { default as SkeletonList } from './components/SkeletonList';
|
2
4
|
export { default as VirtualizedList } from './components/VirtualizedList';
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './topic';
|
File without changes
|