fix(streaming): name the game holding a container the desktop was refused

The desktop claim's 409 carries the rom_name of the session in the way, as a game claim's does, and the desktop showed only a generic in-use message while its test claimed to name the game. The test's i18n mock now keeps params so the name is asserted.
This commit is contained in:
Zach Clendenen
2026-09-18 11:47:11 -05:00
parent 7177ca3181
commit c7dc5ea918
20 changed files with 49 additions and 8 deletions

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} работи в този контейнер. Първо прекратете тази сесия.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} běží v tomto kontejneru. Nejprve ukončete tuto relaci.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} läuft auf diesem Container. Beende zuerst diese Sitzung.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} is running on this container. End that session first.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} is running on this container. End that session first.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} se está ejecutando en este contenedor. Finaliza primero esa sesión.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} est en cours d'exécution sur ce conteneur. Terminez d'abord cette session.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "A(z) {rom} fut ezen a konténeren. Előbb fejezd be azt a munkamenetet.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} è in esecuzione su questo container. Termina prima quella sessione.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} がこのコンテナで実行中です。先にそのセッションを終了してください。",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom}이(가) 이 컨테이너에서 실행 중입니다. 먼저 해당 세션을 종료하세요.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} działa w tym kontenerze. Najpierw zakończ tę sesję.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} está em execução neste contêiner. Encerre essa sessão primeiro.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} rulează pe acest container. Încheie mai întâi acea sesiune.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "В этом контейнере запущена игра {rom}. Сначала завершите этот сеанс.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} bu konteynerde çalışıyor. Önce o oturumu sonlandırın.",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -25,6 +25,7 @@
"desktop-back": "返回管理后台",
"desktop-error-no-container": "未配置该串流容器。",
"desktop-error-occupied": "此容器正在使用中。请先结束占用它的会话。",
"desktop-error-occupied-by": "{rom} 正在此容器上运行。请先结束该会话。",
"desktop-error-release": "无法释放桌面会话。容器可能仍在使用中。",
"desktop-error-server": "无法打开桌面会话。",
"desktop-exit": "结束桌面会话",

View File

@@ -25,6 +25,7 @@
"desktop-back": "Back to administration",
"desktop-error-no-container": "That streaming container is not configured.",
"desktop-error-occupied": "This container is already in use. End the session holding it first.",
"desktop-error-occupied-by": "{rom} 正在此容器上執行。請先結束該工作階段。",
"desktop-error-release": "The desktop session could not be released. The container may still be in use.",
"desktop-error-server": "The desktop session could not be opened.",
"desktop-exit": "End desktop session",

View File

@@ -15,7 +15,10 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("vue-i18n", () => ({
useI18n: () => ({ t: (key: string) => key }),
useI18n: () => ({
t: (key: string, params?: Record<string, unknown>) =>
params ? `${key}:${Object.values(params).join(",")}` : key,
}),
}));
vi.mock("vue-router", () => ({
@@ -139,7 +142,7 @@ describe("Desktop session-ended notices", () => {
await flushPromises();
expect(vmOf(wrapper).state).toBe("error");
expect(vmOf(wrapper).errorMessage).toBe("play.session-ended-by");
expect(vmOf(wrapper).errorMessage).toBe("play.session-ended-by:admin");
});
it("shows the reason the notice gives", async () => {
@@ -215,7 +218,7 @@ describe("Desktop heartbeats", () => {
window.dispatchEvent(new Event("pagehide"));
expect(vmOf(wrapper).state).toBe("error");
expect(vmOf(wrapper).errorMessage).toBe("play.session-ended-by");
expect(vmOf(wrapper).errorMessage).toBe("play.session-ended-by:admin");
expect(vmOf(wrapper).endedReason).toBe("Maintenance");
expect(mocks.releaseSessionKeepalive).not.toHaveBeenCalled();
});
@@ -287,6 +290,18 @@ describe("Desktop refused claims", () => {
draining: false,
});
expect(vmOf(wrapper).errorMessage).toBe(
"play.desktop-error-occupied-by:Ico",
);
});
it("says the container is in use when the game is not the admin's to see", async () => {
const wrapper = await refuseDesktop({
rom_name: null,
claimed_at: "2026-09-17T10:00:00",
draining: false,
});
expect(vmOf(wrapper).errorMessage).toBe("play.desktop-error-occupied");
});

View File

@@ -69,13 +69,21 @@ async function openDesktop(): Promise<void> {
const detail: unknown = isAxiosError(err)
? err.response?.data?.detail
: undefined;
if (status === 409)
if (status === 409) {
const busy = detail as {
draining?: boolean;
rom_name?: string | null;
} | null;
// A drain marker is nobody's claim: the container comes free on its own
// once the previous session has finished saving.
errorMessage.value = (detail as { draining?: boolean } | null)?.draining
? t("play.stream-occupied-draining")
: t("play.desktop-error-occupied");
else if (status === 404)
if (busy?.draining)
errorMessage.value = t("play.stream-occupied-draining");
else if (busy?.rom_name)
errorMessage.value = t("play.desktop-error-occupied-by", {
rom: busy.rom_name,
});
else errorMessage.value = t("play.desktop-error-occupied");
} else if (status === 404)
errorMessage.value = t("play.desktop-error-no-container");
else errorMessage.value = t("play.desktop-error-server");
}