@lobehub/lobehub 2.0.0-next.17 → 2.0.0-next.18

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 (33) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/changelog/v1.json +9 -0
  3. package/locales/ar/oauth.json +1 -0
  4. package/locales/bg-BG/oauth.json +1 -0
  5. package/locales/de-DE/oauth.json +1 -0
  6. package/locales/en-US/oauth.json +1 -0
  7. package/locales/es-ES/oauth.json +1 -0
  8. package/locales/fa-IR/oauth.json +1 -0
  9. package/locales/fr-FR/oauth.json +1 -0
  10. package/locales/it-IT/oauth.json +1 -0
  11. package/locales/ja-JP/oauth.json +1 -0
  12. package/locales/ko-KR/oauth.json +1 -0
  13. package/locales/nl-NL/oauth.json +1 -0
  14. package/locales/pl-PL/oauth.json +1 -0
  15. package/locales/pt-BR/oauth.json +1 -0
  16. package/locales/ru-RU/oauth.json +1 -0
  17. package/locales/tr-TR/oauth.json +1 -0
  18. package/locales/vi-VN/oauth.json +1 -0
  19. package/locales/zh-CN/oauth.json +1 -0
  20. package/locales/zh-TW/oauth.json +1 -0
  21. package/package.json +1 -1
  22. package/packages/types/src/message/ui/params.ts +98 -4
  23. package/packages/types/src/user/index.ts +13 -1
  24. package/packages/types/src/user/settings/index.ts +22 -0
  25. package/src/app/[variants]/oauth/consent/[uid]/Consent/BuiltinConsent.tsx +57 -0
  26. package/src/app/[variants]/oauth/consent/[uid]/{Consent.tsx → Consent/index.tsx} +9 -1
  27. package/src/app/[variants]/oauth/consent/[uid]/Login.tsx +9 -1
  28. package/src/locales/default/oauth.ts +1 -0
  29. package/src/server/routers/lambda/__tests__/integration/message.integration.test.ts +0 -41
  30. package/src/server/routers/lambda/message.ts +4 -11
  31. package/src/server/routers/lambda/user.ts +24 -25
  32. package/src/services/message/server.ts +0 -4
  33. package/src/services/message/type.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 2.0.0-next.18](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.17...v2.0.0-next.18)
6
+
7
+ <sup>Released on **2025-11-03**</sup>
8
+
9
+ #### ♻ Code Refactoring
10
+
11
+ - **misc**: Refactor trpc request to use zod schema.
12
+
13
+ #### 💄 Styles
14
+
15
+ - **misc**: Improve built-in client OIDC user flow.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### Code refactoring
23
+
24
+ - **misc**: Refactor trpc request to use zod schema, closes [#10016](https://github.com/lobehub/lobe-chat/issues/10016) ([1a84f2c](https://github.com/lobehub/lobe-chat/commit/1a84f2c))
25
+
26
+ #### Styles
27
+
28
+ - **misc**: Improve built-in client OIDC user flow, closes [#10020](https://github.com/lobehub/lobe-chat/issues/10020) ([80202ed](https://github.com/lobehub/lobe-chat/commit/80202ed))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
5
38
  ## [Version 2.0.0-next.17](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.16...v2.0.0-next.17)
6
39
 
7
40
  <sup>Released on **2025-11-03**</sup>
package/changelog/v1.json CHANGED
@@ -1,4 +1,13 @@
1
1
  [
2
+ {
3
+ "children": {
4
+ "improvements": [
5
+ "Improve built-in client OIDC user flow."
6
+ ]
7
+ },
8
+ "date": "2025-11-03",
9
+ "version": "2.0.0-next.18"
10
+ },
2
11
  {
3
12
  "children": {
4
13
  "fixes": [
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "طلب الأذونات التالية:",
20
20
  "redirectUri": "سيتم إعادة التوجيه إلى بعد نجاح التفويض",
21
+ "redirecting": "تم التفويض بنجاح، جارٍ إعادة التوجيه...",
21
22
  "scope": {
22
23
  "email": "الوصول إلى عنوان بريدك الإلكتروني",
23
24
  "offline_access": "السماح للتطبيق بالوصول إلى بياناتك",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Искаме следните разрешения:",
20
20
  "redirectUri": "Ще бъдете пренасочени след успешното разрешение",
21
+ "redirecting": "Успешно упълномощено, пренасочване...",
21
22
  "scope": {
22
23
  "email": "Достъп до вашия имейл адрес",
23
24
  "offline_access": "Позволете на клиента да получи достъп до вашите данни",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Anforderung der folgenden Berechtigungen:",
20
20
  "redirectUri": "Nach erfolgreicher Autorisierung werden Sie umgeleitet zu",
21
+ "redirecting": "Autorisierung erfolgreich, Weiterleitung...",
21
22
  "scope": {
22
23
  "email": "Zugriff auf Ihre E-Mail-Adresse",
23
24
  "offline_access": "Erlauben Sie dem Client, auf Ihre Daten zuzugreifen",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Requesting the following permissions:",
20
20
  "redirectUri": "You will be redirected to after successful authorization",
21
+ "redirecting": "Authorization successful, redirecting...",
21
22
  "scope": {
22
23
  "email": "Access your email address",
23
24
  "offline_access": "Allow the client to access your data",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Solicitar los siguientes permisos:",
20
20
  "redirectUri": "Se redirigirá a después de la autorización exitosa",
21
+ "redirecting": "Autorización exitosa, redirigiendo...",
21
22
  "scope": {
22
23
  "email": "Acceder a su dirección de correo electrónico",
23
24
  "offline_access": "Permitir que el cliente acceda a sus datos",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "درخواست مجوزهای زیر:",
20
20
  "redirectUri": "پس از موفقیت در مجوز، به آدرس زیر هدایت می‌شوید",
21
+ "redirecting": "دسترسی با موفقیت انجام شد، در حال انتقال...",
21
22
  "scope": {
22
23
  "email": "دسترسی به آدرس ایمیل شما",
23
24
  "offline_access": "اجازه دسترسی به داده‌های شما توسط کلاینت",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Demander les autorisations suivantes :",
20
20
  "redirectUri": "Vous serez redirigé vers après une autorisation réussie",
21
+ "redirecting": "Autorisation réussie, redirection en cours...",
21
22
  "scope": {
22
23
  "email": "Accéder à votre adresse e-mail",
23
24
  "offline_access": "Autoriser le client à accéder à vos données",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Richiesta delle seguenti autorizzazioni:",
20
20
  "redirectUri": "Verrai reindirizzato a dopo un'autorizzazione riuscita",
21
+ "redirecting": "Autorizzazione completata, reindirizzamento in corso...",
21
22
  "scope": {
22
23
  "email": "Accesso al tuo indirizzo email",
23
24
  "offline_access": "Consenti all'accesso del client ai tuoi dati",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "以下の権限をリクエストします:",
20
20
  "redirectUri": "承認が成功した後、次の場所にリダイレクトされます",
21
+ "redirecting": "認証に成功しました。リダイレクト中です...",
21
22
  "scope": {
22
23
  "email": "あなたのメールアドレスにアクセス",
23
24
  "offline_access": "クライアントがあなたのデータにアクセスすることを許可",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "다음 권한을 요청합니다:",
20
20
  "redirectUri": "인증이 완료되면 다음으로 리디렉션됩니다:",
21
+ "redirecting": "인증이 완료되었습니다. 이동 중...",
21
22
  "scope": {
22
23
  "email": "귀하의 이메일 주소에 접근",
23
24
  "offline_access": "클라이언트가 귀하의 데이터에 접근할 수 있도록 허용",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Vraag om de volgende toestemmingen:",
20
20
  "redirectUri": "U wordt omgeleid naar na succesvolle autorisatie",
21
+ "redirecting": "Autorisatie geslaagd, doorverwijzen...",
21
22
  "scope": {
22
23
  "email": "Toegang tot uw e-mailadres",
23
24
  "offline_access": "Toestaan dat de client toegang heeft tot uw gegevens",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Proszę o następujące uprawnienia:",
20
20
  "redirectUri": "Zostaniesz przekierowany po pomyślnym autoryzowaniu",
21
+ "redirecting": "Autoryzacja zakończona pomyślnie, przekierowywanie...",
21
22
  "scope": {
22
23
  "email": "Dostęp do Twojego adresu e-mail",
23
24
  "offline_access": "Zezwól klientowi na dostęp do Twoich danych",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Solicitar as seguintes permissões:",
20
20
  "redirectUri": "Você será redirecionado após a autorização bem-sucedida",
21
+ "redirecting": "Autorização bem-sucedida, redirecionando...",
21
22
  "scope": {
22
23
  "email": "Acessar seu endereço de e-mail",
23
24
  "offline_access": "Permitir que o cliente acesse seus dados",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Запросить следующие разрешения:",
20
20
  "redirectUri": "После успешного авторизации будет выполнен редирект на",
21
+ "redirecting": "Авторизация прошла успешно, перенаправление...",
21
22
  "scope": {
22
23
  "email": "Доступ к вашему адресу электронной почты",
23
24
  "offline_access": "Разрешить клиенту доступ к вашим данным",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Aşağıdaki izinleri talep et:",
20
20
  "redirectUri": "İzin verildikten sonra şu adrese yönlendirileceksiniz",
21
+ "redirecting": "Yetkilendirme başarılı, yönlendiriliyor...",
21
22
  "scope": {
22
23
  "email": "E-posta adresinize erişim",
23
24
  "offline_access": "Müşterinin verilerinize erişmesine izin ver",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "Yêu cầu các quyền sau:",
20
20
  "redirectUri": "Sẽ được chuyển hướng đến sau khi ủy quyền thành công",
21
+ "redirecting": "Ủy quyền thành công, đang chuyển hướng...",
21
22
  "scope": {
22
23
  "email": "Truy cập địa chỉ email của bạn",
23
24
  "offline_access": "Cho phép ứng dụng truy cập dữ liệu của bạn",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "请求以下权限:",
20
20
  "redirectUri": "授权成功后将重定向到",
21
+ "redirecting": "授权成功,跳转中...",
21
22
  "scope": {
22
23
  "email": "访问您的电子邮件地址",
23
24
  "offline_access": "允许客户端访问您的数据",
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "permissionsTitle": "請求以下權限:",
20
20
  "redirectUri": "授權成功後將重定向到",
21
+ "redirecting": "授權成功,正在跳轉...",
21
22
  "scope": {
22
23
  "email": "訪問您的電子郵件地址",
23
24
  "offline_access": "允許客戶端訪問您的資料",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/lobehub",
3
- "version": "2.0.0-next.17",
3
+ "version": "2.0.0-next.18",
4
4
  "description": "LobeHub - an open-source,comprehensive AI Agent framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
5
5
  "keywords": [
6
6
  "framework",
@@ -1,9 +1,14 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix , typescript-sort-keys/interface */
2
+ import { z } from 'zod';
3
+
2
4
  import { UploadFileItem } from '../../files';
3
5
  import { MessageSemanticSearchChunk } from '../../rag';
4
- import { ChatMessageError } from '../common/base';
6
+ import { ChatMessageError, ChatMessageErrorSchema } from '../common/base';
5
7
  import { ChatPluginPayload } from '../common/tools';
6
- import { UIChatMessage, UIMessageRoleType } from './chat';
8
+ import { UIChatMessage } from './chat';
9
+ import { SemanticSearchChunkSchema } from './rag';
10
+
11
+ export type CreateMessageRoleType = 'user' | 'assistant' | 'tool' | 'supervisor';
7
12
 
8
13
  export interface CreateMessageParams
9
14
  extends Partial<Omit<UIChatMessage, 'content' | 'role' | 'topicId' | 'chunksList'>> {
@@ -14,7 +19,7 @@ export interface CreateMessageParams
14
19
  fromModel?: string;
15
20
  fromProvider?: string;
16
21
  groupId?: string;
17
- role: UIMessageRoleType;
22
+ role: CreateMessageRoleType;
18
23
  sessionId: string;
19
24
  targetId?: string | null;
20
25
  threadId?: string | null;
@@ -28,7 +33,7 @@ export interface CreateMessageParams
28
33
  */
29
34
  export interface CreateNewMessageParams {
30
35
  // ========== Required fields ==========
31
- role: UIMessageRoleType;
36
+ role: CreateMessageRoleType;
32
37
  content: string;
33
38
  sessionId: string;
34
39
 
@@ -103,3 +108,92 @@ export interface SendGroupMessageParams {
103
108
  */
104
109
  targetMemberId?: string | null;
105
110
  }
111
+
112
+ // ========== Zod Schemas ========== //
113
+
114
+ const UIMessageRoleTypeSchema = z.enum(['user', 'assistant', 'tool', 'supervisor']);
115
+
116
+ const ChatPluginPayloadSchema = z.object({
117
+ apiName: z.string(),
118
+ arguments: z.string(),
119
+ identifier: z.string(),
120
+ type: z.string(),
121
+ });
122
+
123
+ export const CreateMessageParamsSchema = z
124
+ .object({
125
+ content: z.string(),
126
+ role: UIMessageRoleTypeSchema,
127
+ sessionId: z.string().nullable().optional(),
128
+ error: ChatMessageErrorSchema.nullable().optional(),
129
+ fileChunks: z.array(SemanticSearchChunkSchema).optional(),
130
+ files: z.array(z.string()).optional(),
131
+ fromModel: z.string().optional(),
132
+ fromProvider: z.string().optional(),
133
+ groupId: z.string().optional(),
134
+ targetId: z.string().nullable().optional(),
135
+ threadId: z.string().nullable().optional(),
136
+ topicId: z.string().optional(),
137
+ traceId: z.string().optional(),
138
+ // Allow additional fields from UIChatMessage (many can be null)
139
+ agentId: z.string().optional(),
140
+ children: z.any().optional(),
141
+ chunksList: z.any().optional(),
142
+ createdAt: z.number().optional(),
143
+ extra: z.any().optional(),
144
+ favorite: z.boolean().optional(),
145
+ fileList: z.any().optional(),
146
+ id: z.string().optional(),
147
+ imageList: z.any().optional(),
148
+ meta: z.any().optional(),
149
+ metadata: z.any().nullable().optional(),
150
+ model: z.string().nullable().optional(),
151
+ observationId: z.string().optional(),
152
+ parentId: z.string().optional(),
153
+ performance: z.any().optional(),
154
+ plugin: z.any().optional(),
155
+ pluginError: z.any().optional(),
156
+ pluginState: z.any().optional(),
157
+ provider: z.string().nullable().optional(),
158
+ quotaId: z.string().optional(),
159
+ ragQuery: z.string().nullable().optional(),
160
+ ragQueryId: z.string().nullable().optional(),
161
+ reasoning: z.any().optional(),
162
+ search: z.any().optional(),
163
+ tool_call_id: z.string().optional(),
164
+ toolCalls: z.any().optional(),
165
+ tools: z.any().optional(),
166
+ translate: z.any().optional(),
167
+ tts: z.any().optional(),
168
+ updatedAt: z.number().optional(),
169
+ })
170
+ .passthrough();
171
+
172
+ export const CreateNewMessageParamsSchema = z
173
+ .object({
174
+ // Required fields
175
+ role: UIMessageRoleTypeSchema,
176
+ content: z.string(),
177
+ sessionId: z.string().nullable().optional(),
178
+ // Tool related
179
+ tool_call_id: z.string().optional(),
180
+ plugin: ChatPluginPayloadSchema.optional(),
181
+ // Grouping
182
+ parentId: z.string().optional(),
183
+ groupId: z.string().optional(),
184
+ // Context
185
+ topicId: z.string().optional(),
186
+ threadId: z.string().nullable().optional(),
187
+ targetId: z.string().nullable().optional(),
188
+ // Model info
189
+ model: z.string().nullable().optional(),
190
+ provider: z.string().nullable().optional(),
191
+ // Content
192
+ files: z.array(z.string()).optional(),
193
+ // Error handling
194
+ error: ChatMessageErrorSchema.nullable().optional(),
195
+ // Metadata
196
+ traceId: z.string().optional(),
197
+ fileChunks: z.array(SemanticSearchChunkSchema).optional(),
198
+ })
199
+ .passthrough();
@@ -3,7 +3,7 @@ import { z } from 'zod';
3
3
 
4
4
  import { Plans } from '../subscription';
5
5
  import { TopicDisplayMode } from '../topic';
6
- import { UserSettings } from '../user/settings';
6
+ import { UserSettings } from './settings';
7
7
 
8
8
  export interface LobeUser {
9
9
  avatar?: string;
@@ -74,3 +74,15 @@ export const NextAuthAccountSchame = z.object({
74
74
  provider: z.string(),
75
75
  providerAccountId: z.string(),
76
76
  });
77
+
78
+ export const UserPreferenceSchema = z
79
+ .object({
80
+ disableInputMarkdownRender: z.boolean().optional(),
81
+ enableGroupChat: z.boolean().optional(),
82
+ guide: UserGuideSchema.optional(),
83
+ hideSyncAlert: z.boolean().optional(),
84
+ telemetry: z.boolean().nullable(),
85
+ topicDisplayMode: z.nativeEnum(TopicDisplayMode).optional(),
86
+ useCmdEnterToSend: z.boolean().optional(),
87
+ })
88
+ .partial();
@@ -1,3 +1,5 @@
1
+ import { z } from 'zod';
2
+
1
3
  import type { LobeAgentSettings } from '../../session';
2
4
  import { UserGeneralConfig } from './general';
3
5
  import { UserHotkeyConfig } from './hotkey';
@@ -18,6 +20,7 @@ export * from './keyVaults';
18
20
  export * from './modelProvider';
19
21
  export * from './sync';
20
22
  export * from './systemAgent';
23
+ export * from './tool';
21
24
  export * from './tts';
22
25
 
23
26
  /**
@@ -34,3 +37,22 @@ export interface UserSettings {
34
37
  tool: UserToolConfig;
35
38
  tts: UserTTSConfig;
36
39
  }
40
+
41
+ /**
42
+ * Zod schema for partial UserSettings updates
43
+ * Uses passthrough to allow any nested settings fields
44
+ */
45
+ export const UserSettingsSchema = z
46
+ .object({
47
+ defaultAgent: z.any().optional(),
48
+ general: z.any().optional(),
49
+ hotkey: z.any().optional(),
50
+ image: z.any().optional(),
51
+ keyVaults: z.any().optional(),
52
+ languageModel: z.any().optional(),
53
+ systemAgent: z.any().optional(),
54
+ tool: z.any().optional(),
55
+ tts: z.any().optional(),
56
+ })
57
+ .passthrough()
58
+ .partial();
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ import { Icon } from '@lobehub/ui';
4
+ import { Card, Result } from 'antd';
5
+ import { useTheme } from 'antd-style';
6
+ import { LoaderCircle } from 'lucide-react';
7
+ import { memo, useEffect, useRef } from 'react';
8
+ import { useTranslation } from 'react-i18next';
9
+ import { Center } from 'react-layout-kit';
10
+
11
+ interface BuiltinConsentProps {
12
+ uid: string;
13
+ }
14
+
15
+ const BuiltinConsent = memo<BuiltinConsentProps>(({ uid }) => {
16
+ const { t } = useTranslation('oauth');
17
+ const formRef = useRef<HTMLFormElement>(null);
18
+
19
+ useEffect(() => {
20
+ // Auto-submit on mount
21
+ formRef.current?.submit();
22
+ }, []);
23
+
24
+ const theme = useTheme();
25
+ return (
26
+ <>
27
+ <Center height="100vh">
28
+ <Card
29
+ style={{
30
+ alignItems: 'center',
31
+ display: 'flex',
32
+ justifyContent: 'center',
33
+ minHeight: 280,
34
+ minWidth: 500,
35
+ width: '100%',
36
+ }}
37
+ >
38
+ <Result
39
+ icon={<Icon icon={LoaderCircle} spin style={{ color: theme.colorText }} />}
40
+ status="success"
41
+ style={{ padding: 0 }}
42
+ subTitle={t('consent.redirecting')}
43
+ title=""
44
+ />
45
+ </Card>
46
+ </Center>
47
+ <form action="/oidc/consent" method="post" ref={formRef} style={{ display: 'none' }}>
48
+ <input name="uid" type="hidden" value={uid} />
49
+ <input name="consent" type="hidden" value="accept" />
50
+ </form>
51
+ </>
52
+ );
53
+ });
54
+
55
+ BuiltinConsent.displayName = 'BuiltinConsent';
56
+
57
+ export default BuiltinConsent;
@@ -7,7 +7,8 @@ import { memo, useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { Center, Flexbox } from 'react-layout-kit';
9
9
 
10
- import OAuthApplicationLogo from './components/OAuthApplicationLogo';
10
+ import OAuthApplicationLogo from '../components/OAuthApplicationLogo';
11
+ import BuiltinConsent from './BuiltinConsent';
11
12
 
12
13
  interface ClientProps {
13
14
  clientId: string;
@@ -117,6 +118,8 @@ function getScopeDescription(scope: string, t: any): string {
117
118
  return t(`consent.scope.${scope.replace(':', '-')}`, scope);
118
119
  }
119
120
 
121
+ const BUILTIN_CLIENTS = new Set(['lobehub-desktop', 'lobehub-mobile', 'lobehub-market']);
122
+
120
123
  const ConsentClient = memo<ClientProps>(({ uid, clientId, scopes, clientMetadata }) => {
121
124
  const { styles } = useStyles();
122
125
  const { t } = useTranslation('oauth');
@@ -124,6 +127,11 @@ const ConsentClient = memo<ClientProps>(({ uid, clientId, scopes, clientMetadata
124
127
  const [isLoading, setIsLoading] = useState(false);
125
128
 
126
129
  const clientDisplayName = clientMetadata?.clientName || clientId;
130
+
131
+ if (BUILTIN_CLIENTS.has(clientId)) {
132
+ return <BuiltinConsent uid={clientId} />;
133
+ }
134
+
127
135
  return (
128
136
  <Center className={styles.container} gap={16}>
129
137
  <Flexbox gap={40}>
@@ -59,6 +59,8 @@ const LoginConfirmClient = memo<LoginConfirmProps>(({ uid, clientMetadata }) =>
59
59
  const avatar = useUserStore(userProfileSelectors.userAvatar);
60
60
  const nickName = useUserStore(userProfileSelectors.nickName);
61
61
 
62
+ const [isLoading, setIsLoading] = React.useState(false);
63
+
62
64
  const titleText = t('login.title', { clientName: clientDisplayName });
63
65
  const descriptionText = t('login.description', { clientName: clientDisplayName });
64
66
  const buttonText = t('login.button'); // Or "Continue"
@@ -99,7 +101,12 @@ const LoginConfirmClient = memo<LoginConfirmProps>(({ uid, clientMetadata }) =>
99
101
 
100
102
  <Flexbox gap={16}>
101
103
  {/* Form points to the endpoint handling login confirmation */}
102
- <form action="/oidc/consent" method="post" style={{ width: '100%' }}>
104
+ <form
105
+ action="/oidc/consent"
106
+ method="post"
107
+ onSubmit={() => setIsLoading(true)}
108
+ style={{ width: '100%' }}
109
+ >
103
110
  {/* Adjust action URL */}
104
111
  <input name="uid" type="hidden" value={uid} />
105
112
  <input name="choice" type="hidden" value={'accept'} />
@@ -108,6 +115,7 @@ const LoginConfirmClient = memo<LoginConfirmProps>(({ uid, clientMetadata }) =>
108
115
  className={styles.authButton}
109
116
  disabled={!isUserStateInit}
110
117
  htmlType="submit"
118
+ loading={isLoading}
111
119
  name="consent"
112
120
  size="large"
113
121
  type="primary"
@@ -19,6 +19,7 @@ const oauth = {
19
19
  },
20
20
  permissionsTitle: '请求以下权限:',
21
21
  redirectUri: '授权成功后将重定向到',
22
+ redirecting: '授权成功,跳转中...',
22
23
  scope: {
23
24
  'email': '访问您的电子邮件地址',
24
25
  'offline_access': '允许客户端访问您的数据',
@@ -318,47 +318,6 @@ describe('Message Router Integration Tests', () => {
318
318
  });
319
319
  });
320
320
 
321
- describe('batchCreateMessages', () => {
322
- it('should create multiple messages in batch', async () => {
323
- const caller = messageRouter.createCaller(createTestContext(userId));
324
-
325
- const messagesToCreate = [
326
- {
327
- content: 'Batch message 1',
328
- role: 'user' as const,
329
- sessionId: testSessionId,
330
- },
331
- {
332
- content: 'Batch message 2',
333
- role: 'assistant' as const,
334
- sessionId: testSessionId,
335
- },
336
- {
337
- content: 'Batch message 3',
338
- role: 'user' as const,
339
- sessionId: testSessionId,
340
- topicId: testTopicId,
341
- },
342
- ];
343
-
344
- const result = await caller.batchCreateMessages(messagesToCreate);
345
-
346
- expect(result.success).toBe(true);
347
- // Note: rowCount might be undefined in PGlite, so we skip this check
348
- // expect(result.added).toBe(3);
349
-
350
- // 验证数据库中的消息
351
- const dbMessages = await serverDB
352
- .select()
353
- .from(messages)
354
- .where(eq(messages.sessionId, testSessionId));
355
-
356
- expect(dbMessages.length).toBeGreaterThanOrEqual(3);
357
- const topicMessage = dbMessages.find((m) => m.content === 'Batch message 3');
358
- expect(topicMessage?.topicId).toBe(testTopicId);
359
- });
360
- });
361
-
362
321
  describe('removeMessages', () => {
363
322
  it('should remove multiple messages', async () => {
364
323
  const caller = messageRouter.createCaller(createTestContext(userId));
@@ -1,5 +1,6 @@
1
1
  import {
2
- BatchTaskResult,
2
+ CreateMessageParamsSchema,
3
+ CreateNewMessageParamsSchema,
3
4
  UIChatMessage,
4
5
  UpdateMessageParamsSchema,
5
6
  UpdateMessageRAGParamsSchema,
@@ -27,14 +28,6 @@ const messageProcedure = authedProcedure.use(serverDatabase).use(async (opts) =>
27
28
  });
28
29
 
29
30
  export const messageRouter = router({
30
- batchCreateMessages: messageProcedure
31
- .input(z.array(z.any()))
32
- .mutation(async ({ input, ctx }): Promise<BatchTaskResult> => {
33
- const data = await ctx.messageModel.batchCreate(input);
34
-
35
- return { added: data.rowCount as number, ids: [], skips: [], success: true };
36
- }),
37
-
38
31
  count: messageProcedure
39
32
  .input(
40
33
  z
@@ -64,7 +57,7 @@ export const messageRouter = router({
64
57
  }),
65
58
 
66
59
  createMessage: messageProcedure
67
- .input(z.object({}).passthrough().partial())
60
+ .input(CreateMessageParamsSchema)
68
61
  .mutation(async ({ input, ctx }) => {
69
62
  const data = await ctx.messageModel.create(input as any);
70
63
 
@@ -72,7 +65,7 @@ export const messageRouter = router({
72
65
  }),
73
66
 
74
67
  createNewMessage: messageProcedure
75
- .input(z.object({}).passthrough().partial())
68
+ .input(CreateNewMessageParamsSchema)
76
69
  .mutation(async ({ input, ctx }) => {
77
70
  return ctx.messageModel.createNewMessage(input as any, {
78
71
  postProcessUrl: (path) => ctx.fileService.getFullFileUrl(path),
@@ -1,9 +1,17 @@
1
1
  import { UserJSON } from '@clerk/backend';
2
+ import { enableClerk, isDesktop } from '@lobechat/const';
3
+ import {
4
+ NextAuthAccountSchame,
5
+ UserGuideSchema,
6
+ UserInitializationState,
7
+ UserPreference,
8
+ UserPreferenceSchema,
9
+ UserSettings,
10
+ UserSettingsSchema,
11
+ } from '@lobechat/types';
2
12
  import { v4 as uuidv4 } from 'uuid';
3
13
  import { z } from 'zod';
4
14
 
5
- import { enableClerk } from '@/const/auth';
6
- import { isDesktop } from '@/const/version';
7
15
  import { MessageModel } from '@/database/models/message';
8
16
  import { SessionModel } from '@/database/models/session';
9
17
  import { UserModel, UserNotFoundError } from '@/database/models/user';
@@ -16,13 +24,6 @@ import { S3 } from '@/server/modules/S3';
16
24
  import { FileService } from '@/server/services/file';
17
25
  import { NextAuthUserService } from '@/server/services/nextAuthUser';
18
26
  import { UserService } from '@/server/services/user';
19
- import {
20
- NextAuthAccountSchame,
21
- UserGuideSchema,
22
- UserInitializationState,
23
- UserPreference,
24
- } from '@/types/user';
25
- import { UserSettings } from '@/types/user/settings';
26
27
 
27
28
  const userProcedure = authedProcedure.use(serverDatabase).use(async ({ ctx, next }) => {
28
29
  return next({
@@ -199,30 +200,28 @@ export const userRouter = router({
199
200
  return ctx.userModel.updateGuide(input);
200
201
  }),
201
202
 
202
- updatePreference: userProcedure.input(z.any()).mutation(async ({ ctx, input }) => {
203
+ updatePreference: userProcedure.input(UserPreferenceSchema).mutation(async ({ ctx, input }) => {
203
204
  return ctx.userModel.updatePreference(input);
204
205
  }),
205
206
 
206
- updateSettings: userProcedure
207
- .input(z.object({}).passthrough())
208
- .mutation(async ({ ctx, input }) => {
209
- const { keyVaults, ...res } = input as Partial<UserSettings>;
207
+ updateSettings: userProcedure.input(UserSettingsSchema).mutation(async ({ ctx, input }) => {
208
+ const { keyVaults, ...res } = input as Partial<UserSettings>;
210
209
 
211
- // Encrypt keyVaults
212
- let encryptedKeyVaults: string | null = null;
210
+ // Encrypt keyVaults
211
+ let encryptedKeyVaults: string | null = null;
213
212
 
214
- if (keyVaults) {
215
- // TODO: better to add a validation
216
- const data = JSON.stringify(keyVaults);
217
- const gateKeeper = await KeyVaultsGateKeeper.initWithEnvKey();
213
+ if (keyVaults) {
214
+ // TODO: better to add a validation
215
+ const data = JSON.stringify(keyVaults);
216
+ const gateKeeper = await KeyVaultsGateKeeper.initWithEnvKey();
218
217
 
219
- encryptedKeyVaults = await gateKeeper.encrypt(data);
220
- }
218
+ encryptedKeyVaults = await gateKeeper.encrypt(data);
219
+ }
221
220
 
222
- const nextValue = { ...res, keyVaults: encryptedKeyVaults };
221
+ const nextValue = { ...res, keyVaults: encryptedKeyVaults };
223
222
 
224
- return ctx.userModel.updateSetting(nextValue);
225
- }),
223
+ return ctx.userModel.updateSetting(nextValue);
224
+ }),
226
225
  });
227
226
 
228
227
  export type UserRouter = typeof userRouter;
@@ -21,10 +21,6 @@ export class ServerService implements IMessageService {
21
21
  });
22
22
  };
23
23
 
24
- batchCreateMessages: IMessageService['batchCreateMessages'] = async (messages) => {
25
- return lambdaClient.message.batchCreateMessages.mutate(messages);
26
- };
27
-
28
24
  getMessages: IMessageService['getMessages'] = async (sessionId, topicId, groupId) => {
29
25
  const data = await lambdaClient.message.getMessages.query({
30
26
  groupId,
@@ -5,7 +5,6 @@ import {
5
5
  ChatTranslate,
6
6
  CreateMessageParams,
7
7
  CreateMessageResult,
8
- DBMessageItem,
9
8
  ModelRankItem,
10
9
  UIChatMessage,
11
10
  UpdateMessageParams,
@@ -19,7 +18,6 @@ import type { HeatmapsProps } from '@lobehub/charts';
19
18
  export interface IMessageService {
20
19
  createMessage(data: CreateMessageParams): Promise<string>;
21
20
  createNewMessage(data: CreateMessageParams): Promise<CreateMessageResult>;
22
- batchCreateMessages(messages: DBMessageItem[]): Promise<any>;
23
21
 
24
22
  getMessages(sessionId: string, topicId?: string, groupId?: string): Promise<UIChatMessage[]>;
25
23
  getGroupMessages(groupId: string, topicId?: string): Promise<UIChatMessage[]>;