if (msg._mode === "start" || msg._mode === "complete") { // Preserve original message for Back to UI (output 2) const originalMsg = {...msg}; // Create select message for refreshing WO table (output 1) msg._mode = "select"; msg.topic = "SELECT * FROM work_orders ORDER BY updated_at DESC;"; return [msg, originalMsg]; } if (msg._mode === "resume" || msg._mode === "restart") { // PHASE 3: After resume/restart, refresh WO list and notify UI const originalMsg = {...msg}; // Create select message for refreshing WO table (output 1) msg._mode = "select"; msg.topic = "SELECT * FROM work_orders ORDER BY updated_at DESC;"; return [msg, originalMsg]; } if (msg._mode === "check-progress") { // PHASE 3: Pass progress check results to Back to UI for processing return [null, msg]; } if (msg._mode === "cycle" || msg._mode === "production-state") { return [null, msg]; } if (msg._mode === "scrap-prompt") { return [null, msg]; } if (msg._mode === "restore-query") { // Pass restore query results to Back to UI return [null, msg]; } if (msg._mode === "current-state") { // Pass current state to Back to UI return [null, msg]; } if (msg._mode === "scrap-complete") { // Preserve original message for Back to UI (output 2) const originalMsg = {...msg}; // Create select message for refreshing WO table (output 1) msg._mode = "select"; msg.topic = "SELECT * FROM work_orders ORDER BY updated_at DESC;"; return [msg, originalMsg]; } return [null, msg];