Skip to content

Canvas SDK: post-merge review followups (PR #1401)#1420

Merged
SteveSandersonMS merged 3 commits into
mainfrom
jmoseley/canvas-pr-1401-followups
May 28, 2026
Merged

Canvas SDK: post-merge review followups (PR #1401)#1420
SteveSandersonMS merged 3 commits into
mainfrom
jmoseley/canvas-pr-1401-followups

Conversation

@jmoseley
Copy link
Copy Markdown
Contributor

Follow-ups to the canvas SDK surface added in #1401. Scope: cross-language polish + .NET cleanups. Excludes the Canvases capability rename (separate session) and E2E canvas tests (separate session).

Cross-language

  • Mark canvas surface as Experimental in Rust (doc-comment warning), Node (JSDoc @experimental), 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; matches the other SDKs.

.NET

  • Rename CanvasErrorCanvasException (C# *Exception convention).
  • Convert init setters → 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 the JsonElement for the JSON literal null to avoid JsonDocument.Parse on every canvas action that returns void/null.
  • Document why JsonRpc.HandleIncomingMethodAsync unwraps TargetInvocationException (handlers are dispatched via reflection / DynamicInvoke).

Validation

  • Rust: cargo fmt --check, cargo clippy --all-features --all-targets -- -D warnings, cargo test --all-features (129 passed).
  • Node: npm run typecheck, npm run lint (0 errors), vitest run (86 passed).
  • Go: gofmt -l ., go build ./..., go vet ./..., unit tests pass.
  • Python: ruff check, ty check copilot (all clean), unit tests (80 passed).
  • .NET: dotnet format --verify-no-changes, dotnet build -f net8.0, canvas tests pass (9/9).

Related: #1401

Co-authored-by: Copilot [email protected]

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 <[email protected]>
Copilot AI review requested due to automatic review settings May 25, 2026 19:18
@jmoseley jmoseley requested a review from a team as a code owner May 25, 2026 19:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR applies post-merge follow-ups to the Canvas SDK surface (added in #1401), focusing on cross-language “experimental” labeling and a set of .NET API/implementation cleanups for consistency and reduced allocations.

Changes:

  • Mark the canvas surface as Experimental across Rust/Node/Python/Go (Rust rustdoc warnings, Node JSDoc @experimental, Python module note + per-type comments, Go per-symbol doc comments).
  • Rust: add Default derives to several canvas declaration/context types to ease forward-compatible construction as optional fields evolve.
  • .NET: rename CanvasErrorCanvasException, switch canvas context properties from init to set, simplify error payload construction via JsonObject + TypesJsonContext, cache a null JsonElement, and document TargetInvocationException unwrapping rationale in JSON-RPC dispatch.
Show a summary per file
File Description
rust/src/canvas.rs Adds experimental rustdoc warnings and derives Default for canvas declaration/context types.
python/copilot/canvas.py Adds module-level experimental note and per-type experimental comments.
nodejs/src/index.ts Re-exports CanvasHostCapabilities from the public Node entrypoint.
nodejs/src/canvas.ts Adds module/type @experimental docs and extracts CanvasHostCapabilities into a named exported interface.
go/canvas.go Adds per-symbol experimental doc comments for the Go canvas surface.
dotnet/test/Unit/CanvasTests.cs Updates unit tests for CanvasErrorCanvasException rename.
dotnet/src/Types.cs Adds JsonObject to source-generated serialization context for canvas error payloads.
dotnet/src/Session.cs Updates exception handling for CanvasException and caches a null JsonElement for action results.
dotnet/src/JsonRpc.cs Documents (and continues) unwrapping TargetInvocationException during handler dispatch.
dotnet/src/Canvas.cs Renames CanvasErrorCanvasException, converts context init setters to set, and simplifies error payload generation.

Copilot's findings

  • Files reviewed: 10/10 changed files
  • Comments generated: 0

@github-actions

This comment has been minimized.

Main's #1413 aligned canvas with the codegen pipeline. Re-applied
followups on top:
- Re-applied Experimental markers to hand-written canvas surfaces
  (Rust doc-comments, Node @experimental JSDoc, Python module/class
  docstrings, Go per-symbol doc comments).
- Re-applied Default derive on CanvasDeclaration in Rust.
- Re-applied .NET CanvasError -> CanvasException rename across
  Canvas.cs, Session.cs, and CanvasTests.cs.
- Re-applied CanvasErrorHelpers.Build simplification (JsonObject +
  TypesJsonContext.Default.JsonObject); removed CanvasErrorPayload
  and CanvasJsonContext partial.
- Re-applied Session.cs NullJsonElement cache and simplified
  SerializeActionResult.
- Updated index.ts re-export to CanvasHostContextCapabilities to
  match codegen rename.

Co-authored-by: Copilot <[email protected]>
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Generated by SDK Consistency Review Agent for issue #1420 · ● 7.4M

…01-followups

# Conflicts:
#	rust/src/canvas.rs
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

Reviewed all 5 affected SDK implementations (Node.js, Python, Go, Rust, .NET). No consistency issues found — this PR is well-coordinated.

Summary

Change Node Python Go Rust .NET
Experimental annotations ✅ added ✅ added ✅ added ✅ added ✅ already present
CanvasHostContextCapabilities export ✅ added ✅ already exported generated type (accessible) generated type (accessible) generated type (accessible)
Error type naming CanvasError CanvasError CanvasError CanvasError CanvasException (C# idiom ✅)

Notes

  • .NET CanvasError → CanvasException: The rename is intentional and correct — C# convention dictates *Exception for exception types. All other languages use CanvasError per their own idioms. This is not an inconsistency.
  • CanvasHostContextCapabilities (Node export): This PR brings Node to parity with Python, which already exports it. Go and .NET have the type in their generated namespaces.
  • Java: No canvas support exists yet in the Java SDK; that's expected and out of scope for this PR.

No cross-SDK action items required.

Generated by SDK Consistency Review Agent for issue #1420 · ● 9.3M ·

@SteveSandersonMS SteveSandersonMS added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit 5c4972f May 28, 2026
41 checks passed
@SteveSandersonMS SteveSandersonMS deleted the jmoseley/canvas-pr-1401-followups branch May 28, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants