LearnNewsExamplesServices
Frontmatter
id8071
titleRefactor LivePreview to handle multi-window logic internally
stateClosed
labels
enhancementairefactoring
assigneestobiu
createdAtDec 9, 2025, 4:56 PM
updatedAtDec 9, 2025, 5:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/8071
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtDec 9, 2025, 5:19 PM

Refactor LivePreview to handle multi-window logic internally

Closed v11.17.0 enhancementairefactoring
tobiu
tobiu commented on Dec 9, 2025, 4:56 PM

This refactoring aims to decouple the Neo.code.LivePreview component from the Portal.view.ViewportController.

Scope:

  1. Internalize Logic: Move the onAppConnect and onAppDisconnect logic from ViewportController.mjs directly into LivePreview.mjs.
  2. Worker Events: LivePreview will subscribe directly to Neo.currentWorker events.
  3. Configuration: Add a windowUrl config to LivePreview (default: './childapps/preview/index.html') to allow apps to customize the location of the preview entry point.
  4. Multi-Window Guard: Ensure the pop-out button and event listeners are only active if Neo.config.useSharedWorkers is true.
  5. Cleanup: Remove the PortalPreview specific logic from apps/portal/view/ViewportController.mjs.

Note on Child Apps: This refactor retains the requirement for the embedding application to provide the physical child app files (index.html, app.mjs) to ensure correct worker path resolution in production builds.

tobiu added the enhancement label on Dec 9, 2025, 4:56 PM
tobiu added the ai label on Dec 9, 2025, 4:56 PM
tobiu added the refactoring label on Dec 9, 2025, 4:56 PM
tobiu assigned to @tobiu on Dec 9, 2025, 4:56 PM
tobiu referenced in commit d9e86fc - "Refactor LivePreview to handle multi-window logic internally #8071" on Dec 9, 2025, 5:18 PM
tobiu
tobiu Dec 9, 2025, 5:19 PM

Input from Gemini 3.0:

✦ I have completed the refactoring to decouple LivePreview from ViewportController.

Changes Implemented:

  1. Logic Internalization: Neo.code.LivePreview now self-manages its multi-window lifecycle. It directly subscribes to Neo.currentWorker connect and disconnect events.
  2. Configuration: Added a windowUrl config to LivePreview (defaults to ./childapps/preview/index.html), allowing for flexible deployment paths.
  3. Clean Separation: Removed all PortalPreview-specific logic and the onAppConnect method from Portal.view.ViewportController.
  4. Feature Guard: The pop-out functionality and event listeners are now strictly conditional on Neo.config.useSharedWorkers.

The component is now portable and reusable across different Neo.mjs applications without requiring a specific controller implementation. The embedding app is only responsible for providing the physical child app files (as referenced by windowUrl) to ensure correct worker path resolution.

tobiu closed this issue on Dec 9, 2025, 5:19 PM