Add Node.js sample using a native WinUI 3 Application and Window - #624
Conversation
Build Metrics ReportBinary Sizes
Test Results✅ 3338 passed, 4 skipped out of 3342 tests in 872.9s (+135.3s vs. baseline) Test Coverage✅ 86.3% line coverage, 80% branch coverage · ✅ no change vs. baseline CLI Startup Time52ms median (x64, Updated 2026-07-16 13:46:21 UTC · commit |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 1cf82a54-b9a0-4437-ab3f-ea9af28a68a8
There was a problem hiding this comment.
Pull request overview
Adds a new Node.js sample that demonstrates creating a native WinUI 3 Application + Window directly from JavaScript using dynwinrt, along with CI coverage to keep the sample working over time.
Changes:
- Adds the
samples/node-winuisample project (restore/generate scripts, WinUI worker implementation, and documentation). - Adds a Pester test for the new sample and wires it into the
test-samples.ymlmatrix. - Updates the repo root
README.mdto include the new sample in the Samples table.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| samples/node-winui/winui-worker.js | Worker-thread WinUI Application.start() sample UI composition + event wiring. |
| samples/node-winui/main.js | Bootstraps Windows App SDK and starts the WinUI worker. |
| samples/node-winui/package.json | Declares sample scripts, #winapp/bindings imports, dynwinrt deps, and winapp.jsBindings config. |
| samples/node-winui/README.md | Sample usage + architecture explanation + binding regeneration guidance. |
| samples/node-winui/winapp.yaml | WinApp restore package set for generating WinUI bindings. |
| samples/node-winui/test.Tests.ps1 | Pester validation for restore + generated bindings + basic JS syntax checks. |
| samples/node-winui/.gitignore | Ignores .winapp/ output and node_modules/. |
| samples/node-winui/.npmrc | Sets npm registry (see review comment). |
| README.md | Fixes formatting in install section and adds the new sample to the Samples table. |
| .github/workflows/test-samples.yml | Adds node-winui to workflow_dispatch options, matrix, and Node setup gating. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Copilot resolve the merge conflicts in this pull request |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)
README.md:255
- This adds a new framework sample to the public sample index, but there is no corresponding Node/WinUI guide under
docs/guides/. Other framework samples have an end-to-end guide surface, and the repository contribution guidance requires language-specific guides to stay synchronized. Add a Node WinUI guide (and link it from the relevant guide index) so this workflow is discoverable outside the sample table.
| [Node.js WinUI 3](/samples/node-winui/README.md) | Native WinUI 3 controls created directly from JavaScript |
samples/node-winui/test.Tests.ps1:100
- Phase 2 only parses the JavaScript and matches source strings; it never executes the restored sample. Consequently, failures in Windows App SDK bootstrap,
Application.create(), resource loading, window activation, or event wiring would all pass CI. Add a smoke test that launchesnode main.jsfrom$script:appDir, waits for thereadymessage/window, exercises one callback, closes it, and asserts a clean exit.
It "Should contain valid JavaScript" -Skip:$script:skip {
& node --check (Join-Path $script:sampleDir 'main.js')
$LASTEXITCODE | Should -Be 0
& node --check (Join-Path $script:sampleDir 'winui-worker.js')
$LASTEXITCODE | Should -Be 0
Co-authored-by: nmetulev <711864+nmetulev@users.noreply.github.com>
Co-authored-by: nmetulev <711864+nmetulev@users.noreply.github.com>
Merge conflicts resolved in 321e001. The only conflicted file was |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.
Suppressed comments (3)
README.md:259
- The new sample is listed here, but no corresponding page was added under
docs/guides/or the top-level Guides section. The repository’s new-sample shipping checklist requires that guide surface; add a Node WinUI guide (the sample README content can be reused) and link it from the Guides section.
| [Node.js WinUI 3](/samples/node-winui/README.md) | Native WinUI 3 controls created directly from JavaScript |
samples/node-winui/winui-worker.js:141
- This ComboBox has no accessible name because its header is a
TextBlock; UI Automation reports only an unnamedComboBox, so screen-reader users cannot identify the theme selector. Using a string-valued header gives it the accessible name “Theme” (verified withwinapp ui inspect).
themePicker.header = createText('Theme', 13, 600);
samples/node-winui/main.js:29
- The sample test only checks syntax and source patterns; it never executes this bootstrap/worker path. CI would therefore pass even if
npm startcrashes before creating a window. Add a smoke test that launches the restored copy, waits for thereadymessage/window, closes it, and asserts a zero exit code.
const { initWinappsdk } = require('@microsoft/dynwinrt');
initWinappsdk(2, 2);
const worker = new Worker(path.join(__dirname, 'winui-worker.js'));
Description
Usage Example
Related Issue
Type of Change
Checklist
docs/fragments/skills/(if CLI commands/workflows changed)Screenshots / Demo
Additional Notes
AI Description
This pull request introduces a new sample demonstrating how to create a WinUI 3 application and window directly from Node.js, using the Microsoft.UI.Xaml controls projected into JavaScript. It includes necessary files like
main.js,package.json, and a README for usage instructions. To run the sample, use the following commands: