推进 INI 面板 restore-load workflow 复用 load helper
This commit is contained in:
@@ -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
|
||||
parsing log text.
|
||||
`runtime/ui/ini-panel/session-workflow.js` contains the reusable UI workflows
|
||||
for saving, restoring, and restore-loading a machine session snapshot as
|
||||
host-boundary operations.
|
||||
for saving, restoring, loading, and restore-loading a machine session snapshot
|
||||
as host-boundary operations.
|
||||
|
||||
The helpers do not implement CNC behavior. G-code execution, canonical events,
|
||||
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
|
||||
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
|
||||
paths. When `loadSession` is supplied, the returned `fields` contain the loaded
|
||||
@@ -101,7 +104,8 @@ The returned object has this shape:
|
||||
loadedSession: { ... },
|
||||
logLines: [
|
||||
"Snapshot: ui-machine-session/ui-machine-session.json",
|
||||
"Workflow: save-session-snapshot"
|
||||
"Workflow: save-session-snapshot",
|
||||
"Loaded machine session into the interpreter WASM filesystem."
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -34,9 +34,6 @@ import {
|
||||
import {
|
||||
runGcodeSessionWorkflow,
|
||||
} from "./run-workflow.js";
|
||||
import {
|
||||
sessionSnapshotSummaryLogLines,
|
||||
} from "./session-summary.js";
|
||||
import {
|
||||
loadMachineSessionIntoWasmWorkflow,
|
||||
restoreMachineSessionSnapshotWorkflow,
|
||||
|
||||
@@ -134,20 +134,17 @@ export async function restoreMachineSessionSnapshotWorkflow({
|
||||
logLines: sessionSnapshotRestoreLogLines(summary),
|
||||
};
|
||||
if (loadSession) {
|
||||
const loadedSession = await loadSession();
|
||||
const loadSummary = createMachineSessionLoadSummary(loadedSession);
|
||||
result.loadedSession = loadedSession;
|
||||
result.loadSummary = loadSummary;
|
||||
const loadWorkflow = await loadMachineSessionIntoWasmWorkflow({ loadSession });
|
||||
result.loadedSession = loadWorkflow.loadedSession;
|
||||
result.loadSummary = loadWorkflow.loadSummary;
|
||||
result.fields = {
|
||||
...fields,
|
||||
sessionIni: loadSummary.iniWasmPath,
|
||||
sessionParameters: loadSummary.parameterWasmPath,
|
||||
sessionToolTable: loadSummary.toolTableWasmPath,
|
||||
...loadWorkflow.fields,
|
||||
sessionGcode: summary.gcodeOpfsPath,
|
||||
};
|
||||
result.logLines = [
|
||||
...sessionSnapshotSummaryLogLines(summary),
|
||||
...machineSessionLoadLogLines(loadSummary),
|
||||
...loadWorkflow.logLines,
|
||||
`G-code: ${summary.gcodeOpfsPath ?? "-"}`,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -279,11 +279,14 @@ assert.deepEqual(restoreLoadWorkflow.fields, {
|
||||
sessionGcode: "linuxcnc/gcode/ui-session.ngc",
|
||||
sessionSnapshot: "ui-machine-session/ui-machine-session.json",
|
||||
});
|
||||
assert.deepEqual(restoreLoadWorkflow.loadSummary, loadWorkflow.loadSummary);
|
||||
assert.equal(restoreLoadWorkflow.loadedSession, loadedSessionFixture);
|
||||
|
||||
assert.deepEqual(restoreLoadWorkflow.logLines, [
|
||||
"Snapshot: ui-machine-session/ui-machine-session.json",
|
||||
"Workflow: save-session-snapshot",
|
||||
"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",
|
||||
"Parameter file: linuxcnc/machines/xyzab-tdr/linuxcnc.var -> /work/session-linuxcnc.var",
|
||||
"Parameters: restore_parameters=0",
|
||||
|
||||
Reference in New Issue
Block a user