feat: 添加 :new 系统命令创建新会话

- Core: 新增 :new/:n 命令返回 new_session action
- Server: 处理 new_session action 创建新会话
- UI: useChat 添加 onSessionSwitch 回调
- Web/Desktop: ChatPage 和 App 实现会话切换逻辑
This commit is contained in:
2025-12-17 19:36:47 +08:00
parent e0444a966f
commit 48a11ff077
7 changed files with 63 additions and 4 deletions
+6
View File
@@ -103,6 +103,11 @@ export function App() {
setSessionTitleUpdate({ sessionId, name });
}, []);
// 会话切换回调(:new 命令创建新会话后切换)
const handleSessionSwitch = useCallback((newSessionId: string) => {
setCurrentSessionId(newSessionId);
}, []);
// 处理面板宽度调整
const handleResize = useCallback((delta: number) => {
setIdePanelWidth((prev) => {
@@ -159,6 +164,7 @@ export function App() {
sessionId={currentSessionId}
onSessionNotFound={handleSessionNotFound}
onSessionUpdated={handleSessionUpdated}
onSessionSwitch={handleSessionSwitch}
responsive
onOpenCommands={() => setShowCommands(true)}
onOpenMCP={() => setShowMCP(true)}
+4
View File
@@ -22,6 +22,8 @@ interface ChatPageProps {
sessionId: string;
onSessionNotFound?: () => void;
onSessionUpdated?: (sessionId: string, name: string) => void;
/** 切换会话回调(如 :new 命令创建新会话) */
onSessionSwitch?: (newSessionId: string) => void;
responsive?: boolean;
// 工具栏按钮
onOpenCommands?: () => void;
@@ -39,6 +41,7 @@ export function ChatPage({
sessionId,
onSessionNotFound,
onSessionUpdated,
onSessionSwitch,
responsive = false,
onOpenCommands,
onOpenMCP,
@@ -74,6 +77,7 @@ export function ChatPage({
},
onSessionNotFound,
onSessionUpdated,
onSessionSwitch,
onConfigError: (error) => {
toast.error(error.message, {
duration: 10000,