From 808472819b1dfb3a8fdfc36e96a91c9884d910f2 Mon Sep 17 00:00:00 2001 From: jedarden Date: Thu, 16 Apr 2026 10:27:00 -0400 Subject: [PATCH] fix: reset to connect step on reload; add back link to flash step MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On page reload the serial port reference is lost. If saved state points to flash_firmware or later and port is null, drop back to connect_device so the user can re-select their device. Also add a small '← Back to Connect' link at the bottom of the flash step so there is always a visible escape route. Co-Authored-By: Claude Sonnet 4.6 --- dashboard/js/onboard.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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); }