推进 INI 面板运行快照上下文日志

This commit is contained in:
2026-06-14 17:12:14 +08:00
parent 0c0da13681
commit 6242b415ff
3 changed files with 77 additions and 4 deletions

View File

@@ -969,3 +969,62 @@ host_wasm_opfs_browser_smokes=ok
也带入 `Run G-code` 成功日志,例如显示 `Snapshot`、`Program source`、`Workflow`
让用户能从一次运行日志中确认程序来源与会话来源;并在 browser smoke 中验证 snapshot
run 与 default fallback run 的日志差异。仍不解析或改写任何 CNC 语义。
十三、2026-06-14 继续执行记录INI panel run snapshot context log
本轮继续沿 OPFS/session/UI boundary 推进,把 machine session snapshot 的上下文摘要
带入 `Run G-code` 成功日志,便于用户从一次运行记录中审计程序来源与会话来源。
完成内容:
- 在 `wasm-port/runtime/ui/ini-panel/app.js` 新增 `runSessionContextLogLines(...)`
- `Run G-code` 成功日志现在统一显示:
- `Program: <opfs> -> <wasm>`
- `Program source: default|snapshot`
- `Snapshot: <session>/<file>` 或 `-`
- `Workflow` 与 `Default G-code` metadata 摘要;
- default fallback run 明确显示没有 snapshot context
- snapshot run 显示 `ui-machine-session/ui-machine-session.json`、
`save-session-snapshot` 与默认 G-code OPFS path
- browser INI panel smoke 验证 fallback run 与 snapshot run 的日志差异;
- 未改变 snapshot envelope、payload 文件清单、metadata JSON 内容、OPFS path model、
G-code 文本内容、interpreter run API、canonical-event 输出或 LinuxCNC-owned runtime
semantics。
验证已通过:
```bash
git diff --check
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_ini_panel_browser.sh
wasm-port/tests/opfs/node/verify_file_service.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
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh
wasm-port/tests/host/verify_host_smokes.sh
```
关键输出:
```text
browser_ini_opfs_smoke=ok
opfs_file_service_node_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/UI boundary 推进。优先让 `Run G-code` 日志中的 session context
同步落到一个可复用的 UI 状态字段或机器可读 run summary例如保存最近一次 run 的
`programSource`、`snapshotLabel`、`workflow`、`programOpfsPath`、`programWasmPath`
供后续 SDK/API 或 UI panel 读取;先只做 UI/测试边界,不改变 interpreter、OPFS bridge
或 LinuxCNC-owned runtime semantics。

View File

@@ -341,6 +341,15 @@ function sessionMetadataLogLines(metadata = {}) {
];
}
function runSessionContextLogLines(program, snapshot = restoredSessionSnapshot) {
return [
`Program: ${program.opfsPath} -> ${program.wasmPath}`,
`Program source: ${program.source}`,
`Snapshot: ${snapshot ? sessionSnapshotLabel(snapshot.sessionId) : "-"}`,
...sessionMetadataLogLines(snapshot?.metadata),
];
}
async function loadSelectedGcodeProgram() {
const opfsPath = restoredSessionSnapshot?.payload?.files?.gcode;
let filename = UI_SESSION.defaultGcodeFilename;
@@ -628,8 +637,7 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
setLog(
[
"Ran G-code through LinuxCNC interpreter WASM.",
`Program: ${program.opfsPath} -> ${program.wasmPath}`,
`Program source: ${program.source}`,
...runSessionContextLogLines(program),
`INI: ${loadedSession.ini.wasmPath}`,
result.trim(),
].join("\n"),

View File

@@ -404,6 +404,9 @@ TOOL_TABLE = browser-tool.tbl
if (
!fallbackRunLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc") ||
!fallbackRunLog.includes("Program source: default") ||
!fallbackRunLog.includes("Snapshot: -") ||
!fallbackRunLog.includes("Workflow: -") ||
!fallbackRunLog.includes("Default G-code: -") ||
!fallbackRunLog.includes("canon_event=STRAIGHT_FEED")
) {
throw new Error(`UI fallback G-code run did not use default OPFS program path: ${fallbackRunLog}`);
@@ -532,9 +535,12 @@ TOOL_TABLE = browser-tool.tbl
const runLog = uiDocument.getElementById("log").textContent;
if (
!runLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc") ||
!runLog.includes("Program source: snapshot")
!runLog.includes("Program source: snapshot") ||
!runLog.includes("Snapshot: ui-machine-session/ui-machine-session.json") ||
!runLog.includes("Workflow: save-session-snapshot") ||
!runLog.includes("Default G-code: linuxcnc/gcode/ui-session.ngc")
) {
throw new Error(`UI G-code run did not use snapshot OPFS program path: ${runLog}`);
throw new Error(`UI G-code run missing snapshot session context: ${runLog}`);
}
if (
!runLog.includes("canon_event=STRAIGHT_TRAVERSE") ||