From b7daab85a4e07f072b99f7899c34fbed759f8a46 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Fri, 18 Sep 2026 11:40:14 -0500 Subject: [PATCH] fix(streaming): enter a running game off the poll only on the claimed container The status poll names no container, so it can answer with another tab's session on the same platform, and a loading tab that missed launch-ready would adopt that room as its own and later save and end it on unload. --- frontend/src/v2/views/Player/Stream.test.ts | 19 +++++++++++++++++++ frontend/src/v2/views/Player/Stream.vue | 5 +++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/v2/views/Player/Stream.test.ts b/frontend/src/v2/views/Player/Stream.test.ts index 36ec771d7..aa84b4734 100644 --- a/frontend/src/v2/views/Player/Stream.test.ts +++ b/frontend/src/v2/views/Player/Stream.test.ts @@ -616,6 +616,25 @@ describe("Stream launch recovery", () => { wrapper.unmount(); }); + it("keeps waiting when the poll finds a game on another container", async () => { + // The unnamed poll reports any session the player holds on the platform, + // which can be another tab's. + const wrapper = await launch({ picker: false }); + await vmOf(wrapper).onPlay(); + mocks.fetchSessionStatus.mockResolvedValue({ + status: "active", + platform: "gba", + host: "http://webstation-dev-2:8080/room/y", + container: "WEBSTATION-DEV-2", + }); + + await pollStatus(); + + expect(vmOf(wrapper).playerState).toBe("loading"); + expect(vmOf(wrapper).containerHost).toBe(""); + wrapper.unmount(); + }); + it("keeps waiting while the launch has no room yet", async () => { const wrapper = await launch({ picker: false }); await vmOf(wrapper).onPlay(); diff --git a/frontend/src/v2/views/Player/Stream.vue b/frontend/src/v2/views/Player/Stream.vue index f229d8b57..e5085959f 100644 --- a/frontend/src/v2/views/Player/Stream.vue +++ b/frontend/src/v2/views/Player/Stream.vue @@ -566,8 +566,9 @@ async function handleSessionStatus( // the room the launch recorded, which is the way back in. async function enterRunningSession(status: SessionStatus): Promise { if (playerState.value !== "loading" || !status.host) return; - // The 202 named it, except for a tab that came back without one. - claimedContainer.value ??= status.container ?? null; + // The poll names no container, so it can answer with another tab's session. + if (!claimedContainer.value || status.container !== claimedContainer.value) + return; launchPhase.value = null; containerHost.value = status.host; playerState.value = "playing";