Skip to content

feat(viewer): fullscreen for surfaces - #272

Open
benvinegar wants to merge 1 commit into
mainfrom
claude/surface-fullscreen
Open

benvinegar wants to merge 1 commit into
mainfrom
claude/surface-fullscreen

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

Surfaces render in sandbox="allow-scripts" iframes with no fullscreen permission, so a presentation's own Fullscreen button could never take over the screen. The viewer's only expander was a mermaid-only dialog that loaded the surface again in a second iframe.

  • Expand button on every sandboxed surface (html, markdown, code, diff, terminal, mermaid). The surface's shell expands in place over the viewer, with a title bar, a real-fullscreen button, and close. Esc closes it and focus returns to the button.
  • A surface's own requestFullscreen() now works. The in-frame bridge routes the standard Fullscreen API (requestFullscreen, exitFullscreen, fullscreenElement, fullscreenchange) to the viewer, which fullscreens the shell and confirms back. If the browser refuses native fullscreen, it falls back to the window-filling dialog.
  • State is kept. The same iframe expands rather than a second one loading, so a deck stays on its slide.
  • The slides kit gains a fullscreen button.

Security

The sandbox is unchanged: no allow-same-origin, and no fullscreen permission granted to the frame. Fullscreen is a new bridge channel, gated like the others:

  • Only frames a Card registered can ask (not Home previews or stray frames).
  • Entering requires a live user gesture. The browser enforces that for native fullscreen, and the dialog fallback is only used when navigator.userActivation.isActive is true. An unprompted request is denied.
  • The host-to-frame message carries only a boolean, and the frame accepts it only from parent.

Notes for review

  • :fullscreen does not match inside the viewer. The fullscreen element carries [data-sideshow-fullscreen] and is stretched over the frame by a rule mirroring the UA :fullscreen sheet. Documented in guide/DESIGN_GUIDE.md.
  • Bench baseline re-recorded. The bridge adds 2.5 KB to every surface document, which trips the deterministic byte gate, so bench/baseline.json is re-recorded in this PR. Timing values in that file moved too, since the whole baseline is recorded at once.
  • The expand button reveals on card hover as well as surface hover. In automated Chromium the shell's :hover did not update with the pointer over the sandboxed frame.
  • e2e/kits.spec.ts selected the deck's "next" button as the last control; it now selects it by label, since the fullscreen button is last.

Testing

  • Chromium e2e: 95/95, including four new tests in e2e/fullscreen.spec.ts (expand button, content-initiated fullscreen, the no-gesture denial, the embedded engine in a shadow root).
  • Real fullscreen driven by hand in full Chromium, including the standalone /s/:id page.
  • npm test, coverage, typecheck, lint, format:check, test:worker, bench:check --gate deterministic, and changeset status pass.
  • Not run locally: WebKit e2e (only Chromium was available). The Safari path depends on a click inside the frame counting as a user gesture in the viewer; CI's WebKit job is the first real check of that.
  • security:audit fails on existing dependency advisories; the lockfile is untouched.

Generated by Claude Code

…the bridge

Surfaces render in sandbox="allow-scripts" iframes with no fullscreen
permission, so a deck's own Fullscreen button could never take over the
screen, and the viewer's only expander was a mermaid-only dialog that loaded
the surface again in a second iframe.

- Every sandboxed surface gets an expand button. The surface's shell expands
  in place (same iframe, state kept) into a dialog filling the viewer, with a
  control for real browser fullscreen.
- The in-frame bridge shims the standard Fullscreen API: requestFullscreen()
  asks the viewer, which fullscreens the shell (falling back to the dialog)
  and confirms back. The host requires a user gesture, so untrusted content
  cannot take over unprompted. The sandbox itself is unchanged.
- The slides kit gains a fullscreen button.

The bridge grows by 2.5 KB per surface document, so bench/baseline.json is
re-recorded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nn5Hphf1wtFxVwDzBXvGEr

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants