diff --git a/dashboard/js/onboard.js b/dashboard/js/onboard.js index 8f8526a..df3b61d 100644 --- a/dashboard/js/onboard.js +++ b/dashboard/js/onboard.js @@ -450,9 +450,19 @@ '
' + '' + + '' + + ' ← Back to Connect' + + '
' + ''; hideNav(); patchConsole(); + document.getElementById('flash-back-link').addEventListener('click', function (e) { + e.preventDefault(); + cancelled = true; + restoreConsole(); + var connectIdx = STEPS.findIndex(function (s) { return s.id === 'connect_device'; }); + goToStep(connectIdx >= 0 ? connectIdx : state.currentStepIndex - 1); + }); // Uses vendored esptool-js (dashboard/js/esptool-bundle.js) loaded via dynamic import. // Flashing starts automatically — no button click required. @@ -1237,7 +1247,16 @@ state.wifiPass = saved.wifiPass || ''; state.mothershipHost = saved.mothershipHost || ''; state.mothershipPort = saved.mothershipPort || 8080; - goToStep(state.currentStepIndex); + // After a page reload the serial port reference is gone. If we were mid-flash + // (step 2 = connect, step 3 = flash) drop back to connect so the user can + // re-select their device rather than landing on a broken flash screen. + var flashStepIndex = STEPS.findIndex(function (s) { return s.id === 'flash_firmware'; }); + var connectStepIndex = STEPS.findIndex(function (s) { return s.id === 'connect_device'; }); + if (state.currentStepIndex >= flashStepIndex && !state.port) { + goToStep(connectStepIndex >= 0 ? connectStepIndex : 0); + } else { + goToStep(state.currentStepIndex); + } } else { goToStep(0); }