From d77d0ca9eb57bfb5251dc90cf1c0222bcf8af688 Mon Sep 17 00:00:00 2001 From: Linghong Date: Fri, 11 Sep 2026 13:11:03 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=A1=BE=E9=97=AE=E6=80=81?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=B8=B8=E6=88=8F=E5=90=8E=E7=9A=84=E7=AD=96?= =?UTF-8?q?=E5=88=92=E5=88=86=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一 runtime mode 下的 planningStartMode 游戏运行态拒绝策划 Agent 续轮与阶段审批 补充游戏态运行时守卫测试 --- .../src-tauri/src/agent/design_runtime.rs | 22 +++++++++++++++++++ .../features/app-shell/WorkspaceLauncher.tsx | 1 + 2 files changed, 23 insertions(+) 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 0f6b61662..36e32fdff 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 @@ -767,6 +767,7 @@ pub(crate) async fn continue_design_agent_at( input: DesignInput, emit: impl FnMut(DesignEvent) + Send, ) -> Result { + ensure_design_runtime_active(root)?; let project_id = design_project_id(root)?; ensure_design_workspace(root)?; let active = try_open_game_creator_agent_runtime_task_lock_file(root, DESIGN_ACTIVE_LOCK)? @@ -798,6 +799,7 @@ pub(crate) async fn decide_design_phase_at( approved: bool, emit: impl FnMut(DesignEvent) + Send, ) -> Result { + ensure_design_runtime_active(root)?; let project_id = design_project_id(root)?; ensure_design_workspace(root)?; let active = try_open_game_creator_agent_runtime_task_lock_file(root, DESIGN_ACTIVE_LOCK)? @@ -810,6 +812,16 @@ pub(crate) async fn decide_design_phase_at( finish_design_command(root, resources, session, active, run, emit).await } +fn ensure_design_runtime_active(root: &Path) -> Result<(), String> { + if read_design_runtime_mode(root)? + .as_ref() + .is_some_and(|mode| mode.active_runtime == "game") + { + return Err("当前项目已切换到游戏运行态,不能继续策划 Agent".into()); + } + Ok(()) +} + #[tauri::command] pub(crate) fn hydrate_design_agent_session( project_path: String, @@ -961,6 +973,16 @@ mod fake_provider { #[cfg(test)] mod tests { use super::*; + + #[test] + fn design_runtime_rejects_design_execution_in_game_mode() { + let temporary = tempfile::tempdir().expect("create runtime mode root"); + let root = temporary.path(); + write_design_runtime_mode(root, "game").expect("write game runtime mode"); + + let error = ensure_design_runtime_active(root).expect_err("game mode must reject design"); + assert!(error.contains("游戏运行态")); + } use serde_json::json; use std::fs; diff --git a/apps/ai-game-creator-shell/src/features/app-shell/WorkspaceLauncher.tsx b/apps/ai-game-creator-shell/src/features/app-shell/WorkspaceLauncher.tsx index 8ee4cde5c..bca56303b 100644 --- a/apps/ai-game-creator-shell/src/features/app-shell/WorkspaceLauncher.tsx +++ b/apps/ai-game-creator-shell/src/features/app-shell/WorkspaceLauncher.tsx @@ -383,6 +383,7 @@ export function WorkspaceLauncherShell({ orchestrationMode="single-supervisor" projectSupervisorOnly planningStartMode={ + agentRuntimeMode === 'design' && currentProjectContext.startMode === 'planning' } playRequest={playRequest}