Canvas Host: build default status with DOM nodes (#58266)

This commit is contained in:
Jacob Tomlinson
2026-03-31 02:29:28 -07:00
committed by GitHub
parent e95f786aa2
commit df0e136bc7
2 changed files with 14 additions and 5 deletions

View File

@@ -145,6 +145,8 @@ describe("canvas host", () => {
expect(html).toContain("Interactive test page"); expect(html).toContain("Interactive test page");
expect(html).toContain("openclawSendUserAction"); expect(html).toContain("openclawSendUserAction");
expect(html).toContain(CANVAS_WS_PATH); expect(html).toContain(CANVAS_WS_PATH);
expect(html).toContain('document.createElement("span")');
expect(html).not.toContain("statusEl.innerHTML");
} finally { } finally {
await server.close(); await server.close();
} }

View File

@@ -121,11 +121,18 @@ function defaultIndexHTML() {
typeof window.openclawCanvasA2UIAction.postMessage === "function") typeof window.openclawCanvasA2UIAction.postMessage === "function")
); );
const hasHelper = () => typeof window.openclawSendUserAction === "function"; const hasHelper = () => typeof window.openclawSendUserAction === "function";
statusEl.innerHTML = const helperReady = hasHelper();
"Bridge: " + statusEl.textContent = "";
(hasHelper() ? "<span class='ok'>ready</span>" : "<span class='bad'>missing</span>") + statusEl.appendChild(document.createTextNode("Bridge: "));
" · iOS=" + (hasIOS() ? "yes" : "no") + const bridgeStatus = document.createElement("span");
" · Android=" + (hasAndroid() ? "yes" : "no"); bridgeStatus.className = helperReady ? "ok" : "bad";
bridgeStatus.textContent = helperReady ? "ready" : "missing";
statusEl.appendChild(bridgeStatus);
statusEl.appendChild(
document.createTextNode(
" · iOS=" + (hasIOS() ? "yes" : "no") + " · Android=" + (hasAndroid() ? "yes" : "no"),
),
);
const onStatus = (ev) => { const onStatus = (ev) => {
const d = ev && ev.detail || {}; const d = ev && ev.detail || {};