Clear stale toolpaths on program replacement

This commit is contained in:
2026-09-02 13:55:45 +08:00
parent ee2c992328
commit 8b7fc5221b
4 changed files with 75 additions and 3 deletions

View File

@@ -1926,6 +1926,11 @@ export class SimSession {
case "PROGRAM_LOAD": {
if (["RUNNING", "PAUSED"].includes(this.task.state.state)) return finish(this.error(input, "task_state", "program_load_while_active"), "failed");
const source = input.payload?.source ?? input.payload?.text ?? input.payload?.program_source;
// PROGRAM_LOAD is a replacement transaction. Clear the previous
// canonical preview before asking the WASM interpreter to parse the
// new source, so a parse/subroutine error cannot re-publish the old
// toolpath as if it belonged to the requested file.
this.previewState = null;
if (this.xyzacProgram) {
this.pendingXyzacMotion = null;
this.pendingProgramControl = 0;