Skip to content

fix(ui): escape ClassName/process name in list-windows to prevent Spectre markup errors#479

Merged
nmetulev merged 1 commit into
mainfrom
fix/ui-list-windows-markup-escape
Apr 21, 2026
Merged

fix(ui): escape ClassName/process name in list-windows to prevent Spectre markup errors#479
nmetulev merged 1 commit into
mainfrom
fix/ui-list-windows-markup-escape

Conversation

@nmetulev
Copy link
Copy Markdown
Member

Fixes #469

Root cause

winapp ui list-windows prints each window via Spectre.Console MarkupLine. The format string interpolates info.ClassName (and procName, info.Label) without escaping. info.ClassName is wrapped in [[ ]] which only escapes the outer brackets — any brackets inside the value pass through as raw markup.

When GetClassName returns a name containing brackets (e.g. CLR/DCOM-hosted windows that report [DefaultDomain;;<guid>]), Spectre parses [DefaultDomain;;<guid>] as a style/color tag and throws:

Could not find color or style 'DefaultDomain;;5b431c9f-d55d-446d-9ed0-c94aee3d2cab'.

Because the throw happens on the next iteration after a long string of successful prints, the user sees all windows listed followed by a stray error — exactly what the screenshot shows.

This isn't always reproducible: it only fires when at least one currently-open window has a bracketed class name, which depends on what's running on the box.

Fix

Markup.Escape ClassName, Label, and the process name before interpolation. Title was already escaped.

Verification

  • dotnet build clean
  • winapp ui list-windows runs cleanly on my box (exit 0, no error trailer)

Spectre.Console MarkupLine treats unescaped square brackets in
interpolated values as markup tags. When a window's class name
contains brackets (e.g. CLR/DCOM-hosted windows that report a class
name like '[DefaultDomain;;<guid>]'), the markup parser tries to
resolve the inner brackets as a color/style and throws:

  Could not find color or style 'DefaultDomain;;<guid>'.

The line ended after a successful run of windows, so the user saw
all windows printed and then a stray error at the end (the failure
happened on the next iteration before any further output).

The outer '[[ ]]' around ClassName only escapes the wrapper
brackets — characters inside the value pass through unescaped.

Fix: Markup.Escape ClassName, Label, and process name before
interpolation. Title was already escaped.

Fixes #469

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 20, 2026 21:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 fixes a crash in the human-readable output path of winapp ui list-windows caused by unescaped Spectre.Console markup characters in window metadata (notably bracketed class names), resolving issue #469.

Changes:

  • Escape process name, window label, and class name with Spectre.Console.Markup.Escape before interpolating into MarkupLine.
  • Preserve existing behavior for JSON output (unchanged).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 30.53 MB 30.53 MB ✅ 0.0 KB (0.00%)
CLI (x64) 30.90 MB 30.90 MB 📈 +0.5 KB (+0.00%)
MSIX (ARM64) 12.89 MB 12.89 MB 📈 +0.3 KB (+0.00%)
MSIX (x64) 13.67 MB 13.67 MB 📈 +0.4 KB (+0.00%)
NPM Package 26.80 MB 26.80 MB 📈 +0.4 KB (+0.00%)
NuGet Package 26.88 MB 26.88 MB 📈 +0.3 KB (+0.00%)
VS Code Extension 19.61 MB 19.61 MB 📈 +0.7 KB (+0.00%)

Test Results

764 passed out of 764 tests in 416.5s (-41.3s vs. baseline)

Test Coverage

20.8% line coverage, 35.1% branch coverage · ✅ no change vs. baseline

CLI Startup Time

38ms median (x64, winapp --version) · ✅ no change vs. baseline


Updated 2026-04-20 21:48:33 UTC · commit 1c63c7d · workflow run

@nmetulev nmetulev merged commit b27de58 into main Apr 21, 2026
25 checks passed
@nmetulev nmetulev deleted the fix/ui-list-windows-markup-escape branch April 21, 2026 04:43
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.

[Bug]: Error output on winapp run list-windows

3 participants