diff --git a/docs/status/WBV2-P1425-001-web-operator-dispatch.md b/docs/status/WBV2-P1425-001-web-operator-dispatch.md index 48cb469cc..28d87da00 100644 --- a/docs/status/WBV2-P1425-001-web-operator-dispatch.md +++ b/docs/status/WBV2-P1425-001-web-operator-dispatch.md @@ -477,6 +477,11 @@ - 视图层集合设置:`排除 开/关` 切换 layer exclude(true→false), `隐藏 开/关` 切换 layer hide_viewport;revision r3/r4/r6。证据 `tools/web/complete/probe-layer-settings.mjs`。 +- 对象可见性(修复):Outliner 眼睛按钮切换 `hide_viewport` 后,此前 + Outliner 会整树塌陷、眼睛状态丢失,必须手动刷新才恢复。现在 + `setObjectVisibility` 成功后自动发送 `OUTLINER_REFRESH`;复测 hide → + 树保持、显示“显示 PBR Studio Ground”,show → `hide_viewport=false`、 + revision r5。证据 `tools/web/complete/probe-object-visibility.mjs`。 - Sequencer:Properties 的 Sequencer Strip Editing → Add Strip 创建 `Web MOVIE`(MOVIE);证据 `tools/web/complete/probe-sequencer.mjs`。 - Outliner:右键 `Data` 菜单 → 重命名,`PBR Studio Ground` → `GroundRenamed`, diff --git a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json index 4293748ff..bba42b72a 100644 --- a/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json +++ b/tests/golden/WBV2-P1425-001/continuation-20261113-web-export.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "task": "WBV2-P1425-001", - "updatedAt": "2026-11-14T09:58:00+08:00", + "updatedAt": "2026-11-14T10:00:00+08:00", "status": "in_progress", "focus": "COMPLETE-TUTORIAL-001 backend export gap (USD/Alembic)", "breakpoint": "blender-5.2.0/source/blender/web_engine/CMakeLists.txt (USD wiring); WASM 6ee2b261", @@ -316,5 +316,12 @@ "result": "排除 toggles layer exclude true→false; 隐藏 toggles layer hide_viewport; restored", "script": "tools/web/complete/probe-layer-settings.mjs", "acceptance": "NOT_CLAIMED" + }, + "objectVisibilityFix": { + "fix": "App.tsx refreshes the active Outliner after a setObjectVisibility command (the native flag change did not rebuild the tree)", + "before": "hiding an object collapsed the whole Outliner until manual refresh; the eye toggle disappeared", + "after": "hide → tree retained, eye 显示 PBR Studio Ground; show → hide_viewport=false, revision r5", + "script": "tools/web/complete/probe-object-visibility.mjs", + "acceptance": "NOT_CLAIMED" } } diff --git a/tools/web/complete/probe-object-visibility.mjs b/tools/web/complete/probe-object-visibility.mjs new file mode 100644 index 000000000..abfa4a2f9 --- /dev/null +++ b/tools/web/complete/probe-object-visibility.mjs @@ -0,0 +1,78 @@ +#!/usr/bin/env node +/** + * Focused case: edit mode -> select all -> UV -> 展开(角度) on a mesh. + * + * node tools/web/complete/probe-object-visibility.mjs --base-url http://127.0.0.1:5176 + */ +import { ASSETS, parseArgs, launchBrowser, newPage, openApp, openFile, waitScene } from "../course/lib/lesson-recorder.mjs"; + +const args = parseArgs(); +const BASE = args.baseUrl || "http://127.0.0.1:5176"; +const browser = await launchBrowser(args.gpu); +const { context, page, consoleErrors } = await newPage(browser, {}); +page.setDefaultTimeout(90_000); +await page.addInitScript(() => { + const NativeWorker = window.Worker; + window.__probeWorkers = []; + window.__probeMessages = []; + window.Worker = class extends NativeWorker { + constructor(...params) { + super(...params); + window.__probeWorkers.push(this); + this.addEventListener("message", (event) => window.__probeMessages.push(event.data)); + } + }; +}); +const log = (...parts) => console.log(new Date().toISOString().slice(11, 19), ...parts); +const python = async (source) => { + const requestId = `probe-${Date.now()}-${Math.random().toString(36).slice(2)}`; + return await page.evaluate(({ requestId, source }) => new Promise((resolve) => { + const started = Date.now(); + const read = () => { + const hit = window.__probeMessages.find((message) => message && message.requestId === requestId && message.kind === "result"); + if (hit) { clearInterval(timer); resolve(hit); return; } + if (Date.now() - started > 240000) { clearInterval(timer); resolve({ timeout: true }); } + }; + const timer = setInterval(read, 250); + for (const worker of window.__probeWorkers) worker.postMessage({ requestId, command: { type: "jsonCommand", cmd: "pythonExec", params: { source, filename: "ProbeObjectVis.py", console: false } } }); + }), { requestId, source }, { timeout: 300_000 }); +}; +const visibilityState = async () => { + const result = await python(` +import bpy, json +obj = bpy.data.objects.get('PBR Studio Ground') +print('OBJVIS ' + json.dumps({'hide_viewport': obj.hide_viewport if obj else None, 'hide_get': obj.hide_get() if obj else None})) +`); + const out = result?.result?.json; + const status = await page.evaluate(() => document.querySelector('[data-testid="engine-status"]')?.textContent ?? ""); + const eye = await page.evaluate(() => Array.from(document.querySelectorAll('[data-testid="collection-visibility-workbench"] button, .tree-action')).map((button) => button.getAttribute('aria-label')).filter(Boolean).slice(0, 12)); + return { state: out?.state, output: out?.output, error: out?.error, status, eye, tree: await page.evaluate(() => document.querySelector('.outliner-tree, [aria-label="场景层级"]')?.textContent?.slice(0, 300) ?? null) }; +}; +const menu = async (label, item) => { + await page.getByRole("button", { name: label, exact: true }).click(); + await page.getByRole("menuitem", { name: item, exact: true }).click(); +}; +try { + await openApp(page, BASE); + await openFile(page, ASSETS.studio); + await waitScene(page, { objects: 6, timeout: 240_000 }); + log("before", JSON.stringify(await visibilityState())); + const hide = page.locator('button[aria-label="隐藏 PBR Studio Ground"]').first(); + await hide.waitFor({ timeout: 30_000 }); + await hide.evaluate((element) => element.click()); + await page.waitForTimeout(1500); + log("hidden", JSON.stringify(await visibilityState())); + const show = page.locator('button[aria-label="显示 PBR Studio Ground"]').first(); + if (await show.count()) { + await show.evaluate((element) => element.click()); + await page.waitForTimeout(1500); + } + log("shown", JSON.stringify(await visibilityState())); +} catch (error) { + log("probe error", error instanceof Error ? error.message : String(error)); + log("state", JSON.stringify(await visibilityState().catch(() => null))); +} finally { + log("consoleErrors", JSON.stringify(consoleErrors.slice(-10))); + await context.close(); + await browser.close(); +} diff --git a/web/app/src/app/App.tsx b/web/app/src/app/App.tsx index 22e3200c9..5eb391f02 100644 --- a/web/app/src/app/App.tsx +++ b/web/app/src/app/App.tsx @@ -5770,6 +5770,18 @@ export function App({localOnly=false,course}:{localOnly?:boolean;course?:Availab setGeometryBuffers(result.geometryBuffers); setNonMeshGeometryBuffers(result.nonMeshGeometryBuffers ?? []); setFrame(result.snapshot.frame.current); + if (command.type === 'setObjectVisibility') { + // The native visibility flag changes without touching the Outliner tree; + // refresh the active Outliner so rows and the eye state stay current. + const flow = nextSnapshot.editorWorkflow; + const workspace = flow?.workspaces.find(item => item.id === flow.context.workspaceId); + const outlinerArea = workspace?.areas.find(area => area.editor === 'OUTLINER' && + area.regions.some(region => region.kind === 'MAIN' && region.visible)); + if (flow && workspace?.writable && workspace.screenId && outlinerArea) { + void applyEditCommand({ type: 'editEditorContext', baseRevision: nextSnapshot.revision, + edit: { action: 'OUTLINER_REFRESH', workspaceId: workspace.id, screenId: workspace.screenId, areaId: outlinerArea.id } }); + } + } if (command.type === "setObjectTransform" && webPreferences.animation.useAutoKeying) { const objectId = command.objectId; const keyFrame = result.snapshot.frame.current;