feat: 添加 :new 系统命令创建新会话
- Core: 新增 :new/:n 命令返回 new_session action - Server: 处理 new_session action 创建新会话 - UI: useChat 添加 onSessionSwitch 回调 - Web/Desktop: ChatPage 和 App 实现会话切换逻辑
This commit is contained in:
@@ -322,7 +322,19 @@ async function handleSystemCommand(sessionId: string, content: string): Promise<
|
||||
sessionManager.updateStatus(sessionId, 'idle');
|
||||
break;
|
||||
}
|
||||
// 可以在这里添加其他操作类型的处理
|
||||
|
||||
case 'new_session': {
|
||||
// 获取当前会话信息以复用配置
|
||||
const currentSession = sessionManager.get(sessionId);
|
||||
const workdir = currentSession?.workdir || process.cwd();
|
||||
|
||||
// 创建新会话
|
||||
const newSession = await sessionManager.create({ workdir });
|
||||
|
||||
// 更新 action 中的 sessionId
|
||||
result.action = { type: 'new_session', sessionId: newSession.id };
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user