Files
cnc_wams/wasm-port/docs/ui-panel-state-summary.md

81 lines
2.7 KiB
Markdown

# UI Panel State Summary
## Purpose
`runtime/ui/ini-panel/panel-state-summary.js` contains a pure helper for
bundling the already-observed host/runtime boundary state of the INI panel into
a single machine-readable snapshot.
The helper does not implement CNC behavior. It only packages the summary
objects produced by the run/session/machine-file helpers and the visible badge
state so browser tests or future UI consumers can compare panel state without
reading ad hoc DOM text.
## `createIniPanelStateSummary(input)`
`input` may contain:
```js
{
badges: { ini: "INI WASM: ready", interp: "Interpreter WASM: ready", opfs: "OPFS: ready" },
machine: { machine: "xyzab-tdr", kinematics: "trivkins" },
machineFiles: { iniOpfsPath: "...", toolTableOpfsPath: "...", parameterOpfsPath: "...", gcodeOpfsPath: "..." },
sessionSnapshot: { snapshotLabel: "...", workflow: "save-session-snapshot" },
sessionLoad: { iniOpfsPath: "...", iniWasmPath: "..." },
run: { runStatus: "ok", programSource: "snapshot" },
fiveaxisRemap: "ok"
}
```
The returned snapshot preserves those nested objects and normalizes missing
badge entries to `null`.
## `createMachineSessionStateSnapshot(input)`
This helper builds the richer state snapshot used by the INI panel and exposed
as `window.linuxCncIniPanelMachineSessionState`.
It preserves the base panel state and adds:
```js
{
selectedProgram: { source: "snapshot", opfsPath: "...", wasmPath: "..." },
fields: {
sessionIni: "/work/session-machine.ini",
sessionParameters: "/work/session-linuxcnc.var",
sessionToolTable: "/work/session-tool.tbl",
sessionGcode: "linuxcnc/gcode/ui-session.ngc",
sessionSnapshot: "ui-machine-session/ui-machine-session.json",
runStatus: "ok",
runSource: "snapshot",
runSnapshot: "ui-machine-session/ui-machine-session.json",
runWorkflow: "save-session-snapshot",
runOpfsPath: "linuxcnc/gcode/ui-session.ngc",
runWasmPath: "/work/ui-session.ngc"
},
lastAction: "run-gcode",
error: null
}
```
The INI panel updates this state after save, restore, load, run, and error
paths so browser tests and future API consumers can read one machine-readable
state object instead of collecting DOM fields and log text.
## Boundary Rules
- Do not parse G-code text in this helper.
- Do not infer CNC semantics from the nested summaries.
- Keep the helper as a bundling layer over already-observed UI boundary state.
- Keep workflow result objects as host/runtime boundary facts; this helper must
not promote, reinterpret, or synthesize CNC behavior.
## Validation
The helper is covered by:
```bash
wasm-port/tests/ui/node/verify_ini_panel_state_summary.sh
wasm-port/tests/ui/node/verify_ui_node_smokes.sh
```