From 93314b074b58cce149daa67484e554e1a61828b8 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Sun, 9 Aug 2026 22:27:57 +0200 Subject: [PATCH] fix(esp32sim): re-sync the flat simulator field after a bridge rebuild MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Second half of the deep-link race: an overlay board kind added BEFORE the overlay registers makes isEsp32Kind() false, so addBoard wires the board as a generic AVR — and the parts on the canvas attach their I2C device models to THAT simulator (measured live: the gesture's device sat on an AVRSimulator while the C6 engine booted with an empty bus). The overlay's rebuild then swapped simulatorMap but left the flat `simulator` field stale, so DynamicComponent's [simulator] effect never re-attached anything. Re-syncing the flat field when the rebuilt board is the active one makes every part re-attach against the real shim — sensors, displays, mic sources, the lot. --- frontend/src/store/useSimulatorStore.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/frontend/src/store/useSimulatorStore.ts b/frontend/src/store/useSimulatorStore.ts index 4343fcd4..cce1da49 100644 --- a/frontend/src/store/useSimulatorStore.ts +++ b/frontend/src/store/useSimulatorStore.ts @@ -1406,6 +1406,21 @@ export const useSimulatorStore = create((set, get) => { try { old.disconnect(); } catch { /* ignore */ } } wireEsp32Board(boardId, board.boardKind, pm); + // A deep-linked overlay board is created BEFORE the overlay registers + // its kinds, so isEsp32Kind() was false at addBoard time and the board + // was wired as a generic AVR. Parts attach their device models against + // the flat `simulator` field — if it still holds that placeholder, the + // whole part layer (I2C devices included) is talking to a simulator + // nobody will ever run: the C6 gesture example booted with an empty + // engine I2C bus and every Wire transaction died. Re-sync the flat + // field so DynamicComponent's [simulator] effect re-attaches every + // part against the rebuilt shim. + if (get().activeBoardId === boardId) { + set({ + simulator: (simulatorMap.get(boardId) ?? null) as never, + pinManager: pinManagerMap.get(boardId) ?? legacyPinManager, + }); + } return true; },