From 77d3917d9c7fbce23d325f4f21f204911449cde7 Mon Sep 17 00:00:00 2001 From: Linghong Date: Tue, 15 Sep 2026 04:22:45 +0000 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=AD=96=E5=88=92=20Agent=20?= =?UTF-8?q?Debug=20=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 策划 Debug 日志与快速推进入口共用 GENARRATIVE_AGC_DESIGN_DEBUG。 通过 Tauri 查询构建与运行时状态,移除前端 VITE Debug 开关依赖。 更新开发启动器、策划工作区测试和技术方案文档。 --- .../scripts/start-tauri-dev.mjs | 3 --- .../src-tauri/src/agent/design_runtime.rs | 25 +++++++++++-------- .../src-tauri/src/main.rs | 1 + .../DesignWorkspacePanel.tsx | 13 +++++++++- .../tests/designWorkspaceDebug.test.tsx | 4 ++- ...】策划Agent生产迁移与工作区浏览-2026-09-10.md | 2 +- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/apps/ai-game-creator-shell/scripts/start-tauri-dev.mjs b/apps/ai-game-creator-shell/scripts/start-tauri-dev.mjs index 0ce7e6a2b..3ab0f2ced 100644 --- a/apps/ai-game-creator-shell/scripts/start-tauri-dev.mjs +++ b/apps/ai-game-creator-shell/scripts/start-tauri-dev.mjs @@ -22,7 +22,6 @@ const appRoot = fileURLToPath(new URL('..', import.meta.url)); const repoRoot = resolve(appRoot, '../..'); const tauriCliPath = resolve(repoRoot, 'node_modules/@tauri-apps/cli/tauri.js'); const AGC_DESIGN_DEBUG_ENV = 'GENARRATIVE_AGC_DESIGN_DEBUG'; -const AGC_DESIGN_DEBUG_VITE_ENV = 'VITE_GENARRATIVE_AGC_DESIGN_DEBUG'; const designDebugEnabled = process.env[AGC_DESIGN_DEBUG_ENV]?.trim() === '0' ? '0' : '1'; @@ -137,7 +136,6 @@ async function runTauriDev( env: { ...withAgcDevEndpointEnv(endpoint), [AGC_DESIGN_DEBUG_ENV]: designDebugEnabled, - [AGC_DESIGN_DEBUG_VITE_ENV]: designDebugEnabled, }, }); const childResult = waitForCli(child); @@ -191,7 +189,6 @@ async function prepareFrontendDev(endpoint, { onChild, signal }) { cwd: repoRoot, env: { ...withAgcDevEndpointEnv(endpoint), - [AGC_DESIGN_DEBUG_VITE_ENV]: designDebugEnabled, }, }, ); 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 2d24a4997..38e7a2f8a 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 @@ -606,11 +606,7 @@ fn build_design_request( // 调试队列只接收副本,写盘慢或失败时丢弃,不参与会话恢复。 fn design_debug(root: &Path, kind: &str, data: Value) { - if std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG") - .ok() - .as_deref() - != Some("1") - { + if !design_debug_enabled() { return; } type Entry = (PathBuf, Value); @@ -1133,6 +1129,18 @@ fn resolve_design_runtime_mode(root: &Path) -> Result, })) } +fn design_debug_enabled() -> bool { + std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG") + .ok() + .as_deref() + == Some("1") +} + +#[tauri::command] +pub(crate) fn is_design_agent_debug_enabled() -> bool { + cfg!(debug_assertions) && design_debug_enabled() +} + #[tauri::command] pub(crate) fn set_design_agent_runtime_mode( project_path: String, @@ -1159,12 +1167,7 @@ pub(crate) fn debug_fast_forward_design_session( project_path: String, target_phase: String, ) -> Result { - if !cfg!(debug_assertions) - || std::env::var("GENARRATIVE_AGC_DESIGN_DEBUG") - .ok() - .as_deref() - != Some("1") - { + if !is_design_agent_debug_enabled() { return Err("策划 Agent 快速推进仅可用于 Debug 构建".to_string()); } let root = Path::new(project_path.trim()); 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 5d93e78bc..2f2f5b7e2 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -2672,6 +2672,7 @@ fn main() { hydrate_design_agent_session, reset_design_agent_session, get_design_agent_runtime_mode, + is_design_agent_debug_enabled, set_design_agent_runtime_mode, debug_fast_forward_design_session, continue_design_agent_session, diff --git a/apps/ai-game-creator-shell/src/features/project-workspace/DesignWorkspacePanel.tsx b/apps/ai-game-creator-shell/src/features/project-workspace/DesignWorkspacePanel.tsx index 53d01cbe1..c651a5764 100644 --- a/apps/ai-game-creator-shell/src/features/project-workspace/DesignWorkspacePanel.tsx +++ b/apps/ai-game-creator-shell/src/features/project-workspace/DesignWorkspacePanel.tsx @@ -185,6 +185,7 @@ export function DesignWorkspacePanel({ const [loading, setLoading] = useState(true); const [previewLoading, setPreviewLoading] = useState(false); const [debugPreparing, setDebugPreparing] = useState(false); + const [designDebugEnabled, setDesignDebugEnabled] = useState(false); const [error, setError] = useState(''); const [expandedPaths, setExpandedPaths] = useState>( () => new Set(), @@ -264,6 +265,16 @@ export function DesignWorkspacePanel({ void loadWorkspace({ showLoading: true, hydrateSession: true }); }, [loadWorkspace]); + useEffect(() => { + const invoke = resolveTauriInvoke(); + if (!invoke) { + return; + } + void invoke('is_design_agent_debug_enabled') + .then(setDesignDebugEnabled) + .catch(() => setDesignDebugEnabled(false)); + }, []); + useEffect(() => { if (!canSubscribeTauriEvents() || !projectPath.trim()) { return; @@ -360,7 +371,7 @@ export function DesignWorkspacePanel({

Agent 产生的策划文档会显示在这里。

- {import.meta.env.VITE_GENARRATIVE_AGC_DESIGN_DEBUG === '1' ? ( + {designDebugEnabled ? (