feat(web): draggable floating panels and a non-hanging tutorial demo open
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

- add a shared useDraggablePanel hook (pointer capture, clamping, offset
  persistence in localStorage, double-click / button / menu reset) and use it
  for the tutorial step panel, the quick toolbar, the adjust-last-operation
  panel and the robot tool drawer
- quick toolbar drags out of the dock into a compact floating bar and can be
  folded; robot tool scrim is transparent and click-through so the 3D scene
  stays visible and usable while the tool is open
- 窗口 > 恢复默认面板位置 clears every stored panel offset
- fix a pre-existing hang: tutorial demo scene opens went through the
  "save current project?" prompt and waited forever; course demos now persist
  the current OPFS project like the dialog's 保存后继续 and continue
- PBR tutorial spec: demos must not auto-download .blend (OPFS-only rule)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-23 21:43:40 +08:00
parent cb2829cad1
commit 2c8449f422
15 changed files with 716 additions and 92 deletions

View File

@@ -0,0 +1,35 @@
# WEB-PANEL-DRAG-20261123 status
- case: `WEB-PANEL-DRAG-20261123`(PBR Studio Ground 等步骤面板、快捷操作栏、调整上一步操作、机器人工具:可拖动 + 位置记忆 + 一键复位)
- 类型:用户案例补缺(用户明确要求:“面板可以拖动,相关类似面板都可以拖动,要不影响观看三维场景。优化布局,方便使用”);不是队列任务,未改动 `docs/EXECUTION_QUEUE.md` 与 `nextTask`
- 计划:`/home/mes123456/.claude/plans/dynamic-foraging-sundae.md`(范围经用户确认:教学/渲染类浮层 + 快捷操作栏 + 工具面板;位置记忆并带复位)
- 改动文件:
- `web/app/src/app/use-draggable-panel.ts`(新增):共享拖动钩子。指针捕获 + `transform: translate()` 偏移,手柄始终可抓回窗口(`left ∈ [8 - width/2, innerWidth - 160]`,`top ∈ [-48, innerHeight - 60]`);位置写入 localStorage `web-blender.panel-offsets.v1`(`Record<panelId,{x,y}>`,UI 偏好,不涉及工程数据,工程数据仍只走 OPFS),首次读取时迁移旧键 `web-blender.tutorial-panel-offset.v1`;`reset()` 归零、头部双击复位、挂载时若手柄完全在窗口外自动复位;`resetAllPanelOffsets()` 清两个键并广播 `web-blender:panel-offsets-reset`。
- `web/app/src/tutorial/TutorialOverlay.tsx`:改用钩子;头部加 `⠿` 手柄与「复位教程面板位置」按钮;保留药丸收起与画中画(PiP)时禁用拖动(`data-draggable-disabled`)。
- `web/app/src/tutorial/parts/parts-tutorial.css`:手柄、拖动中高亮、复位按钮禁用态样式。
- `web/app/src/app/App.tsx`:快捷操作栏接入钩子 + `⠿` 手柄 + 「复位快捷操作栏位置」+「折叠快捷操作栏」(折叠后由「展开快捷操作栏」按钮恢复);`createPortal` 的「调整上一步操作」面板接入钩子 + 手柄 + 复位;「窗口」菜单新增「恢复默认面板位置」(清空全部偏移并把快捷操作栏展开)。
- `web/app/src/app/desktop-menus.css`:快捷操作栏停靠/浮动两态(`data-quick-toolbar-floating`,浮动时 `position:fixed; width:max-content`,不再横跨并覆盖各区域顶部)、折叠隐藏、展开按钮样式。
- `web/app/src/robot/RobotTool.tsx`、`web/app/src/robot/robot-tool.css`:抽屉头部可拖动 + 复位;遮罩改为透明且 `pointer-events:none`,机器人工具打开时三维场景仍然可见、可操作(`pointer-events:auto` 只在抽屉本体上)。
- 流程与结果(Chromium,OPFS):
1. `cd web && npm run typecheck`:通过(exit 0)。
2. `npx playwright test tests/e2e/wbv2-panel-drag-production.spec.ts --workers=1`:`3 passed (26.6s)`。
- 教程面板(`/?ui=web&tutorial=pbr&start=1`):默认偏移 `{0,0}` → 拖头部 (160,120) → `data-panel-offset` 与 `localStorage` 均写入 → `reload` 后保持 → 「复位」回 `{0,0}` → 再次拖动后双击头部同样归零。
- 快捷操作栏:默认 `data-quick-toolbar-floating="false"` 且 `elementFromPoint` 证实它覆盖视口顶部 → 拖手柄 (120,150) → 浮动为 `true`、偏移入库、浮动后同一位置不再是工具栏(不再遮挡)→ 折叠/展开 → 复位回 0。
- 工具面板:快捷栏「Add Monkey」(走 `invokeNativeOperator`)产生「调整上一步操作」→ 拖头部 (180,-120) 并入库;打开机器人工具,遮罩计算样式为 `background: transparent; pointer-events: none`,拖抽屉 (-260,90) 并入库。
- 证据:`tests/golden/WEB-PANEL-DRAG-20261123/{tutorial-panel,quick-toolbar,tool-panels}.json`。
- 过程中发现并处理:
- 「调整上一步操作」只由 `invokeNativeOperator` 路径记录;「添加 > 网格 > 猴头」走 `queueLocalDesktopOperator`/`invokeEmbeddedOperator`,不会写入 `lastNativeOperator`。用例改用快捷操作栏的 Add Monkey 走真实记录路径,产品代码不做特判。
- 该路径本身是既有行为差异(两条菜单路径记录不一致),已在此记录,未在本批修改。
- **回归发现既有缺口(非本批引入,已在 HEAD 上 A/B 复现):`wbv2-pbr-tutorial-production.spec.ts` 卡死。** 现象:第 3 步「载入摄影棚场景」点「演示本步」后按钮永久停在「演示中…」、`下一步` 禁用、`data-tutorial-ready="false"`,引擎状态停在 `SceneIR r3 (3 objects)`。根因:`studio.blend` 本身可正常打开(直接走 `blend-file-input` 得到 `SceneIR r1 (6 objects)`),但教程演示走 `openTutorialScene` → `openBlendFile` → `prepareProjectReplacement()`,工程有未保存修改时弹出「保存当前工程的修改?」对话框并一直等回答;脚本演示无人回答,流程永久挂起。修复(`web/app/src/app/App.tsx`,单文件约 10 行):`prepareProjectReplacement(mode: 'ask' | 'save')`,`openBlendFile` 新增 `options.saveDirtyProject`,`openTutorialScene` 传 `{ saveDirtyProject: true }`——课程演示按对话框的「保存后继续」语义自动把当前工程持久化到 OPFS 再打开,不再阻塞;文本草稿未应用时仍返回 false(演示显示错误而不是挂起)。
- 修复后 `wbv2-pbr-tutorial-production.spec.ts` 由 4.2m 超时失败变为 `1 passed (1.1m)`;同时把该用例中过期的「演示必须下载 .blend」断言改为「演示不得下载 .blend」(工程只写 OPFS,本地下载须用户显式触发),与项目铁律一致。
3. 发布与线上复验:
- `BW_DEPLOY_PASSWORD=… tools/web/deploy-58014.sh` → release `20261123-workinf_blender_wasm-cb2829cad`,`health=200`,`index=200`,wasm 本地/远程哈希一致(`9febac5d…c31a2c`),`lights/forest.bin=200`;
- 线上包内容核对:`assets/App-D-Zw4fzp.js` 含 `saveDirtyProject`、`拖动标题栏可移动面板`、`复位教程面板位置`、`恢复默认面板位置`;
- 线上 Chromium 实走(1440×900,`https://49.232.250.35:58014/?ui=web&tutorial=pbr&start=1`):拖头部 → `data-panel-offset = "130,130"`,`localStorage["web-blender.panel-offsets.v1"] = {"tutorial":{"x":130,"y":130}}`,`reload` 后仍为 `"130,130"`,点「复位」回 `"0,0"`;无 `pageerror`。
4. 相关回归(`--workers=1`):`wbv2-panel-drag-production`(3)+ `wbv2-adjust-last-operation-production` + `pbr-tutorial-accessibility` + `parts-tutorial-accessibility` → `6 passed (46.6s)`;`wbv2-pbr-tutorial-production` → `1 passed (1.1m)`。
- 未验证 / 剩余缺口:
- 触摸/笔输入下的拖动未在真机验证(仅 Chromium 鼠标指针);
- 多显示器/极小窗口(< 500px)下的钳制边界只做了逻辑覆盖,未逐窗口尺寸截图;
- 「恢复默认面板位置」只覆盖面板偏移,不重置时间线 dock 的独立位置。
- 验收:`NOT_CLAIMED`。
- 下一动作:如需继续,统一「添加」菜单与快捷操作栏的 `lastNativeOperator` 记录路径,或补小窗口钳制的人工截图证据。