From f505d2792f6b4882ce5e38593fbf1be8d2b28afe Mon Sep 17 00:00:00 2001 From: Linghong Date: Sat, 12 Sep 2026 07:33:49 +0000 Subject: [PATCH] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=8D=9F=E5=9D=8F=E7=AD=96?= =?UTF-8?q?=E5=88=92=E4=BC=9A=E8=AF=9D=E9=99=8D=E7=BA=A7=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 会话读取失败时保留工作台与产物访问能力 新增策划会话备份重置命令,不删除工作区产物 --- .../src-tauri/src/agent/design_runtime.rs | 18 ++++++++++++++++++ .../src-tauri/src/main.rs | 1 + apps/ai-game-creator-shell/src/App.tsx | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/design_runtime.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/design_runtime.rs index 7c6f2d4db..3fad0ae77 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/design_runtime.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/design_runtime.rs @@ -845,6 +845,24 @@ pub(crate) fn hydrate_design_agent_session( Ok(Some(design_view(&session, active.is_none()))) } +#[tauri::command] +pub(crate) fn reset_design_agent_session(project_path: String) -> Result<(), String> { + let root = Path::new(project_path.trim()); + enforce_project_permission_policy(root, "conversation.write")?; + design_project_id(root)?; + let _lock = acquire_game_creator_agent_runtime_project_write_lock_with_wait( + root, + "design.session-reset", + )?; + let path = crate::agent::runtime_protocol::design_session_path(root); + if path.exists() { + let backup = path.with_file_name(format!("session.corrupted.{}.json", unix_timestamp())); + std::fs::rename(&path, &backup) + .map_err(|error| format!("备份损坏的策划会话失败:{error}"))?; + } + Ok(()) +} + #[tauri::command] pub(crate) fn get_design_agent_runtime_mode( 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 5be012475..8fc62362c 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -2583,6 +2583,7 @@ fn main() { decide_planning_artifact_v2, hydrate_planning_session_v2, hydrate_design_agent_session, + reset_design_agent_session, get_design_agent_runtime_mode, set_design_agent_runtime_mode, debug_fast_forward_design_session, diff --git a/apps/ai-game-creator-shell/src/App.tsx b/apps/ai-game-creator-shell/src/App.tsx index 21ab10253..cc58ed5c8 100644 --- a/apps/ai-game-creator-shell/src/App.tsx +++ b/apps/ai-game-creator-shell/src/App.tsx @@ -3117,7 +3117,9 @@ export function App({ } } catch (error) { if (planningStartMode) { - throw error; + setPlanGddError( + `策划会话无法恢复:${error instanceof Error ? error.message : String(error)}`, + ); } } try {