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}