@lobehub/chat 1.96.17 → 1.96.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.
- package/.cursor/rules/backend-architecture.mdc +54 -51
- package/.cursor/rules/code-review.mdc +69 -0
- package/.cursor/rules/cursor-rules.mdc +28 -0
- package/.cursor/rules/cursor-ux.mdc +94 -0
- package/.cursor/rules/debug.mdc +193 -0
- package/.cursor/rules/i18n/i18n.mdc +66 -68
- package/.cursor/rules/packages/react-layout-kit.mdc +19 -26
- package/.cursor/rules/react-component.mdc +91 -6
- package/.cursor/rules/rules-attach.mdc +76 -0
- package/.cursor/rules/system-role.mdc +2 -6
- package/.cursor/rules/testing-guide.mdc +881 -0
- package/.cursor/rules/typescript.mdc +19 -0
- package/.cursor/rules/zustand-action-patterns.mdc +57 -15
- package/.cursor/rules/zustand-slice-organization.mdc +12 -12
- package/CHANGELOG.md +33 -0
- package/changelog/v1.json +12 -0
- package/package.json +1 -1
- package/src/app/[variants]/(main)/files/(content)/NotSupportClient.tsx +8 -1
- package/src/config/modelProviders/github.ts +1 -1
- package/.cursor/rules/cursor-ux-optimize.mdc +0 -27
- package/.cursor/rules/packages/lobe-ui.mdc +0 -72
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
description:
|
3
|
+
globs: *.ts,*.tsx,*.mts
|
4
|
+
alwaysApply: false
|
5
|
+
---
|
6
|
+
|
7
|
+
TypeScript Code Style Guide:
|
8
|
+
|
9
|
+
- Avoid explicit type annotations when TypeScript can infer types.
|
10
|
+
- Avoid defining `any` type variables (e.g., `let a: number;` instead of `let a;`).
|
11
|
+
- Use the most accurate type possible (e.g., use `Record<PropertyKey, unknown>` instead of `object`).
|
12
|
+
- Prefer `interface` over `type` (e.g., define react component props).
|
13
|
+
- Use `as const satisfies XyzInterface` instead of `as const` when suitable
|
14
|
+
- import index.ts module(directory module) like `@/db/index` instead of `@/db`
|
15
|
+
- Instead of calling Date.now() multiple times, assign it to a constant once and reuse it. This ensures consistency and improves readability
|
16
|
+
- Always refactor repeated logic into a reusable function
|
17
|
+
- Don't remove meaningful code comments, be sure to keep original comments when providing applied code
|
18
|
+
- Update the code comments when needed after you modify the related code
|
19
|
+
- Please respect my prettier preferences when you provide code
|
@@ -87,7 +87,7 @@ internal_dispatchTopic: (payload, action) => {
|
|
87
87
|
|
88
88
|
### 使用 Reducer 模式的场景
|
89
89
|
|
90
|
-
|
90
|
+
适用于复杂的数据结构管理,特别是:
|
91
91
|
- 管理对象列表或映射(如 `messagesMap`, `topicMaps`)
|
92
92
|
- 需要乐观更新的场景
|
93
93
|
- 状态转换逻辑复杂
|
@@ -125,7 +125,7 @@ export const messagesReducer = (state: ChatMessage[], payload: MessageDispatch):
|
|
125
125
|
|
126
126
|
### 使用简单 `set` 的场景
|
127
127
|
|
128
|
-
|
128
|
+
适用于简单状态更新:
|
129
129
|
- 切换布尔值
|
130
130
|
- 更新简单字符串/数字
|
131
131
|
- 设置单一状态字段
|
@@ -204,6 +204,43 @@ internal_createMessage: async (message, context) => {
|
|
204
204
|
},
|
205
205
|
```
|
206
206
|
|
207
|
+
### 删除操作模式(不使用乐观更新)
|
208
|
+
|
209
|
+
删除操作通常不适合乐观更新,因为:
|
210
|
+
- 删除是破坏性操作,错误恢复复杂
|
211
|
+
- 用户对删除操作的即时反馈期望较低
|
212
|
+
- 删除失败时恢复原状态会造成困惑
|
213
|
+
|
214
|
+
```typescript
|
215
|
+
// 删除操作的标准模式 - 无乐观更新
|
216
|
+
removeGenerationTopic: async (id: string) => {
|
217
|
+
const { internal_removeGenerationTopic } = get();
|
218
|
+
await internal_removeGenerationTopic(id);
|
219
|
+
},
|
220
|
+
|
221
|
+
internal_removeGenerationTopic: async (id: string) => {
|
222
|
+
// 1. 显示加载状态
|
223
|
+
get().internal_updateGenerationTopicLoading(id, true);
|
224
|
+
|
225
|
+
try {
|
226
|
+
// 2. 直接调用后端服务
|
227
|
+
await generationTopicService.deleteTopic(id);
|
228
|
+
|
229
|
+
// 3. 刷新数据获取最新状态
|
230
|
+
await get().refreshGenerationTopics();
|
231
|
+
} finally {
|
232
|
+
// 4. 确保清除加载状态(无论成功或失败)
|
233
|
+
get().internal_updateGenerationTopicLoading(id, false);
|
234
|
+
}
|
235
|
+
},
|
236
|
+
```
|
237
|
+
|
238
|
+
删除操作的特点:
|
239
|
+
- 直接调用服务,不预先更新状态
|
240
|
+
- 依赖 loading 状态提供用户反馈
|
241
|
+
- 操作完成后刷新整个列表确保一致性
|
242
|
+
- 使用 `try/finally` 确保 loading 状态总是被清理
|
243
|
+
|
207
244
|
## 加载状态管理模式
|
208
245
|
|
209
246
|
LobeChat 使用统一的加载状态管理模式:
|
@@ -292,27 +329,32 @@ refreshTopic: async () => {
|
|
292
329
|
## 命名规范总结
|
293
330
|
|
294
331
|
### Action 命名模式
|
295
|
-
-
|
332
|
+
- Public Actions: 动词形式,描述用户意图
|
296
333
|
- `createTopic`, `sendMessage`, `regenerateMessage`
|
297
|
-
-
|
334
|
+
- Internal Actions: `internal_` + 动词,描述内部操作
|
298
335
|
- `internal_createTopic`, `internal_updateMessageContent`
|
299
|
-
-
|
336
|
+
- Dispatch Methods: `internal_dispatch` + 实体名
|
300
337
|
- `internal_dispatchTopic`, `internal_dispatchMessage`
|
301
|
-
-
|
338
|
+
- Toggle Methods: `internal_toggle` + 状态名
|
302
339
|
- `internal_toggleMessageLoading`, `internal_toggleChatLoading`
|
303
340
|
|
304
341
|
### 状态命名模式
|
305
|
-
-
|
306
|
-
-
|
307
|
-
-
|
308
|
-
-
|
342
|
+
- ID 数组: `[entity]LoadingIds`, `[entity]EditingIds`
|
343
|
+
- 映射结构: `[entity]Maps`, `[entity]Map`
|
344
|
+
- 当前激活: `active[Entity]Id`
|
345
|
+
- 初始化标记: `[entity]sInit`
|
309
346
|
|
310
347
|
## 最佳实践
|
311
348
|
|
312
|
-
1.
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
349
|
+
1. 合理使用乐观更新:
|
350
|
+
- ✅ 适用:创建、更新操作(用户交互频繁)
|
351
|
+
- ❌ 避免:删除操作(破坏性操作,错误恢复复杂)
|
352
|
+
2. 加载状态管理:使用统一的加载状态数组管理并发操作
|
353
|
+
3. 类型安全:为所有 action payload 定义 TypeScript 接口
|
354
|
+
4. SWR 集成:使用 SWR 管理数据获取和缓存失效
|
355
|
+
5. AbortController:为长时间运行的操作提供取消能力
|
356
|
+
6. 操作模式选择:
|
357
|
+
- 创建/更新:乐观更新 + 最终一致性
|
358
|
+
- 删除:加载状态 + 服务调用 + 数据刷新
|
317
359
|
|
318
360
|
这套 Action 组织模式确保了代码的一致性、可维护性,并提供了优秀的用户体验。
|
@@ -13,10 +13,10 @@ LobeChat 的 `chat` store (`src/store/chat/`) 采用模块化的 slice 结构来
|
|
13
13
|
|
14
14
|
### 关键聚合文件
|
15
15
|
|
16
|
-
-
|
17
|
-
-
|
18
|
-
-
|
19
|
-
-
|
16
|
+
- `src/store/chat/initialState.ts`: 聚合所有 slice 的初始状态
|
17
|
+
- `src/store/chat/store.ts`: 定义顶层的 `ChatStore`,组合所有 slice 的 actions
|
18
|
+
- `src/store/chat/selectors.ts`: 统一导出所有 slice 的 selectors
|
19
|
+
- `src/store/chat/helpers.ts`: 提供聊天相关的辅助函数
|
20
20
|
|
21
21
|
### Store 聚合模式
|
22
22
|
|
@@ -81,7 +81,7 @@ src/store/chat/slices/
|
|
81
81
|
|
82
82
|
### 文件职责说明
|
83
83
|
|
84
|
-
1.
|
84
|
+
1. `initialState.ts`:
|
85
85
|
- 定义 slice 的 TypeScript 状态接口
|
86
86
|
- 提供初始状态默认值
|
87
87
|
|
@@ -104,7 +104,7 @@ export const initialTopicState: ChatTopicState = {
|
|
104
104
|
};
|
105
105
|
```
|
106
106
|
|
107
|
-
2.
|
107
|
+
2. `reducer.ts` (复杂状态使用):
|
108
108
|
- 定义纯函数 reducer,处理同步状态转换
|
109
109
|
- 使用 `immer` 确保不可变更新
|
110
110
|
|
@@ -150,10 +150,10 @@ export const topicReducer = (state: ChatTopic[] = [], payload: ChatTopicDispatch
|
|
150
150
|
};
|
151
151
|
```
|
152
152
|
|
153
|
-
3.
|
153
|
+
3. `selectors.ts`:
|
154
154
|
- 提供状态查询和计算函数
|
155
155
|
- 供 UI 组件使用的状态订阅接口
|
156
|
-
-
|
156
|
+
- 重要: 使用 `export const xxxSelectors` 模式聚合所有 selectors
|
157
157
|
|
158
158
|
```typescript
|
159
159
|
// 典型的 selectors.ts 结构
|
@@ -277,22 +277,22 @@ export { aiChatSelectors } from './slices/aiChat/selectors';
|
|
277
277
|
|
278
278
|
## 最佳实践
|
279
279
|
|
280
|
-
1.
|
280
|
+
1. Slice 划分原则:
|
281
281
|
- 按功能领域划分(message, topic, aiChat 等)
|
282
282
|
- 每个 slice 管理相关的状态和操作
|
283
283
|
- 避免 slice 之间的强耦合
|
284
284
|
|
285
|
-
2.
|
285
|
+
2. 文件命名规范:
|
286
286
|
- 使用小驼峰命名 slice 目录
|
287
287
|
- 文件名使用一致的模式(action.ts, selectors.ts 等)
|
288
288
|
- 复杂 actions 时使用 actions/ 子目录
|
289
289
|
|
290
|
-
3.
|
290
|
+
3. 状态结构设计:
|
291
291
|
- 扁平化的状态结构,避免深层嵌套
|
292
292
|
- 使用 Map 结构管理列表数据
|
293
293
|
- 分离加载状态和业务数据
|
294
294
|
|
295
|
-
4.
|
295
|
+
4. 类型安全:
|
296
296
|
- 为每个 slice 定义清晰的 TypeScript 接口
|
297
297
|
- 使用 Zustand 的 StateCreator 确保类型一致性
|
298
298
|
- 在顶层聚合时保持类型安全
|
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,39 @@
|
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
5
|
+
### [Version 1.96.18](https://github.com/lobehub/lobe-chat/compare/v1.96.17...v1.96.18)
|
6
|
+
|
7
|
+
<sup>Released on **2025-07-06**</sup>
|
8
|
+
|
9
|
+
#### 🐛 Bug Fixes
|
10
|
+
|
11
|
+
- **misc**: Change the wrong github checkmodel name.
|
12
|
+
|
13
|
+
#### 💄 Styles
|
14
|
+
|
15
|
+
- **misc**: Files hello pages should scroll.
|
16
|
+
|
17
|
+
<br/>
|
18
|
+
|
19
|
+
<details>
|
20
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
21
|
+
|
22
|
+
#### What's fixed
|
23
|
+
|
24
|
+
- **misc**: Change the wrong github checkmodel name, closes [#8339](https://github.com/lobehub/lobe-chat/issues/8339) ([f07d912](https://github.com/lobehub/lobe-chat/commit/f07d912))
|
25
|
+
|
26
|
+
#### Styles
|
27
|
+
|
28
|
+
- **misc**: Files hello pages should scroll, closes [#8340](https://github.com/lobehub/lobe-chat/issues/8340) ([df9b7df](https://github.com/lobehub/lobe-chat/commit/df9b7df))
|
29
|
+
|
30
|
+
</details>
|
31
|
+
|
32
|
+
<div align="right">
|
33
|
+
|
34
|
+
[](#readme-top)
|
35
|
+
|
36
|
+
</div>
|
37
|
+
|
5
38
|
### [Version 1.96.17](https://github.com/lobehub/lobe-chat/compare/v1.96.16...v1.96.17)
|
6
39
|
|
7
40
|
<sup>Released on **2025-07-03**</sup>
|
package/changelog/v1.json
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
[
|
2
|
+
{
|
3
|
+
"children": {
|
4
|
+
"fixes": [
|
5
|
+
"Change the wrong github checkmodel name."
|
6
|
+
],
|
7
|
+
"improvements": [
|
8
|
+
"Files hello pages should scroll."
|
9
|
+
]
|
10
|
+
},
|
11
|
+
"date": "2025-07-06",
|
12
|
+
"version": "1.96.18"
|
13
|
+
},
|
2
14
|
{
|
3
15
|
"children": {},
|
4
16
|
"date": "2025-07-03",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lobehub/chat",
|
3
|
-
"version": "1.96.
|
3
|
+
"version": "1.96.18",
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot 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",
|
@@ -88,7 +88,14 @@ const NotSupportClient = () => {
|
|
88
88
|
];
|
89
89
|
|
90
90
|
return (
|
91
|
-
<Center
|
91
|
+
<Center
|
92
|
+
gap={40}
|
93
|
+
height={'100%'}
|
94
|
+
style={{
|
95
|
+
overflow: 'scroll',
|
96
|
+
}}
|
97
|
+
width={'100%'}
|
98
|
+
>
|
92
99
|
<Flexbox className={styles.iconGroup} gap={12} horizontal>
|
93
100
|
<Center
|
94
101
|
className={styles.icon}
|
@@ -256,7 +256,7 @@ const Github: ModelProviderCard = {
|
|
256
256
|
maxOutput: 4096,
|
257
257
|
},
|
258
258
|
],
|
259
|
-
checkModel: 'Phi-3-mini-4k-instruct',
|
259
|
+
checkModel: 'microsoft/Phi-3-mini-4k-instruct',
|
260
260
|
// Ref: https://github.blog/news-insights/product-news/introducing-github-models/
|
261
261
|
description: '通过GitHub模型,开发人员可以成为AI工程师,并使用行业领先的AI模型进行构建。',
|
262
262
|
id: 'github',
|
@@ -1,27 +0,0 @@
|
|
1
|
-
---
|
2
|
-
description:
|
3
|
-
globs:
|
4
|
-
alwaysApply: false
|
5
|
-
---
|
6
|
-
## Formatting Response
|
7
|
-
|
8
|
-
This is about how you should format your responses.
|
9
|
-
|
10
|
-
### Render Markdown Table
|
11
|
-
|
12
|
-
- Be aware that the cursor chat you are in can't render markdown table correctly.
|
13
|
-
- IMPORTANT: Tables need to be rendered in plain text and not markdown
|
14
|
-
|
15
|
-
When rendering tables, do not use markdown table syntax or plain text alone. Instead, place the entire table inside a code/text block (using triple backticks). This ensures the table formatting is preserved and readable in the chat interface.
|
16
|
-
|
17
|
-
Example:
|
18
|
-
|
19
|
-
```plaintext
|
20
|
-
+----+---------+-----------+
|
21
|
-
| ID | Name | Role |
|
22
|
-
+----+---------+-----------+
|
23
|
-
| 1 | Alice | Admin |
|
24
|
-
| 2 | Bob | User |
|
25
|
-
| 3 | Charlie | Moderator |
|
26
|
-
+----+---------+-----------+
|
27
|
-
```
|
@@ -1,72 +0,0 @@
|
|
1
|
-
---
|
2
|
-
description: @lobehub/ui components list
|
3
|
-
globs:
|
4
|
-
alwaysApply: false
|
5
|
-
---
|
6
|
-
## @lobehub/ui Components
|
7
|
-
|
8
|
-
- General
|
9
|
-
ActionIcon
|
10
|
-
ActionIconGroup
|
11
|
-
Block
|
12
|
-
Button
|
13
|
-
Icon
|
14
|
-
- Data Display
|
15
|
-
Avatar
|
16
|
-
Collapse
|
17
|
-
FileTypeIcon
|
18
|
-
FluentEmoji
|
19
|
-
GuideCard
|
20
|
-
Highlighter
|
21
|
-
Hotkey
|
22
|
-
Image
|
23
|
-
List
|
24
|
-
Markdown
|
25
|
-
MaterialFileTypeIcon
|
26
|
-
Mermaid
|
27
|
-
Segmented
|
28
|
-
Snippet
|
29
|
-
SortableList
|
30
|
-
Tag
|
31
|
-
Tooltip
|
32
|
-
Video
|
33
|
-
- Data Entry
|
34
|
-
AutoComplete
|
35
|
-
CodeEditor
|
36
|
-
ColorSwatches
|
37
|
-
CopyButton
|
38
|
-
DatePicker
|
39
|
-
EditableText
|
40
|
-
EmojiPicker
|
41
|
-
Form
|
42
|
-
FormModal
|
43
|
-
HotkeyInput
|
44
|
-
ImageSelect
|
45
|
-
Input
|
46
|
-
SearchBar
|
47
|
-
Select
|
48
|
-
SliderWithInput
|
49
|
-
ThemeSwitch
|
50
|
-
- Feedback
|
51
|
-
Alert
|
52
|
-
Drawer
|
53
|
-
Modal
|
54
|
-
- Layout
|
55
|
-
DraggablePanel
|
56
|
-
Footer
|
57
|
-
Grid
|
58
|
-
Header
|
59
|
-
Layout
|
60
|
-
MaskShadow
|
61
|
-
ScrollShadow
|
62
|
-
- Navigation
|
63
|
-
Burger
|
64
|
-
Dropdown
|
65
|
-
Menu
|
66
|
-
SideNav
|
67
|
-
Tabs
|
68
|
-
Toc
|
69
|
-
- Theme
|
70
|
-
ConfigProvider
|
71
|
-
FontLoader
|
72
|
-
ThemeProvider
|