推进 INI 面板 G-code 回退来源 guard
This commit is contained in:
@@ -323,9 +323,11 @@ function gcodeFilenameFromSnapshotPath(path) {
|
||||
async function loadSelectedGcodeProgram() {
|
||||
const opfsPath = restoredSessionSnapshot?.payload?.files?.gcode;
|
||||
const filename = gcodeFilenameFromSnapshotPath(opfsPath);
|
||||
const hasSnapshotGcode = typeof opfsPath === "string" && opfsPath.startsWith("linuxcnc/gcode/");
|
||||
return {
|
||||
filename,
|
||||
opfsPath: opfsPath ?? `linuxcnc/gcode/${filename}`,
|
||||
source: hasSnapshotGcode ? "snapshot" : "default",
|
||||
wasmPath: GCODE_WASM_FILE,
|
||||
text: await loadGcodeProgram(filename),
|
||||
};
|
||||
@@ -593,6 +595,7 @@ document.getElementById("run-gcode").addEventListener("click", async () => {
|
||||
[
|
||||
"Ran G-code through LinuxCNC interpreter WASM.",
|
||||
`Program: ${program.opfsPath} -> ${program.wasmPath}`,
|
||||
`Program source: ${program.source}`,
|
||||
`INI: ${loadedSession.ini.wasmPath}`,
|
||||
result.trim(),
|
||||
].join("\n"),
|
||||
|
||||
@@ -379,6 +379,24 @@ TOOL_TABLE = browser-tool.tbl
|
||||
() => uiDocument.getElementById("log")?.textContent.includes("Saved machine text files"),
|
||||
"machine file save",
|
||||
);
|
||||
uiDocument.getElementById("load-session").click();
|
||||
await waitFor(
|
||||
() => uiDocument.getElementById("log")?.textContent.includes("Loaded machine session"),
|
||||
"fallback machine session load",
|
||||
);
|
||||
uiDocument.getElementById("run-gcode").click();
|
||||
await waitFor(
|
||||
() => uiDocument.getElementById("log")?.textContent.includes("Ran G-code"),
|
||||
"fallback G-code run",
|
||||
);
|
||||
const fallbackRunLog = uiDocument.getElementById("log").textContent;
|
||||
if (
|
||||
!fallbackRunLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc") ||
|
||||
!fallbackRunLog.includes("Program source: default") ||
|
||||
!fallbackRunLog.includes("canon_event=STRAIGHT_FEED")
|
||||
) {
|
||||
throw new Error(`UI fallback G-code run did not use default OPFS program path: ${fallbackRunLog}`);
|
||||
}
|
||||
uiDocument.getElementById("save-session-snapshot").click();
|
||||
await waitFor(
|
||||
() => uiDocument.getElementById("log")?.textContent.includes("Saved machine session snapshot"),
|
||||
@@ -464,7 +482,10 @@ TOOL_TABLE = browser-tool.tbl
|
||||
"UI G-code run status",
|
||||
);
|
||||
const runLog = uiDocument.getElementById("log").textContent;
|
||||
if (!runLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc")) {
|
||||
if (
|
||||
!runLog.includes("Program: linuxcnc/gcode/ui-session.ngc -> /work/ui-session.ngc") ||
|
||||
!runLog.includes("Program source: snapshot")
|
||||
) {
|
||||
throw new Error(`UI G-code run did not use snapshot OPFS program path: ${runLog}`);
|
||||
}
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user