Skip to content

CmdPal: Icons (10/n) - Add generated swatch and Unicode initials icons - #50190

Open
Jiří Polášek (jiripolasek) wants to merge 4 commits into
dev/jpolasek/f/49941-cmdpal-icon-presentationfrom
dev/jpolasek/f/49942-cmdpal-generated-icons
Open

CmdPal: Icons (10/n) - Add generated swatch and Unicode initials icons#50190
Jiří Polášek (jiripolasek) wants to merge 4 commits into
dev/jpolasek/f/49941-cmdpal-icon-presentationfrom
dev/jpolasek/f/49942-cmdpal-generated-icons

Conversation

@jiripolasek

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

Copy link
Copy Markdown
Collaborator

Summary of the Pull Request

Part 10 of 12 in the CmdPal icon-loading series. Depends on #50189. Next: #50191.

This PR lets extensions request color tiles and initials without supplying custom bitmap assets.

  • Adds shared circle/rounded-square geometry, hex/semantic colors, and normal/transparent backgrounds.
  • Shapes Unicode initials off the STA and canonicalizes cache identity with a fast path for simple canonical inputs.
  • Migrates saved-color icons and adds samples, including a 256-color palette.

Motivation: centralize sizing, theme handling, contrast, and fallback behavior instead of duplicating image generation in extensions.

Examples

new IconInfo("|Swatch|#0067C0|");                       // Default circle
new IconInfo("|Swatch|#FF0067C0|#FF60CDFF|square|");   // Light/dark colors
new IconInfo("|Swatch|success|circle|");               // Semantic color
new IconInfo("|Initials|JP|info|square|");
new IconInfo("|Initials|T|transparent|square|");
new IconInfo("|Initials|👩‍💻|info|circle|");             // One grapheme cluster
new IconInfo("|Initials|A%7CB|info|square|");           // Literal A|B

Semantic colors are danger, subtle, info, warning, success, neutral, dark, normal, and transparent. Initials accept one to three Unicode text elements.

Evidence

Historical adjacent-stage comparison (2026-08-18); shared method and limitations: the diagnostics foundation PR #50181. A/B/C are regression checks, not measurements of the new generated-icon workload.

  • A cold-ish process CPU: 139109.375 → 139390.625 ms (+0.2%); allocations: 839531672 → 839083632 bytes (−0.1%). Both overlap observed variation and change direction across pairs.
  • C warm applied average: 0.141 → 0.229 ms (+0.088 ms); p95 stayed ≤0.25 ms. Two of three pairs actually improved, so the median increase is not a consistent regression.
  • Tests cover Unicode/graphemes, escaping, equivalent cache keys, shape geometry, theme colors, and missing-font fallback.
  • Focused palette and Unicode/emoji-initials measurements are still needed. These results do not establish that emoji shaping costs the same as ordinary Fluent glyphs.

The justification is the new shared capability and its correctness coverage. These small, inconsistent changes support neither a general performance win nor a demonstrated regression.

Technical notes

  • The 32-unit SVG viewBox is a design coordinate system, not a fixed 32-pixel bitmap. Materialization uses the requested size/scale. square means rounded square; both protocols share the background geometry.
  • Hex colors use XAML ordering: #RGB, #ARGB, #RRGGBB, or #AARRGGBB, not CSS alpha-last forms. Semantic colors choose their own light/dark values.
  • Swatch preparation can be synchronous; initials preparation must shape off the STA. Both produce SVG data, whose later source materialization can be asynchronous. Placement fallbacks cover that gap.
  • Initials are shaped into vector outlines, not promised as full-color emoji. Missing font coverage produces a background tile; unexpected shaping/interop failures are logged once instead of silently masquerading as unsupported characters.
  • Normalize initials to NFC and escape literal % before | (%25, %7C). Human-authored initials use readable percent encoding; machine-generated app requests use length prefixes. Canonical simple inputs reuse the original string, and style normalization scans small tokens—not a full visual-equivalence algorithm.

Implementation: src/modules/cmdpal/Microsoft.CmdPal.UI/Helpers/Icons/GeneratedIconProtocol.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

- Injects initials path generation so protocol tests do not depend on Win2D, installed fonts, or an interactive graphics environment.
- Rendereing in production is unchanged.
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 (9/n) - Add generated swatch and initials protocols

2 participants