[PR #5081] [GUI] let the side panel's page preview use pointer lock #5303

Open
opened 2026-11-07 16:34:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5081
Author: @storm-ace
Created: 11/3/2026
Status: 🔄 Open

Base: main ← Head: gui-preview-pointer-lock


📝 Commits (1)

  • 9b02b6c fix(host): let the HTML preview panel use pointer lock

📊 Changes

2 files changed (+13 additions, -1 deletions)

View changed files

📝 apps/host/src/components/ArtifactPanel.tsx (+1 -1)
➕ apps/host/tests/artifact-preview-sandbox.test.mjs (+12 -0)

📄 Description

Problem and result

A web page that the agent writes opens in the side panel's preview. That preview is an iframe with sandbox="allow-scripts". A page that captures the mouse calls requestPointerLock(), for example a first-person game with "click to play". In that frame the call is refused with a SecurityError, so the game never starts in the desktop app. The same file works when it is opened in a browser tab.

This adds allow-pointer-lock to that one sandbox. The frame keeps its opaque origin: no same-origin access, forms, popups or top navigation. Pointer lock only starts after a click in the frame, and Esc releases it.

I searched the open and closed issues and pull requests for "pointer lock" and "allow-pointer-lock" and found nothing that covers this.

Approach

  • apps/host/src/components/ArtifactPanel.tsx: sandbox="allow-scripts" becomes sandbox="allow-scripts allow-pointer-lock" on the website preview iframe. Nothing else changes.
  • apps/host/tests/artifact-preview-sandbox.test.mjs (new): checks that this iframe's sandbox has exactly allow-scripts and allow-pointer-lock. A wider sandbox would fail the test as well.
  • The Time-skip compare frames (HTML_PREVIEW_SANDBOX) are not changed. They show two versions side by side for comparison, not for play.

Validation

Environment: Windows 11 Pro 10.0.26200, Node from the shipped app, this branch (upstream ffa80d73 plus this commit).

Passed

  • The new test fails on ffa80d73 (actual: [ 'allow-scripts' ], expected: [ 'allow-pointer-lock', 'allow-scripts' ]) and passes with the change.

  • npm run typecheck and npm run build in apps/host.

  • A standalone page in Chromium with two srcdoc frames, each with a button that calls document.body.requestPointerLock():

    • the frame with sandbox="allow-scripts" gets SecurityError and pointerlockerror;
    • the frame with sandbox="allow-scripts allow-pointer-lock" gets past the sandbox check. In that run the browser window was in the background, so it then got WrongDocumentError (no focus), not a lock.
  • The desktop app on Windows (Radeon 8060S), with the same one-word change made in its installed bundle: a three.js first-person game in the side panel now captures the mouse after "click to play" and plays. Before the change, the click did nothing.

Failed

  • npm test in apps/host: 1,346 passed, 108 skipped, 3 failed. All 3 are outside this change:

    • new hosts create the default; custom folders and legacy weights remain in place (model-directory-default.test.mjs)
    • #4783 the composer acts on the choice, … (ui-do.test.mjs)
    • directory API protects loaded models, active requests and downloads, … (model-directory.test.mjs)

    Running those three files again on ffa80d73 without this change, the first two fail the same way; the third passed that time.

Not run

  • macOS and Linux app builds. The attribute is standard HTML and WebKit supports it, but I did not try it there.
  • apps/desktop (Tauri) was not rebuilt; the change is only in the host's web UI.

Limits

  • Fullscreen (allowfullscreen) is not added. It was not needed for the case I hit, and it is a larger change to what a preview may do.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5081 **Author:** [@storm-ace](https://github.com/storm-ace) **Created:** 11/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `gui-preview-pointer-lock` --- ### 📝 Commits (1) - [`9b02b6c`](https://github.com/Niko1221/Strata/commit/9b02b6cd6ec47239b642894b72f3c4f8fb95c5e4) fix(host): let the HTML preview panel use pointer lock ### 📊 Changes **2 files changed** (+13 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `apps/host/src/components/ArtifactPanel.tsx` (+1 -1) ➕ `apps/host/tests/artifact-preview-sandbox.test.mjs` (+12 -0) </details> ### 📄 Description ### Problem and result A web page that the agent writes opens in the side panel's preview. That preview is an iframe with `sandbox="allow-scripts"`. A page that captures the mouse calls `requestPointerLock()`, for example a first-person game with "click to play". In that frame the call is refused with a `SecurityError`, so the game never starts in the desktop app. The same file works when it is opened in a browser tab. This adds `allow-pointer-lock` to that one sandbox. The frame keeps its opaque origin: no same-origin access, forms, popups or top navigation. Pointer lock only starts after a click in the frame, and Esc releases it. ### Related discussion I searched the open and closed issues and pull requests for "pointer lock" and "allow-pointer-lock" and found nothing that covers this. ### Approach - `apps/host/src/components/ArtifactPanel.tsx`: `sandbox="allow-scripts"` becomes `sandbox="allow-scripts allow-pointer-lock"` on the website preview iframe. Nothing else changes. - `apps/host/tests/artifact-preview-sandbox.test.mjs` (new): checks that this iframe's sandbox has exactly `allow-scripts` and `allow-pointer-lock`. A wider sandbox would fail the test as well. - The Time-skip compare frames (`HTML_PREVIEW_SANDBOX`) are not changed. They show two versions side by side for comparison, not for play. ### Validation Environment: Windows 11 Pro 10.0.26200, Node from the shipped app, this branch (upstream `ffa80d73` plus this commit). **Passed** - The new test fails on `ffa80d73` (`actual: [ 'allow-scripts' ]`, `expected: [ 'allow-pointer-lock', 'allow-scripts' ]`) and passes with the change. - `npm run typecheck` and `npm run build` in `apps/host`. - A standalone page in Chromium with two `srcdoc` frames, each with a button that calls `document.body.requestPointerLock()`: - the frame with `sandbox="allow-scripts"` gets `SecurityError` and `pointerlockerror`; - the frame with `sandbox="allow-scripts allow-pointer-lock"` gets past the sandbox check. In that run the browser window was in the background, so it then got `WrongDocumentError` (no focus), not a lock. - The desktop app on Windows (Radeon 8060S), with the same one-word change made in its installed bundle: a three.js first-person game in the side panel now captures the mouse after "click to play" and plays. Before the change, the click did nothing. **Failed** - `npm test` in `apps/host`: 1,346 passed, 108 skipped, 3 failed. All 3 are outside this change: - `new hosts create the default; custom folders and legacy weights remain in place` (`model-directory-default.test.mjs`) - `#4783 the composer acts on the choice, …` (`ui-do.test.mjs`) - `directory API protects loaded models, active requests and downloads, …` (`model-directory.test.mjs`) Running those three files again on `ffa80d73` without this change, the first two fail the same way; the third passed that time. **Not run** - macOS and Linux app builds. The attribute is standard HTML and WebKit supports it, but I did not try it there. - `apps/desktop` (Tauri) was not rebuilt; the change is only in the host's web UI. ### Limits - Fullscreen (`allowfullscreen`) is not added. It was not needed for the case I hit, and it is a larger change to what a preview may do. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5303
No description provided.