feat(web): adjustable workspace partitions, floating areas and uncluttered panels
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 workspace-layout.tsx: three draggable separators (viewport/right column,
  viewport/timeline, outliner/properties) with pointer, arrow-key and
  double-click reset, remembered in one shared localStorage record.
- Areas can pop out of the grid into floating windows from the area menu; the
  same section is only re-positioned, so the WebGL canvas and editor state
  survive. Title-bar drag, corner resize, dock button and grid placeholder.
- Viewport overlays (N-panel, tool shelf, shading/navigation cluster) are
  draggable inside the viewport, with reset and a 视图 menu entry to reopen
  them.
- Remove overlap: the docked quick toolbar gets its own grid band, the area
  switcher moves into the header (and only fades in over headerless areas),
  properties controls wrap when the column narrows, the N-panel stops growing
  to 714px, and the 901-1280px media query no longer freezes the right column
  at 290px over the draggable variable.
- New spec wbv2-workspace-layout-production with evidence in
  tests/golden/WEB-WORKSPACE-LAYOUT-20261123 (NOT_CLAIMED); status doc records
  the local regressions, the A/B that pinned them and the online walk at
  1440x900 and 1280x800 on release 20261124-workinf_blender_wasm-2c8449f42.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-11-24 04:33:38 +08:00
parent 2c8449f422
commit 570aa2dd54
18 changed files with 1006 additions and 42 deletions

View File

@@ -0,0 +1,61 @@
# WEB-WORKSPACE-LAYOUT-20261124 status
- case: `WEB-WORKSPACE-LAYOUT-20261124`(网页 Blender 面板可拖拽、布局可调整、区域可弹出为浮动窗口、面板内部控件不再互相遮挡)
- 类型:用户案例补缺。用户原话:“完善‘web blender’的页面,实现网页上面的控制面板可以拖拽,面板固定会影响三维设计场景查看。优化面板布局,面板内部控件不要互相遮挡,布局合理,方便使用。”
- 范围(经用户确认):
- **分区可拖**:视口↔右栏、视口↔时间线、大纲↔属性三条分隔条;
- **视口浮层可拖**:N 面板、工具架、着色/导航按钮簇;
- **区域可弹出为浮动窗口**:任意区域菜单「浮动为独立窗口 / 停靠回布局」;
- 位置记忆**全局共用一份**(所有工作区共享),带一键复位。
- 计划:`/home/mes123456/.claude/plans/dynamic-foraging-sundae.md`(已批准);上一批浮层拖动见 `docs/status/WEB-PANEL-DRAG-20261123.md`。
## 改动文件
| 文件 | 改动 |
| --- | --- |
| `web/app/src/app/workspace-layout.tsx`(新增) | 布局状态与持久化(localStorage `web-blender.workspace-layout.v1`,纯 UI 偏好,工程数据仍只走 OPFS)、`splitStyle()` CSS 变量、`<WorkspaceSplitters/>` 三条分隔条(指针拖拽 + 方向键 ±16 / Shift ±48 + Home/双击复位 + `ResizeObserver` 重测)。钳制:右栏 240–50vw、时间线 48–40vh、大纲占比 0.2–0.8。 |
| `web/app/src/app/WasmWorkspace.tsx` | 网页模式 `.workspace-grid` 写入 `splitStyle(splits)` 并渲染 `<WorkspaceSplitters/>`。原生/custom 布局不受影响。 |
| `web/app/src/main.tsx` | `<App>` 外层挂 `WorkspaceLayoutProvider`。 |
| `web/app/src/app/App.tsx` | ① 区域浮动窗口:同一 `section.area-frame` 改为 `position:fixed`(不 portal、不重挂载,WebGL 上下文与文本草稿保留),标题栏拖动、右下角缩放手柄、停靠按钮、网格占位块「已弹出为浮动窗口 · 停靠回布局」;② 区域菜单新增「浮动为独立窗口 / 停靠回布局」;③ 视口浮层接入 `useDraggablePanel`:N 面板(新增关闭 ×)、工具架、着色+导航合并为一个可拖簇;④ 「视图」菜单新增「侧栏 (N)」「工具架 (T)」,为已关闭的浮层提供恢复入口;⑤ 「窗口 → 恢复默认面板位置」同时复位分区尺寸与浮窗;⑥ 区域编辑器切换器改为:有标题栏的区域放进标题栏,无标题栏的区域(视口/时间线/节点/控制台等)才悬浮,且每个区域只保留一个 ⋮ 菜单。 |
| `web/app/src/app/use-draggable-panel.ts` | 新增可选 `bounds` 钳制:视口浮层必须整体留在 `.viewport-placeholder` 内(该容器 `overflow:hidden`,旧的全窗口钳制会把面板推到看不见的位置);泛型化 `panelRef`。 |
| `web/app/src/app/app-shell.css` | 网格轨道改为 `--ws-*` 变量且默认值与旧值逐像素一致;分隔条样式(默认透明,悬停/拖动/聚焦显示 2px 蓝线);浮窗与占位块样式;视口浮层把手样式;**快捷操作栏停靠时占用独立网格行**(不再压住各区域顶部);区域切换器默认只在悬停/聚焦时出现;属性栏窄化换行与 `min-width:0`;N 面板 `max-height` + 滚动;901–1280px 的右栏宽度改用变量(原为写死 290px,会覆盖拖动结果)。 |
| `web/app/src/app/desktop-menus.css` | 状态栏隐藏时的网格行同步快捷操作栏行高。 |
| `web/tests/e2e/wbv2-workspace-layout-production.spec.ts`(新增) | 三条用例:分隔条拖动/持久化/键盘微调/双击复位;区域浮出/拖动/停靠;视口浮层拖动、N 面板关闭与恢复、浮层始终留在视口内。 |
| `tests/golden/WEB-WORKSPACE-LAYOUT-20261123/` | 证据:`splits.json`、`floating-area.json`、`floating-properties.png`、`viewport-overlays.json`,均 `acceptance: "NOT_CLAIMED"`。 |
## 过程中发现并处理的既有或自引入缺口
1. **901–1280px 窗口下右栏宽度写死 `290px`**(`app-shell.css` 媒体查询):会覆盖拖拽变量,使分隔条在这个区间完全无效。改为 `var(--ws-right-width, 290px)`,并让首次加载在 ≤1280px 时仍以 290px 起步,窄窗口观感不变。
2. **区域切换器压住标题栏自己的 ⋮ 菜单**(自引入):首个版本把切换器叠在标题栏右上角,Playwright 报 “subtree intercepts pointer events”,用户也点不到菜单。改为切换器进标题栏;旧用例要求切换器内仍有 ⋮,故保留切换器内的 ⋮、标题栏不再重复渲染一个。
3. **视口标题栏并非所有工作区都隐藏**(自引入后发现):`[data-workspace="Scripting"] .viewport-area > .editor-header { display:flex }`。第一版按类名一刀切删掉视口标题栏,`web-manual-ui-gaps.spec.ts` 在 HEAD 上通过、在我的改动上失败;A/B(`git stash` 后仅跑该用例)确认属回归。改为由 `AreaEditorContext.workspace` 决定。
4. **快捷操作栏停靠时覆盖各区域顶部约 35px**(既有):改为 `.blender-app` 网格里的独立行,折叠时 24px、浮出时为 0;`.render-result-view` 不再需要 `padding-top:35px` 补偿。
5. **N 面板被本身内容撑到 714px 宽**(既有,线上实测发现):`.viewport-sidebar` 没有宽度约束,着色分组的 `select` 把它撑到 509px,整个面板占去视口 70% 以上,正是用户说的“面板影响查看三维场景”。给面板加 `max-width: min(70%, 420px)`、着色分组固定 200px 并允许内部换行;实测宽度 714 → 407px,并加进本次用例断言(`≤424px`)。
## 流程与结果(Chromium,OPFS,开发服务器)
1. `cd web && npm run typecheck`:通过(exit 0,多轮)。
2. `npx playwright test tests/e2e/wbv2-workspace-layout-production.spec.ts --workers=1`:
- `partition splitters resize, persist and reset the workspace areas` — 拖右栏分隔条 → `splits.rightWidth` 由 320 变为 456 → `.properties-area` 加宽、视口变窄 → 拖时间线上移 → 时间线变高 → `reload` 后尺寸保持 → 方向键 → 双击复位回 320。
- `an area pops out as a floating window and docks back` — 属性区菜单「浮动为独立窗口」→ `position:fixed`、`data-floating="true"`、占位块出现、入 localStorage → 拖标题栏 (140,80) → 停靠回网格、`floating` 清空。
- `viewport overlays move out of the model and stay inside the viewport` — N 面板拖动后仍在视口矩形内 → × 关闭 → 「视图 → 侧栏」恢复 → 复位;着色簇与导航簇纵向不重叠;整簇拖动入库;「视图 → 工具架」打开工具架并可拖动标题栏;无 `pageerror`。
3. 回归(`--workers=1`):
- `web-area-layout.spec.ts`(2)、`web-manual-ui-gaps.spec.ts`(2)、`wbv2-panel-drag-production.spec.ts`(3)、`wbv2-adjust-last-operation-production.spec.ts`(1)、`pbr-tutorial-accessibility`(1)、`parts-tutorial-accessibility`(1)→ 全部通过。
- A/B:`web-area-layout` + `web-manual-ui-gaps` 在 HEAD(`git stash` 掉本次全部源码改动)上 4 passed,证明失败来自本次改动,已按源码修正而非改断言。
- `wbv2-pbr-tutorial-production.spec.ts`:`1 passed (2.2m)`(12 个步骤全部演示通过,无 `.blend` 自动下载)。
4. 发布与线上复验:
- `BW_DEPLOY_PASSWORD=… tools/web/deploy-58014.sh` → release `20261124-workinf_blender_wasm-2c8449f42`,`health=200`、`index=200`,wasm 本地/远程哈希一致(`9febac5d…c31a2c`),`studios=200`;N 面板宽度修复后按同一 release id 重新上传切换一次(`current` 指向同一路径,`health=200`)。
- 线上 Chromium 实走(1440×900,`https://49.232.250.35:58014/?ui=web` + `basic_scene.blend`):拖右栏分隔条 → `.properties-area` 320 → 430px,`localStorage` 记录 `rightWidth:430`;属性区「浮动为独立窗口」→ `position:fixed` → 拖标题栏 (120,70) → 位置随之变化 → 「停靠回布局」→ 浮窗记录清空;N 面板拖动入库 `{x:-2,y:50}` 且整体仍在视口内;无 `pageerror`。证据:`tests/golden/WEB-WORKSPACE-LAYOUT-20261123/online-verification.json`、`online-floating-properties.png`、`online-workspace-layout.png`。
- 线上小窗口复验(1280×800,同一 release):右栏初始 290px(媒体查询默认),拖动分隔条后 320→400px 且 `localStorage` 记录 `rightWidth:400`,浮窗与 N 面板同样正常;证据 `online-verification-1280.json`。修复前该区间拖动完全无效。
- 线上检查脚本必须沿用 `tools/web/check-deployed-web-blender.mjs` 的 Chromium 参数(含 `--enable-unsafe-webgpu --use-webgpu-adapter=swiftshader`):缺这些参数时引擎停在 “WASM: starting”,与产品无关。
## 未验证 / 剩余缺口
- 触摸/笔输入下的拖动、分隔条双指缩放未在真机验证(仅 Chromium 鼠标指针)。
- 浮动窗口在多显示器/负坐标(`window.screenX < 0`)下的行为未验证;钳制以当前窗口为准。
- 原生模式(`?ui=desktop` / `localOnly`)下区域由原生屏幕矩形驱动,分隔条按设计不渲染;原生模式下把区域浮动为窗口只改变显示位置,未在原生会话里实测。
- 除 `Layout` 外的工作区使用各自固定模板(如 Modeling 的 `190px` 行),分隔条在这些工作区不渲染;这些模板是否需要同样可调,留给用户使用后决定。
- 「恢复默认面板位置」复位面板偏移、分区尺寸与浮窗,但不复位时间线 dock 的独立位置(沿用上一批的遗留项)。
## 验收
`NOT_CLAIMED`。