feat: create(html:) — one-step create directly on authored HTML#21
Merged
Conversation
…s the agent_ui blank race)
A consumer can now create a CEF browser DIRECTLY on an authored document instead of
create('about:blank') + a later loadHtmlString. The two-step form is inherently racy (the second
load depends on create-resolution, body-mount, a one-shot onPageStarted, and visibility all
interleaving right) — the root cause of nondeterministic blank agent_ui tiles. One-step create makes
an html tile structurally identical to a URL tile (cefWebview), which is rock-solid.
- cef_host (main.mm): a data:/file: create URL — host-trusted content-injection schemes that can
NEVER arise from an untrusted page navigation (the allowlist refuses them in OnBeforeBrowse) — arms
the trusted-load exemption for its INITIAL load, exactly as DoNavigateTrusted does for a post-create
loadTrusted. Same trust model; only the timing (at create) differs. Protocol bumped 2 -> 3 so a
stale host without this is refused at the handshake rather than silently blanking a data: create.
- CefWebController.create gains `html:` (base64 data: URL, shared with loadHtmlString via _htmlDataUrl).
- CefWebView gains `html:` (routes to create(html:)).
Tests: create(html:) emits the trusted data: URL as the sole create, no separate loadTrusted; suite
40 green. Changes native -> new content hash -> republish + consumer pin bump.
Co-Authored-By: Claude Fable 5 <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.
Why
Hosts that inject an authored document (like Campus's
agent_uitiles) currently do a two-step load:create('about:blank'), then laterloadHtmlString(doc)once the browser resolves. That second step races create-resolution, body-mount, the one-shotonPageStarted, and visibility — the well-known nondeterministic blank tile. A plaincefWebviewdoes ONE step (create(realURL)) and is rock-solid.This makes the authored-doc path structurally identical to a webview: the browser is born on the document, so there is no second step to race and the tile can never be blank (worst case a stale doc, corrected by a normal reload).
What
CefWebController.create({String? html})/CefWebView(html: …)— whenhtmlis set, the browser is created directly on adata:text/html;charset=utf-8;base64,…URL built from the doc (same encoderloadHtmlStringnow uses).cef_host/main.mm): when the create URL is a host-trusted content-injection scheme (data:/file:) and a scheme allowlist is active, auto-arm thetrusted_pendingexemption for that URL so the initial load isn't refused byOnBeforeBrowse. These schemes can never arise from untrusted page navigation, so this is safe.cef_hostis refused loudly (protocolMismatch) rather than silently blanking.create(html:)creates on the authoreddata:URL and issues noloadTrustedfollow-up. 40 tests pass.Validated end-to-end in the example app against a v3 host: the authored HTML renders directly from the
data:create URL, zero refusals.