Files
cnc_wams/wasm-port/docs/ui-machine-file-helpers.md

69 lines
1.8 KiB
Markdown

# UI Machine File Helpers
## Purpose
`runtime/ui/ini-panel/machine-file-summary.js` contains small host-boundary
helpers for summarizing machine text file save/load actions. These helpers are
pure so browser UI panels, SDK-facing wrappers, and Node smoke tests can share
the same data shape without parsing log text.
The helpers do not implement CNC behavior. They only describe OPFS path mapping
and captured text lengths for machine files staged by the UI.
## `createMachineFileSaveSummary(paths, gcodePath)`
`paths` is the object returned by `saveMachineTextFiles(...)`.
`gcodePath` is the OPFS path returned by `saveGcodeProgram(...)`.
The returned summary has this shape:
```js
{
iniOpfsPath: "linuxcnc/machines/xyzab-tdr/machine.ini",
toolTableOpfsPath: "linuxcnc/machines/xyzab-tdr/tool.tbl",
parameterOpfsPath: "linuxcnc/machines/xyzab-tdr/linuxcnc.var",
gcodeOpfsPath: "linuxcnc/gcode/ui-session.ngc"
}
```
## `createMachineFileLoadSummary(files)`
`files` is the object returned by `loadMachineTextFiles(...)`.
The returned summary has this shape:
```js
{
iniBytes: 26,
toolTableBytes: 13,
parameterBytes: 7
}
```
## Log Helpers
- `machineFileSaveLogLines(summary)` renders the staged OPFS paths.
- `machineFileLoadLogLines(summary)` renders the loaded byte lengths.
## Boundary Rules
- Do not parse G-code text in these helpers.
- Do not infer tool, parameter, kinematics, planner, or modal semantics.
- Do not derive new CNC behavior from the staged file names or lengths.
- Keep new fields limited to host/runtime boundary facts already produced by
the LinuxCNC-owned runtime or UI staging layer.
## Validation
Run the focused Node smoke after changing these helpers:
```bash
wasm-port/tests/ui/node/verify_ini_panel_machine_file_summary.sh
```
The aggregate UI Node smoke is:
```bash
wasm-port/tests/ui/node/verify_ui_node_smokes.sh
```