Skip to content

#10822 Auto preview cannot skip browser-only failures#10824

Draft
rymsha wants to merge 1 commit into
masterfrom
liveview-render-verdict
Draft

#10822 Auto preview cannot skip browser-only failures#10824
rymsha wants to merge 1 commit into
masterfrom
liveview-render-verdict

Conversation

@rymsha

@rymsha rymsha commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #10822

The widget probe is synchronous and answered from the server's network view, but some liveview widgets (e.g. the same-origin wrapper in enonic/app-liveview-iframe#22) only learn whether they can render once their document probes from the browser. This adds the verdict half of that contract to ExtensionRenderingHandler:

  • A widget declares verdict: true in its probe's enonic-widget-data → Content Studio frames it but keeps the loading mask up.
  • The widget posts liveview-render-verdict ({ok, contentId, url}, IframeEventBus envelope): ok reveals the preview; not ok marks the widget failed for the current content and auto mode re-renders the remaining candidates behind the mask — no widget flash.
  • Explicit selection keeps the widget's own failure UI; auto mode with no remaining candidate reveals the widget's failure view instead of rendering nothing; a 6s fail-open timeout guards against a widget that promises a verdict and never delivers; stale verdicts are dropped by contentId; the failed set resets on content change.
  • Widgets that declare nothing reveal on load exactly as before — no timeout penalty for legacy widgets.

Companion: enonic/app-liveview-iframe#22 (wrapper + verdict emission). Independent of #10788 — works with or without the CSP adoption branch; tsc and eslint clean.

🤖 Generated with Claude Code

@rymsha rymsha force-pushed the liveview-render-verdict branch from ba60d98 to db2495f Compare June 15, 2026 08:40
Probes are answered from the server's network view, but some liveview
widgets only learn whether they can render once their document probes
from the browser. Widgets that declare verdict:true in their probe data
are now framed behind the loading mask; the mask drops on an ok
liveview-render-verdict (or a 6s fail-open timeout) and a failed
verdict advances auto mode to the next candidate without the widget
ever becoming visible. Explicit selection keeps the widget's own
failure UI, as does auto mode when no other candidate remains. The
failed set resets when the content selection changes. Widgets that
promise nothing reveal on load as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rymsha rymsha force-pushed the liveview-render-verdict branch from bda9a40 to 566e77f Compare June 16, 2026 07:53
@rymsha rymsha requested a review from pmi June 16, 2026 07:56
ViewExtensionEvent.on(this.handleExtensionEvent.bind(this));
EmulatedDeviceEvent.listen(this.handleEmulatorEvent.bind(this));
IframeEventBus.get().onEvent(RENDER_STATUS_EVENT, (event) => {
// the bus delivers the parsed message detail, not an IframeEvent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does inflate it as long as you register the class with IframeEventBus.get().registerClass('EventName', EventClass), but it's the legacy approach and the DTO is preferred.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a demo - how to workaround CSP.
Feel free to implement it the way you like it

Comment on lines +330 to +331
this.renderedExtension = extension;
this.renderedInAutoMode = isAuto;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these are available to the widget and therefore can be sent from the iframe wrapper in the RenderStatusData event instead of creating extra fields here.

this.clearVerdictWait(true);
return;
}
if (!this.renderedInAutoMode || !this.renderedExtension) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add those to RenderStatusData event returned from the iframe wrapper

Comment on lines +80 to +82
private renderedExtension: Extension;

private renderedInAutoMode: boolean = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used to carry info between async events and should be added to the event itself.

}).finally(() => {
deferred.resolve(isRenderable);
if (isRenderable !== wasRenderable) {
this.notifyRenderableChanged(isRenderable, wasRenderable);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the listeners are still notified if the page is renderable the old way, paying no attention to new verdict.

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.

Auto preview cannot skip browser-only failures

2 participants