@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.
Files changed (57) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/locales/ar/error.json +1 -0
  3. package/locales/ar/models.json +3 -9
  4. package/locales/bg-BG/error.json +1 -0
  5. package/locales/bg-BG/models.json +3 -9
  6. package/locales/de-DE/error.json +1 -0
  7. package/locales/de-DE/models.json +3 -9
  8. package/locales/en-US/error.json +1 -0
  9. package/locales/en-US/models.json +3 -9
  10. package/locales/es-ES/error.json +1 -0
  11. package/locales/es-ES/models.json +4 -10
  12. package/locales/fa-IR/error.json +1 -0
  13. package/locales/fa-IR/models.json +3 -9
  14. package/locales/fr-FR/error.json +1 -0
  15. package/locales/fr-FR/models.json +4 -10
  16. package/locales/it-IT/error.json +1 -0
  17. package/locales/it-IT/models.json +3 -9
  18. package/locales/ja-JP/error.json +1 -0
  19. package/locales/ja-JP/models.json +3 -9
  20. package/locales/ko-KR/error.json +1 -0
  21. package/locales/ko-KR/models.json +3 -9
  22. package/locales/nl-NL/error.json +1 -0
  23. package/locales/nl-NL/models.json +3 -9
  24. package/locales/pl-PL/error.json +1 -0
  25. package/locales/pl-PL/models.json +4 -10
  26. package/locales/pt-BR/error.json +1 -0
  27. package/locales/pt-BR/models.json +3 -9
  28. package/locales/ru-RU/error.json +1 -0
  29. package/locales/ru-RU/models.json +3 -9
  30. package/locales/tr-TR/error.json +1 -0
  31. package/locales/tr-TR/models.json +3 -9
  32. package/locales/vi-VN/error.json +1 -0
  33. package/locales/vi-VN/models.json +3 -9
  34. package/locales/zh-CN/error.json +2 -1
  35. package/locales/zh-CN/models.json +3 -9
  36. package/locales/zh-TW/error.json +1 -0
  37. package/locales/zh-TW/models.json +3 -9
  38. package/package.json +3 -3
  39. package/src/{features → app/(main)/chat/(workspace)/@conversation/features}/ChatInput/Desktop/TextArea.test.tsx +13 -13
  40. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/TextArea.tsx +29 -0
  41. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +46 -0
  42. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/index.tsx +2 -1
  43. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx +13 -11
  44. package/src/app/(main)/settings/llm/components/Checker.tsx +9 -2
  45. package/src/const/message.ts +4 -0
  46. package/src/features/ChatInput/Desktop/Footer/ShortcutHint.tsx +61 -0
  47. package/src/features/ChatInput/Desktop/Footer/index.tsx +11 -46
  48. package/src/features/ChatInput/Desktop/{TextArea.tsx → InputArea/index.tsx} +11 -20
  49. package/src/features/ChatInput/Desktop/index.tsx +23 -32
  50. package/src/features/Conversation/Messages/index.ts +11 -11
  51. package/src/features/Conversation/components/ChatItem/index.tsx +83 -44
  52. package/src/features/Conversation/components/VirtualizedList/index.tsx +90 -92
  53. package/src/features/Conversation/index.ts +2 -0
  54. package/src/libs/agent-runtime/error.ts +2 -0
  55. package/src/locales/default/error.ts +1 -0
  56. package/src/types/topic/index.ts +1 -0
  57. /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>(({ mobile, dataSource }) => {
26
- const virtuosoRef = useRef<VirtuosoHandle>(null);
27
- const [atBottom, setAtBottom] = useState(true);
28
- const [isScrolling, setIsScrolling] = useState(false);
29
-
30
- const [id] = useChatStore((s) => [chatSelectors.currentChatKey(s)]);
31
- const [isFirstLoading, isCurrentChatLoaded] = useChatStore((s) => [
32
- chatSelectors.currentChatLoadingState(s),
33
- chatSelectors.isCurrentChatLoaded(s),
34
- ]);
35
-
36
- useEffect(() => {
37
- if (virtuosoRef.current) {
38
- virtuosoRef.current.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
39
- }
40
- }, [id]);
41
-
42
- const prevDataLengthRef = useRef(dataSource.length);
43
-
44
- const getFollowOutput = useCallback(() => {
45
- const newFollowOutput = dataSource.length > prevDataLengthRef.current ? 'auto' : false;
46
- prevDataLengthRef.current = dataSource.length;
47
- return newFollowOutput;
48
- }, [dataSource.length]);
49
-
50
- const theme = useTheme();
51
- // overscan should be 3 times the height of the window
52
- const overscan = typeof window !== 'undefined' ? window.innerHeight * 3 : 0;
53
-
54
- const itemContent = useCallback(
55
- (index: number, id: string) => {
56
- if (id === WELCOME_GUIDE_CHAT_ID) return <InboxWelcome />;
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
- return (
83
- <Flexbox height={'100%'}>
84
- <Virtuoso
85
- atBottomStateChange={setAtBottom}
86
- atBottomThreshold={50 * (mobile ? 2 : 1)}
87
- computeItemKey={(_, item) => item}
88
- data={dataSource}
89
- followOutput={getFollowOutput}
90
- increaseViewportBy={overscan}
91
- initialTopMostItemIndex={dataSource?.length - 1}
92
- isScrolling={setIsScrolling}
93
- itemContent={itemContent}
94
- overscan={overscan}
95
- ref={virtuosoRef}
96
- />
97
- <AutoScroll
98
- atBottom={atBottom}
99
- isScrolling={isScrolling}
100
- onScrollToBottom={(type) => {
101
- const virtuoso = virtuosoRef.current;
102
- switch (type) {
103
- case 'auto': {
104
- virtuoso?.scrollToIndex({ align: 'end', behavior: 'auto', index: 'LAST' });
105
- break;
106
- }
107
- case 'click': {
108
- virtuoso?.scrollToIndex({ align: 'end', behavior: 'smooth', index: 'LAST' });
109
- break;
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
- </Flexbox>
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';
@@ -17,6 +17,8 @@ export const AgentRuntimeErrorType = {
17
17
 
18
18
  InvalidGithubToken: 'InvalidGithubToken',
19
19
 
20
+ ConnectionCheckFailed: 'ConnectionCheckFailed',
21
+
20
22
  /**
21
23
  * @deprecated
22
24
  */
@@ -124,6 +124,7 @@ export default {
124
124
 
125
125
  // Github Token
126
126
  InvalidGithubToken: 'Github PAT 不正确或为空,请检查 Github PAT 后重试',
127
+ ConnectionCheckFailed: '请求返回为空,请检查 API 代理地址末尾是否未包含 `/v1`',
127
128
 
128
129
  /* eslint-enable */
129
130
  },
@@ -0,0 +1 @@
1
+ export * from './topic';
File without changes