推进 INI 面板 restore-load workflow 复用 load helper

This commit is contained in:
2026-06-15 05:09:41 +08:00
parent cb6ef7824c
commit a883af2d3e
5 changed files with 80 additions and 15 deletions

View File

@@ -370,3 +370,67 @@ host_wasm_opfs_browser_smokes=ok
继续推进 OPFS/session persistence 的实质链路。下一批建议将 `restore-load-session` 路径改为复用 继续推进 OPFS/session persistence 的实质链路。下一批建议将 `restore-load-session` 路径改为复用
`loadMachineSessionIntoWasmWorkflow()`,避免 restore+load 与单独 load 的 field/log 状态模型 `loadMachineSessionIntoWasmWorkflow()`,避免 restore+load 与单独 load 的 field/log 状态模型
分叉;仍保持由 LinuxCNC/OPFS bridge 执行实际语义,不在 JS 中解释 CNC 行为。 分叉;仍保持由 LinuxCNC/OPFS bridge 执行实际语义,不在 JS 中解释 CNC 行为。
三、2026-06-15 继续执行记录INI panel restore-load workflow 复用 load-session helper
本轮按“第一原则:加快实质性推进”继续推进 OPFS/session persistence 主链路,将
`restore-load-session` 路径收敛到已存在的 `loadMachineSessionIntoWasmWorkflow()`,让单独
load 与 restore+load 共享同一套 load summary、field state 和 log lines 模型。
完成内容:
- `restoreMachineSessionSnapshotWorkflow()` 的 restore+load 分支改为调用
`loadMachineSessionIntoWasmWorkflow({ loadSession })`
- restore+load 返回的 `loadedSession`、`loadSummary` 和 INI/parameter/tool-table field state
直接来自 load workflow
- restore+load 日志纳入 load workflow 的统一首行:
`Loaded machine session into the interpreter WASM filesystem.`
- 删除 `app.js` 中已不再使用的 `sessionSnapshotSummaryLogLines` import
- `verify_ini_panel_session_workflow.mjs` 增加 restore+load 复用断言,确认
`loadSummary` 与单独 load workflow 一致,且 `loadedSession` 保持 loader 返回对象;
- `ui-session-summary-helpers.md` 同步说明 restore-load 复用 load workflow
- 未新增控制按钮;
- 未解析 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_session_workflow.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_session_workflow_node_smoke=ok
ui_node_smokes=ok
browser_ini_opfs_smoke=ok
browser_ini_control_page_smoke=ok
browser_ini_launch_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
browser_interp_smoke=ok
host_wasm_opfs_browser_smokes=ok
```
下一步建议:
继续推进 OPFS/session persistence 的实质链路。下一批建议抽出 `run-session` 首帧 readiness
或 run 前置状态 helper把“已加载 session、已选择/恢复 snapshot、默认 G-code 路径、run
按钮可执行条件”统一成可复用状态模型;仍保持只描述 UI/host boundary facts不在 JS 中解释
G-code、canonical events 或 CNC 运行语义。

View File

@@ -9,8 +9,8 @@ for machine-session load state. These helpers are pure so browser UI panels,
SDK-facing wrappers, and Node smoke tests can share the same data shape without SDK-facing wrappers, and Node smoke tests can share the same data shape without
parsing log text. parsing log text.
`runtime/ui/ini-panel/session-workflow.js` contains the reusable UI workflows `runtime/ui/ini-panel/session-workflow.js` contains the reusable UI workflows
for saving, restoring, and restore-loading a machine session snapshot as for saving, restoring, loading, and restore-loading a machine session snapshot
host-boundary operations. as host-boundary operations.
The helpers do not implement CNC behavior. G-code execution, canonical events, The helpers do not implement CNC behavior. G-code execution, canonical events,
tool handling, parameters, kinematics, and planner behavior remain owned by the tool handling, parameters, kinematics, and planner behavior remain owned by the
@@ -76,7 +76,10 @@ The persistence functions are injected by the caller:
The workflow loads the machine session snapshot, loads the persisted machine The workflow loads the machine session snapshot, loads the persisted machine
text files so the editor can be restored, and optionally loads the machine text files so the editor can be restored, and optionally loads the machine
session into the interpreter WASM filesystem. session into the interpreter WASM filesystem. The optional restore-load path
reuses `loadMachineSessionIntoWasmWorkflow()` so standalone load and
restore-load consumers share the same load summary, field state, and load log
line model.
When `loadSession` is omitted, the returned `fields` contain the OPFS snapshot When `loadSession` is omitted, the returned `fields` contain the OPFS snapshot
paths. When `loadSession` is supplied, the returned `fields` contain the loaded paths. When `loadSession` is supplied, the returned `fields` contain the loaded
@@ -101,7 +104,8 @@ The returned object has this shape:
loadedSession: { ... }, loadedSession: { ... },
logLines: [ logLines: [
"Snapshot: ui-machine-session/ui-machine-session.json", "Snapshot: ui-machine-session/ui-machine-session.json",
"Workflow: save-session-snapshot" "Workflow: save-session-snapshot",
"Loaded machine session into the interpreter WASM filesystem."
] ]
} }
``` ```

View File

@@ -34,9 +34,6 @@ import {
import { import {
runGcodeSessionWorkflow, runGcodeSessionWorkflow,
} from "./run-workflow.js"; } from "./run-workflow.js";
import {
sessionSnapshotSummaryLogLines,
} from "./session-summary.js";
import { import {
loadMachineSessionIntoWasmWorkflow, loadMachineSessionIntoWasmWorkflow,
restoreMachineSessionSnapshotWorkflow, restoreMachineSessionSnapshotWorkflow,

View File

@@ -134,20 +134,17 @@ export async function restoreMachineSessionSnapshotWorkflow({
logLines: sessionSnapshotRestoreLogLines(summary), logLines: sessionSnapshotRestoreLogLines(summary),
}; };
if (loadSession) { if (loadSession) {
const loadedSession = await loadSession(); const loadWorkflow = await loadMachineSessionIntoWasmWorkflow({ loadSession });
const loadSummary = createMachineSessionLoadSummary(loadedSession); result.loadedSession = loadWorkflow.loadedSession;
result.loadedSession = loadedSession; result.loadSummary = loadWorkflow.loadSummary;
result.loadSummary = loadSummary;
result.fields = { result.fields = {
...fields, ...fields,
sessionIni: loadSummary.iniWasmPath, ...loadWorkflow.fields,
sessionParameters: loadSummary.parameterWasmPath,
sessionToolTable: loadSummary.toolTableWasmPath,
sessionGcode: summary.gcodeOpfsPath, sessionGcode: summary.gcodeOpfsPath,
}; };
result.logLines = [ result.logLines = [
...sessionSnapshotSummaryLogLines(summary), ...sessionSnapshotSummaryLogLines(summary),
...machineSessionLoadLogLines(loadSummary), ...loadWorkflow.logLines,
`G-code: ${summary.gcodeOpfsPath ?? "-"}`, `G-code: ${summary.gcodeOpfsPath ?? "-"}`,
]; ];
} }

View File

@@ -279,11 +279,14 @@ assert.deepEqual(restoreLoadWorkflow.fields, {
sessionGcode: "linuxcnc/gcode/ui-session.ngc", sessionGcode: "linuxcnc/gcode/ui-session.ngc",
sessionSnapshot: "ui-machine-session/ui-machine-session.json", sessionSnapshot: "ui-machine-session/ui-machine-session.json",
}); });
assert.deepEqual(restoreLoadWorkflow.loadSummary, loadWorkflow.loadSummary);
assert.equal(restoreLoadWorkflow.loadedSession, loadedSessionFixture);
assert.deepEqual(restoreLoadWorkflow.logLines, [ assert.deepEqual(restoreLoadWorkflow.logLines, [
"Snapshot: ui-machine-session/ui-machine-session.json", "Snapshot: ui-machine-session/ui-machine-session.json",
"Workflow: save-session-snapshot", "Workflow: save-session-snapshot",
"Default G-code: linuxcnc/gcode/ui-session.ngc", "Default G-code: linuxcnc/gcode/ui-session.ngc",
"Loaded machine session into the interpreter WASM filesystem.",
"INI: linuxcnc/machines/xyzab-tdr/machine.ini -> /work/session-machine.ini", "INI: linuxcnc/machines/xyzab-tdr/machine.ini -> /work/session-machine.ini",
"Parameter file: linuxcnc/machines/xyzab-tdr/linuxcnc.var -> /work/session-linuxcnc.var", "Parameter file: linuxcnc/machines/xyzab-tdr/linuxcnc.var -> /work/session-linuxcnc.var",
"Parameters: restore_parameters=0", "Parameters: restore_parameters=0",