From 7791bd7de08e55291ef2c3b713c12b2734ec108f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 5 Sep 2026 10:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=20DirectProject=20=E5=AF=B9?= =?UTF-8?q?=E8=AF=9D=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 DirectProject 专用读写命令 恢复 legacy 对话命令的单一职责 更新工作台 DirectProject 读取调用 --- .../src-tauri/src/commands.rs | 35 ++++++++++++------- .../src-tauri/src/main.rs | 2 ++ apps/ai-game-creator-shell/src/App.tsx | 11 +++--- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/commands.rs b/apps/ai-game-creator-shell/src-tauri/src/commands.rs index aef229a17..73ea34142 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/commands.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/commands.rs @@ -4708,12 +4708,18 @@ pub(crate) fn read_local_conversation( ) -> Result { let root = Path::new(project_path.trim()); enforce_project_permission_policy(root, "conversation.read")?; - if agent_id.is_none() && session_id.is_none() { - return read_direct_project_chat_history_at(root); - } read_local_conversation_for_session_at(root, agent_id.as_deref(), session_id.as_deref()) } +#[tauri::command] +pub(crate) fn read_direct_project_conversation( + project_path: String, +) -> Result { + let root = Path::new(project_path.trim()); + enforce_project_permission_policy(root, "conversation.read")?; + read_direct_project_chat_history_at(root) +} + #[tauri::command] pub(crate) fn append_local_conversation_message( project_path: String, @@ -4724,15 +4730,6 @@ pub(crate) fn append_local_conversation_message( ) -> Result { let root = Path::new(project_path.trim()); enforce_project_permission_policy(root, "conversation.write")?; - if agent_id.is_none() && session_id.is_none() { - let item = direct_project_local_message_item( - &message.role, - &message.content, - message_id.as_deref(), - )?; - append_direct_project_history_item_at(root, &item)?; - return read_direct_project_chat_history_at(root); - } let _lock = acquire_project_write_lock(root, "conversation.write")?; match message_id.as_deref() { Some(message_id) => append_local_conversation_message_for_session_idempotent_at( @@ -4751,6 +4748,20 @@ pub(crate) fn append_local_conversation_message( } } +#[tauri::command] +pub(crate) fn append_direct_project_conversation_message( + project_path: String, + message: LocalConversationMessage, + message_id: Option, +) -> Result { + let root = Path::new(project_path.trim()); + enforce_project_permission_policy(root, "conversation.write")?; + let item = + direct_project_local_message_item(&message.role, &message.content, message_id.as_deref())?; + append_direct_project_history_item_at(root, &item)?; + read_direct_project_chat_history_at(root) +} + #[tauri::command] pub(crate) fn build_local_project_index( project_path: String, diff --git a/apps/ai-game-creator-shell/src-tauri/src/main.rs b/apps/ai-game-creator-shell/src-tauri/src/main.rs index b49bd19d9..1f0e6345c 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -2573,7 +2573,9 @@ fn main() { set_active_game_creator_agent_session, archive_game_creator_agent_session, read_local_conversation, + read_direct_project_conversation, append_local_conversation_message, + append_direct_project_conversation_message, build_local_project_index, create_local_project_checkpoint, export_local_project_package, diff --git a/apps/ai-game-creator-shell/src/App.tsx b/apps/ai-game-creator-shell/src/App.tsx index 952319540..cadf990b4 100644 --- a/apps/ai-game-creator-shell/src/App.tsx +++ b/apps/ai-game-creator-shell/src/App.tsx @@ -2576,11 +2576,12 @@ export function App({ : await readProjectSupervisorActiveSession(invoke, nextProjectPath); let runtimeError = ''; const projectConversation = await invoke( - 'read_local_conversation', - { - projectPath: nextProjectPath, - agentId: null, - }, + directCodexProductRuntime + ? 'read_direct_project_conversation' + : 'read_local_conversation', + directCodexProductRuntime + ? { projectPath: nextProjectPath } + : { projectPath: nextProjectPath, agentId: null }, ); let supervisorConversation: LocalConversationResult | null = null; let runtime: AgentRuntimeState | null = null;