Open
Conversation
Expose window.LanternProxy global API that allows host pages to control the proxy without rendering the unbounded UI. When data-headless="true" is set on the embed element, React rendering is skipped entirely while the WASM proxy remains fully functional. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document the data-headless attribute, window.LanternProxy API, events, methods, and a minimal usage example. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a headless, programmatic control surface for the Unbounded WASM proxy so host pages can run the proxy without rendering the React widget UI.
Changes:
- Registers a global
window.LanternProxyAPI for initializing/starting/stopping the WASM proxy and subscribing to proxy-state events. - Adds a
data-headless="true"embed mode that skips React rendering while still loading the proxy engine. - Documents the new
headlessembed option and headless API usage in the README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| ui/src/index.tsx | Imports headless API unconditionally and skips UI rendering when data-headless="true" is set. |
| ui/src/headlessApi.ts | Implements and registers window.LanternProxy and forwards internal emitters to external listeners. |
| README.md | Documents the headless dataset flag and the window.LanternProxy API/events with examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Fix concurrent init() race: use shared initPromise so duplicate calls return the same promise instead of creating multiple WasmInterface instances - Fix usage examples: subscribe to events BEFORE calling init() to avoid missing the ready event; use type="module" for top-level await - Fix JSDoc: start()/stop() are fire-and-forget, not Promise-returning - Use Object.defineProperty for window.LanternProxy to prevent accidental overwrites and make it non-enumerable - Add unit tests for on/off subscriptions, getState, init idempotency, and global immutability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Gate start()/stop() on `initialized` flag, not just wasmInterface existence, to prevent calls during in-progress init() - Return shallow copies of arrays from getState() to prevent external mutation of internal state - Fix README: clarify that headless mode requires explicit init() call (WASM engine doesn't auto-load) - Update index.tsx log message to match documentation - Fix test mock to use class-based MockWasmInterface - Add test for getState() returning shallow copies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
window.LanternProxyglobal API (headlessApi.ts) that exposesinit(),start(),stop(), event subscriptions (on/off), andgetState()for controlling the WASM proxy programmatically<browsers-unbounded data-headless="true">is used, React UI rendering is skipped entirely — the WASM proxy runs but the host page controls the lookdata-headlesswork identically; the global API is registered on all pages as a bonusMotivation
The Lantern dashboard needs to run the WASM proxy in the background while rendering its own native UI for proxy stats (connections, throughput, session data) on its world map. This avoids embedding the full unbounded widget UI and gives the host page full control.
Test plan
<browsers-unbounded>embeds still render and function normally<browsers-unbounded data-headless="true">skips UI, logs to consolewindow.LanternProxy.init()/.start()/.stop()work in headless mode.on('connections', cb)and other events fire with live data.getState()returns current snapshot🤖 Generated with Claude Code