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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Uo885XxwhN8wfC4oCtR48
This commit is contained in:
Sam Dornan
2026-09-15 16:05:55 +00:00
committed by Claude
parent ba0d861c49
commit 2be9eb4aea
3 changed files with 33 additions and 7 deletions

View File

@@ -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

View File

@@ -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<HTMLElement | null>(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")),

View File

@@ -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<void>) => () => run().catch(() => {});
const swallowDenial = (run: () => Promise<void>) => () => 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<void>) => () =>
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),
};
}