fix: 收紧拼图草稿恢复判定

This commit is contained in:
2026-06-04 03:34:06 +08:00
parent cd959b4095
commit 46a36222cb
8 changed files with 413 additions and 75 deletions

View File

@@ -0,0 +1,44 @@
# 【前端架构】Platform Puzzle Draft Recovery Model 收口计划
## 背景
`PlatformEntryFlowShellImpl.tsx` 曾内联维护拼图生成完成后刷新恢复的两个纯函数:`normalizeRecoveredPuzzleDraftSession``hasRecoverableGeneratedPuzzleDraft`。旧逻辑只要草稿有 `coverImageSrc`、首关 cover 或候选图,就会把恢复会话的 draft 和首关 `generationStatus` 抬成 `ready`,再进入结果页。
`.hermes/shared-memory/pitfalls.md` 已记录拼图待发布判定偏弱时只有首图但缺关卡画面、UI spritesheet 或关卡背景的半成品会被误当完成,用户进入结果页后仍可能空图或无法发布。
本切片先修前端恢复链路:只有完整首关资产包存在时,恢复流程才视为可完成。后端 `build_result_preview` / `validate_publish_requirements` / `is_puzzle_session_snapshot_publish_ready` 的发布门槛收紧另作后续切片,不混入本次前端模型收口。
## 决策
新增 `src/components/platform-entry/platformPuzzleDraftRecoveryModel.ts` 作为 Platform Puzzle Draft Recovery **Module**。其公开 **Interface** 为:
- `normalizeRecoveredPuzzleDraftSession(session)`:从恢复会话里补齐首图 cover、assetId 和 selectedCandidateId只有完整资产包满足时才把 draft 与首关 `generationStatus` 改为 `ready`
- `hasRecoverableGeneratedPuzzleDraft(session)`:判断恢复会话是否拥有完整首关资产包。
`PlatformEntryFlowShellImpl.tsx` 仍作为 **Adapter**:它继续负责拉取 session、写 background task、写 React state、打开结果页和切换 stage。
## Interface 约束
- 无 draft 时保持原 session并判定不可恢复完成态。
- 首图可来自 `draft.coverImageSrc`、首关 `coverImageSrc` 或选中 / 首个候选图。
- 完整首关资产包必须同时具备:
- 首图 cover
- `levelSceneImageSrc``levelSceneImageObjectKey`
- `uiSpritesheetImageSrc``uiSpritesheetImageObjectKey`
- `levelBackgroundImageSrc``levelBackgroundImageObjectKey`
- cover / assetId / selectedCandidateId 可按旧优先级从 draft、首关、候选图回填但若完整资产包不满足不得把 `generationStatus` 抬为 `ready`
- 只修复前端恢复判定,不改变拼图发布接口、后端 session stage 或后端 preview compiler。
## Depth / Leverage / Locality
- **Depth**:壳层以两个函数表达“恢复会话归一化”和“是否可作为生成完成态恢复”;完整资产门槛和候选图 fallback 藏入 Module Implementation。
- **Leverage**:后续后端补齐发布门槛时,可用同一资产语言对齐前端恢复模型,避免壳层再散落条件判断。
- **Locality**:拼图恢复判定集中到纯测试面,避免在异步恢复 callback 中把半成品 ready 规则继续隐身。
## 验收
- `npm run test -- src/components/platform-entry/platformPuzzleDraftRecoveryModel.test.ts`
- `npx eslint src/components/platform-entry/platformPuzzleDraftRecoveryModel.ts src/components/platform-entry/platformPuzzleDraftRecoveryModel.test.ts src/components/platform-entry/PlatformEntryFlowShellImpl.tsx --quiet`
- `npm run test -- src/components/rpg-entry/RpgEntryFlowShell.agent.interaction.test.tsx -t "persisted generating puzzle draft"`
- `npm run typecheck`
- `npm run check:encoding`