fix(editor): Run button bypassed circuit pre-flight verification

The Run (and Run All) buttons were wired `onClick={handleRun}`, so React
passed the click event as the first argument. handleRun(skipVerify=false)
then treated the truthy event as skipVerify=true and skipped checkOrBlock
entirely -- the pre-flight circuit verifier never ran on a button click.
This is the real reason a 9V battery wired straight to an LED ran with no
warning even though the verifier exists and is correct (project 2840fd12).

- onClick={() => handleRun()} and onClick={() => handleRunAll()} so
  skipVerify stays at its false default.
- Give handleRunAll the same checkOrBlock pre-flight gate handleRun has.
This commit is contained in:
David Montero 2026-06-17 21:02:57 +02:00
parent f523dfb554
commit f7f0eb4ba8
1 changed files with 10 additions and 3 deletions

View File

@ -1068,12 +1068,19 @@ export const EditorToolbar = ({
* fresh WASM/ROM) + resuming the electrical solver when there's no board.
* Mirrors single Run, generalised across all targets.
*/
const handleRunAll = async () => {
const handleRunAll = async (skipVerify = false) => {
const sim = useSimulatorStore.getState();
const boardsList = sim.boards;
const chips = sim.components.filter((c) => c.metadataId === 'custom-chip');
if (boardsList.length === 0 && chips.length === 0) return;
// Same pre-flight safety check as handleRun — block on shorts / overcurrent
// before starting every board, with a "Run anyway" escape.
if (!skipVerify) {
const ok = await checkOrBlock(() => handleRunAll(true));
if (!ok) return;
}
// A chip needs compiling when it has no WASM yet, or it references a program
// file but hasn't been assembled to ROM.
const chipNeedsCompile = chips.some((c) => {
@ -1392,7 +1399,7 @@ export const EditorToolbar = ({
{/* Run */}
<button
onClick={handleRun}
onClick={() => handleRun()}
disabled={
isBoardless
? digitalRunning
@ -1478,7 +1485,7 @@ export const EditorToolbar = ({
{/* Run All */}
<button
onClick={handleRunAll}
onClick={() => handleRunAll()}
disabled={compileAllRunning || anyBoardRunning || digitalRunning}
className="tb-btn tb-btn-run-all"
title={t('editor.toolbar.runAll')}