Skip to content

Commit df0e136

Browse files
Canvas Host: build default status with DOM nodes (#58266)
1 parent e95f786 commit df0e136

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎src/canvas-host/server.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ describe("canvas host", () => {
145145
expect(html).toContain("Interactive test page");
146146
expect(html).toContain("openclawSendUserAction");
147147
expect(html).toContain(CANVAS_WS_PATH);
148+
expect(html).toContain('document.createElement("span")');
149+
expect(html).not.toContain("statusEl.innerHTML");
148150
} finally {
149151
await server.close();
150152
}

‎src/canvas-host/server.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,18 @@ function defaultIndexHTML() {
121121
typeof window.openclawCanvasA2UIAction.postMessage === "function")
122122
);
123123
const hasHelper = () => typeof window.openclawSendUserAction === "function";
124-
statusEl.innerHTML =
125-
"Bridge: " +
126-
(hasHelper() ? "<span class='ok'>ready</span>" : "<span class='bad'>missing</span>") +
127-
" · iOS=" + (hasIOS() ? "yes" : "no") +
128-
" · Android=" + (hasAndroid() ? "yes" : "no");
124+
const helperReady = hasHelper();
125+
statusEl.textContent = "";
126+
statusEl.appendChild(document.createTextNode("Bridge: "));
127+
const bridgeStatus = document.createElement("span");
128+
bridgeStatus.className = helperReady ? "ok" : "bad";
129+
bridgeStatus.textContent = helperReady ? "ready" : "missing";
130+
statusEl.appendChild(bridgeStatus);
131+
statusEl.appendChild(
132+
document.createTextNode(
133+
" · iOS=" + (hasIOS() ? "yes" : "no") + " · Android=" + (hasAndroid() ? "yes" : "no"),
134+
),
135+
);
129136
130137
const onStatus = (ev) => {
131138
const d = ev && ev.detail || {};

0 commit comments

Comments
 (0)