feat: wire WebView2 native↔SPA bridge in CanvasWindow#259
feat: wire WebView2 native↔SPA bridge in CanvasWindow#259AlexAlves87 wants to merge 1 commit intoopenclaw:masterfrom
Conversation
85c44b9 to
aa449d2
Compare
|
The failing test ( I noticed a recent run on 0f54bc1 showing a different integration test failing in the same pattern, which suggests this might be intermittent CI flakiness rather than a regression. Happy to trigger a re-run if that would help move this forward! |
|
🤖 This is an automated response from Repo Assist. The CI test failure here is not caused by this PR's changes. The failing test is: This is a The PR's own validation reports
|
Adds BridgeMessageReceived + PostBridgeMessage to CanvasWindow following the same pattern as WebChatWindow (c7630fa), closing the CanvasWindow item on the openclaw#191 checklist. Removes SendA2UIMessageAsync, ResetA2UIAsync, and their heuristic ExecuteScriptAsync helpers; both had no active callers and are replaced by the bridge. IsTrustedBridgeSource accepts only _trustedGatewayOrigin and openclaw-canvas.local. Source-scan test added in TrayMenuWindowMarkupTests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
aa449d2 to
85a5c3f
Compare
Summary
Adds the bidirectional WebView2 bridge to
CanvasWindowand removes the fragileExecuteScriptAsyncheuristic paths, closing the remaining item on the #191 checklist after #192 landed theWebChatWindowhalf.Native → SPA
SPA → native
Why
The #191 checklist had one item outstanding after #192:
SendA2UIMessageAsyncandResetA2UIAsyncused 11 and 6 heuristic fallbacks respectively (window.__a2ui,window.a2ui,window.A2UI,dispatchEvent,postMessage…) to push messages into the SPA — the exact fragile pattern the issue calls out. Both methods had no active callers; the A2UI path is now served by the nativeA2UICanvasWindowrenderer. They are removed and the bridge is the replacement.Trust boundary
IsTrustedBridgeSourceaccepts messages from exactly two origins:_trustedGatewayOrigin— the gateway configured viaSetTrustedGatewayOriginhttps://openclaw-canvas.local— the local virtual host for canvas filesEverything else is rejected with a warning log entry.
What is not changed
EvalAsync— untouched; it is thecanvas.evalagent API, not a messaging pathEnsureA2UIHostAsync— untouched; usesNavigate, not the heuristic patternNodeService— no changesA2UICanvasWindow— not touchedTests
Source-scan added in
TrayMenuWindowMarkupTestsasserting presence ofBridgeMessageReceived,IsTrustedBridgeSource,openclaw-canvas.local, dispatcher marshaling,PostWebMessageAsJson,SanitizeBridgeLogValue, andWebMessageReceivedcleanup inOnWindowClosed.Validation
build.ps1✅ —OpenClaw.Shared.Tests1100/1100 ✅ —OpenClaw.Tray.Tests407/407 ✅