From 820a0fa024537c2731aaebab7a558d1af01ab7dc Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Tue, 11 Aug 2026 22:37:15 +0200 Subject: [PATCH] fix(flash): block web flashing for MicroPython boards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compiledProgram holds the 'micropython-loaded' sentinel in MicroPython mode, not a flash image — atob() blew up with an encoding DOMException before the port chooser even opened. The menu item now disables with an explanatory tooltip and the modal shows the limitation instead of the Connect button. --- frontend/src/components/simulator/FlashModal.tsx | 14 ++++++++++++-- .../src/components/simulator/SimulatorCanvas.tsx | 14 ++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/simulator/FlashModal.tsx b/frontend/src/components/simulator/FlashModal.tsx index 4fa14108..29fc882c 100644 --- a/frontend/src/components/simulator/FlashModal.tsx +++ b/frontend/src/components/simulator/FlashModal.tsx @@ -404,7 +404,10 @@ interface WebReadyProps { } const WebReadyView = ({ board, onFlash }: WebReadyProps) => { - const hasCompiled = !!board.compiledProgram; + // MicroPython boards carry the 'micropython-loaded' sentinel instead of + // a flash image — nothing to write. Arduino/ESP-IDF sketches only. + const isMpy = board.languageMode === 'micropython'; + const hasCompiled = !!board.compiledProgram && !isMpy; return (
@@ -418,7 +421,14 @@ const WebReadyView = ({ board, onFlash }: WebReadyProps) => {
- {!hasCompiled && ( + {isMpy && ( +
+ MicroPython projects cannot be flashed to a real board yet — only + compiled Arduino/ESP-IDF sketches. +
+ )} + + {!board.compiledProgram && !isMpy && (
No compiled program for this board yet. Click Compile in the toolbar first.
diff --git a/frontend/src/components/simulator/SimulatorCanvas.tsx b/frontend/src/components/simulator/SimulatorCanvas.tsx index 975aab43..98444c93 100644 --- a/frontend/src/components/simulator/SimulatorCanvas.tsx +++ b/frontend/src/components/simulator/SimulatorCanvas.tsx @@ -3447,13 +3447,19 @@ export const SimulatorCanvas = ({ headerSlot }: SimulatorCanvasProps = {}) => { // on the web the pro overlay may install a Web Serial flasher // for this board kind (no-op in pure OSS builds). if (isTauriRuntime || webFlashAvailable(board.boardKind)) { + // MicroPython boards don't compile to a flash image — the store + // keeps the 'micropython-loaded' sentinel, which no flasher can + // write. Arduino/ESP-IDF sketches only. + const isMpy = board.languageMode === 'micropython'; actions.push({ id: 'flash', label: t('editor.canvas.flashToBoard'), - disabled: !board.compiledProgram, - title: board.compiledProgram - ? 'Flash the compiled sketch to a real USB-attached board' - : 'Compile the sketch first', + disabled: !board.compiledProgram || isMpy, + title: isMpy + ? 'MicroPython projects cannot be flashed yet — Arduino sketches only' + : board.compiledProgram + ? 'Flash the compiled sketch to a real USB-attached board' + : 'Compile the sketch first', onSelect: () => { setFlashModalFor(boardContextMenu.boardId); setBoardContextMenu(null);