Repository navigation
feat(linux): canvas UI via CLI-node + Tauri app IPC bridge - #107633
Conversation
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9a8e3d7f5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // dashboard cookies or origin storage with the privileged main window. | ||
| .incognito(true) | ||
| .initialization_script(ACTION_BRIDGE_SCRIPT) | ||
| .on_navigation(|url| matches!(url.scheme(), "http" | "https") || is_bundled_canvas_url(url)) |
There was a problem hiding this comment.
Block local HTTP targets from Linux Canvas
When an agent invokes canvas.present/canvas.navigate with http://127.0.0.1/... (or first loads a remote page that redirects there), this navigation callback admits the load and subsequent canvas.eval/canvas.snapshot can inspect or render local desktop services from the app WebView. The sibling Android canvas policy explicitly rejects malformed and device-local web hosts (apps/android/app/src/main/java/ai/openclaw/app/node/CanvasNavigationPolicy.kt:14-20), so Linux needs the same host check here and in parse_canvas_url rather than allowing every http(s) URL.
Useful? React with 👍 / 👎.
| }, | ||
| onManifestChanged: (manifest) => { | ||
| gatewayHelloReceived = false; | ||
| client.updateNodeManifest(manifest); |
There was a problem hiding this comment.
Preserve active invokes during manifest refresh
When the Linux desktop socket appears or disappears while an unrelated node command is running, the availability watcher reaches this callback and updateNodeManifest() intentionally closes the Gateway socket; that close then goes through onClose above (src/node-host/runner.ts:299-302), which calls activeRuntime.cancelAll() and aborts in-flight system.run/duplex/plugin commands just because the desktop app started or stopped. Re-advertise the manifest without the normal failure-close path, or mark this intentional reconnect so active invokes are not cancelled.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 95720b99c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| }; | ||
| const nodeId = normalizeOptionalString(p.nodeId) ?? ""; | ||
| const command = normalizeOptionalString(p.command) ?? ""; | ||
| const sessionKey = normalizeOptionalString(p.sessionKey); |
There was a problem hiding this comment.
Forward sessionKey through plugin invoke policies
When a Canvas tool call invokes any canvas.* command, extensions/canvas/index.ts registers a node invoke policy and that policy forwards via ctx.invokeNode(). This parsed sessionKey is only used on the direct nodeRegistry.invoke path below, not passed into applyPluginNodeInvokePolicy/its invokeNode, so Linux receives canvas.a2ui.pushJSONL/canvas.a2ui.push as sessionless and extensions/linux-canvas clears or never sets ownerContext; subsequent A2UI clicks then fail with node host event relay unavailable instead of routing back to the owning agent session. Pass the session key through the policy invoke path as well.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d57bce29f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Gateway-only agent ownership metadata. Forwarded beside params, never inside them. | ||
| sessionKey: Type.Optional(NonEmptyString), |
There was a problem hiding this comment.
Derive session ownership from trusted callers
This makes sessionKey a public node.invoke parameter even though node.invoke is available to ordinary operator.write clients, not just the signed agent runtime. In the Linux Canvas flow, a caller can invoke canvas.a2ui.push/present with any sessionKey; the node host stores it as the Canvas owner and later relays WebView clicks as agent.request into that claimed session. Please derive this ownership from client.internal.agentRuntimeIdentity (or reject mismatches) instead of trusting the RPC field.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1216107416
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "params" in params && invokeParams !== undefined ? JSON.stringify(invokeParams) : null, | ||
| timeoutMs, | ||
| idempotencyKey: params.idempotencyKey, | ||
| sessionKey: normalizeString(params.sessionKey) || undefined, |
There was a problem hiding this comment.
Preserve sessionKey when decoding invoke events
Fresh evidence beyond the earlier policy-path comment: runNodeHost decodes every node.invoke.request through coerceNodeInvokePayload, and that helper still returns only id/nodeId/command/paramsJSON/timeoutMs/idempotencyKey from src/node-host/invoke-payload.ts:24-31, so the new sessionKey added to this payload is dropped before activeRuntime.invoke() ever sees it. In the Linux Canvas flow, even after forwarding the field through the Gateway policy, canvas.a2ui.push/present reaches extensions/linux-canvas as sessionless, leaving A2UI clicks unable to route back to the owning agent session.
Useful? React with 👍 / 👎.
0dd18ea to
b9e6b4a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b9e6b4af44
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| method === "POST" && | ||
| (normalizedPath === "/profiles/create" || normalizedPath === "/reset-profile") | ||
| ) { |
There was a problem hiding this comment.
Block profile imports before forwarding
When a direct node.invoke targets browser.proxy with POST /profiles/import, this new Gateway-side guard lets it through even though the browser plugin's own policy classifies /profiles/import as a persistent profile mutation and host-local route (extensions/browser/src/browser/request-policy.ts:29-36). In the admin direct-invoke path this means the request is forwarded to the browser node instead of being rejected before dispatch like /profiles/create and /reset-profile, relying on the remote implementation to enforce a core no-forwarding policy and potentially starting the node browser proxy before rejection. Add /profiles/import to this persistent-mutation list.
Useful? React with 👍 / 👎.
b9e6b4a to
d089809
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b453e70181
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "canvas.a2ui.push" => { | ||
| let params: PushParams = decode_params(&request.params_json)?; | ||
| apply_a2ui_messages(app, params.messages, true) |
There was a problem hiding this comment.
Preserve JSONL fallback for canvas.a2ui.push
When a Linux node receives canvas.a2ui.push with a jsonl payload and no messages, this decode requires messages and rejects before rendering. That payload is still admitted by the Canvas node policy (extensions/canvas/index.ts:155-161) and sibling native handlers accept it (apps/ios/Sources/Model/NodeAppModel.swift:2173-2176, apps/android/app/src/main/java/ai/openclaw/app/node/A2UIHandler.kt:57-63), so callers using the existing push-JSONL fallback work on iOS/Android but fail only on Linux. Decode the jsonl fallback here the same way as canvas.a2ui.pushJSONL.
Useful? React with 👍 / 👎.
…/protocol/deadcode
…lize module; add canvas glossary term
Wry's Linux/WebKitGTK incognito mode discards Tauri's registered WebContext (wry webkitgtk/mod.rs), so the Canvas window got a fresh ephemeral context without the openclaw-canvas:// scheme handler — the bundled A2UI page never committed (stayed about:blank) and every A2UI command timed out. Use an isolated cache-backed data_directory instead, which keeps the protocol handler while still isolating Canvas storage from the dashboard window.
Autoreview flagged that a dedicated data_directory alone persists Canvas browser state (cookies, localStorage, IndexedDB, service workers) across restarts, so an agent that navigates Canvas to a site could leak an authenticated session into a later session. iOS uses a non-persistent store; Linux should match. Add .incognito(true) alongside .data_directory(): the distinct directory gives Tauri a fresh WebContext key so it still attaches the openclaw-canvas:// protocol closure, and incognito makes Wry swap in a fresh *ephemeral* context carrying those protocols. Live-verified on a Wayland/WebKitGTK box: the bundled page still loads (location.href=openclaw-canvas://localhost/index.html, openclawA2UI present, A2UI renders) and the canvas-webview dir holds no persistent cookie/storage files.
b453e70 to
b0fb9c7
Compare
|
Merged via squash.
|
…107633) * feat(linux): canvas via CLI-node + Tauri app IPC bridge * refactor: extract gateway helper modules * build(linux-canvas): register plugin package in lockfile * fix(linux-canvas): move canvas advertise test out of core, regen docs/protocol/deadcode * fix(gateway): break node-catalog/registry import cycle via leaf normalize module; add canvas glossary term * style: oxfmt invoke.ts and runtime.ts after buildNodeEventParams extraction * fix(linux): load Canvas WebView via dedicated data_directory context Wry's Linux/WebKitGTK incognito mode discards Tauri's registered WebContext (wry webkitgtk/mod.rs), so the Canvas window got a fresh ephemeral context without the openclaw-canvas:// scheme handler — the bundled A2UI page never committed (stayed about:blank) and every A2UI command timed out. Use an isolated cache-backed data_directory instead, which keeps the protocol handler while still isolating Canvas storage from the dashboard window. * fix(linux): keep Canvas WebView ephemeral via incognito + data_directory Autoreview flagged that a dedicated data_directory alone persists Canvas browser state (cookies, localStorage, IndexedDB, service workers) across restarts, so an agent that navigates Canvas to a site could leak an authenticated session into a later session. iOS uses a non-persistent store; Linux should match. Add .incognito(true) alongside .data_directory(): the distinct directory gives Tauri a fresh WebContext key so it still attaches the openclaw-canvas:// protocol closure, and incognito makes Wry swap in a fresh *ephemeral* context carrying those protocols. Live-verified on a Wayland/WebKitGTK box: the bundled page still loads (location.href=openclaw-canvas://localhost/index.html, openclawA2UI present, A2UI renders) and the canvas-webview dir holds no persistent cookie/storage files.
…107633) * feat(linux): canvas via CLI-node + Tauri app IPC bridge * refactor: extract gateway helper modules * build(linux-canvas): register plugin package in lockfile * fix(linux-canvas): move canvas advertise test out of core, regen docs/protocol/deadcode * fix(gateway): break node-catalog/registry import cycle via leaf normalize module; add canvas glossary term * style: oxfmt invoke.ts and runtime.ts after buildNodeEventParams extraction * fix(linux): load Canvas WebView via dedicated data_directory context Wry's Linux/WebKitGTK incognito mode discards Tauri's registered WebContext (wry webkitgtk/mod.rs), so the Canvas window got a fresh ephemeral context without the openclaw-canvas:// scheme handler — the bundled A2UI page never committed (stayed about:blank) and every A2UI command timed out. Use an isolated cache-backed data_directory instead, which keeps the protocol handler while still isolating Canvas storage from the dashboard window. * fix(linux): keep Canvas WebView ephemeral via incognito + data_directory Autoreview flagged that a dedicated data_directory alone persists Canvas browser state (cookies, localStorage, IndexedDB, service workers) across restarts, so an agent that navigates Canvas to a site could leak an authenticated session into a later session. iOS uses a non-persistent store; Linux should match. Add .incognito(true) alongside .data_directory(): the distinct directory gives Tauri a fresh WebContext key so it still attaches the openclaw-canvas:// protocol closure, and incognito makes Wry swap in a fresh *ephemeral* context carrying those protocols. Live-verified on a Wayland/WebKitGTK box: the bundled page still loads (location.href=openclaw-canvas://localhost/index.html, openclawA2UI present, A2UI renders) and the canvas-webview dir holds no persistent cookie/storage files.
What Problem This Solves
Canvas — the agent-driven WebView UI (the
canvas.*and A2UI commands) — worked only on macOS/iOS/Android. Linux nodes had no way to present agent-authored interactive UI. A headless CLI node host can't render a WebView, so canvas needs a GUI process.Why This Change Was Made
Canvas on Linux keeps the CLI node host as the single gateway connection (as with the camera/location/notify capabilities) and delegates rendering to the running Tauri desktop app over a local IPC bridge:
extensions/linux-canvas: registers the 8canvas.*node-host commands.isAvailableadvertises them only when the app's IPC socket exists — so a headless server without the app never offers canvas. Each command forwards over a Unix-socket IPC to the app and relays the result; A2UI user actions flow back app → node host → gateway → the owning agent session.apps/linux/src-tauri/src/canvas.rs: an IPC server (NDJSON,$XDG_RUNTIME_DIR/openclaw-canvas.sock, 0600, peer-UID verified), a dedicated Canvas WebView that loads the bundled A2UI renderer (mirrored fromextensions/canvas/src/host/a2ui, with a drift guard), and handlers for present/hide/navigate/eval/snapshot/a2ui.push/pushJSONL/reset plus theopenclawCanvasA2UIActionbridge."linux"added to the canvas plugin'sdefaultPlatforms; asessionKeyis threaded through invoke so A2UI actions route to the correct agent session; the node re-advertises its command surface (via a new gateway-clientupdateNodeManifest) when the app socket appears.Modeled on the iOS design (bundle A2UI locally, load into the WebView,
applyMessages) rather than the macOS gateway-fetch path. Two gateway helper modules were extracted (node-browser-proxy.ts,client-address-utils.ts) to keep the touched files within the LOC ratchet. Also included:scripts/sync-native-a2ui.mjsnow guards thatcanvas.rsembeds the synced A2UI resources (drift guard), andscripts/run-vitest.mjsauto-adds--isolatewhen multiple explicit directory targets are mixed (running this PR's extension + node-host tests together surfaced cross-project mock poisoning; covered bytest/scripts/run-vitest.test.ts).User Impact
An agent can present interactive A2UI on a Linux desktop running the OpenClaw app. Canvas is only advertised when the app is running; no behavior change for headless nodes or other platforms.
Evidence
agent → CLI-node → Unix-socket IPC → app → globalThis.openclawA2UI.applyMessages:canvas.*commands only once the app IPC socket existed.canvas.evalround-trips JS to the WebView (1+1→2).location.href === openclaw-canvas://localhost/index.html,globalThis.openclawA2UIis defined.canvas.a2ui.pushJSONL→{"ok":true,"surfaces":["main"]}; the pushed A2UI Text rendered as<a2ui-surface>→<a2ui-root>→<a2ui-text>, and a full recursive shadow-DOM read returned the pushed string"OpenClaw Canvas rendered on Linux".incognitomode alone reused Tauri's defaultWebContextwithout the registered custom-scheme handler, so theopenclaw-canvas://page never committed (stayedabout:blank). Fix: set both a dedicated.data_directory(<cache>/canvas-webview)and.incognito(true)— the distinct directory gives Tauri a fresh WebContext key so it attaches the protocol closure, andincognitomakes Wry swap in a fresh ephemeral context carrying those protocols (refswry-0.55.1/src/webkitgtk/mod.rs,tauri-runtime-wry-2.11.4/src/lib.rs). Result: the page loads, Canvas storage stays isolated from the dashboard and non-persistent across restarts (live-verified: no cookie/localStorage/IndexedDB files written), matching iOS's non-persistent Canvas store.Known limitations (documented): one Canvas window per app in v1; requires the desktop app running (headless nodes don't get canvas); WebKitGTK rendering.
canvas.snapshotneeds a GPU/compositor for WebKitGTK offscreen capture, so it is unavailable on a headless GPU-less box (works on a real desktop).