fix(editor): surface QEMU compile failure to the user instead of silent warning

When the auto-compile path in handleRun() finishes without producing a
compiledProgram, the previous code dropped the failure on the floor with
only a `console.warn` — the user clicked Run, nothing happened, and they
had no idea why. The accompanying comment also promised "always start
even if compiledProgram is empty" but the code did the opposite.

This commit replaces the dead comment + silent warn with a top-level
error toast + addLog entry, with a different copy for MicroPython mode
(suggests "click Load MicroPython to retry") vs Arduino C++ mode
(directs the user to the output console for the underlying error).

handleCompile already writes the actual cause to the compile-output
console via addLog — this fix just makes sure the user knows their
click failed and where to look.
This commit is contained in:
David Montero 2026-05-23 08:39:26 +02:00
parent e91aaea2fd
commit 2f60e3816a
1 changed files with 13 additions and 4 deletions

View File

@ -597,10 +597,6 @@ export const EditorToolbar = ({
compiledProgramLen: updatedBoard?.compiledProgram?.length ?? 0,
autoRunFlag: autoRunAfterCompile.current,
});
// For QEMU boards, always start even if compiledProgram is empty —
// the bridge can be told to start without firmware (for waiting on
// a later upload) and is the safest path when the binary may be
// present on the bridge but not yet reflected in the store.
if (autoRunAfterCompile.current) {
autoRunAfterCompile.current = false;
if (updatedBoard?.compiledProgram) {
@ -610,7 +606,20 @@ export const EditorToolbar = ({
startBoard(activeBoardId);
setMessage(null);
} else {
// handleCompile returned without producing a firmware/program.
// Most common causes: arduino-cli unreachable, ESP-IDF compile
// error in the user's sketch, MicroPython firmware download
// failed, or the bridge rejected the load. handleCompile has
// already addLog'd the underlying error — surface a top-level
// toast too so the user knows their Run click didn't silently
// succeed.
const isMicropython = updatedBoard?.languageMode === 'micropython';
const errText = isMicropython
? 'MicroPython firmware did not load. Click "Load MicroPython" to retry, or check the console for the underlying error.'
: 'Compilation produced no firmware. Check the output console for the underlying error.';
console.warn('[handleRun] compile finished but no compiledProgram — not starting');
setMessage({ type: 'error', text: errText });
addLog({ timestamp: new Date(), type: 'error', message: errText });
}
}
return;