From 13612bfa9966b85eab71d50eadf23cd382c950e4 Mon Sep 17 00:00:00 2001 From: Jose Luis Date: Sat, 21 Mar 2026 21:11:02 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Workshop=20load=20doesn't=20stop=20audio?= =?UTF-8?q?=20=E2=80=94=20matches=20loadPreset=20pattern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling stopAudio() before deserialize+rebuildGraph broke the audio graph because rebuildGraph needs isRunning=true to work properly. Now follows the same pattern as loadPreset(): deserialize then rebuildGraph (which destroys and recreates all nodes internally). Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/client/src/components/Workshop.jsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/client/src/components/Workshop.jsx b/packages/client/src/components/Workshop.jsx index 6a5b819..160aae9 100644 --- a/packages/client/src/components/Workshop.jsx +++ b/packages/client/src/components/Workshop.jsx @@ -1,8 +1,8 @@ import React, { useState, useEffect, useCallback } from 'react'; import { workshop as workshopApi } from '../services/api.js'; import { useAuth } from '../services/AuthContext.jsx'; -import { state, deserialize, emit } from '../engine/state.js'; -import { stopAudio, rebuildGraph } from '../engine/audioEngine.js'; +import { state, deserialize } from '../engine/state.js'; +import { rebuildGraph } from '../engine/audioEngine.js'; import { getPresets } from '../engine/presets.js'; const TAGS = ['ambient', 'bass', 'drums', 'pad', 'lead', 'fx', 'chiptune', 'experimental']; @@ -171,14 +171,11 @@ export default function Workshop({ onSwitchToSandbox, onSwitchToGame, onSwitchTo const handleLoad = (patch) => { if (!patch.data) return; - // Stop audio, clean state, then load - if (state.isRunning) stopAudio(); - - // Deep clone to avoid reference issues + // Deep clone and load — same pattern as loadPreset() + // Don't stop audio first: rebuildGraph destroys and recreates all nodes const cleanData = JSON.parse(JSON.stringify(patch.data)); deserialize(cleanData); - rebuildGraph(); - emit(); + if (state.isRunning) rebuildGraph(); onSwitchToSandbox?.(); };