推进 INI 面板 control view DOM consumer

This commit is contained in:
2026-06-14 22:45:45 +08:00
parent 4133d202f0
commit 74617cc3fa
3 changed files with 120 additions and 0 deletions

View File

@@ -1019,3 +1019,63 @@ host_wasm_opfs_browser_smokes=ok
继续推进实际控制网页界面的只读展示层。下一批建议新增一个极薄的 browser smoke 或
文档化控制页消费示例,直接读取 `window.linuxCncIniPanelApi.getMachineSessionControlView()`
并渲染 sections仍保持只读不加控制按钮不解析 G-code。
十一、2026-06-14 继续执行记录INI panel control view DOM consumer
本轮按“加快实质性推进”把 control view 从纯数据 helper 推到真实 browser consumer 层,
新增一个极薄的只读 DOM 渲染示例,直接消费
`window.linuxCncIniPanelApi.getMachineSessionControlView()`。
完成内容:
- `wasm-port/tests/browser/ini_panel_smoke.html` 新增只读 control view DOM 容器;
- 新增 `renderControlView(document, view)`,按 `view.sections` 渲染 section heading 与
`dl/dt/dd` rows
- browser smoke 在真实 save、restore-load、run 流程后:
- 读取 `getMachineSessionControlView()`
- 渲染 sections
- 验证 DOM status
- 验证 DOM section count
- 验证 run section canonical-event row
- `wasm-port/docs/ui-panel-state-summary.md` 增加最小 browser consumer 示例;
- 未新增控制按钮;
- 未解析 G-code
- 未解释 canonical events
- 未改变 OPFS/session persistence、LinuxCNC interpreter、tool、parameter、planner 或
LinuxCNC-owned runtime semantics。
验证已通过:
```bash
git diff --check
wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh
wasm-port/tests/ui/node/verify_ui_node_smokes.sh
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_ini_panel_browser.sh
wasm-port/tools/verify_vendor_sync.sh
wasm-port/tools/verify_no_standalone_cnc_semantics.sh
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh
wasm-port/tests/host/verify_host_smokes.sh
```
关键输出:
```text
ini_panel_state_summary_node_smoke=ok
ui_node_smokes=ok
browser_ini_opfs_smoke=ok
vendor sync up to date
standalone CNC semantics guard complete
interp_wasm_node_smoke=ok
sim_configs_wasm_node_inventory_executed=28
sim_configs_wasm_node_inventory_passed=28
sim_configs_wasm_node_inventory_skipped=131
sim_configs_wasm_node_inventory_unexpected_fail=0
host_wasm_opfs_browser_smokes=ok
```
下一步建议:
继续推进实质控制网页界面,但保持只读边界。下一批建议把这个 DOM consumer 提取为一个
可复用的纯 renderer helper例如 `renderMachineSessionControlView(container, view)`
供真实页面和 smoke 共用;仍不新增控制按钮,不解析 G-code。

View File

@@ -161,6 +161,18 @@ This helper maps a bundle into UI-ready status and sections:
It is a presentation mapping over the bundle only. It does not parse G-code,
canonical events, or LinuxCNC-owned runtime content.
A minimal read-only browser consumer can render the sections directly:
```js
const view = window.linuxCncIniPanelApi.getMachineSessionControlView();
for (const section of view.sections) {
renderSection(section.title, section.rows);
}
```
Consumers should treat `rows` as display data and keep actions wired through
explicit workflow APIs instead of deriving behavior from labels.
## Boundary Rules
- Do not parse G-code text in this helper.

View File

@@ -6,6 +6,10 @@
</head>
<body>
<pre id="status">running</pre>
<div id="control-view">
<div id="control-status"></div>
<div id="control-sections"></div>
</div>
<script type="module">
import { createLinuxCncIniSdk } from "../../runtime/sdk/src/index.js";
import { loadTextFile, saveTextFile } from "../../runtime/opfs/file-service.js";
@@ -76,6 +80,34 @@
return frame.contentDocument;
}
function renderControlView(containerDocument, view) {
const statusNode = containerDocument.getElementById("control-status");
const sectionsNode = containerDocument.getElementById("control-sections");
statusNode.textContent = [
view.status.lastAction ?? "-",
view.status.runStatus ?? "-",
view.status.error ?? "-",
].join(" | ");
sectionsNode.textContent = "";
for (const section of view.sections) {
const sectionNode = containerDocument.createElement("section");
sectionNode.dataset.sectionId = section.id;
const heading = containerDocument.createElement("h2");
heading.textContent = section.title;
sectionNode.appendChild(heading);
const list = containerDocument.createElement("dl");
for (const row of section.rows) {
const term = containerDocument.createElement("dt");
term.textContent = row.label;
const def = containerDocument.createElement("dd");
def.textContent = String(row.value ?? "-");
list.append(term, def);
}
sectionNode.appendChild(list);
sectionsNode.appendChild(sectionNode);
}
}
try {
const ini = await createLinuxCncIniSdk();
const wasmPath = "/work/browser-smoke.ini";
@@ -832,6 +864,7 @@ TOOL_TABLE = browser-tool.tbl
"UI legacy machine session state bundle getter matches API namespace",
);
const machineSessionControlView = uiApi.getMachineSessionControlView();
renderControlView(document, machineSessionControlView);
assertEqual(
machineSessionControlView.status.runStatus,
"ok",
@@ -852,6 +885,21 @@ TOOL_TABLE = browser-tool.tbl
2,
"UI machine session control view canonical event row",
);
assertEqual(
document.getElementById("control-status").textContent,
"run-gcode | ok | -",
"UI machine session control view DOM status",
);
assertEqual(
document.getElementById("control-sections").querySelectorAll("section").length,
3,
"UI machine session control view DOM section count",
);
assertEqual(
document.getElementById("control-sections").querySelector('section[data-section-id=\"run\"] dd:nth-of-type(2)').textContent,
"2",
"UI machine session control view DOM canonical event row",
);
assertEqual(
uiDocument.defaultView.getMachineSessionControlView().status.lastAction,
machineSessionControlView.status.lastAction,