@lobehub/chat 1.31.5 → 1.31.6

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 (54) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/locales/ar/models.json +39 -7
  3. package/locales/ar/providers.json +4 -0
  4. package/locales/bg-BG/models.json +38 -6
  5. package/locales/bg-BG/providers.json +4 -0
  6. package/locales/de-DE/models.json +39 -7
  7. package/locales/de-DE/providers.json +4 -0
  8. package/locales/en-US/models.json +38 -6
  9. package/locales/en-US/providers.json +4 -0
  10. package/locales/es-ES/models.json +38 -6
  11. package/locales/es-ES/providers.json +4 -0
  12. package/locales/fa-IR/modelProvider.json +12 -0
  13. package/locales/fa-IR/models.json +39 -7
  14. package/locales/fa-IR/providers.json +4 -0
  15. package/locales/fr-FR/models.json +38 -6
  16. package/locales/fr-FR/providers.json +4 -0
  17. package/locales/it-IT/models.json +38 -6
  18. package/locales/it-IT/providers.json +4 -0
  19. package/locales/ja-JP/models.json +39 -7
  20. package/locales/ja-JP/providers.json +4 -0
  21. package/locales/ko-KR/models.json +38 -6
  22. package/locales/ko-KR/providers.json +4 -0
  23. package/locales/nl-NL/models.json +38 -6
  24. package/locales/nl-NL/providers.json +4 -0
  25. package/locales/pl-PL/models.json +37 -5
  26. package/locales/pl-PL/providers.json +4 -0
  27. package/locales/pt-BR/models.json +38 -6
  28. package/locales/pt-BR/providers.json +4 -0
  29. package/locales/ru-RU/models.json +38 -6
  30. package/locales/ru-RU/providers.json +4 -0
  31. package/locales/tr-TR/models.json +39 -7
  32. package/locales/tr-TR/providers.json +4 -0
  33. package/locales/vi-VN/models.json +37 -5
  34. package/locales/vi-VN/providers.json +4 -0
  35. package/locales/zh-CN/modelProvider.json +1 -1
  36. package/locales/zh-CN/models.json +37 -5
  37. package/locales/zh-CN/providers.json +4 -0
  38. package/locales/zh-TW/models.json +38 -6
  39. package/locales/zh-TW/providers.json +4 -0
  40. package/package.json +1 -1
  41. package/src/app/(main)/chat/(workspace)/@conversation/default.tsx +2 -2
  42. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/Header/index.tsx +6 -1
  43. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Desktop/index.tsx +63 -43
  44. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatInput/Mobile/index.tsx +19 -1
  45. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/Content.tsx +35 -0
  46. package/src/app/(main)/chat/(workspace)/@conversation/features/ChatList/index.tsx +28 -0
  47. package/src/config/modelProviders/cloudflare.ts +1 -0
  48. package/src/features/ChatInput/ActionBar/config.ts +1 -20
  49. package/src/features/ChatInput/ActionBar/index.tsx +25 -28
  50. package/src/features/ChatInput/types.ts +1 -0
  51. package/src/features/Conversation/components/ChatItem/index.tsx +1 -1
  52. package/src/features/Conversation/components/VirtualizedList/index.tsx +13 -28
  53. package/src/features/Conversation/index.ts +2 -0
  54. package/src/features/Conversation/index.tsx +0 -30
@@ -166,7 +166,7 @@ const Item = memo<ChatListItemProps>(({ index, id }) => {
166
166
  return (
167
167
  item && (
168
168
  <>
169
- {enableHistoryDivider && <History />}
169
+ {enableHistoryDivider && <History />}
170
170
  <ChatItem
171
171
  actions={
172
172
  <ActionsBar
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { Icon } from '@lobehub/ui';
4
4
  import { useTheme } from 'antd-style';
5
- import isEqual from 'fast-deep-equal';
6
5
  import { Loader2Icon } from 'lucide-react';
7
6
  import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
8
7
  import { Center, Flexbox } from 'react-layout-kit';
@@ -12,7 +11,6 @@ import { WELCOME_GUIDE_CHAT_ID } from '@/const/session';
12
11
  import { isServerMode } from '@/const/version';
13
12
  import { useChatStore } from '@/store/chat';
14
13
  import { chatSelectors } from '@/store/chat/selectors';
15
- import { useSessionStore } from '@/store/session';
16
14
 
17
15
  import AutoScroll from '../AutoScroll';
18
16
  import Item from '../ChatItem';
@@ -20,33 +18,20 @@ import InboxWelcome from '../InboxWelcome';
20
18
  import SkeletonList from '../SkeletonList';
21
19
 
22
20
  interface VirtualizedListProps {
21
+ dataSource: string[];
23
22
  mobile?: boolean;
24
23
  }
25
- const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
24
+
25
+ const VirtualizedList = memo<VirtualizedListProps>(({ mobile, dataSource }) => {
26
26
  const virtuosoRef = useRef<VirtuosoHandle>(null);
27
27
  const [atBottom, setAtBottom] = useState(true);
28
28
  const [isScrolling, setIsScrolling] = useState(false);
29
29
 
30
30
  const [id] = useChatStore((s) => [chatSelectors.currentChatKey(s)]);
31
-
32
- const [activeTopicId, useFetchMessages, isFirstLoading, isCurrentChatLoaded] = useChatStore(
33
- (s) => [
34
- s.activeTopicId,
35
- s.useFetchMessages,
36
- chatSelectors.currentChatLoadingState(s),
37
- chatSelectors.isCurrentChatLoaded(s),
38
- ],
39
- );
40
-
41
- const [sessionId] = useSessionStore((s) => [s.activeId]);
42
- useFetchMessages(sessionId, activeTopicId);
43
-
44
- const data = useChatStore((s) => {
45
- const showInboxWelcome = chatSelectors.showInboxWelcome(s);
46
- return showInboxWelcome
47
- ? [WELCOME_GUIDE_CHAT_ID]
48
- : chatSelectors.currentChatIDsWithGuideMessage(s);
49
- }, isEqual);
31
+ const [isFirstLoading, isCurrentChatLoaded] = useChatStore((s) => [
32
+ chatSelectors.currentChatLoadingState(s),
33
+ chatSelectors.isCurrentChatLoaded(s),
34
+ ]);
50
35
 
51
36
  useEffect(() => {
52
37
  if (virtuosoRef.current) {
@@ -54,13 +39,13 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
54
39
  }
55
40
  }, [id]);
56
41
 
57
- const prevDataLengthRef = useRef(data.length);
42
+ const prevDataLengthRef = useRef(dataSource.length);
58
43
 
59
44
  const getFollowOutput = useCallback(() => {
60
- const newFollowOutput = data.length > prevDataLengthRef.current ? 'auto' : false;
61
- prevDataLengthRef.current = data.length;
45
+ const newFollowOutput = dataSource.length > prevDataLengthRef.current ? 'auto' : false;
46
+ prevDataLengthRef.current = dataSource.length;
62
47
  return newFollowOutput;
63
- }, [data.length]);
48
+ }, [dataSource.length]);
64
49
 
65
50
  const theme = useTheme();
66
51
  // overscan should be 3 times the height of the window
@@ -100,10 +85,10 @@ const VirtualizedList = memo<VirtualizedListProps>(({ mobile }) => {
100
85
  atBottomStateChange={setAtBottom}
101
86
  atBottomThreshold={50 * (mobile ? 2 : 1)}
102
87
  computeItemKey={(_, item) => item}
103
- data={data}
88
+ data={dataSource}
104
89
  followOutput={getFollowOutput}
105
90
  increaseViewportBy={overscan}
106
- initialTopMostItemIndex={data?.length - 1}
91
+ initialTopMostItemIndex={dataSource?.length - 1}
107
92
  isScrolling={setIsScrolling}
108
93
  itemContent={itemContent}
109
94
  overscan={overscan}
@@ -0,0 +1,2 @@
1
+ export { default as SkeletonList } from './components/SkeletonList';
2
+ export { default as VirtualizedList } from './components/VirtualizedList';
@@ -1,30 +0,0 @@
1
- import { Suspense, lazy } from 'react';
2
- import { Flexbox } from 'react-layout-kit';
3
-
4
- import SkeletonList from './components/SkeletonList';
5
-
6
- const ChatList = lazy(() => import('./components/VirtualizedList'));
7
-
8
- interface ConversationProps {
9
- mobile?: boolean;
10
- }
11
-
12
- const Conversation = ({ mobile }: ConversationProps) => {
13
- return (
14
- <Flexbox
15
- flex={1}
16
- style={{
17
- overflowX: 'hidden',
18
- overflowY: 'auto',
19
- position: 'relative',
20
- }}
21
- width={'100%'}
22
- >
23
- <Suspense fallback={<SkeletonList mobile={mobile} />}>
24
- <ChatList mobile={mobile} />
25
- </Suspense>
26
- </Flexbox>
27
- );
28
- };
29
-
30
- export default Conversation;