From 6e63a118e0aa3f9e63a58ea94c3bc46e52ac44c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Fri, 18 Sep 2026 12:53:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E5=90=8E=E8=B5=84=E6=BA=90=E8=8D=89?= =?UTF-8?q?=E7=A8=BF=E7=9B=B4=E5=88=B0=E7=B4=A0=E6=9D=90=E7=B4=A2=E5=BC=95?= =?UTF-8?q?=E5=8F=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免初始编辑器挂载时 assetsById 为空导致资源引用永久丢失。 保留 Lexical 节点自行解析资产名称的后续 TODO。 --- .../project-workspace/ResourceReferenceInput.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx index b061cf091..033931eb8 100644 --- a/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx +++ b/apps/ai-game-creator-shell/src/features/project-workspace/ResourceReferenceInput.tsx @@ -726,6 +726,20 @@ function ResourceReferenceEditor({ if (initialDraftAppliedRef.current || !initialContent) { return; } + // Manifest assets can arrive after the initial editor mount. Do not mark the + // draft as applied while resource references still have no lookup table; + // otherwise the later assetsById update cannot restore those references. + const hasUnresolvedResourceReference = initialContent.some( + (part) => + part.type === 'agc_resource_reference' && + !assetsById.has(part.resourceId), + ); + if (hasUnresolvedResourceReference && assetsById.size === 0) { + return; + } + // TODO: let the Lexical resource node resolve its asset label from the + // manifest itself, so unresolved references can remain as nodes while the + // manifest loads instead of waiting in this effect. initialDraftAppliedRef.current = true; editor.update(() => { applyContentToRoot(initialContent, assetsById);