mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-21 22:15:40 +00:00
fix(orbit): dedupe guest outbox entries per host sweep
Guest outboxes are append-only from the host's POV — every sweep reads the same playlist. `applyOutboxSnapshotsToState` was unconditionally pushing every trackId in every snapshot into `state.queue`, so the pending-approval list grew by one duplicate per tick for every unhandled suggestion (visible as 4+ identical rows after ~10 s). Dedupe against `(user, trackId)` already present in `state.queue` or `state.currentTrack` before appending. A guest re-suggesting the same track after it lands/plays is a rare enough case to live with for now. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -870,9 +870,24 @@ export function applyOutboxSnapshotsToState(
|
||||
nowMs: number = Date.now(),
|
||||
): OrbitState {
|
||||
// ── Queue additions ──
|
||||
// Guest outboxes are append-only from the host's POV — the host reads the
|
||||
// same playlist every sweep, so we must dedupe against anything already in
|
||||
// `state.queue` (or currently playing) by (user, trackId). Without this,
|
||||
// every host tick re-adds every outbox entry and the pending-approval list
|
||||
// balloons indefinitely. A user re-suggesting the same track after it
|
||||
// lands/plays is a rare enough case to live with for now.
|
||||
const existingKeys = new Set<string>(
|
||||
state.queue.map(q => `${q.addedBy} | ||||