From 73c493f894ff80fae36edcf7ee30edbaead59ca7 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Fri, 18 Sep 2026 13:46:51 -0500 Subject: [PATCH] fix(streaming): report only the ended notice of the claim a poll names A desktop re-claim leaves the last claim's notice in place, and a pool can hold one per container, so a stamped poll or heartbeat could show another claim's ended-by and reason. --- backend/endpoints/streaming.py | 6 ++++-- backend/tests/endpoints/test_streaming.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/backend/endpoints/streaming.py b/backend/endpoints/streaming.py index 7ec349d28..9b61f401a 100644 --- a/backend/endpoints/streaming.py +++ b/backend/endpoints/streaming.py @@ -243,8 +243,10 @@ async def _session_status( termination = None for candidate in candidates: notice = await get_termination(candidate.key, request.user.id) - if notice is not None and access.notice_in_scope( - notice, platform, include_desktop + if ( + notice is not None + and access.notice_in_scope(notice, platform, include_desktop) + and (claimed_at is None or notice.get("claimed_at") == claimed_at) ): termination = notice break diff --git a/backend/tests/endpoints/test_streaming.py b/backend/tests/endpoints/test_streaming.py index 09393c289..c36aa7035 100644 --- a/backend/tests/endpoints/test_streaming.py +++ b/backend/tests/endpoints/test_streaming.py @@ -3071,6 +3071,27 @@ def test_a_termination_notice_names_the_claim_it_ended( assert r.json()["termination"]["claimed_at"] == claimed_at +def test_status_does_not_report_the_notice_of_another_claim( + client, access_token, viewer_access_token, rom: Rom +): + """A poll names the claim it asks about, so a notice filed for another + claim on the container must not tell it who ended its own.""" + with _streaming(_container_for(rom)): + _claim_ok(client, viewer_access_token, rom.id) + client.delete( + f"/api/streaming/sessions/{rom.platform_slug}", + params={"reason": "maintenance window"}, + headers=_auth(access_token), + ) + r = client.get( + f"/api/streaming/sessions/{rom.platform_slug}/status", + params={"claimed_at": "2026-09-17T10:05:00+00:00"}, + headers=_auth(viewer_access_token), + ) + assert r.json()["status"] == "ended" + assert r.json()["termination"] is None + + def test_a_termination_notice_lands_before_the_drain( client, access_token, viewer_access_token, rom: Rom ):