Add SDK canvas runtime support#1401
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds cross-SDK “canvas runtime” support, enabling SDK consumers to declare canvases, receive direct provider callbacks (canvas.*), and use host-side session.canvas.* RPCs with stable extension identity (extensionInfo)—without requiring the larger handler refactor from the prototype branch.
Changes:
- Rust: Introduces a new
canvasmodule (declarations, handler traits, dispatch, host RPC types) and wiresSessionConfig/ResumeSessionConfigto serialize canvas-related fields onsession.create/session.resume. - Rust: Adds
Session::canvas()host API and updates the session event loop/router to handle direct provider callback requests (canvas.open|focus|reload|close|action.invoke). - Node.js: Adds a canvas surface (
createCanvas, types, dispatch), forwards canvas declarations + request flags +extensionInfoon session create/resume, and routes directcanvas.*JSON-RPC requests to registered canvases with tests.
Show a summary per file
| File | Description |
|---|---|
| rust/tests/session_test.rs | Adds coverage for Rust canvas wire fields, provider dispatch routing, and SessionCanvas host API behavior. |
| rust/tests/e2e/elicitation.rs | Updates capability struct test to include the new ui.canvases field. |
| rust/src/wire.rs | Extends session create/resume wire payloads with canvases, request flags, and extension_info. |
| rust/src/types.rs | Adds ExtensionInfo, canvas config fields on session configs, resume result open-canvas capture, and UiCapabilities.canvases. |
| rust/src/session.rs | Adds SessionCanvas host API + open-canvas tracking and routes canvas.* provider callbacks through a per-session registry. |
| rust/src/router.rs | Adds debug logging when routing requests to a registered session. |
| rust/src/lib.rs | Exposes the new canvas module publicly. |
| rust/src/jsonrpc.rs | Adds debug logging for incoming JSON-RPC requests from the runtime. |
| rust/src/canvas.rs | New Rust canvas module: declarations, handler traits, registry + dispatch, request/response types, and unit tests. |
| nodejs/test/extension.test.ts | Verifies createCanvas is exported from the extension surface. |
| nodejs/test/client.test.ts | Adds tests for forwarding canvas fields on create/resume and for direct provider dispatch behavior. |
| nodejs/src/types.ts | Adds SessionCapabilities.ui.canvases, introduces ExtensionInfo, and extends session configs with canvas fields. |
| nodejs/src/session.ts | Adds per-session canvas registration and lookup to support direct dispatch routing. |
| nodejs/src/index.ts | Exports canvas APIs/types and ExtensionInfo from the main entrypoint. |
| nodejs/src/extension.ts | Exports canvas APIs/types and ExtensionInfo from the extension surface. |
| nodejs/src/client.ts | Forwards canvas fields on create/resume and registers handlers for direct canvas.* provider callbacks. |
| nodejs/src/canvas.ts | New Node canvas module: canvas declaration/types, createCanvas, and provider request dispatch helper. |
Copilot's findings
- Files reviewed: 17/17 changed files
- Comments generated: 5
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1202bc1 to
c50b728
Compare
This comment has been minimized.
This comment has been minimized.
Add Node extension canvas APIs and direct canvas provider callback routing. Add Rust canvas declarations, provider handlers, create/resume wiring, and host session.canvas APIs aligned with the runtime schema. Validation: nodejs typecheck/lint/tests; rust fmt/check/clippy; cargo test --all-features. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Expose stable extension identity metadata on Node and Rust session create/resume options and forward extensionInfo on the wire for canvas providers. Validation: nodejs typecheck/lint/vitest; rust fmt/clippy/test --all-features. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced May 25, 2026
pull Bot
pushed a commit
to rashworld-max/copilot-sdk
that referenced
this pull request
May 28, 2026
Cross-language: - Mark canvas surface as Experimental in Rust (doc-comment warning), Node (JSDoc @experimental tag), Python (module + per-type comment), and Go (per-symbol doc comment). .NET already had [Experimental(Diagnostics.Experimental)]. Rust: - Add Default impls (via #[derive(Default)]) to CanvasDeclaration, CanvasOpenContext, CanvasActionContext, and CanvasLifecycleContext for forward-proofing against new optional members. Node: - Extract CanvasHostCapabilities as a named exported interface (previously inlined into CanvasHostContext). Matches the other SDKs. .NET: - Rename CanvasError -> CanvasException (C# *Exception convention). - Convert init-only setters to set on canvas context types (consistent with the rest of the SDK). - Simplify CanvasErrorHelpers.Build using SerializeToElement with a JsonObject + TypesJsonContext; drop the bespoke CanvasErrorPayload type and now-empty CanvasJsonContext. - Cache JsonElement for the JSON literal 'null' to avoid parsing on every canvas action that returns void/null. - Document why JsonRpc.HandleIncomingMethodAsync unwraps TargetInvocationException (handlers are dispatched via reflection). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 2, 2026
Closed
This was referenced Jun 10, 2026
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Adds canvas runtime support across the Rust, Node, Python, Go, and .NET SDKs so consumers can declare canvases on
session.create/session.resume, install a singleCanvasHandler, and receive routedcanvas.open/canvas.close/canvas.action.invokeJSON-RPC requests from the runtime. Resume surfacesopenCanvasesfor rehydration, and host code can callsession.canvas.*for native UI / chrome actions.Per-language surface
rust/src/canvas.rs):CanvasDeclaration,CanvasHandlertrait,CanvasHostContext/CanvasOpenContext/CanvasActionContext/CanvasLifecycleContext,CanvasError,CanvasOpenResponse,ExtensionInfo. Wire types (OpenCanvasInstance,CanvasAction,CanvasInstanceAvailability,CanvasInvokeActionRequest/Result, etc.) consumed directly fromgenerated::api_types— no duplication.Session::open_canvases()accessor; host APIs viasession.rpc().canvas().nodejs/src/canvas.ts):createCanvas, canvas declarations, handler contexts, errors, exports. Session create/resume threadcanvases,requestCanvasRenderer,requestExtensions,extensionInfo.python/copilot/canvas.py):CanvasHandlerABC with defaulton_close/on_action(raisescanvas_action_no_handler)._jsonrpcloosened to allow arbitrary JSON return values for action results.go/canvas.go):CanvasHandlerinterface +CanvasHandlerDefaultsembeddable for partial impls. Inbound RPC registered viajsonrpc2.RequestHandlerForwith{code,message}error envelope.dotnet/src/Canvas.cs): idiomaticICanvasHandlerwith async methods; same dispatch shape.Java is intentionally not included in this PR and will follow separately.
Shared design
CanvasHandlerper session. Consumers switch oncanvas_idthemselves — no per-canvas registry inside the SDK.{"code":"canvas_handler_unset","message":"..."}.ExtensionInfo { source, name }lets consumers opt into stable agent-facing extension IDs (github-app:<provider-name>).Notes for reviewers
Additive on top of the existing permission / user-input / tool handler models — no broad handler refactor. Canvas declarations require
displayName.capabilities.ui.canvasesis boolean.session.canvas.listOpenis a real RPC.Validation
Per language:
cargo +nightly-2026-04-14 fmt --check,cargo clippy --all-features --all-targets -- -D warnings,cargo test --all-features,cargo doc --no-deps --all-featuresnpm run typecheck,npm run lint,npx vitest runuv run ruff format/check,uv run ty check copilot,uv run pytestgofmt,go build/vet/test ./...dotnet format --verify-no-changes,dotnet build,dotnet test