fix(venue-crowd): reset crowd mood to neutral on song load

Codex preflight: a song ending in ecstatic/bored left the next song's
crowd stuck in that mood until the hysteresis window passed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
byrongamatos
2026-07-12 20:58:15 +02:00
co-authored by Claude Fable 5
parent c83fec267e
commit f9a57ba044
+17
View File
@@ -53,6 +53,11 @@
let lastSwitchAt = -Infinity;
return {
get current() { return current; },
reset() {
current = "neutral";
candidate = null;
lastSwitchAt = -Infinity;
},
// Feed the latest perf state; returns the new crowd state when a
// transition commits, else null.
update(perfState, nowMs) {
@@ -328,6 +333,15 @@
}
}
function onSongLoaded() {
machine.reset();
_prevStreak = 0;
_lastAccuracyPct = null;
if (_venueActive && _manifest && !_stingerUntilEnded) {
showLoop(machine.current, FADE_MS);
}
}
function onStatsRecorded() {
if (!_venueActive || !_manifest) return;
// stats:recorded carries only {filename, arrangement} — the accuracy
@@ -422,6 +436,9 @@
if (sm && typeof sm.on === 'function') {
sm.on('v3:live-performance-state', onPerformanceState);
sm.on('stats:recorded', onStatsRecorded);
// A new song must not inherit the previous song's crowd mood
// through the hysteresis/dwell window.
sm.on('song:loaded', onSongLoaded);
}
const dev = readDevManifest();
if (dev && !_manifest) setManifest(dev);