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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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("openclawSendUserAction");
expect(html).toContain(CANVAS_WS_PATH);
expect(html).toContain('document.createElement("span")');
expect(html).not.toContain("statusEl.innerHTML");
} finally {
await server.close();
}

View File

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