Rounds 1 (621523c6f) and 2 (6e05901c9) each tried to enumerate, per track,
whether it was safe to re-stream after a sidecar disconnect/reconnect, and
each left a real gap on review (round 2's unsafeAfterDisconnectRef missed
tracks whose local AudioContext/AudioWorkletNode wiring was still in flight
when the disconnect fired). The sidecar's own trackIndex-assignment rule can
reassign colliding indices on any reload, and a WS disconnect doesn't reliably
tell the client whether the same stateful process answered the reconnect or
a fresh one did (server-side protocol flaw, out of scope here) — so no
client-side per-track tracking has proven complete.
Replace all of it with one suspendedRef in useVstPreview: the first
disconnect this hook instance ever observes permanently stops it from
loading ANY track — previously-loaded, previously-attempted, or never-seen
— for the rest of its mounted lifetime. Delete unsafeAfterDisconnectRef
entirely. Also fix the "Load chains" effect's cancellation branch to fully
teardownTrack() a load that resolves after a disconnect (unmuting the
element) instead of only closing its AudioContext, which previously left a
mid-flight track muted forever with no audio ever routed to it.
useVstHost's trackIndexRef mirror-clearing behavior is left unchanged: it's
still needed for the FX property panel's independent, direct loadChain
calls on the shared connection, which aren't gated by useVstPreview's
suspension.
Tradeoff, stated plainly: a single transient WS blip now permanently
disables VST preview for the rest of the studio session (recoverable only
by reloading the page) — accepted because two narrower recovery attempts
have each shipped with a real correctness gap, and a wrong/misrouted track
is worse than an honest, visible fallback to dry audio.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>