惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
IT之家
IT之家
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
L
LangChain Blog
博客园 - Franky
美团技术团队
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
小众软件
小众软件
Y
Y Combinator Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Docker
Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
perf: split canvas a2ui shared imports · openclaw/opencla...
steipete · 2026-04-25 · via Recent Commits to openclaw:main

@@ -4,13 +4,16 @@ import path from "node:path";

44

import { fileURLToPath } from "node:url";

55

import { detectMime } from "../media/mime.js";

66

import { lowercasePreservingWhitespace } from "../shared/string-coerce.js";

7+

import { A2UI_PATH, injectCanvasLiveReload, isA2uiPath } from "./a2ui-shared.js";

78

import { resolveFileWithinRoot } from "./file-resolver.js";

899-

export const A2UI_PATH = "/__openclaw__/a2ui";

10-11-

export const CANVAS_HOST_PATH = "/__openclaw__/canvas";

12-13-

export const CANVAS_WS_PATH = "/__openclaw__/ws";

10+

export {

11+

A2UI_PATH,

12+

CANVAS_HOST_PATH,

13+

CANVAS_WS_PATH,

14+

injectCanvasLiveReload,

15+

isA2uiPath,

16+

} from "./a2ui-shared.js";

14171518

let cachedA2uiRootReal: string | null | undefined;

1619

let resolvingA2uiRoot: Promise<string | null> | null = null;

@@ -79,67 +82,6 @@ async function resolveA2uiRootReal(): Promise<string | null> {

7982

return resolvingA2uiRoot;

8083

}

818482-

export function injectCanvasLiveReload(html: string): string {

83-

const snippet = `

84-

<script>

85-

(() => {

86-

// Cross-platform action bridge helper.

87-

// Works on:

88-

// - iOS: window.webkit.messageHandlers.openclawCanvasA2UIAction.postMessage(...)

89-

// - Android: window.openclawCanvasA2UIAction.postMessage(...)

90-

const handlerNames = ["openclawCanvasA2UIAction"];

91-

function postToNode(payload) {

92-

try {

93-

const raw = typeof payload === "string" ? payload : JSON.stringify(payload);

94-

for (const name of handlerNames) {

95-

const iosHandler = globalThis.webkit?.messageHandlers?.[name];

96-

if (iosHandler && typeof iosHandler.postMessage === "function") {

97-

iosHandler.postMessage(raw);

98-

return true;

99-

}

100-

const androidHandler = globalThis[name];

101-

if (androidHandler && typeof androidHandler.postMessage === "function") {

102-

// Important: call as a method on the interface object (binding matters on Android WebView).

103-

androidHandler.postMessage(raw);

104-

return true;

105-

}

106-

}

107-

} catch {}

108-

return false;

109-

}

110-

function sendUserAction(userAction) {

111-

const id =

112-

(userAction && typeof userAction.id === "string" && userAction.id.trim()) ||

113-

(globalThis.crypto?.randomUUID?.() ?? String(Date.now()));

114-

const action = { ...userAction, id };

115-

return postToNode({ userAction: action });

116-

}

117-

globalThis.OpenClaw = globalThis.OpenClaw ?? {};

118-

globalThis.OpenClaw.postMessage = postToNode;

119-

globalThis.OpenClaw.sendUserAction = sendUserAction;

120-

globalThis.openclawPostMessage = postToNode;

121-

globalThis.openclawSendUserAction = sendUserAction;

122-123-

try {

124-

const cap = new URLSearchParams(location.search).get("oc_cap");

125-

const proto = location.protocol === "https:" ? "wss" : "ws";

126-

const capQuery = cap ? "?oc_cap=" + encodeURIComponent(cap) : "";

127-

const ws = new WebSocket(proto + "://" + location.host + ${JSON.stringify(CANVAS_WS_PATH)} + capQuery);

128-

ws.onmessage = (ev) => {

129-

if (String(ev.data || "") === "reload") location.reload();

130-

};

131-

} catch {}

132-

})();

133-

</script>

134-

`.trim();

135-136-

const idx = lowercasePreservingWhitespace(html).lastIndexOf("</body>");

137-

if (idx >= 0) {

138-

return `${html.slice(0, idx)}\n${snippet}\n${html.slice(idx)}`;

139-

}

140-

return `${html}\n${snippet}\n`;

141-

}

142-14385

export async function handleA2uiHttpRequest(

14486

req: IncomingMessage,

14587

res: ServerResponse,

@@ -150,8 +92,7 @@ export async function handleA2uiHttpRequest(

15092

}

1519315294

const url = new URL(urlRaw, "http://localhost");

153-

const basePath =

154-

url.pathname === A2UI_PATH || url.pathname.startsWith(`${A2UI_PATH}/`) ? A2UI_PATH : undefined;

95+

const basePath = isA2uiPath(url.pathname) ? A2UI_PATH : undefined;

15596

if (!basePath) {

15697

return false;

15798

}