Skip to content

Add optional PNG icons to canvas declarations - #2699

Draft
cschleiden wants to merge 2 commits into
mainfrom
cschleiden-canvas-icon-sdk-support
Draft

cschleiden wants to merge 2 commits into
mainfrom
cschleiden-canvas-icon-sdk-support

Conversation

@cschleiden

@cschleiden cschleiden commented Sep 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Add optional icon PNG paths to existing canvas declaration APIs in Node.js, Rust, Go, Python, and .NET.
  • Preserve icon in Node's constructor projection and Python's wire serialization; follow existing optional-field and serialization conventions in the other SDKs, including Rust's with_icon builder.
  • Keep icons optional and preserve Python positional constructor compatibility. Document extension-relative paths in API comments and Node/Rust authoring examples.
  • Leave generated RPC/event types unchanged; they already support canvas icons. No SDK-side path validation or per-instance icon override is introduced.
  • Fix the two Rust version snapshot scripts on Windows Git Bash by reading the package version relative to its directory rather than embedding a shell path in JavaScript. Cover ordinary paths and directories containing spaces and apostrophes.

Validation

Regression tests were added before implementation and reproduced missing icon preservation or unsupported arguments in all five affected SDKs. The snapshot path tests also reproduced both Windows MODULE_NOT_FOUND errors and apostrophe-related JavaScript syntax errors before the portability fix.

SDK Focused check Result
Node.js npm test -- test\canvas.test.ts test\rust-version-snapshot.test.ts 7 passed
Rust cargo test --lib --no-default-features canvas::tests::declaration 4 passed
Go go test . -run '^TestCanvasDeclaration_' -count=1 5 passed
Python uv run --no-sync pytest test_canvas.py -k canvas_declaration -q 5 passed
.NET dotnet test dotnet\test\GitHub.Copilot.SDK.Test.csproj --framework net8.0 -p:TargetFrameworks=net8.0 -p:CopilotSkipCliDownload=true --filter FullyQualifiedName~CanvasDeclarationTests 3 passed

Both complete Rust version snapshot scripts also ran successfully under Windows Git Bash, each producing the pinned version and eight platform hashes.

Also passed: focused Node strict type-check, ESLint and Prettier; Rust library Clippy (--no-default-features -- -D warnings) and changed-module rustfmt; Go formatting; Python Ruff lint/format; and git diff --check. Full test suites and feature/framework matrices were not run.

Preserve canvas icon paths across Node, Rust, Go, Python, and .NET declaration APIs. Add serialization regressions and document extension-relative paths.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Read the package version relative to its directory instead of embedding a shell path in JavaScript. Cover Windows paths and directories with spaces and apostrophes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review — PR #2699 (Canvas icon field)

Reviewed the authoritative diff (get_files + get_diff) touching dotnet/, go/, nodejs/, python/, and rust/.

✅ Consistent feature addition

The optional PNG icon field for CanvasDeclaration was added uniformly across all five SDKs that expose canvas authoring:

SDK Field/API Optional Omit-if-empty
.NET CanvasDeclaration.Icon (string?) ✅ (JsonIgnoreCondition.WhenWritingNull)
Go CanvasDeclaration.Icon (*string, json:"icon,omitempty")
Node.js/TS CanvasDeclaration.icon / CanvasOptions.icon (string?)
Python CanvasDeclaration.icon (str | None) ✅ (only added to to_dict() if not None)
Rust CanvasDeclaration.icon (Option(String)) + with_icon() builder ✅ (skip_serializing_if)

Naming follows each language's idiom (Icon/icon), semantics match (relative paths resolved against extension.mjs for extensions), and each SDK includes new unit tests covering serialize/roundtrip/omit-when-unset. Node.js and Rust READMEs were also updated with matching "Canvas icons" documentation sections.

i️ Note (not a regression from this PR)

The Java SDK (java/sdk/src/main/java/) does not yet expose a public canvas-authoring API (no CanvasDeclaration/createCanvas equivalent — only generated wire/consumer-side types like OpenCanvasInstance). Since canvas authoring doesn't exist in Java today, there's nothing for this PR to update there; this is a pre-existing gap, not an inconsistency introduced by this change.

Other changes in the PR

  • rust/scripts/snapshot-bundled-*-version.sh: fixes a node -e require(...) path-resolution bug for the bundled CLI/in-process version scripts. This is internal Rust build tooling with no equivalent in other SDKs, so no cross-SDK action needed.

Overall: This PR maintains excellent cross-SDK consistency for the new icon field. No changes requested.

Generated by SDK Consistency Review Agent for #2699 · copilot · sonnet50 · 57 AIC · ⌖ 12.2 AIC · ⊞ 8.3K ·

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.

1 participant