diff --git a/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts b/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts index 976be5cbd..172b3eabb 100644 --- a/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts +++ b/apps/ai-game-creator-shell/src/features/app-shell/homeWebPreflight.ts @@ -1,4 +1,5 @@ import type { ProjectStartMode, TauriInvoke } from '../../app/types'; +import { visibleClientErrorMessage } from '../../services/errorReporting'; import type { HomeCreationType } from '../../view/home/useHomeDraftStore'; /** @@ -28,12 +29,32 @@ function knownPreflightCode(value: unknown): string | undefined { } export function homeWebPreflightErrorMessage(value: unknown): string { + const visible = visibleClientErrorMessage(value, ''); + if ( + visible.startsWith('Web 游戏环境预检未通过(') || + visible.startsWith(HOME_WEB_PREFLIGHT_IPC_FAILURE) + ) { + return visible; + } if (value instanceof Error && value.message === HOME_WEB_PREFLIGHT_FAILURE) { return HOME_WEB_PREFLIGHT_FAILURE; } const code = knownPreflightCode(value); - if (code) return `Web 游戏环境预检未通过(${code});尚未开始生成。`; - return HOME_WEB_PREFLIGHT_IPC_FAILURE; + const safeDetail = visible + .replace(/Web 游戏环境预检未通过[::]?/u, '') + .replace(code ?? '', '') + .replace(/[;;]?\s*尚未启动生成[。.]?/u, '') + .replace(/^\s*[;::,,-]\s*/u, '') + .replace(/[;;]\s*$/u, '') + .trim(); + if (code) { + return safeDetail + ? `Web 游戏环境预检未通过(${code}):${safeDetail};尚未开始生成。` + : `Web 游戏环境预检未通过(${code});尚未开始生成。`; + } + return safeDetail + ? `${HOME_WEB_PREFLIGHT_IPC_FAILURE}(${safeDetail})` + : HOME_WEB_PREFLIGHT_IPC_FAILURE; } function isHostPreflightError(value: unknown): boolean { diff --git a/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx b/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx index 99325fff0..171e0b567 100644 --- a/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx +++ b/apps/ai-game-creator-shell/tests/homeWebPreflight.test.tsx @@ -101,7 +101,7 @@ it('distinguishes an IPC failure from a host preflight failure', async () => { 'direct-build', ); }); - expect(status).toBe(HOME_WEB_PREFLIGHT_IPC_FAILURE); + expect(status).toBe(`${HOME_WEB_PREFLIGHT_IPC_FAILURE}(Failed to fetch)`); expect(calls).toEqual([ 'preflight_web_game_creation', 'preflight_web_game_creation',