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";