From f118e6b77ca201a3e947fafcb23c6f1a46e21fc2 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Mon, 5 Oct 2026 23:53:08 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=A7=E7=BB=AD=E6=94=B6=E6=95=9B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=B8=83=E5=B1=80=E9=94=99=E8=AF=AF=E6=AD=A3=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把布局读写失败的脱敏底层原因附到工作台提示 更新资源布局回归断言和错误展示记录 --- .../useProjectResourceCanvasLayout.ts | 25 ++++++++----------- .../appSurface/project-development.suite.ts | 2 +- .../useProjectResourceCanvasLayout.test.ts | 20 +++++++++++---- ...€�里程碑】AGC错误具体文本展示-2026-10-04.md | 1 + 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/apps/ai-game-creator-shell/src/view/project-development/useProjectResourceCanvasLayout.ts b/apps/ai-game-creator-shell/src/view/project-development/useProjectResourceCanvasLayout.ts index 949847eb6..e19141611 100644 --- a/apps/ai-game-creator-shell/src/view/project-development/useProjectResourceCanvasLayout.ts +++ b/apps/ai-game-creator-shell/src/view/project-development/useProjectResourceCanvasLayout.ts @@ -34,13 +34,7 @@ function describeResourceCanvasLayoutFailure(error: unknown) { return visibleClientErrorMessage(error).slice(0, 400); } -type LayoutNotice = - | '' - | '布局已保存' - | '布局读取失败,已使用当前会话布局' - | '布局保存失败,已保留当前会话布局' - | '布局保存失败,已恢复上次布局' - | '布局已在其他窗口更新'; +type LayoutNotice = string; type LayoutScope = { key: string; @@ -762,8 +756,8 @@ export function useProjectResourceCanvasLayout({ } setNotice( intent.kind === 'resources' - ? '布局保存失败,已保留当前会话布局' - : '布局保存失败,已恢复上次布局', + ? '布局保存失败:布局状态无效;已保留当前会话布局' + : '布局保存失败:布局状态无效;已恢复上次布局', ); void Promise.resolve().then(() => pumpWritesRef.current()); return; @@ -867,9 +861,8 @@ export function useProjectResourceCanvasLayout({ } // 原因先落一行脱敏日志:下面那条提示在部分分支里是刻意不显示的, // 若不记日志,这种"用户看不到、排障也看不到"的失败就完全消失。 - console.warn( - `[resource-canvas-layout] 布局保存失败:${describeResourceCanvasLayoutFailure(error)}`, - ); + const failureDetail = describeResourceCanvasLayoutFailure(error); + console.warn(`[resource-canvas-layout] 布局保存失败:${failureDetail}`); removeWriteIntent(intent); rebuildOptimisticLayout( currentScope.epoch, @@ -885,8 +878,8 @@ export function useProjectResourceCanvasLayout({ ) { setNotice( intent.kind === 'resources' - ? '布局保存失败,已保留当前会话布局' - : '布局保存失败,已恢复上次布局', + ? `布局保存失败:${failureDetail};已保留当前会话布局` + : `布局保存失败:${failureDetail};已恢复上次布局`, ); } }) @@ -1031,7 +1024,9 @@ export function useProjectResourceCanvasLayout({ epoch, automaticPositionPolicy(rederiveAutomaticPositions), ); - setNotice('布局读取失败,已使用当前会话布局'); + setNotice( + `布局读取失败:${describeResourceCanvasLayoutFailure(error)};已使用当前会话布局`, + ); pumpWritesRef.current(); }); return () => { diff --git a/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts index 625dc433b..ef37a425c 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts @@ -5870,7 +5870,7 @@ export function registerProjectWorkbenchFoundationTests() { ); expect( - await screen.findByText('布局保存失败,已保留当前会话布局'), + await screen.findByText(/布局保存失败:.*disk full.*已保留当前会话布局/), ).not.toBeNull(); await openResourceBookCategory('文档'); expect( diff --git a/apps/ai-game-creator-shell/tests/useProjectResourceCanvasLayout.test.ts b/apps/ai-game-creator-shell/tests/useProjectResourceCanvasLayout.test.ts index bbd90923d..b08b7687d 100644 --- a/apps/ai-game-creator-shell/tests/useProjectResourceCanvasLayout.test.ts +++ b/apps/ai-game-creator-shell/tests/useProjectResourceCanvasLayout.test.ts @@ -442,7 +442,9 @@ describe('useProjectResourceCanvasLayout', () => { ); await waitFor(() => - expect(result.current.notice).toBe('布局读取失败,已使用当前会话布局'), + expect(result.current.notice).toContain( + '布局读取失败:layout response revision or coordinates are invalid', + ), ); expect( invoke.mock.calls.filter( @@ -490,7 +492,10 @@ describe('useProjectResourceCanvasLayout', () => { act(() => result.current.commitPosition('resource-a', 'document', 100, 30)); await waitFor(() => - expect(result.current.notice).toBe('布局保存失败,已恢复上次布局'), + expect(result.current.notice).toContain('布局保存失败:'), + ); + expect(result.current.notice).toContain( + 'layout response revision or coordinates are invalid', ); expect(result.current.layout.positions[0]).toMatchObject({ x: 10, y: 20 }); expect(result.current.saving).toBe(false); @@ -1519,7 +1524,10 @@ describe('布局落盘 / 读盘失败的原因不再被吞掉', () => { act(() => result.current.commitPosition('resource-a', 'document', 100, 30)); await waitFor(() => - expect(result.current.notice).toBe('布局保存失败,已恢复上次布局'), + expect(result.current.notice).toContain('布局保存失败:'), + ); + expect(result.current.notice).toContain( + 'layout response revision or coordinates are invalid', ); // 用户可见文案保持原样(不把内部原因塞进面板),原因落到日志里可查。 @@ -1556,8 +1564,9 @@ describe('布局落盘 / 读盘失败的原因不再被吞掉', () => { }), ); await waitFor(() => - expect(result.current.notice).toBe('布局读取失败,已使用当前会话布局'), + expect(result.current.notice).toContain('布局读取失败:'), ); + expect(result.current.notice).toContain('读取布局失败'); const logged = warnMessages(warn).filter((message) => message.includes('[resource-canvas-layout] 布局读取失败'), @@ -2564,8 +2573,9 @@ describe('资源画布整理与批量坐标写入', () => { act(() => result.current.organizeNow(['document'])); await waitFor(() => - expect(result.current.notice).toBe('布局保存失败,已保留当前会话布局'), + expect(result.current.notice).toContain('布局保存失败:'), ); + expect(result.current.notice).toContain('layout write rejected'); expect( invoke.mock.calls.filter( ([command]) => diff --git a/docs/project-memory/plans/【里程碑】AGC错误具体文本展示-2026-10-04.md b/docs/project-memory/plans/【里程碑】AGC错误具体文本展示-2026-10-04.md index 5f77e0821..35d261e1b 100644 --- a/docs/project-memory/plans/【里程碑】AGC错误具体文本展示-2026-10-04.md +++ b/docs/project-memory/plans/【里程碑】AGC错误具体文本展示-2026-10-04.md @@ -75,3 +75,4 @@ DirectProject 回合失败在确认不是客户端内部不可归类故障时, - 前端继续实测发现预览活体复用的 IPC / 权限拒绝会被当成“没有活体”并静默重启,资源生成事件订阅失败也只回退轮询;现在两条回退仍保留,但分别把复用失败正文附到重启结果、把订阅失败正文附到任务阶段。预览与生成队列定向测试 25 项通过。 - 继续扫前端外围又发现 Direct 回合后的清单刷新、资源卡片预览未知错误、UI 编辑器单图预览读取失败仍会静默或使用无因固定句;现分别进入运行错误出口、保留脱敏后的预览错误正文并在编辑器状态提示中显示。 - 资源依赖图读取失败原先只切到 fallback 布局状态,用户看不到 IPC/权限正文;现把安全错误保存到状态并在依赖画布内联显示。 +- 资源画布布局读写失败原先只把原因写日志、界面仍显示固定“布局失败”;现把脱敏后的 revision/IPC/权限/磁盘正文附到读取与保存提示,原有回退布局行为不变。