Add viewport safe-area API for play overlays#34
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a viewport “safe area” API to the runtime/behavior interfaces so screen-space UI and DOM overlays can avoid host chrome (e.g., player watermark), and documents how behaviors should consume it.
Changes:
- Introduces viewport safe-area measurement utilities (+ tests) and exposes them via
EngineRuntime,GameManager, andthis.erth.viewport.getSafeArea(). - Registers the player watermark as a safe-area occluder so the measured safe area excludes it.
- Updates developer docs (runtime API + planning note) to describe the new API and intended usage.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/runtime-api.md | Documents this.erth.viewport and provides a usage example. |
| docs/planning/2026-06-03-viewport-safe-area.md | Planning/implementation checklist for the safe-area feature. |
| client/packages/shared/src/player/component/PlayerWatermark.tsx | Registers watermark DOM as an occluder for safe-area measurement. |
| client/packages/editor-oss/src/utils/viewportSafeArea.ts | Implements safe-area measurement from viewport + occluder rects. |
| client/packages/editor-oss/src/utils/viewportSafeArea.test.ts | Adds unit tests for safe-area measurement behavior. |
| client/packages/editor-oss/src/editor/assets/v2/BehaviorEditor/types/behavior.d.ts | Adds typing for viewport.getSafeArea() and getViewportSafeArea(). |
| client/packages/editor-oss/src/behaviors/stem/createStemEngineInterface.ts | Exposes viewport.getSafeArea() on the behavior erth interface. |
| client/packages/editor-oss/src/behaviors/stem/StemEngineInterface.ts | Adds StemViewport interface/type imports for safe area. |
| client/packages/editor-oss/src/behaviors/game/GameManager.ts | Adds getViewportSafeArea() passthrough for behaviors/game API. |
| client/packages/editor-oss/src/EngineRuntime.ts | Stores occluder elements and computes viewport safe area on demand. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a runtime viewport safe-area API so play-mode overlays can avoid Stem Studio chrome instead of relying on raw window bounds.
This change:
Why
Play-mode UI already has host chrome layered around the viewport, but custom DOM overlays and behavior-driven screen-space UI did not have a stable way to know which part of the screen was actually safe to use.
That led to UI being positioned under Stem Studio elements like the top nav or watermark.
What changed
this.erth.viewport.getSafeArea()game.getViewportSafeArea()path for compatibility with existing behavior code