From 86adaa738fb8810d7234773b7c20d8640f9dc4fb Mon Sep 17 00:00:00 2001 From: Linghong Date: Sat, 12 Sep 2026 00:48:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AD=96=E5=88=92=E9=A6=96?= =?UTF-8?q?=E8=BD=AE=E9=94=99=20lane=20=E6=8C=82=E8=BD=BD=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=20Agent=20=E4=B8=8D=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 运行模式改为随项目上下文同步派生,移除 effect 后置修正 做成游戏切换记录按项目路径与创建时间定位,跨项目自动失效 消除首帧游戏运行时挂载消耗首轮 claim 后策划实例无法补发的问题 --- .../features/app-shell/WorkspaceLauncher.tsx | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) 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 1d4ccf8e5..2d5c33203 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 @@ -58,10 +58,13 @@ export function WorkspaceLauncherShell({ title: string; message: string; } | null>(null); - const [agentRuntimeMode, setAgentRuntimeMode] = useState<'design' | 'game'>( - 'game', - ); - const [suppressInitialGameTurn, setSuppressInitialGameTurn] = useState(false); + // 「做成游戏」切换记录按项目上下文(路径 + createdAt)定位。运行模式必须随 + // currentProjectContext 同步派生,不能靠 effect 后置修正:首帧挂错 lane 会先 + // 以游戏运行时挂载并消耗首轮 claim,重挂后的策划实例再也发不出首轮。 + const [gameRuntimeSwitch, setGameRuntimeSwitch] = useState<{ + projectPath: string; + createdAt: number; + } | null>(null); const developerAgent = useDeveloperAgentPanel(launcherView); const homeProject = useHomeProjectCreation({ setStatus, @@ -85,15 +88,17 @@ export function WorkspaceLauncherShell({ createHomeDraftAutomatically, openProject, } = homeProject; - useEffect(() => { - setSuppressInitialGameTurn(false); - setAgentRuntimeMode( - currentProjectContext?.startMode === 'planning' ? 'design' : 'game', - ); - }, [currentProjectContext?.projectPath, currentProjectContext?.startMode]); + const switchedToGameRuntime = + gameRuntimeSwitch !== null && + currentProjectContext !== null && + gameRuntimeSwitch.projectPath === currentProjectContext.projectPath && + gameRuntimeSwitch.createdAt === currentProjectContext.createdAt; const planningStartMode = - currentProjectContext?.startMode === 'planning' && - (agentRuntimeMode === 'design' || !suppressInitialGameTurn); + currentProjectContext?.startMode === 'planning' && !switchedToGameRuntime; + const agentRuntimeMode: 'design' | 'game' = planningStartMode + ? 'design' + : 'game'; + const suppressInitialGameTurn = switchedToGameRuntime; const activeProjectContextRef = useRef(currentProjectContext); const manifestMergeRef = useRef(null); activeProjectContextRef.current = currentProjectContext; @@ -258,8 +263,10 @@ export function WorkspaceLauncherShell({ projectPath: nextProjectPath, activeRuntime: 'game', }); - setSuppressInitialGameTurn(true); - setAgentRuntimeMode('game'); + setGameRuntimeSwitch({ + projectPath: nextProjectPath, + createdAt: currentProjectContext?.createdAt ?? 0, + }); } const currentHelpTitle =