@lobehub/lobehub 2.0.0-next.13 → 2.0.0-next.15

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 (219) hide show
  1. package/.github/workflows/desktop-pr-build.yml +6 -6
  2. package/.github/workflows/release-desktop-beta.yml +4 -4
  3. package/.github/workflows/release.yml +1 -2
  4. package/.github/workflows/test.yml +4 -5
  5. package/.nvmrc +1 -1
  6. package/CHANGELOG.md +42 -0
  7. package/apps/desktop/tsconfig.json +0 -1
  8. package/changelog/v1.json +14 -0
  9. package/e2e/tsconfig.json +0 -1
  10. package/package.json +58 -58
  11. package/packages/const/src/version.ts +3 -3
  12. package/packages/database/src/repositories/dataImporter/deprecated/__tests__/index.test.ts +2 -1
  13. package/packages/database/src/repositories/dataImporter/deprecated/index.ts +7 -1
  14. package/packages/web-crawler/tsconfig.json +0 -1
  15. package/src/app/[variants]/(main)/(mobile)/me/(home)/__tests__/useCategory.test.tsx +9 -0
  16. package/src/app/[variants]/(main)/(mobile)/me/(home)/layout.tsx +0 -2
  17. package/src/app/[variants]/(main)/chat/@session/features/SessionListContent/List/Item/Actions.tsx +3 -28
  18. package/src/app/[variants]/(main)/chat/_layout/Desktop/index.tsx +0 -2
  19. package/src/app/[variants]/(main)/chat/_layout/Mobile.tsx +1 -5
  20. package/src/app/[variants]/(main)/chat/settings/features/HeaderContent.tsx +2 -62
  21. package/src/app/[variants]/(main)/image/page.tsx +0 -2
  22. package/src/app/[variants]/(main)/profile/_layout/Desktop/index.tsx +23 -24
  23. package/src/app/[variants]/(main)/profile/_layout/Mobile/index.tsx +5 -9
  24. package/src/app/[variants]/(main)/settings/_layout/Desktop/index.tsx +0 -2
  25. package/src/app/[variants]/(main)/settings/_layout/Mobile/index.tsx +0 -2
  26. package/src/app/[variants]/(main)/settings/provider/(list)/ProviderGrid/Card.tsx +1 -1
  27. package/src/app/[variants]/loading/index.tsx +1 -10
  28. package/src/components/Link.tsx +12 -0
  29. package/src/envs/app.ts +5 -8
  30. package/src/features/DataImporter/index.tsx +15 -60
  31. package/src/features/DevPanel/PostgresViewer/usePgTable.ts +3 -2
  32. package/src/hooks/useInterceptingRoutes.test.ts +21 -3
  33. package/src/libs/trpc/client/index.ts +0 -1
  34. package/src/libs/trpc/client/lambda.ts +8 -5
  35. package/src/server/routers/desktop/mcp.ts +1 -3
  36. package/src/server/routers/lambda/config/index.test.ts +2 -2
  37. package/src/server/routers/tools/mcp.ts +2 -3
  38. package/src/server/routers/tools/search.test.ts +1 -7
  39. package/src/server/routers/tools/search.ts +1 -4
  40. package/src/services/__tests__/tool.test.ts +0 -3
  41. package/src/services/aiModel/index.test.ts +0 -3
  42. package/src/services/aiModel/index.ts +1 -7
  43. package/src/services/aiProvider/index.test.ts +0 -3
  44. package/src/services/aiProvider/index.ts +1 -7
  45. package/src/services/chatGroup/index.ts +1 -10
  46. package/src/services/config.ts +1 -65
  47. package/src/services/export/index.ts +1 -4
  48. package/src/services/file/index.ts +1 -11
  49. package/src/services/import/index.ts +1 -7
  50. package/src/services/message/index.ts +1 -11
  51. package/src/services/plugin/index.ts +1 -11
  52. package/src/services/session/index.ts +1 -11
  53. package/src/services/tableViewer/client.ts +12 -15
  54. package/src/services/thread/index.ts +1 -7
  55. package/src/services/topic/index.ts +1 -11
  56. package/src/services/user/index.ts +1 -13
  57. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChat.test.ts +0 -241
  58. package/src/store/chat/slices/aiChat/actions/__tests__/generateAIChatV2.test.ts +26 -1
  59. package/src/store/chat/slices/aiChat/actions/__tests__/helpers.ts +3 -1
  60. package/src/store/chat/slices/aiChat/actions/generateAIChat.ts +1 -138
  61. package/src/store/user/slices/common/action.test.ts +1 -4
  62. package/tsconfig.json +0 -1
  63. package/src/app/(backend)/trpc/edge/[trpc]/route.ts +0 -26
  64. package/src/app/[variants]/(main)/(mobile)/me/data/features/Category.tsx +0 -48
  65. package/src/app/[variants]/(main)/(mobile)/me/data/features/Header.tsx +0 -33
  66. package/src/app/[variants]/(main)/(mobile)/me/data/layout.tsx +0 -13
  67. package/src/app/[variants]/(main)/(mobile)/me/data/loading.tsx +0 -5
  68. package/src/app/[variants]/(main)/(mobile)/me/data/page.tsx +0 -29
  69. package/src/app/[variants]/(main)/chat/features/Migration/DBReader.ts +0 -290
  70. package/src/app/[variants]/(main)/chat/features/Migration/ExportConfigButton.tsx +0 -35
  71. package/src/app/[variants]/(main)/chat/features/Migration/Failed.tsx +0 -120
  72. package/src/app/[variants]/(main)/chat/features/Migration/Modal.tsx +0 -81
  73. package/src/app/[variants]/(main)/chat/features/Migration/Start.tsx +0 -108
  74. package/src/app/[variants]/(main)/chat/features/Migration/UpgradeButton.tsx +0 -71
  75. package/src/app/[variants]/(main)/chat/features/Migration/const.ts +0 -15
  76. package/src/app/[variants]/(main)/chat/features/Migration/index.tsx +0 -50
  77. package/src/app/[variants]/loading/Client/Content.tsx +0 -48
  78. package/src/app/[variants]/loading/Client/Error.tsx +0 -27
  79. package/src/app/[variants]/loading/Client/Redirect.tsx +0 -47
  80. package/src/app/[variants]/loading/Client/index.tsx +0 -22
  81. package/src/components/InnerLink.tsx +0 -20
  82. package/src/database/_deprecated/core/__tests__/db-upgrade.test.ts +0 -42
  83. package/src/database/_deprecated/core/__tests__/db.test.ts +0 -79
  84. package/src/database/_deprecated/core/__tests__/model.test.ts +0 -55
  85. package/src/database/_deprecated/core/db.ts +0 -246
  86. package/src/database/_deprecated/core/index.ts +0 -2
  87. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/input.json +0 -55
  88. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/fixtures/output.json +0 -60
  89. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.test.ts +0 -14
  90. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/index.ts +0 -22
  91. package/src/database/_deprecated/core/migrations/migrateSettingsToUser/type.ts +0 -105
  92. package/src/database/_deprecated/core/model.ts +0 -218
  93. package/src/database/_deprecated/core/schemas.ts +0 -88
  94. package/src/database/_deprecated/core/types/db.ts +0 -15
  95. package/src/database/_deprecated/models/__DEBUG.ts +0 -124
  96. package/src/database/_deprecated/models/__tests__/file.test.ts +0 -83
  97. package/src/database/_deprecated/models/__tests__/message.test.ts +0 -426
  98. package/src/database/_deprecated/models/__tests__/plugin.test.ts +0 -81
  99. package/src/database/_deprecated/models/__tests__/session.test.ts +0 -253
  100. package/src/database/_deprecated/models/__tests__/sessionGroup.test.ts +0 -220
  101. package/src/database/_deprecated/models/__tests__/topic.test.ts +0 -523
  102. package/src/database/_deprecated/models/__tests__/user.test.ts +0 -82
  103. package/src/database/_deprecated/models/file.ts +0 -51
  104. package/src/database/_deprecated/models/message.ts +0 -277
  105. package/src/database/_deprecated/models/plugin.ts +0 -62
  106. package/src/database/_deprecated/models/session.ts +0 -271
  107. package/src/database/_deprecated/models/sessionGroup.ts +0 -93
  108. package/src/database/_deprecated/models/topic.ts +0 -250
  109. package/src/database/_deprecated/models/user.ts +0 -69
  110. package/src/database/_deprecated/schemas/files.ts +0 -39
  111. package/src/database/_deprecated/schemas/message.ts +0 -50
  112. package/src/database/_deprecated/schemas/plugin.ts +0 -12
  113. package/src/database/_deprecated/schemas/session.ts +0 -54
  114. package/src/database/_deprecated/schemas/sessionGroup.ts +0 -8
  115. package/src/database/_deprecated/schemas/topic.ts +0 -12
  116. package/src/database/_deprecated/schemas/user.ts +0 -40
  117. package/src/features/DataImporter/_deprecated.ts +0 -43
  118. package/src/features/InitClientDB/EnableModal.tsx +0 -118
  119. package/src/features/InitClientDB/ErrorResult.tsx +0 -143
  120. package/src/features/InitClientDB/InitIndicator.tsx +0 -124
  121. package/src/features/InitClientDB/PGliteIcon.tsx +0 -28
  122. package/src/features/InitClientDB/features/DatabaseRepair/Backup.tsx +0 -75
  123. package/src/features/InitClientDB/features/DatabaseRepair/Diagnosis.tsx +0 -98
  124. package/src/features/InitClientDB/features/DatabaseRepair/Repair.tsx +0 -218
  125. package/src/features/InitClientDB/features/DatabaseRepair/index.tsx +0 -91
  126. package/src/features/InitClientDB/index.tsx +0 -37
  127. package/src/libs/trpc/client/edge.ts +0 -26
  128. package/src/libs/trpc/edge/context.ts +0 -71
  129. package/src/libs/trpc/edge/index.ts +0 -45
  130. package/src/libs/trpc/edge/init.ts +0 -26
  131. package/src/libs/trpc/edge/middleware/jwtPayload.test.ts +0 -75
  132. package/src/libs/trpc/edge/middleware/jwtPayload.ts +0 -14
  133. package/src/migrations/FromV0ToV1.ts +0 -10
  134. package/src/migrations/FromV1ToV2/fixtures/input-v1-session.json +0 -191
  135. package/src/migrations/FromV1ToV2/fixtures/output-v2.json +0 -202
  136. package/src/migrations/FromV1ToV2/index.ts +0 -82
  137. package/src/migrations/FromV1ToV2/migrations.test.ts +0 -224
  138. package/src/migrations/FromV1ToV2/types/v1.ts +0 -78
  139. package/src/migrations/FromV1ToV2/types/v2.ts +0 -52
  140. package/src/migrations/FromV2ToV3/fixtures/input-v2-session.json +0 -72
  141. package/src/migrations/FromV2ToV3/fixtures/output-v3-from-v1.json +0 -203
  142. package/src/migrations/FromV2ToV3/fixtures/output-v3.json +0 -74
  143. package/src/migrations/FromV2ToV3/index.ts +0 -30
  144. package/src/migrations/FromV2ToV3/migrations.test.ts +0 -42
  145. package/src/migrations/FromV2ToV3/types/v3.ts +0 -27
  146. package/src/migrations/FromV3ToV4/fixtures/azure-input-v3.json +0 -79
  147. package/src/migrations/FromV3ToV4/fixtures/azure-output-v4.json +0 -75
  148. package/src/migrations/FromV3ToV4/fixtures/ollama-input-v3.json +0 -85
  149. package/src/migrations/FromV3ToV4/fixtures/ollama-output-v4.json +0 -86
  150. package/src/migrations/FromV3ToV4/fixtures/openai-input-v3.json +0 -77
  151. package/src/migrations/FromV3ToV4/fixtures/openai-output-v4.json +0 -77
  152. package/src/migrations/FromV3ToV4/fixtures/openrouter-input-v3.json +0 -82
  153. package/src/migrations/FromV3ToV4/fixtures/openrouter-output-v4.json +0 -85
  154. package/src/migrations/FromV3ToV4/fixtures/output-v4-from-v1.json +0 -203
  155. package/src/migrations/FromV3ToV4/index.ts +0 -102
  156. package/src/migrations/FromV3ToV4/migrations.test.ts +0 -195
  157. package/src/migrations/FromV3ToV4/types/v3.ts +0 -52
  158. package/src/migrations/FromV3ToV4/types/v4.ts +0 -37
  159. package/src/migrations/FromV4ToV5/fixtures/from-v1-to-v5-output.json +0 -245
  160. package/src/migrations/FromV4ToV5/fixtures/function-input-v4.json +0 -96
  161. package/src/migrations/FromV4ToV5/fixtures/function-output-v5.json +0 -120
  162. package/src/migrations/FromV4ToV5/index.ts +0 -58
  163. package/src/migrations/FromV4ToV5/migrations.test.ts +0 -49
  164. package/src/migrations/FromV4ToV5/types/v4.ts +0 -21
  165. package/src/migrations/FromV4ToV5/types/v5.ts +0 -27
  166. package/src/migrations/FromV5ToV6/fixtures/from-v1-to-v6-output.json +0 -247
  167. package/src/migrations/FromV5ToV6/fixtures/session-input-v5.json +0 -81
  168. package/src/migrations/FromV5ToV6/fixtures/session-output-v6.json +0 -85
  169. package/src/migrations/FromV5ToV6/index.ts +0 -61
  170. package/src/migrations/FromV5ToV6/migrations.test.ts +0 -50
  171. package/src/migrations/FromV5ToV6/types/v5.ts +0 -48
  172. package/src/migrations/FromV5ToV6/types/v6.ts +0 -63
  173. package/src/migrations/FromV6ToV7/fixtures/output-v7-from-v1.json +0 -203
  174. package/src/migrations/FromV6ToV7/fixtures/provider-input-v6.json +0 -103
  175. package/src/migrations/FromV6ToV7/fixtures/provider-output-v7.json +0 -118
  176. package/src/migrations/FromV6ToV7/index.ts +0 -101
  177. package/src/migrations/FromV6ToV7/migrations.test.ts +0 -64
  178. package/src/migrations/FromV6ToV7/types/v6.ts +0 -61
  179. package/src/migrations/FromV6ToV7/types/v7.ts +0 -69
  180. package/src/migrations/VersionController.test.ts +0 -88
  181. package/src/migrations/VersionController.ts +0 -67
  182. package/src/migrations/index.ts +0 -61
  183. package/src/server/routers/edge/appStatus.ts +0 -3
  184. package/src/server/routers/edge/index.ts +0 -14
  185. package/src/server/routers/edge/upload.ts +0 -16
  186. package/src/services/aiModel/client.ts +0 -70
  187. package/src/services/aiProvider/client.ts +0 -58
  188. package/src/services/baseClientService/index.ts +0 -9
  189. package/src/services/chatGroup/client.ts +0 -63
  190. package/src/services/export/_deprecated.ts +0 -155
  191. package/src/services/export/client.ts +0 -15
  192. package/src/services/file/_deprecated.test.ts +0 -119
  193. package/src/services/file/_deprecated.ts +0 -80
  194. package/src/services/file/client.test.ts +0 -199
  195. package/src/services/file/client.ts +0 -85
  196. package/src/services/import/_deprecated.ts +0 -115
  197. package/src/services/import/client.test.ts +0 -1015
  198. package/src/services/import/client.ts +0 -64
  199. package/src/services/message/_deprecated.test.ts +0 -398
  200. package/src/services/message/_deprecated.ts +0 -168
  201. package/src/services/message/client.test.ts +0 -410
  202. package/src/services/message/client.ts +0 -192
  203. package/src/services/plugin/_deprecated.test.ts +0 -162
  204. package/src/services/plugin/_deprecated.ts +0 -42
  205. package/src/services/plugin/client.test.ts +0 -177
  206. package/src/services/plugin/client.ts +0 -46
  207. package/src/services/session/_deprecated.test.ts +0 -440
  208. package/src/services/session/_deprecated.ts +0 -190
  209. package/src/services/session/client.test.ts +0 -413
  210. package/src/services/session/client.ts +0 -193
  211. package/src/services/thread/client.ts +0 -51
  212. package/src/services/topic/_deprecated.test.ts +0 -245
  213. package/src/services/topic/_deprecated.ts +0 -75
  214. package/src/services/topic/client.ts +0 -89
  215. package/src/services/topic/pglite.test.ts +0 -212
  216. package/src/services/user/_deprecated.test.ts +0 -101
  217. package/src/services/user/_deprecated.ts +0 -70
  218. package/src/services/user/client.test.ts +0 -111
  219. package/src/services/user/client.ts +0 -104
@@ -1,3 +1,5 @@
1
+ import { isDesktop } from '@lobechat/const';
2
+ import { SessionDefaultGroup } from '@lobechat/types';
1
3
  import { ActionIcon, Dropdown, Icon } from '@lobehub/ui';
2
4
  import { App } from 'antd';
3
5
  import { createStyles } from 'antd-style';
@@ -6,7 +8,6 @@ import isEqual from 'fast-deep-equal';
6
8
  import {
7
9
  Check,
8
10
  ExternalLink,
9
- HardDriveDownload,
10
11
  ListTree,
11
12
  LucideCopy,
12
13
  LucidePlus,
@@ -18,14 +19,11 @@ import {
18
19
  import { memo, useMemo } from 'react';
19
20
  import { useTranslation } from 'react-i18next';
20
21
 
21
- import { isDesktop, isServerMode } from '@/const/version';
22
- import { configService } from '@/services/config';
23
- import { useGlobalStore } from '@/store/global';
24
22
  import { useChatGroupStore } from '@/store/chatGroup';
23
+ import { useGlobalStore } from '@/store/global';
25
24
  import { useSessionStore } from '@/store/session';
26
25
  import { sessionHelpers } from '@/store/session/helpers';
27
26
  import { sessionGroupSelectors, sessionSelectors } from '@/store/session/selectors';
28
- import { SessionDefaultGroup } from '@/types/session';
29
27
 
30
28
  const useStyles = createStyles(({ css }) => ({
31
29
  modalRoot: css`
@@ -148,29 +146,6 @@ const Actions = memo<ActionProps>(({ group, id, openCreateGroupModal, parentType
148
146
  {
149
147
  type: 'divider',
150
148
  },
151
- isServerMode
152
- ? undefined
153
- : {
154
- children: [
155
- {
156
- key: 'agent',
157
- label: t('exportType.agent', { ns: 'common' }),
158
- onClick: () => {
159
- configService.exportSingleAgent(id);
160
- },
161
- },
162
- {
163
- key: 'agentWithMessage',
164
- label: t('exportType.agentWithMessage', { ns: 'common' }),
165
- onClick: () => {
166
- configService.exportSingleSession(id);
167
- },
168
- },
169
- ],
170
- icon: <Icon icon={HardDriveDownload} />,
171
- key: 'export',
172
- label: t('export', { ns: 'common' }),
173
- },
174
149
  {
175
150
  danger: true,
176
151
  icon: <Icon icon={Trash} />,
@@ -2,7 +2,6 @@ import { Suspense } from 'react';
2
2
  import { Flexbox } from 'react-layout-kit';
3
3
 
4
4
  import { isDesktop } from '@/const/version';
5
- import InitClientDB from '@/features/InitClientDB';
6
5
  import ProtocolUrlHandler from '@/features/ProtocolUrlHandler';
7
6
 
8
7
  import { LayoutProps } from '../type';
@@ -22,7 +21,6 @@ const Layout = ({ children, session }: LayoutProps) => {
22
21
  <SessionPanel>{session}</SessionPanel>
23
22
  <Workspace>{children}</Workspace>
24
23
  </Flexbox>
25
- {!isDesktop && <InitClientDB bottom={60} />}
26
24
  {/* ↓ cloud slot ↓ */}
27
25
 
28
26
  {/* ↑ cloud slot ↑ */}
@@ -1,11 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import { createStyles } from 'antd-style';
4
- import { Suspense, memo } from 'react';
4
+ import { memo } from 'react';
5
5
  import { Flexbox } from 'react-layout-kit';
6
6
 
7
7
  import { withSuspense } from '@/components/withSuspense';
8
- import InitClientDB from '@/features/InitClientDB';
9
8
  import { useShowMobileWorkspace } from '@/hooks/useShowMobileWorkspace';
10
9
 
11
10
  import { LayoutProps } from './type';
@@ -40,9 +39,6 @@ const Layout = memo<LayoutProps>(({ children, session }) => {
40
39
  >
41
40
  {children}
42
41
  </Flexbox>
43
- <Suspense>
44
- <InitClientDB bottom={100} />
45
- </Suspense>
46
42
  </>
47
43
  );
48
44
  });
@@ -1,69 +1,9 @@
1
- import { ActionIcon, Button, Dropdown, type MenuProps } from '@lobehub/ui';
2
- import { HardDriveDownload } from 'lucide-react';
3
- import { memo, useMemo } from 'react';
4
- import { useTranslation } from 'react-i18next';
5
-
6
- import { HEADER_ICON_SIZE } from '@/const/layoutTokens';
7
- import { isServerMode } from '@/const/version';
8
- import { configService } from '@/services/config';
9
- import { useServerConfigStore } from '@/store/serverConfig';
10
- import { useSessionStore } from '@/store/session';
1
+ import { memo } from 'react';
11
2
 
12
3
  import SubmitAgentButton from './SubmitAgentButton';
13
4
 
14
5
  export const HeaderContent = memo<{ mobile?: boolean; modal?: boolean }>(({ modal }) => {
15
- const { t } = useTranslation('setting');
16
- const id = useSessionStore((s) => s.activeId);
17
-
18
- const mobile = useServerConfigStore((s) => s.isMobile);
19
-
20
- const items = useMemo<MenuProps['items']>(
21
- () =>
22
- isServerMode
23
- ? []
24
- : [
25
- {
26
- key: 'agent',
27
- label: <div>{t('exportType.agent', { ns: 'common' })}</div>,
28
- onClick: () => {
29
- if (!id) return;
30
-
31
- configService.exportSingleAgent(id);
32
- },
33
- },
34
- {
35
- key: 'agentWithMessage',
36
- label: <div>{t('exportType.agentWithMessage', { ns: 'common' })}</div>,
37
- onClick: () => {
38
- if (!id) return;
39
-
40
- configService.exportSingleSession(id);
41
- },
42
- },
43
- ],
44
- [],
45
- );
46
-
47
- return (
48
- <>
49
- <SubmitAgentButton modal={modal} />
50
- {!isServerMode && (
51
- <Dropdown arrow={false} menu={{ items }} trigger={['click']}>
52
- {modal ? (
53
- <Button block icon={HardDriveDownload} variant={'filled'}>
54
- {t('export', { ns: 'common' })}
55
- </Button>
56
- ) : (
57
- <ActionIcon
58
- icon={HardDriveDownload}
59
- size={HEADER_ICON_SIZE(mobile)}
60
- title={t('export', { ns: 'common' })}
61
- />
62
- )}
63
- </Dropdown>
64
- )}
65
- </>
66
- );
6
+ return <SubmitAgentButton modal={modal} />;
67
7
  });
68
8
 
69
9
  export default HeaderContent;
@@ -2,7 +2,6 @@ import { Suspense } from 'react';
2
2
 
3
3
  import StructuredData from '@/components/StructuredData';
4
4
  import { BRANDING_NAME } from '@/const/branding';
5
- import InitClientDB from '@/features/InitClientDB';
6
5
  import { ldModule } from '@/server/ld';
7
6
  import { metadataModule } from '@/server/metadata';
8
7
  import { translation } from '@/server/translation';
@@ -34,7 +33,6 @@ const AiImage = async (props: DynamicLayoutProps) => {
34
33
  return (
35
34
  <>
36
35
  <StructuredData ld={ld} />
37
- <InitClientDB bottom={100} />
38
36
  <Suspense fallback={<SkeletonList />}>
39
37
  <ImageWorkspace />
40
38
  </Suspense>
@@ -5,7 +5,6 @@ import { memo, useRef } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
 
8
- import InitClientDB from '@/features/InitClientDB';
9
8
  import Footer from '@/features/Setting/Footer';
10
9
  import SettingContainer from '@/features/Setting/SettingContainer';
11
10
  import { useActiveProfileKey } from '@/hooks/useActiveTabKey';
@@ -21,30 +20,30 @@ const Layout = memo<LayoutProps>(({ children, category }) => {
21
20
  const activeKey = useActiveProfileKey();
22
21
 
23
22
  return (
24
- <>
25
- <Flexbox
26
- height={'100%'}
27
- horizontal={md}
28
- ref={ref}
29
- style={{ position: 'relative' }}
30
- width={'100%'}
23
+ <Flexbox
24
+ height={'100%'}
25
+ horizontal={md}
26
+ ref={ref}
27
+ style={{ position: 'relative' }}
28
+ width={'100%'}
29
+ >
30
+ {md ? (
31
+ <SideBar>{category}</SideBar>
32
+ ) : (
33
+ <Header getContainer={() => ref.current} title={<>{t(`tab.${activeKey}`)}</>}>
34
+ {category}
35
+ </Header>
36
+ )}
37
+ <SettingContainer
38
+ addonAfter={<Footer />}
39
+ style={{
40
+ paddingBlock: 24,
41
+ paddingInline: 32,
42
+ }}
31
43
  >
32
- {md ? (
33
- <SideBar>{category}</SideBar>
34
- ) : (
35
- <Header getContainer={() => ref.current} title={<>{t(`tab.${activeKey}`)}</>}>
36
- {category}
37
- </Header>
38
- )}
39
- <SettingContainer
40
- addonAfter={<Footer />}
41
- style={{
42
- paddingBlock: 24,
43
- paddingInline: 32,
44
- }}>{children}</SettingContainer>
45
- </Flexbox>
46
- <InitClientDB />
47
- </>
44
+ {children}
45
+ </SettingContainer>
46
+ </Flexbox>
48
47
  );
49
48
  });
50
49
 
@@ -1,5 +1,4 @@
1
1
  import MobileContentLayout from '@/components/server/MobileNavLayout';
2
- import InitClientDB from '@/features/InitClientDB';
3
2
  import Footer from '@/features/Setting/Footer';
4
3
 
5
4
  import { LayoutProps } from '../type';
@@ -7,14 +6,11 @@ import Header from './Header';
7
6
 
8
7
  const Layout = ({ children }: LayoutProps) => {
9
8
  return (
10
- <>
11
- <MobileContentLayout header={<Header />}>
12
- {children}
13
- <div style={{ flex: 1 }} />
14
- <Footer />
15
- </MobileContentLayout>
16
- <InitClientDB />
17
- </>
9
+ <MobileContentLayout header={<Header />}>
10
+ {children}
11
+ <div style={{ flex: 1 }} />
12
+ <Footer />
13
+ </MobileContentLayout>
18
14
  );
19
15
  };
20
16
 
@@ -5,7 +5,6 @@ import { parseAsStringEnum, useQueryState } from 'nuqs';
5
5
  import { memo, useRef } from 'react';
6
6
  import { Flexbox } from 'react-layout-kit';
7
7
 
8
- import InitClientDB from '@/features/InitClientDB';
9
8
  import SettingContainer from '@/features/Setting/SettingContainer';
10
9
  import { SettingsTabs } from '@/store/global/initialState';
11
10
 
@@ -43,7 +42,6 @@ const Layout = memo<LayoutProps>((props) => {
43
42
  <SettingContainer maxWidth={'none'}>
44
43
  <SettingsContent activeTab={activeTab} mobile={false} showLLM={showLLM} />
45
44
  </SettingContainer>
46
- <InitClientDB />
47
45
  </Flexbox>
48
46
  );
49
47
  });
@@ -3,7 +3,6 @@
3
3
  import { useQueryState } from 'nuqs';
4
4
 
5
5
  import MobileContentLayout from '@/components/server/MobileNavLayout';
6
- import InitClientDB from '@/features/InitClientDB';
7
6
  import Footer from '@/features/Setting/Footer';
8
7
  import { SettingsTabs } from '@/store/global/initialState';
9
8
 
@@ -19,7 +18,6 @@ const Layout = () => {
19
18
  <MobileContentLayout header={<Header />}>
20
19
  <SettingsContent activeTab={activeTab} mobile={true} />
21
20
  <Footer />
22
- <InitClientDB />
23
21
  </MobileContentLayout>
24
22
  );
25
23
  };
@@ -1,11 +1,11 @@
1
1
  import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
2
2
  import { Avatar, Text } from '@lobehub/ui';
3
3
  import { Divider, Skeleton } from 'antd';
4
- import Link from 'next/link';
5
4
  import { memo } from 'react';
6
5
  import { useTranslation } from 'react-i18next';
7
6
  import { Flexbox } from 'react-layout-kit';
8
7
 
8
+ import Link from '@/components/Link';
9
9
  import { AiProviderListItem } from '@/types/aiProvider';
10
10
 
11
11
  import EnableSwitch from './EnableSwitch';
@@ -1,10 +1 @@
1
- import { isServerMode } from '@/const/version';
2
-
3
- import Client from './Client';
4
- import Server from './Server';
5
-
6
- const ScreenLoading = () => (isServerMode ? <Server /> : <Client />);
7
-
8
- ScreenLoading.displayName = 'ScreenLoading';
9
-
10
- export default ScreenLoading;
1
+ export { default } from './Server';
@@ -0,0 +1,12 @@
1
+ import NextLink, { LinkProps as NextLinkProps } from 'next/link';
2
+ import React, { memo } from 'react';
3
+
4
+ interface LinkProps extends NextLinkProps {
5
+ children?: React.ReactNode | undefined;
6
+ }
7
+
8
+ const Link = memo<LinkProps>((props) => {
9
+ return <NextLink {...props} prefetch={false} />;
10
+ });
11
+
12
+ export default Link;
package/src/envs/app.ts CHANGED
@@ -2,8 +2,6 @@
2
2
  import { createEnv } from '@t3-oss/env-nextjs';
3
3
  import { z } from 'zod';
4
4
 
5
- import { isServerMode } from '@/const/version';
6
-
7
5
  declare global {
8
6
  // eslint-disable-next-line @typescript-eslint/no-namespace
9
7
  namespace NodeJS {
@@ -16,12 +14,11 @@ const isInVercel = process.env.VERCEL === '1';
16
14
 
17
15
  const vercelUrl = `https://${process.env.VERCEL_URL}`;
18
16
 
19
- const APP_URL = process.env.APP_URL ? process.env.APP_URL : isInVercel ? vercelUrl : undefined;
20
-
21
- // only throw error in server mode and server side
22
- if (typeof window === 'undefined' && isServerMode && !APP_URL) {
23
- throw new Error('`APP_URL` is required in server mode');
24
- }
17
+ const APP_URL = process.env.APP_URL
18
+ ? process.env.APP_URL
19
+ : isInVercel
20
+ ? vercelUrl
21
+ : 'http://localhost:3010';
25
22
 
26
23
  const ASSISTANT_INDEX_URL = 'https://registry.npmmirror.com/@lobehub/agents-index/v1/files/public';
27
24
 
@@ -9,21 +9,32 @@ import { Center } from 'react-layout-kit';
9
9
 
10
10
  import DataStyleModal from '@/components/DataStyleModal';
11
11
  import { importService } from '@/services/import';
12
- import { ImportResult, ImportResults } from '@/services/import/_deprecated';
13
12
  import { useChatStore } from '@/store/chat';
14
13
  import { useSessionStore } from '@/store/session';
15
14
  import { ImportPgDataStructure } from '@/types/export';
16
- import { ConfigFile } from '@/types/exportConfig';
17
- import { ErrorShape, FileUploadState, ImportStage, OnImportCallbacks } from '@/types/importer';
15
+ import { ErrorShape, FileUploadState, ImportStage } from '@/types/importer';
18
16
 
19
17
  import ImportError from './Error';
20
18
  import { FileUploading } from './FileUploading';
21
19
  import ImportPreviewModal from './ImportDetail';
22
20
  import DataLoading from './Loading';
23
21
  import SuccessResult from './SuccessResult';
24
- import { importConfigFile } from './_deprecated';
25
22
  import { parseConfigFile } from './config';
26
23
 
24
+ export interface ImportResult {
25
+ added: number;
26
+ errors: number;
27
+ skips: number;
28
+ updated?: number;
29
+ }
30
+ export interface ImportResults {
31
+ messages?: ImportResult;
32
+ sessionGroups?: ImportResult;
33
+ sessions?: ImportResult;
34
+ topics?: ImportResult;
35
+ type?: string;
36
+ }
37
+
27
38
  const useStyles = createStyles(({ css }) => ({
28
39
  children: css`
29
40
  &::before {
@@ -157,62 +168,6 @@ const DataImporter = memo<DataImporterProps>(({ children, onFinishImport }) => {
157
168
  const config = await parseConfigFile(file);
158
169
  if (!config) return false;
159
170
 
160
- if (!('schemaHash' in config)) {
161
- // TODO: remove in V2
162
- await importConfigFile(file, async (config) => {
163
- setImportState(ImportStage.Preparing);
164
- console.log(config);
165
-
166
- const importConfigState = async (
167
- config: ConfigFile,
168
- callbacks?: OnImportCallbacks,
169
- ): Promise<void> => {
170
- if (config.exportType === 'settings') {
171
- await importService.importSettings(config.state.settings);
172
- callbacks?.onStageChange?.(ImportStage.Success);
173
- return;
174
- }
175
-
176
- if (config.exportType === 'all') {
177
- await importService.importSettings(config.state.settings);
178
- }
179
-
180
- await importService.importData(
181
- {
182
- messages: (config.state as any).messages || [],
183
- sessionGroups: (config.state as any).sessionGroups || [],
184
- sessions: (config.state as any).sessions || [],
185
- topics: (config.state as any).topics || [],
186
- version: config.version,
187
- },
188
- callbacks,
189
- );
190
- };
191
-
192
- await importConfigState(config, {
193
- onError: (error) => {
194
- setImportError(error);
195
- },
196
- onFileUploading: (state) => {
197
- setUploadingState(state);
198
- },
199
- onStageChange: (stage) => {
200
- setImportState(stage);
201
- },
202
- onSuccess: (data, duration) => {
203
- if (data) setImportResults(data);
204
- setDuration(duration);
205
- },
206
- });
207
-
208
- await refreshSessions();
209
- await refreshMessages();
210
- await refreshTopics();
211
- });
212
-
213
- return false;
214
- }
215
-
216
171
  setImportPgData(config);
217
172
  setShowImportModal(true);
218
173
 
@@ -25,7 +25,8 @@ export const useTableColumns = (tableName?: string) => {
25
25
  export const usePgTable = (tableName?: string) => {
26
26
  const isDBInited = useGlobalStore(systemStatusSelectors.isDBInited);
27
27
 
28
- return useSWR(isDBInited && tableName ? FETCH_TABLE_DATA_KEY(tableName) : null, ([, table]) =>
29
- tableViewerService.getTableData(table),
28
+ return useSWR(
29
+ isDBInited && tableName ? FETCH_TABLE_DATA_KEY(tableName) : null,
30
+ ([, table]) => tableViewerService.getTableData(table) as any,
30
31
  );
31
32
  };
@@ -10,21 +10,27 @@ import { useSessionStore } from '@/store/session';
10
10
  import { useOpenChatSettings } from './useInterceptingRoutes';
11
11
 
12
12
  // Mocks
13
+ const mockPush = vi.fn((href) => href);
13
14
  vi.mock('next/navigation', () => ({
14
15
  useRouter: vi.fn(() => ({
15
- push: vi.fn((href) => href),
16
+ push: mockPush,
16
17
  replace: vi.fn((href) => href),
17
18
  })),
18
19
  }));
19
20
  vi.mock('nextjs-toploader/app', () => ({
20
21
  useRouter: vi.fn(() => ({
21
- push: vi.fn((href) => href),
22
+ push: mockPush,
22
23
  replace: vi.fn((href) => href),
23
24
  })),
24
25
  }));
25
26
  vi.mock('@/hooks/useQuery', () => ({
26
27
  useQuery: vi.fn(() => ({})),
27
28
  }));
29
+ vi.mock('@/hooks/useQueryRoute', () => ({
30
+ useQueryRoute: vi.fn(() => ({
31
+ push: mockPush,
32
+ })),
33
+ }));
28
34
  vi.mock('@/hooks/useIsMobile', () => ({
29
35
  useIsMobile: vi.fn(),
30
36
  }));
@@ -36,20 +42,32 @@ vi.mock('@/store/global', () => ({
36
42
  setState: vi.fn(),
37
43
  },
38
44
  }));
45
+ let isDeprecatedEdition = false;
46
+ vi.mock('@/const/version', async (importOriginal) => {
47
+ const actual = await importOriginal<typeof import('@/const/version')>();
48
+ return {
49
+ ...actual,
50
+ get isDeprecatedEdition() {
51
+ return isDeprecatedEdition;
52
+ },
53
+ };
54
+ });
39
55
 
40
56
  describe('useOpenChatSettings', () => {
41
57
  it('should handle inbox session id correctly', () => {
58
+ isDeprecatedEdition = true;
42
59
  vi.mocked(useSessionStore).mockReturnValue(INBOX_SESSION_ID);
43
60
  const { result } = renderHook(() => useOpenChatSettings());
44
61
 
45
62
  expect(result.current()).toBe('/settings?active=agent'); // Assuming openSettings returns a function
63
+ isDeprecatedEdition = false;
46
64
  });
47
65
 
48
66
  it('should handle mobile route for chat settings', () => {
49
67
  vi.mocked(useSessionStore).mockReturnValue('123');
50
68
  vi.mocked(useIsMobile).mockReturnValue(true);
51
69
  const { result } = renderHook(() => useOpenChatSettings(ChatSettingsTabs.Meta));
52
- expect(result.current()).toBe('/chat/settings?session=123');
70
+ expect(result.current()).toBe('/chat/settings');
53
71
  });
54
72
 
55
73
  it('should handle desktop route for chat settings with session and tab', () => {
@@ -1,5 +1,4 @@
1
1
  export { asyncClient } from './async';
2
2
  export * from './desktop';
3
- export { edgeClient } from './edge';
4
3
  export * from './lambda';
5
4
  export * from './tools';
@@ -22,10 +22,12 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {
22
22
  complete: () => observer.complete(),
23
23
  error: async (err) => {
24
24
  // Check if this is an abort error and should be ignored
25
- const isAbortError = err.message.includes('aborted') || err.name === 'AbortError' ||
26
- err.cause?.name === 'AbortError' ||
27
- err.message.includes('signal is aborted without reason');
28
-
25
+ const isAbortError =
26
+ err.message.includes('aborted') ||
27
+ err.name === 'AbortError' ||
28
+ err.cause?.name === 'AbortError' ||
29
+ err.message.includes('signal is aborted without reason');
30
+
29
31
  const showError = (op.context?.showNotification as boolean) ?? true;
30
32
  const status = err.data?.httpStatus as number;
31
33
 
@@ -50,7 +52,8 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {
50
52
  }
51
53
 
52
54
  default: {
53
- fetchErrorNotification.error({ errorMessage: err.message, status });
55
+ if (fetchErrorNotification)
56
+ fetchErrorNotification.error({ errorMessage: err.message, status });
54
57
  }
55
58
  }
56
59
  }
@@ -2,8 +2,6 @@ import { GetStreamableMcpServerManifestInputSchema } from '@lobechat/types';
2
2
  import debug from 'debug';
3
3
  import { z } from 'zod';
4
4
 
5
- import { isServerMode } from '@/const/version';
6
- import { passwordProcedure } from '@/libs/trpc/edge';
7
5
  import { authedProcedure, router } from '@/libs/trpc/lambda';
8
6
  import { mcpService } from '@/server/services/mcp';
9
7
 
@@ -24,7 +22,7 @@ const stdioParamsSchema = z.object({
24
22
  type: z.literal('stdio').default('stdio'),
25
23
  });
26
24
 
27
- const mcpProcedure = isServerMode ? authedProcedure : passwordProcedure;
25
+ const mcpProcedure = authedProcedure;
28
26
 
29
27
  export const mcpRouter = router({
30
28
  getStdioMcpServerManifest: mcpProcedure.input(stdioParamsSchema).query(async ({ input }) => {
@@ -4,8 +4,8 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
  /**
5
5
  * This file contains the root router of your tRPC-backend
6
6
  */
7
- import { createCallerFactory } from '@/libs/trpc/edge';
8
- import { AuthContext, createContextInner } from '@/libs/trpc/edge/context';
7
+ import { createCallerFactory } from '@/libs/trpc/lambda';
8
+ import { AuthContext, createContextInner } from '@/libs/trpc/lambda/context';
9
9
 
10
10
  import { configRouter } from './index';
11
11
 
@@ -1,3 +1,4 @@
1
+ import { isDesktop } from '@lobechat/const';
1
2
  import {
2
3
  GetStreamableMcpServerManifestInputSchema,
3
4
  StreamableHTTPAuthSchema,
@@ -5,8 +6,6 @@ import {
5
6
  import { TRPCError } from '@trpc/server';
6
7
  import { z } from 'zod';
7
8
 
8
- import { isDesktop, isServerMode } from '@/const/version';
9
- import { passwordProcedure } from '@/libs/trpc/edge';
10
9
  import { authedProcedure, router } from '@/libs/trpc/lambda';
11
10
  import { mcpService } from '@/server/services/mcp';
12
11
 
@@ -38,7 +37,7 @@ const checkStdioEnvironment = (params: z.infer<typeof mcpClientParamsSchema>) =>
38
37
  }
39
38
  };
40
39
 
41
- const mcpProcedure = isServerMode ? authedProcedure : passwordProcedure;
40
+ const mcpProcedure = authedProcedure;
42
41
 
43
42
  export const mcpRouter = router({
44
43
  getStreamableMcpServerManifest: mcpProcedure
@@ -23,13 +23,7 @@ vi.mock('@/server/services/search/impls/searxng/client');
23
23
 
24
24
  describe('searchRouter', () => {
25
25
  const mockContext = {
26
- req: {
27
- headers: {
28
- authorization: 'Bearer mock-token',
29
- },
30
- },
31
- authorizationHeader: 'Bearer mock-token',
32
- jwtPayload: { userId: '1' },
26
+ userId: 'test-user-id',
33
27
  };
34
28
 
35
29
  beforeEach(() => {