From 2be9eb4aea89f5ca1b4cb7bd34d98634c4ebdcf5 Mon Sep 17 00:00:00 2001 From: Sam Dornan Date: Tue, 15 Sep 2026 16:05:55 +0000 Subject: [PATCH] fix(frontend): report a failed fullscreen exit instead of swallowing it Entry and exit failures are not the same. A rejected request is a denial and the stage just stays windowed, but callers exit before opening a body-teleported dialog, so a failed exit leaves that dialog painted over by the stage with nothing said. The shared wrapper discarded both. Uses console.error rather than the console.warn this replaced, which v2 does not allow to ship. Also drops indexdb-monitor.ts from the frontend architecture doc's source tree, which still listed the deleted file. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019Uo885XxwhN8wfC4oCtR48 --- docs/FRONTEND_ARCHITECTURE.md | 3 +-- .../usePlayerFullscreen/index.test.ts | 22 ++++++++++++++++++- .../composables/usePlayerFullscreen/index.ts | 15 +++++++++---- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/docs/FRONTEND_ARCHITECTURE.md b/docs/FRONTEND_ARCHITECTURE.md index bbe543773..0ec63a741 100644 --- a/docs/FRONTEND_ARCHITECTURE.md +++ b/docs/FRONTEND_ARCHITECTURE.md @@ -292,8 +292,7 @@ frontend/ │ ├── index.ts # ~825 lines of utilities │ ├── covers.ts # Procedural SVG cover generation │ ├── formData.ts # FormData builder - │ ├── tasks.ts # Task status maps - │ └── indexdb-monitor.ts # IndexedDB change detection + │ └── tasks.ts # Task status maps │ └── __generated__/ # OpenAPI codegen output └── models/ # Generated TypeScript interfaces diff --git a/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts b/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts index 8f565ad8a..67a43d405 100644 --- a/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts +++ b/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from "vitest"; +import { afterEach, describe, expect, it, vi } from "vitest"; import { effectScope, ref, type EffectScope } from "vue"; import { useFullscreenFallback, usePlayerFullscreen } from "./index"; @@ -53,6 +53,26 @@ describe("usePlayerFullscreen", () => { expect(el.hasAttribute("data-fullscreen-fallback")).toBe(true); }); + it("reports a failed exit, which leaves a dialog painted over", async () => { + const el = document.createElement("div"); + document.body.appendChild(el); + const { value } = runInScope(() => + usePlayerFullscreen(ref(el)), + ); + await value.enter(); + const error = vi.spyOn(console, "error").mockImplementation(() => {}); + Object.defineProperty(document, "exitFullscreen", { + value: () => Promise.reject(new Error("denied")), + configurable: true, + writable: true, + }); + + await expect(value.exit()).resolves.toBeUndefined(); + + expect(error).toHaveBeenCalledOnce(); + error.mockRestore(); + }); + it("swallows a denied request instead of rejecting", async () => { Object.defineProperty(Element.prototype, "requestFullscreen", { value: () => Promise.reject(new Error("denied")), diff --git a/frontend/src/v2/composables/usePlayerFullscreen/index.ts b/frontend/src/v2/composables/usePlayerFullscreen/index.ts index 8bc1487b3..aaf0847a5 100644 --- a/frontend/src/v2/composables/usePlayerFullscreen/index.ts +++ b/frontend/src/v2/composables/usePlayerFullscreen/index.ts @@ -22,7 +22,14 @@ export function useFullscreenFallback(): void { // A rejected request is a denial (permissions policy, or no user gesture), // not a fault to report: the stage simply stays windowed. -const swallow = (run: () => Promise) => () => run().catch(() => {}); +const swallowDenial = (run: () => Promise) => () => run().catch(() => {}); + +// A failed exit is not benign: callers exit before opening a body-teleported +// dialog, which would then be painted over by the fullscreen stage. +const reportFailure = (run: () => Promise) => () => + run().catch((error: unknown) => { + console.error("Failed to exit fullscreen", error); + }); /** Fullscreen controls for `target`. */ export function usePlayerFullscreen(target: MaybeElementRef): { @@ -39,8 +46,8 @@ export function usePlayerFullscreen(target: MaybeElementRef): { return { isFullscreen, - enter: swallow(enter), - exit: swallow(exit), - toggle: swallow(toggle), + enter: swallowDenial(enter), + exit: reportFailure(exit), + toggle: swallowDenial(toggle), }; }