Skip to content

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

Open
jmoseley wants to merge 2 commits into
mainfrom
jmoseley/canvas-pr-1401-followups
Open

Canvas SDK: post-merge review followups (PR #1401)#1420
jmoseley wants to merge 2 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 223556219+Copilot@users.noreply.github.com

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>
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 <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review ✅

The PR does a good job of maintaining cross-language consistency. Changes reviewed:

Change Node Python Go .NET Rust
@experimental / Experimental: doc markers ✅ Added ✅ Added ✅ Added (most types) ✅ Already present ✅ Added
CanvasHostContextCapabilities named export ✅ Now re-exported ✅ Present ✅ In go/rpc/zrpc.go ✅ In generated Rpc.cs ✅ In generated types
CanvasError naming CanvasError CanvasError CanvasError CanvasException (this PR) CanvasError
Default derives on canvas structs N/A N/A N/A N/A ✅ Rust-specific

One minor gap: NewCanvasError and CanvasErrorNoHandler in go/canvas.go are missing the // Experimental: doc comment added to all surrounding types in this PR — see inline comment above.

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

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

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.

2 participants