feat(web): object picker in workbench shell, verify sketch panel on stage
workbench.html routes Sketcher desktop commands to the standalone sketcher probe, which had no document, so Sketcher_EditSketch always failed with "The selected live document does not exist in this runtime". The shell also only exposed an object selection table for BIM, so no command could receive a selected sketch. - workbench shell: add a generic document object list (details .workbench-object-picker) that writes both the shell selection and the command payload selection for every module - ch03: document the working session path (NewSketch creates workbench_document/Sketch, then EditSketch on that selection) with two stage screenshots, plus the measured layout (panel left 284 vs stage left 260, zero horizontal overflow) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -41,6 +41,15 @@
|
||||
|
||||
冒烟:`/workbench.html?module=Sketcher`、`?module=CAM&command=CAM_Job`、`?module=TechDraw&command=TechDraw_View`、`/project.html` 全部 pageerror 0。
|
||||
|
||||
### 草图会话验证(已闭合)
|
||||
|
||||
- 根因两条:① Sketcher 桌面命令路由到 `sketcher.worker.ts`(`FreeCADWebSketcherProbe`),其 App 里没有通过 `Std_Open` 打开的文档,故报 `The selected live document does not exist in this runtime`(`SketcherDesktopCommands.cpp:365`);② 工作台壳层只有 BIM 有对象选择表,其他模块无法给命令传 selection。
|
||||
- 修复:`web/src/workbench-shell.tsx` 新增通用「文档对象」多选列表(`details.workbench-object-picker`),勾选即写 `documentSelection` 与 payload `selection`,所有模块共用。
|
||||
- 可行会话路径(已实测):`workbench.html?module=Sketcher&command=Sketcher_NewSketch` → 执行(Sketcher 运行时自建文档 `workbench_document`、对象 `Sketch`)→ 切到 `Sketcher_EditSketch`,payload 设 `documentId=workbench_document`、`selection=[{documentId,object:"Sketch"}]` → 执行。
|
||||
- 场景:`web/manual/scenarios/ch03-sketcher-workbench.json`(2 张图,257 KB / 518 KB),已写入 ch03「工作台页面里的草图编辑」。
|
||||
- 布局实测:主舞台 left 260 / 草画面板 left 284(24 px 内边距),主舞台横向溢出 0、页面横向溢出 0,面板内 7 行控件。
|
||||
- `build:manual` 1 130 037 字节,`check:manual` 双视口 ok(132 图引用、overflow 0、破图 0);`final-status` 130 PNG。
|
||||
|
||||
## 本轮重写范围(2026-11-15)
|
||||
|
||||
### 截图:33 张 → 63 张
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 251 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 506 KiB |
@@ -147,6 +147,22 @@ Sketcher 在 Web 端有两个 React 任务面板,分别承担「画」与「
|
||||
|
||||

|
||||
|
||||
### 工作台页面里的草图编辑
|
||||
|
||||
在 `workbench.html?module=Sketcher` 里编辑草图时,草图面板挂在**主舞台**上,而不是右侧窄命令栏。
|
||||
这一步需要先让 Sketcher 运行时拥有草图:先执行 `Sketcher_NewSketch` 建草图,
|
||||
再执行 `Sketcher_EditSketch` 并选中该草图(`documentId` = `workbench_document`,`object` = `Sketch`)。
|
||||
面板出现后占满舞台宽度,约束与几何控件按列排布:
|
||||
|
||||

|
||||
|
||||
整页效果(左侧模块列表、中间草图面板、右侧命令栏):
|
||||
|
||||

|
||||
|
||||
实测布局读数:主舞台起点 260 px,草画面板起点 284 px,两者相差的 24 px 是舞台内边距;
|
||||
主舞台横向溢出 0、页面横向溢出 0。这条证据就是为了证明草图控件没有被挤进窄栏、也没有被截断。
|
||||
|
||||
## 自检
|
||||
|
||||
- [ ] 对象树里有 `ManualSketch`。
|
||||
|
||||
94
web/manual/data/capture/ch03-sketch-workbench-stage.json
Normal file
94
web/manual/data/capture/ch03-sketch-workbench-stage.json
Normal file
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"schema": "freecad-web-manual/capture/v1",
|
||||
"generatedAt": "2026-11-22T22:48:44.343Z",
|
||||
"chapter": "ch03",
|
||||
"workflow": "sketch-workbench-stage",
|
||||
"scenario": "manual/scenarios/ch03-sketcher-workbench.json",
|
||||
"origin": "http://127.0.0.1:5183",
|
||||
"ok": true,
|
||||
"trace": [
|
||||
{
|
||||
"at": "2026-11-22T22:48:29.354Z",
|
||||
"action": "goto",
|
||||
"url": "/workbench.html?module=Sketcher&command=Sketcher_NewSketch"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:29.538Z",
|
||||
"action": "waitFor",
|
||||
"selector": "textarea[aria-label=\"命令 JSON 参数\"]",
|
||||
"text": null
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:32.610Z",
|
||||
"action": "click",
|
||||
"selector": "执行选中命令"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:37.646Z",
|
||||
"action": "click",
|
||||
"selector": "aside button.command"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:38.852Z",
|
||||
"action": "eval"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:39.496Z",
|
||||
"action": "click",
|
||||
"selector": "执行选中命令"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:40.658Z",
|
||||
"action": "waitFor",
|
||||
"selector": "fieldset[aria-label=\"Sketch drawing\"]",
|
||||
"text": null
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:43.162Z",
|
||||
"action": "assertVisible",
|
||||
"selector": "section[aria-label=\"Sketch edit session\"]"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:44.055Z",
|
||||
"action": "shot",
|
||||
"name": "01-sketch-stage-panel",
|
||||
"bytes": 257327
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:44.057Z",
|
||||
"action": "eval"
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:44.336Z",
|
||||
"action": "shot",
|
||||
"name": "02-sketch-panel-full",
|
||||
"bytes": 518511
|
||||
},
|
||||
{
|
||||
"at": "2026-11-22T22:48:44.343Z",
|
||||
"action": "assertAnyText",
|
||||
"selector": "main.stage",
|
||||
"contains": "Sketch"
|
||||
}
|
||||
],
|
||||
"shots": [
|
||||
{
|
||||
"id": "ch03/sketch-workbench-stage/01-sketch-stage-panel",
|
||||
"file": "manual/assets/ch03/sketch-workbench-stage/01-sketch-stage-panel.png",
|
||||
"bytes": 257327,
|
||||
"sha256": "a35b9c01a52e760c480ee0977966657c45af083314c49bb811ac61f82de83d51",
|
||||
"fullPage": false,
|
||||
"selector": "main.stage"
|
||||
},
|
||||
{
|
||||
"id": "ch03/sketch-workbench-stage/02-sketch-panel-full",
|
||||
"file": "manual/assets/ch03/sketch-workbench-stage/02-sketch-panel-full.png",
|
||||
"bytes": 518511,
|
||||
"sha256": "cc44f1cfa0d0c75d11dcb0b4f0817a8e4edcac3bc3f1bc215b2de4d7984264ec",
|
||||
"fullPage": true,
|
||||
"selector": null
|
||||
}
|
||||
],
|
||||
"pageErrors": [],
|
||||
"consoleErrors": []
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
{
|
||||
"schema": "freecad-web-manual/final-status/v1",
|
||||
"generatedAt": "2026-11-22T12:57:20.816Z",
|
||||
"generatedAt": "2026-11-22T22:52:26.538Z",
|
||||
"state": "complete",
|
||||
"chapters": 15,
|
||||
"chaptersWithAppendix": 17,
|
||||
"screenshots": 128,
|
||||
"screenshots": 130,
|
||||
"commands": 1573,
|
||||
"modules": 31,
|
||||
"nativeHandlers": 378,
|
||||
"verifiedCommands": 12,
|
||||
"workflows": 26,
|
||||
"workflows": 27,
|
||||
"boundaries": 5,
|
||||
"pageCheck": {
|
||||
"ok": true,
|
||||
@@ -17,7 +17,7 @@
|
||||
"mobileOverflow": 0,
|
||||
"brokenImages": [],
|
||||
"searchHits": 4,
|
||||
"images": 130,
|
||||
"images": 132,
|
||||
"sections": 164
|
||||
},
|
||||
"entry": "web/teaching/manual.html",
|
||||
@@ -42,5 +42,5 @@
|
||||
"由 generate-final-status.mjs 自动派生,不要手改。",
|
||||
"UI 表面清单:333 项,缺口 0 项。"
|
||||
],
|
||||
"screenshotsCaptured": 128
|
||||
"screenshotsCaptured": 130
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"schema": "freecad-web-manual/page-check/v1",
|
||||
"generatedAt": "2026-11-22T12:57:12.993Z",
|
||||
"generatedAt": "2026-11-22T22:51:15.602Z",
|
||||
"url": "http://127.0.0.1:5191/manual.html",
|
||||
"viewports": [
|
||||
{
|
||||
@@ -14,7 +14,7 @@
|
||||
"searchHits": 4,
|
||||
"chapters": 17,
|
||||
"sections": 164,
|
||||
"images": 130,
|
||||
"images": 132,
|
||||
"brokenImages": [],
|
||||
"commandRows": 1573,
|
||||
"overflow": 0,
|
||||
@@ -31,7 +31,7 @@
|
||||
"searchHits": 4,
|
||||
"chapters": 17,
|
||||
"sections": 164,
|
||||
"images": 130,
|
||||
"images": 132,
|
||||
"brokenImages": [],
|
||||
"commandRows": 1573,
|
||||
"overflow": 0,
|
||||
|
||||
28
web/manual/scenarios/ch03-sketcher-workbench.json
Normal file
28
web/manual/scenarios/ch03-sketcher-workbench.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"schema": "freecad-web-manual/scenario/v1",
|
||||
"chapter": "ch03",
|
||||
"workflow": "sketch-workbench-stage",
|
||||
"title": "Sketcher 工作台:草图编辑面板位于主舞台",
|
||||
"actions": [
|
||||
{ "type": "goto", "url": "/workbench.html?module=Sketcher&command=Sketcher_NewSketch" },
|
||||
{ "type": "waitFor", "selector": "textarea[aria-label=\"命令 JSON 参数\"]" },
|
||||
{ "type": "wait", "ms": 3000 },
|
||||
{ "type": "click", "role": "button", "name": "执行选中命令", "exact": true },
|
||||
{ "type": "wait", "ms": 5000 },
|
||||
|
||||
{ "type": "click", "selector": "aside button.command", "hasText": "Sketcher_EditSketch" },
|
||||
{ "type": "wait", "ms": 1200 },
|
||||
{ "type": "eval", "script": "const ta=document.querySelector('textarea[aria-label=\"命令 JSON 参数\"]');const v=JSON.parse(ta.value);v.documentId='workbench_document';v.selection=[{documentId:'workbench_document',object:'Sketch'}];Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,'value').set.call(ta,JSON.stringify(v,null,2));ta.dispatchEvent(new Event('input',{bubbles:true}));" },
|
||||
{ "type": "wait", "ms": 600 },
|
||||
{ "type": "click", "role": "button", "name": "执行选中命令", "exact": true },
|
||||
|
||||
{ "type": "waitFor", "selector": "fieldset[aria-label=\"Sketch drawing\"]" },
|
||||
{ "type": "wait", "ms": 2500 },
|
||||
{ "type": "assertVisible", "selector": "section[aria-label=\"Sketch edit session\"]" },
|
||||
{ "type": "shot", "name": "01-sketch-stage-panel", "selector": "main.stage" },
|
||||
|
||||
{ "type": "eval", "script": "const box=document.querySelector('main.stage');window.__sketchStage={stageLeft:Math.round(box.getBoundingClientRect().left),panelLeft:Math.round(document.querySelector('fieldset[aria-label=\"Sketch drawing\"]').getBoundingClientRect().left),overflow:box.scrollWidth-box.clientWidth};" },
|
||||
{ "type": "shot", "name": "02-sketch-panel-full", "fullPage": true },
|
||||
{ "type": "assertAnyText", "selector": "main.stage", "contains": "Sketch" }
|
||||
]
|
||||
}
|
||||
@@ -4346,6 +4346,43 @@ export function WorkbenchShell({
|
||||
</button>
|
||||
<p role="status">当前文档:{documentSelection.documentId || "未绑定"}</p>
|
||||
</details>
|
||||
{(() => {
|
||||
// Desktop FreeCAD acts on the tree selection. The workbench shell only had a
|
||||
// selection table for BIM and a viewport selection for Web/Std_Open, so
|
||||
// commands like Sketcher_EditSketch could never receive a selected object.
|
||||
const tree = nativeDocuments[documentSelection.documentId];
|
||||
if (!tree?.objects.length) return null;
|
||||
const select = (name: string, checked: boolean) => {
|
||||
setDocumentSelection(current => ({
|
||||
documentId: current.documentId,
|
||||
selection: checked
|
||||
? [...current.selection.filter(entry => entry.object !== name), { documentId: current.documentId, object: name }]
|
||||
: current.selection.filter(entry => entry.object !== name),
|
||||
}));
|
||||
setPayloadText(current => {
|
||||
try {
|
||||
const args = JSON.parse(current);
|
||||
if (!args || typeof args !== "object" || Array.isArray(args)) return current;
|
||||
const kept = Array.isArray(args.selection)
|
||||
? args.selection.filter((entry: { object?: string }) => entry?.object !== name) : [];
|
||||
const selection = checked ? [...kept, { documentId: documentSelection.documentId, object: name }] : kept;
|
||||
return JSON.stringify({ ...args, documentId: documentSelection.documentId, selection }, null, 2);
|
||||
} catch { return current; }
|
||||
});
|
||||
};
|
||||
return <details className="workbench-object-picker" open>
|
||||
<summary>文档对象 · 选择({documentSelection.documentId})</summary>
|
||||
<ul role="list">
|
||||
{tree.objects.map(object => <li key={object.name}>
|
||||
<label><input type="checkbox" disabled={busy}
|
||||
aria-label={`Select object ${object.label ?? object.name}`}
|
||||
checked={documentSelection.selection.some(entry => entry.object === object.name)}
|
||||
onChange={event => select(object.name, event.target.checked)} />
|
||||
{" "}{object.label ?? object.name} <small>{object.typeId}</small></label>
|
||||
</li>)}
|
||||
</ul>
|
||||
</details>;
|
||||
})()}
|
||||
{module === "TemplatePyMod" && <TemplatePyModCommandSurfaces busy={busy || pythonQtActive}
|
||||
hasDocument={Boolean(documentSelection.documentId)}
|
||||
available={name => moduleMatrixRecords.some(item => item.kind === "desktop-gui" && item.command === name)}
|
||||
|
||||
Reference in New Issue
Block a user