From 35761aa85c704ef2a3d433ab66b83ffda27ba004 Mon Sep 17 00:00:00 2001 From: Zach Clendenen Date: Fri, 18 Sep 2026 12:27:43 -0500 Subject: [PATCH] refactor(streaming): type a claim's 409 detail in one place The player and the desktop each spelled the busy-container detail inline, and the two copies had already drifted. --- frontend/src/services/api/streaming.ts | 10 ++++++++++ frontend/src/v2/views/Player/Desktop.vue | 9 ++++----- frontend/src/v2/views/Player/Stream.vue | 7 ++----- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/frontend/src/services/api/streaming.ts b/frontend/src/services/api/streaming.ts index f4c6a046c..c9415b30b 100644 --- a/frontend/src/services/api/streaming.ts +++ b/frontend/src/services/api/streaming.ts @@ -80,6 +80,16 @@ export function isMemoryCardImportDetail( ); } +/** Body of the 409 a claim returns when the container is taken. The route + * raises it as a plain detail dict, so it has no generated schema. */ +export interface ContainerBusyDetail { + message: string; + draining: boolean; + /** The game holding it, null when the caller may not see which. */ + rom_name: string | null; + claimed_at: string | null; +} + // ── Requests ────────────────────────────────────────────────────────────────── async function fetchConfig() { diff --git a/frontend/src/v2/views/Player/Desktop.vue b/frontend/src/v2/views/Player/Desktop.vue index 0552b05bb..35c0304bc 100644 --- a/frontend/src/v2/views/Player/Desktop.vue +++ b/frontend/src/v2/views/Player/Desktop.vue @@ -14,7 +14,9 @@ import { computed, onMounted, ref } from "vue"; import { useI18n } from "vue-i18n"; import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router"; import { ROUTES } from "@/plugins/router"; -import streamingApi from "@/services/api/streaming"; +import streamingApi, { + type ContainerBusyDetail, +} from "@/services/api/streaming"; import { type SessionTermination, useStreamingStore } from "@/stores/streaming"; import StreamStage from "@/v2/components/Player/StreamStage.vue"; import { useConfirm } from "@/v2/composables/useConfirm"; @@ -70,10 +72,7 @@ async function openDesktop(): Promise { ? err.response?.data?.detail : undefined; if (status === 409) { - const busy = detail as { - draining?: boolean; - rom_name?: string | null; - } | null; + const busy = detail as ContainerBusyDetail | null; // A drain marker is nobody's claim: the container comes free on its own // once the previous session has finished saving. if (busy?.draining) diff --git a/frontend/src/v2/views/Player/Stream.vue b/frontend/src/v2/views/Player/Stream.vue index a6e47c502..32836a8e8 100644 --- a/frontend/src/v2/views/Player/Stream.vue +++ b/frontend/src/v2/views/Player/Stream.vue @@ -42,6 +42,7 @@ import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router"; import type { SaveSchema, UserStateSchema } from "@/__generated__"; import romApi from "@/services/api/rom"; import streamingApi, { + type ContainerBusyDetail, isMemoryCardImportDetail, type LaunchFailed, type LaunchPhase, @@ -905,11 +906,7 @@ async function onPlay(cardImport?: MemoryCardImport): Promise { errorType.value = "occupied"; const busy = detail && typeof detail === "object" - ? (detail as { - rom_name: string | null; - claimed_at: string | null; - draining?: boolean; - }) + ? (detail as ContainerBusyDetail) : null; // A draining container is nobody's: the previous session is over and its // exit state is still being collected, so there is no holder to name.