推进 INI 面板 load-session workflow helper

This commit is contained in:
2026-06-15 05:05:21 +08:00
parent 98d236250f
commit cb6ef7824c
4 changed files with 161 additions and 34 deletions

View File

@@ -34,14 +34,11 @@ import {
import {
runGcodeSessionWorkflow,
} from "./run-workflow.js";
import {
createMachineSessionLoadSummary,
machineSessionLoadLogLines,
} from "./session-load-summary.js";
import {
sessionSnapshotSummaryLogLines,
} from "./session-summary.js";
import {
loadMachineSessionIntoWasmWorkflow,
restoreMachineSessionSnapshotWorkflow,
saveMachineSessionSnapshotWorkflow,
} from "./session-workflow.js";
@@ -712,24 +709,17 @@ document.getElementById("restore-session-snapshot").addEventListener("click", as
document.getElementById("load-session").addEventListener("click", async () => {
try {
await loadMachineSessionIntoWasm();
const loadSummary = createMachineSessionLoadSummary(loadedSession);
const workflow = await loadMachineSessionIntoWasmWorkflow({
loadSession: () => loadMachineSessionIntoWasm(),
});
loadedSession = workflow.loadedSession;
updatePanelMachineSessionState({
sessionLoad: loadSummary,
fields: {
sessionIni: loadSummary.iniWasmPath,
sessionParameters: loadSummary.parameterWasmPath,
sessionToolTable: loadSummary.toolTableWasmPath,
},
sessionLoad: workflow.loadSummary,
fields: workflow.fields,
lastAction: "load-session",
error: null,
});
setLog(
[
"Loaded machine session into the interpreter WASM filesystem.",
...machineSessionLoadLogLines(loadSummary),
].join("\n"),
);
setLog(workflow.logLines.join("\n"));
} catch (error) {
updatePanelMachineSessionState({
lastAction: "load-session",

View File

@@ -37,6 +37,35 @@ export function sessionSnapshotRestoreLogLines(summary) {
];
}
export function createMachineSessionLoadFieldState(summary) {
return {
sessionIni: summary.iniWasmPath,
sessionParameters: summary.parameterWasmPath,
sessionToolTable: summary.toolTableWasmPath,
};
}
export function machineSessionLoadWorkflowLogLines(summary) {
return [
"Loaded machine session into the interpreter WASM filesystem.",
...machineSessionLoadLogLines(summary),
];
}
export async function loadMachineSessionIntoWasmWorkflow({ loadSession }) {
if (typeof loadSession !== "function") {
throw new Error("A machine session loader is required.");
}
const loadedSession = await loadSession();
const loadSummary = createMachineSessionLoadSummary(loadedSession);
return {
loadedSession,
loadSummary,
fields: createMachineSessionLoadFieldState(loadSummary),
logLines: machineSessionLoadWorkflowLogLines(loadSummary),
};
}
export async function saveMachineSessionSnapshotWorkflow({
machineId,
snapshotId,