Skip to content

feat(linux): canvas UI via CLI-node + Tauri app IPC bridge - #107633

Merged
steipete merged 8 commits into
mainfrom
claude/linux-canvas
Jul 14, 2026
Merged

steipete merged 8 commits into
mainfrom
claude/linux-canvas

Conversation

@steipete

@steipete steipete commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • New bundled extensions/linux-canvas: registers the 8 canvas.* node-host commands. isAvailable advertises 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.
  • New 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 from extensions/canvas/src/host/a2ui, with a drift guard), and handlers for present/hide/navigate/eval/snapshot/a2ui.push/pushJSONL/reset plus the openclawCanvasA2UIAction bridge.
  • "linux" added to the canvas plugin's defaultPlatforms; a sessionKey is threaded through invoke so A2UI actions route to the correct agent session; the node re-advertises its command surface (via a new gateway-client updateNodeManifest) 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.mjs now guards that canvas.rs embeds the synced A2UI resources (drift guard), and scripts/run-vitest.mjs auto-adds --isolate when multiple explicit directory targets are mixed (running this PR's extension + node-host tests together surfaced cross-project mock poisoning; covered by test/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

  • Focused vitest (extension IPC/commands/socket, node-host, gateway node policy, canvas plugin, gateway-client incl. watchdog) — all pass; import cycles 0; prod types + test-types + oxlint + LOC ratchet + format clean.
  • Live end-to-end proof on a real headless Wayland/WebKitGTK Linux desktop (AWS Crabbox): built the Tauri app + CLI node + gateway, approved the node command surface, and drove the full path agent → CLI-node → Unix-socket IPC → app → globalThis.openclawA2UI.applyMessages:
    • Node advertised all 8 canvas.* commands only once the app IPC socket existed.
    • canvas.eval round-trips JS to the WebView (1+1 → 2).
    • The bundled canvas page loads: location.href === openclaw-canvas://localhost/index.html, globalThis.openclawA2UI is 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".
  • The WebView-load fix (this PR's key commit): Wry's Linux/WebKitGTK incognito mode alone reused Tauri's default WebContext without the registered custom-scheme handler, so the openclaw-canvas:// page never committed (stayed about: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, and incognito makes Wry swap in a fresh ephemeral context carrying those protocols (refs wry-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.
  • Autoreview (Codex gpt-5.6-sol, xhigh) clean.

Known limitations (documented): one Canvas window per app in v1; requires the desktop app running (headless nodes don't get canvas); WebKitGTK rendering. canvas.snapshot needs a GPU/compositor for WebKitGTK offscreen capture, so it is unavailable on a headless GPU-less box (works on a real desktop).

@steipete
steipete requested a review from a team as a code owner July 14, 2026 15:51
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling plugin: file-transfer app: linux plugin: linux-node size: XL maintainer Maintainer-authored PR labels Jul 14, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/linux-canvas/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of @openclaw/openclaw-secops.

  • Current SHA: b0fb9c77e1d3ddb73b2682d8cf1036985de494dd
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread src/node-host/runner.ts
},
onManifestChanged: (manifest) => {
gatewayHelloReceived = false;
client.updateNodeManifest(manifest);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +142 to +143
// Gateway-only agent ownership metadata. Forwarded beside params, never inside them.
sessionKey: Type.Optional(NonEmptyString),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@steipete
steipete force-pushed the claude/linux-canvas branch 4 times, most recently from 0dd18ea to b9e6b4a Compare July 14, 2026 20:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +18 to +20
method === "POST" &&
(normalizedPath === "/profiles/create" || normalizedPath === "/reset-profile")
) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@steipete
steipete force-pushed the claude/linux-canvas branch from b9e6b4a to d089809 Compare July 14, 2026 21:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +491 to +493
"canvas.a2ui.push" => {
let params: PushParams = decode_params(&request.params_json)?;
apply_a2ui_messages(app, params.messages, true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

steipete added 3 commits July 14, 2026 16:03
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.
@steipete
steipete force-pushed the claude/linux-canvas branch from b453e70 to b0fb9c7 Compare July 14, 2026 23:04
@steipete
steipete merged commit b363d5a into main Jul 14, 2026
104 checks passed
@steipete
steipete deleted the claude/linux-canvas branch July 14, 2026 23:05
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 15, 2026
…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.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: linux app: web-ui App: web-ui dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR plugin: file-transfer plugin: linux-node scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant