Skip to content

CmdPal: Icons (11/n) - Add plain and theme-aware SVG icon protocols - #50191

Open
Jiří Polášek (jiripolasek) wants to merge 2 commits into
dev/jpolasek/f/49942-cmdpal-generated-iconsfrom
dev/jpolasek/f/49944-cmdpal-svg-icons
Open

CmdPal: Icons (11/n) - Add plain and theme-aware SVG icon protocols#50191
Jiří Polášek (jiripolasek) wants to merge 2 commits into
dev/jpolasek/f/49942-cmdpal-generated-iconsfrom
dev/jpolasek/f/49944-cmdpal-svg-icons

Conversation

@jiripolasek

@jiripolasek Jiří Polášek (jiripolasek) commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

Part 11 of 12 in the CmdPal icon-loading series. Depends on #50190. Next: #50192.

This PR accepts SVG files or inline SVG text, with explicit opt-in theme-aware coloring.

  • Separates plain SVG from theme/accent substitution and supports semantic/custom accents.
  • Includes theme in relevant cache identities and normalizes small style tokens without rewriting SVG payloads.
  • Handles XML encoding declarations, records SVG-data materialization separately, and adds representative samples.

Motivation: extensions can supply scalable, theme-correct icons through the existing SDK icon string without generating separate files per theme.

Examples

new IconInfo(@"|Svg|C:\Icons\status.svg");
new IconInfo(@"|ThemedSvg|warning|C:\Icons\status.svg");
new IconInfo("""|Svg|<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" fill="#0067C0"/></svg>""");

new IconInfo("""
    |ThemedSvg|success|<svg xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 20 20" color="{{ThemeColor}}">
      <circle cx="10" cy="10" r="8" fill="currentColor"/>
      <path d="M6 10h8M10 6v8" stroke="{{AccentColor}}" stroke-width="2"/>
    </svg>
    """);

{{ThemeColor}} resolves to black/light-theme or white/dark-theme foreground; {{AccentColor}} uses the requested accent. For a custom accent, replace success with an opaque color such as #7A3E9D. Omitting the accent uses the built-in info palette, not the live Windows accent.

Evidence

Historical adjacent-stage comparison (2026-08-18); shared method and limitations: the diagnostics foundation PR #50181.

  • C warm applied average: 0.229 → 0.501 ms (+0.272 ms); p95 stayed ≤0.25 ms. The run ranges overlap and one of three pairs improved.
  • C warm cache-hit averages remain around 0.086–0.091 ms. The higher blended average comes from a small set of slower misses, not uniformly slower cache hits.
  • C warm demanded queue-wait average: 0.089 → 3.590 ms. In the 13-sample candidate run, one 45.627 ms wait accounts for approximately 98% of cumulative demanded queue wait.
  • C warm queued dispatcher callbacks: 11 → 13; cumulative measured icon UI time: 35.170 → 35.341 ms (+0.171 ms across approximately 26 seconds).
  • Tests cover plain/themed behavior, BOM-less XML declarations, accent rejection, and cache identity.

Keep the slow-miss tail visible, but this mixed Home workload does not establish a broad SVG-induced regression. The cumulative UI-work delta is negligible at this scale; focused file/inline × plain/themed measurements are still needed to evaluate the new path.

Technical notes

  • Plain SVG does not expand placeholders. Themed SVG is opt-in; currentColor works through SVG inheritance when the template sets color="{{ThemeColor}}", not by globally replacing every occurrence.
  • SVG accents accept opaque #RGB/#RRGGBB or supported semantic colors. transparent and alpha-bearing hex accents are rejected consistently by classification and parsing; express transparency with SVG opacity attributes.
  • File paths, XML IDs, and payload text retain their case. Canonicalization only normalizes accent-token casing and is deliberately not a full XML canonicalizer on every cache lookup.
  • Plain files retain their bytes. Themed files honor BOM/XML encoding before substitution; inline strings are re-encoded as UTF-8 without a conflicting original XML declaration.
  • File reading is off the STA, but still occupies a loader slot. Yielding the slot during I/O and re-entering the demand queue is a separate proposed change, not implemented here.

Implementation: src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/Icons/SvgIconProtocol.cs.

Pictures? Pictures!

image

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

@jiripolasek
Jiří Polášek (jiripolasek) force-pushed the dev/jpolasek/f/49944-cmdpal-svg-icons branch from 78f8e33 to 3a166b7 Compare August 29, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Command Palette Refers to the Command Palette utility Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmdPal: Icon loading (10/n) - Add plain and themed SVG protocols

2 participants