Skip to content

feat: make Windows AI API hardware requirement message dynamic per API#615

Merged
haoliuu merged 4 commits into
mainfrom
haoliu/windowsaiapi-hardware-requirement
Jun 30, 2026
Merged

feat: make Windows AI API hardware requirement message dynamic per API#615
haoliuu merged 4 commits into
mainfrom
haoliu/windowsaiapi-hardware-requirement

Conversation

@haoliuu

@haoliuu haoliuu commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

The model-download/unavailable screens for Windows AI APIs showed a static "A Copilot+ PC with Windows 11 Build 26120.3073 or higher is required" message. That text dates from when all WCR APIs were NPU-only. Several APIs now also run off the NPU — Phi Silica & the language-model skills on GPU; Speech Recognition and Video Super Resolution on CPU — so a Copilot+ PC-only message is misleading.

What changed

  • Each Windows AI API now declares its hardware in apis.json via SupportedHardwareAccelerators (enum array, e.g. ["NPU","GPU"]) and a SupportedHardwareUrl, surfaced through the source generator onto ApiDefinition.
  • WcrApiHelpers.GetHardwareRequirementInfo derives the requirement sentence per API.
  • "Learn more" links go to each API's supported-hardware doc; dropped the hardcoded build number.
  • Updated download, error, and unavailable surfaces to show/hide the requirement dynamically.

Tests

Added WcrApiConfigurationTests covering the derived GPU/CPU sentences, NPU-only fallback, and valid per-API URLs.

The "Copilot+ PC required" text was a static string from when WCR APIs
were NPU-only. Phi Silica (and language-model skills), Speech Recognition,
and Video Super Resolution now also run on GPU/CPU, so the message is
derived per API instead.

- Add SupportedHardwareAccelerators + SupportedHardwareUrl to apis.json /
  ApiDefinition; WcrApiHelpers.GetHardwareRequirementInfo derives the
  requirement sentence (NPU-only, +GPU, +CPU, or none when CPU+GPU both)
  and per-API supported-hardware link
- Drop hardcoded Copilot+ PC build number; update download, error, and
  unavailable surfaces to show/hide the requirement dynamically
- Add WcrApiConfigurationTests for the derived requirement + URLs
Copilot AI review requested due to automatic review settings June 29, 2026 04:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the Windows AI API model download/unavailable UX so the “hardware requirement” message and “Learn more” link are derived per-API from definition metadata (instead of a single hardcoded Copilot+ PC + build requirement), and wires that metadata through the source generator into ApiDefinition.

Changes:

  • Added SupportedHardwareAccelerators + SupportedHardwareUrl to Windows AI API definitions (apis.json) and surfaced them via the source generator onto ApiDefinition.
  • Implemented WcrApiHelpers.GetHardwareRequirementInfo and integrated it into compatibility messaging and the downloader/unavailable surfaces.
  • Added unit tests validating the derived requirement sentences and per-API “Learn more” URLs.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
AIDevGallery/Samples/Definitions/WcrApis/WcrApiHelpers.cs Adds per-API hardware requirement/learn-more derivation helper.
AIDevGallery/Samples/Definitions/WcrApis/apis.json Declares supported hardware + doc URLs for select APIs.
AIDevGallery/Models/Samples.cs Extends runtime ApiDefinition with supported hardware metadata.
AIDevGallery/Models/ModelCompatibility.cs Uses derived hardware requirement in incompatibility messaging.
AIDevGallery/Controls/WcrModelUnavailable.xaml.cs Updates default unavailable title/message copy.
AIDevGallery/Controls/WcrModelDownloader.xaml.cs Sets requirement text/link and toggles visibility dynamically.
AIDevGallery/Controls/WcrModelDownloader.xaml Splits requirement into a dedicated TextBlock/Hyperlink for dynamic updates.
AIDevGallery/Controls/SampleContainer.xaml.cs Hooks “Learn more” URI to per-API supported-hardware docs for incompatible WCR APIs.
AIDevGallery.Tests/UnitTests/WcrApiConfigurationTests.cs Adds tests for requirement sentence derivation + URL validity.
AIDevGallery.SourceGenerator/ModelsSourceGenerator.cs Emits new supported hardware fields into generated ApiDefinitionDetails.
AIDevGallery.SourceGenerator/Models/ApiDefinition.cs Extends source-generator model to parse/hold supported hardware metadata.

Comment on lines +245 to +251
var requirement = (runsOnGpu, runsOnCpu) switch
{
(true, true) => string.Empty,
(true, false) => CopilotPlusOrGpuRequirement,
(false, true) => CopilotPlusOrCpuRequirement,
_ => DefaultHardwareRequirement,
};

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

Comment thread AIDevGallery/Controls/SampleContainer.xaml.cs Outdated
var statusDescription = WcrApiHelpers.GetStringDescription(apiType, availbility);
description = string.IsNullOrEmpty(hardwareRequirement)
? statusDescription
: $"{hardwareRequirement}\n {statusDescription}";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

updated

@haoliuu haoliuu merged commit f804eaf into main Jun 30, 2026
11 of 12 checks passed
@haoliuu haoliuu deleted the haoliu/windowsaiapi-hardware-requirement branch June 30, 2026 02:30
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