@lobehub/chat 0.42.3 → 0.44.0

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 (74) hide show
  1. package/.github/workflows/release.yml +1 -1
  2. package/CHANGELOG.md +74 -0
  3. package/package.json +5 -2
  4. package/src/const/meta.ts +3 -0
  5. package/src/const/session.ts +1 -0
  6. package/src/helpers/export.ts +15 -9
  7. package/src/locales/default/common.ts +8 -1
  8. package/src/pages/chat/SessionList/Inbox.tsx +23 -0
  9. package/src/pages/chat/SessionList/List/SessionItem.tsx +15 -4
  10. package/src/pages/chat/SessionList/List/index.tsx +3 -2
  11. package/src/pages/chat/SessionList/index.tsx +13 -1
  12. package/src/pages/chat/[id]/index.page.tsx +7 -9
  13. package/src/pages/chat/[id]/layout.tsx +7 -23
  14. package/src/pages/chat/[id]/setting/index.page.tsx +3 -3
  15. package/src/pages/chat/features/Conversation/ChatList/SkeletonList.tsx +43 -0
  16. package/src/pages/chat/{[id] → features}/Conversation/ChatList/index.tsx +35 -5
  17. package/src/pages/chat/{[id] → features}/Conversation/Input/index.tsx +1 -1
  18. package/src/pages/chat/{[id] → features}/Header/index.tsx +32 -34
  19. package/src/pages/chat/features/Sidebar/Inner.tsx +42 -0
  20. package/src/pages/chat/{[id]/Sidebar/Inner.tsx → features/Sidebar/SystemRole.tsx} +7 -37
  21. package/src/pages/chat/{[id] → features}/Sidebar/index.tsx +8 -4
  22. package/src/pages/chat/index.page.tsx +39 -1
  23. package/src/pages/chat/layout.tsx +27 -0
  24. package/src/pages/settings/Settings/Common.tsx +11 -2
  25. package/src/pages/welcome/Footer/index.tsx +1 -0
  26. package/src/services/chatModel.ts +1 -1
  27. package/src/store/global/hooks/useOnFinishHydrationGlobal.ts +18 -0
  28. package/src/store/global/hooks/useSwitchSideBarOnInit.ts +4 -8
  29. package/src/store/global/slices/settings.ts +2 -2
  30. package/src/store/session/hooks/index.ts +2 -0
  31. package/src/store/session/hooks/useOnFinishHydrationSession.ts +18 -0
  32. package/src/store/session/hooks/useSessionHydrated.ts +1 -1
  33. package/src/store/session/index.ts +1 -3
  34. package/src/store/session/initialState.ts +6 -3
  35. package/src/store/session/selectors.ts +3 -3
  36. package/src/store/session/slices/agentConfig/action.ts +2 -1
  37. package/src/store/session/slices/agentConfig/selectors.ts +11 -11
  38. package/src/store/session/slices/chat/actions/message.ts +13 -20
  39. package/src/store/session/slices/chat/actions/topic.ts +3 -1
  40. package/src/store/session/slices/chat/selectors/chat.ts +1 -1
  41. package/src/store/session/slices/chat/selectors/token.ts +1 -1
  42. package/src/store/session/slices/chat/selectors/topic.ts +4 -2
  43. package/src/store/session/slices/session/action.ts +29 -15
  44. package/src/store/session/slices/session/initialState.ts +18 -4
  45. package/src/store/session/slices/session/selectors/export.ts +13 -8
  46. package/src/store/session/slices/session/selectors/list.test.ts +303 -0
  47. package/src/store/session/slices/session/selectors/list.ts +8 -3
  48. package/src/store/session/store.ts +5 -5
  49. package/src/types/exportConfig.ts +93 -31
  50. package/src/utils/config.ts +9 -0
  51. package/src/pages/chat/SessionList/List/style.ts +0 -36
  52. package/src/store/session/slices/chat/index.ts +0 -3
  53. package/src/store/session/slices/session/index.ts +0 -3
  54. package/src/pages/chat/{[id] → features}/Conversation/ChatList/Error/ApiKeyForm.tsx +0 -0
  55. package/src/pages/chat/{[id] → features}/Conversation/ChatList/Error/ErrorActionContainer.tsx +0 -0
  56. package/src/pages/chat/{[id] → features}/Conversation/ChatList/Error/InvalidAccess.tsx +1 -1
  57. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Error/OpenAiBizError.tsx +0 -0
  58. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Error/style.tsx +0 -0
  59. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/MessageExtra.tsx +0 -0
  60. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/OTPInput.tsx +0 -0
  61. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Plugins/FunctionCall.tsx +0 -0
  62. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Plugins/PluginMessage.tsx +0 -0
  63. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Plugins/PluginResultRender.tsx +0 -0
  64. /package/src/pages/chat/{[id] → features}/Conversation/ChatList/Plugins/style.ts +0 -0
  65. /package/src/pages/chat/{[id] → features}/Conversation/Input/Action.tsx +0 -0
  66. /package/src/pages/chat/{[id] → features}/Conversation/Input/ActionRight.tsx +0 -0
  67. /package/src/pages/chat/{[id] → features}/Conversation/Input/Token.tsx +0 -0
  68. /package/src/pages/chat/{[id] → features}/Conversation/index.tsx +0 -0
  69. /package/src/pages/chat/{[id] → features}/Header/PluginTag.tsx +0 -0
  70. /package/src/pages/chat/{[id] → features}/Sidebar/Header.tsx +0 -0
  71. /package/src/pages/chat/{[id] → features}/Sidebar/Topic/DefaultContent.tsx +0 -0
  72. /package/src/pages/chat/{[id] → features}/Sidebar/Topic/TopicContent.tsx +0 -0
  73. /package/src/pages/chat/{[id] → features}/Sidebar/Topic/TopicItem.tsx +0 -0
  74. /package/src/pages/chat/{[id] → features}/Sidebar/Topic/index.tsx +0 -0
@@ -1,61 +1,123 @@
1
- import { LobeSessions } from '@/types/session';
1
+ import { LobeAgentSession, LobeSessions } from '@/types/session';
2
2
  import { GlobalSettings } from '@/types/settings';
3
3
 
4
- // 存在4种导出方式
5
- export type ExportType = 'agents' | 'sessions' | 'settings' | 'all';
4
+ /**
5
+ * 导出方式
6
+ * @enum ['agents', 'sessions', 'singleSession', 'settings', 'all']
7
+ * @enumNames ['agents', 'sessions', 'singleSession', 'settings', 'all']
8
+ */
9
+ export type ExportType = 'agents' | 'sessions' | 'singleSession' | 'settings' | 'all';
6
10
 
7
- // 4种方式对应的 state
8
- export interface ConfigStateAll {
11
+ /**
12
+ * 配置模型映射
13
+ */
14
+ export interface ConfigModelMap {
15
+ agents: {
16
+ file: ConfigFileAgents;
17
+ state: ConfigStateAgents;
18
+ };
19
+ all: {
20
+ file: ConfigFileAll;
21
+ state: ConfigStateAll;
22
+ };
23
+ sessions: {
24
+ file: ConfigFileSessions;
25
+ state: ConfigStateSessions;
26
+ };
27
+ settings: {
28
+ file: ConfigFileSettings;
29
+ state: ConfigStateSettings;
30
+ };
31
+ singleSession: {
32
+ file: ConfigFileSingleSession;
33
+ state: ConfigStateSingleSession;
34
+ };
35
+ }
36
+
37
+ // ============= 配置数据结构 ============= //
38
+
39
+ /**
40
+ * 配置状态:会话
41
+ */
42
+ export interface ConfigStateSessions {
43
+ inbox: LobeAgentSession;
9
44
  sessions: LobeSessions;
10
- settings: GlobalSettings;
11
45
  }
12
- export interface ConfigStateSettings {
13
- settings: GlobalSettings;
46
+
47
+ /**
48
+ * 配置状态:单个会话
49
+ */
50
+ export interface ConfigStateSingleSession {
51
+ sessions: LobeSessions;
14
52
  }
15
- export interface ConfigStateSessions {
53
+
54
+ /**
55
+ * 配置状态:角色
56
+ */
57
+ export interface ConfigStateAgents {
16
58
  sessions: LobeSessions;
17
59
  }
18
60
 
19
- // 4种方式对应的 file
61
+ /**
62
+ * 配置状态:设置
63
+ */
64
+ export interface ConfigStateSettings {
65
+ settings: GlobalSettings;
66
+ }
67
+
68
+ /**
69
+ * 配置状态:全部
70
+ */
71
+ export interface ConfigStateAll extends ConfigStateSessions, ConfigStateSettings {}
72
+
73
+ // ============= 配置文件类型 ============= //
74
+
75
+ /**
76
+ * 配置文件:设置
77
+ */
20
78
  export interface ConfigFileSettings {
21
79
  exportType: 'settings';
22
80
  state: ConfigStateSettings;
23
81
  version: number;
24
82
  }
83
+
84
+ /**
85
+ * 配置文件:会话
86
+ */
25
87
  export interface ConfigFileSessions {
26
88
  exportType: 'sessions';
27
89
  state: ConfigStateSessions;
28
90
  version: number;
29
91
  }
92
+
93
+ /**
94
+ * 配置文件:单个会话
95
+ */
96
+ export interface ConfigFileSingleSession {
97
+ exportType: 'sessions';
98
+ state: ConfigStateSingleSession;
99
+ version: number;
100
+ }
101
+
102
+ /**
103
+ * 配置文件:角色
104
+ */
30
105
  export interface ConfigFileAgents {
31
106
  exportType: 'agents';
32
- state: ConfigStateSessions;
107
+ state: ConfigStateAgents;
33
108
  version: number;
34
109
  }
110
+
111
+ /**
112
+ * 配置文件:全部
113
+ */
35
114
  export interface ConfigFileAll {
36
115
  exportType: 'all';
37
116
  state: ConfigStateAll;
38
117
  version: number;
39
118
  }
40
119
 
120
+ /**
121
+ * 配置文件
122
+ */
41
123
  export type ConfigFile = ConfigFileSettings | ConfigFileSessions | ConfigFileAll | ConfigFileAgents;
42
-
43
- // 用于 map 收集类型的 map
44
- export interface ConfigModelMap {
45
- agents: {
46
- file: ConfigFileAgents;
47
- state: ConfigStateSessions;
48
- };
49
- all: {
50
- file: ConfigFileAll;
51
- state: ConfigStateAll;
52
- };
53
- sessions: {
54
- file: ConfigFileSessions;
55
- state: ConfigStateSessions;
56
- };
57
- settings: {
58
- file: ConfigFileSettings;
59
- state: ConfigStateSettings;
60
- };
61
- }
@@ -7,6 +7,7 @@ import {
7
7
  ConfigFileAll,
8
8
  ConfigFileSessions,
9
9
  ConfigFileSettings,
10
+ ConfigFileSingleSession,
10
11
  ConfigModelMap,
11
12
  ExportType,
12
13
  } from '@/types/exportConfig';
@@ -90,6 +91,14 @@ export const createConfigFile = <T extends ExportType>(
90
91
  } as ConfigFileSettings;
91
92
  }
92
93
 
94
+ case 'singleSession': {
95
+ return {
96
+ exportType: 'sessions',
97
+ state,
98
+ version: Migration.targetVersion,
99
+ } as ConfigFileSingleSession;
100
+ }
101
+
93
102
  case 'all': {
94
103
  return {
95
104
  exportType: 'all',
@@ -1,36 +0,0 @@
1
- import { createStyles } from 'antd-style';
2
- import { rgba } from 'polished';
3
-
4
- export const useStyles = createStyles(({ css, token }) => {
5
- return {
6
- button: css`
7
- position: sticky;
8
- z-index: 30;
9
- bottom: 0;
10
-
11
- display: flex;
12
- gap: 8px;
13
- align-items: center;
14
- justify-content: center;
15
-
16
- margin-top: 8px;
17
- padding: 12px;
18
-
19
- background: ${rgba(token.colorBgLayout, 0.5)};
20
- backdrop-filter: blur(8px);
21
- `,
22
- container: css`
23
- position: relative;
24
- `,
25
-
26
- modalRoot: css`
27
- z-index: 2000;
28
- `,
29
- pin: css`
30
- background-color: ${token.colorFillTertiary};
31
- `,
32
- time: css`
33
- align-self: flex-start;
34
- `,
35
- };
36
- });
@@ -1,3 +0,0 @@
1
- export * from './actions';
2
- export * from './initialState';
3
- export * from './selectors';
@@ -1,3 +0,0 @@
1
- export * from './action';
2
- export * from './initialState';
3
- export * from './selectors';
@@ -24,8 +24,8 @@ const InvalidAccess = memo<{ id: string }>(({ id }) => {
24
24
  block
25
25
  onChange={(value) => setMode(value as string)}
26
26
  options={[
27
- { icon: <Icon icon={SquareAsterisk} />, label: '密码', value: 'password' },
28
27
  { icon: <Icon icon={KeySquare} />, label: 'OpenAI API Key', value: 'api' },
28
+ { icon: <Icon icon={SquareAsterisk} />, label: '密码', value: 'password' },
29
29
  ]}
30
30
  style={{ width: '100%' }}
31
31
  value={mode}