feat: 添加会话标题自动生成功能

- 后端:首次 AI 回复后自动从用户消息提取标题
- 后端:通过 WebSocket 推送 session_updated 事件
- 前端:useChat hook 处理标题更新事件
- 前端:Sidebar 组件实时更新会话标题显示
This commit is contained in:
2025-12-12 17:45:17 +08:00
parent f561687307
commit 65a23f1e71
9 changed files with 141 additions and 3 deletions
+16
View File
@@ -253,6 +253,22 @@ export class SessionManager {
return fullMessage;
}
/**
* 更新会话名称/标题
*/
async updateSessionName(sessionId: string, name: string): Promise<Session | undefined> {
const session = this.sessions.get(sessionId);
if (!session) return undefined;
session.name = name;
session.updatedAt = new Date().toISOString();
// 持久化
await this.persist(sessionId);
return session;
}
/**
* 获取会话数量
*/