fix(esp32sim): re-sync the flat simulator field after a bridge rebuild
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.
This commit is contained in:
parent
77e947ef98
commit
93314b074b
|
|
@ -1406,6 +1406,21 @@ export const useSimulatorStore = create<SimulatorState>((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;
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue