Skip to content

fix(windows): load XmlDocument WinRT type before use - #16

Open
mark-nhk wants to merge 1 commit into
egiray:mainfrom
mark-nhk:patch-1
Open

fix(windows): load XmlDocument WinRT type before use#16
mark-nhk wants to merge 1 commit into
egiray:mainfrom
mark-nhk:patch-1

Conversation

@mark-nhk

Copy link
Copy Markdown

Thanks for the extension — the sound alerts already solved most of my 'did Claude finish?' problem. This PR fixes the banner half on Windows.

Problem

On Windows, sound notifications work but the system banner never appears. The extension's own diagnostics pinpoint the failure:

FAIL 1/2 System banner: Command failed: powershell -NoProfile -Command [...] New-Object : Cannot find type [Windows.Data.Xml.Dom.XmlDocument]: verify that the assembly containing this type is loaded.

OK 2/2 Sound: Command ran without error

Cause

In Windows PowerShell 5.1, each WinRT type must be loaded with the [Type, Assembly, ContentType=WindowsRuntime] syntax before first use. The toast command in lib/system-notification.js only loads ToastNotificationManager, so New-Object Windows.Data.Xml.Dom.XmlDocument fails, which cascades into the two follow-up errors (LoadXml on null, missing ToastNotification constructor).

This affects all Windows users of the extension, not a specific machine configuration.

Fix

Add the missing type-load statement for Windows.Data.Xml.Dom.XmlDocument before it is instantiated. One line, no behavior change on macOS/Linux.

Verified

Windows 11, Windows PowerShell 5.1:

  • Reproduced the failure by running the original command manually — same three errors as the diagnostics.
  • Ran the command with the added type-load line — the banner appears.
  • (Side note: the snippet only works in Windows PowerShell 5.1; PowerShell 7 cannot load WinRT types this way at all. The extension correctly invokes powershell, so this is fine — just worth knowing for future changes.)

Thanks for the extension — the sound alerts already solved most of my 'did Claude finish?' problem. This PR fixes the banner half on Windows.

## Problem

On Windows, sound notifications work but the system banner never appears.
The extension's own diagnostics pinpoint the failure:

FAIL 1/2 System banner: Command failed: powershell -NoProfile -Command [...]
New-Object : Cannot find type [Windows.Data.Xml.Dom.XmlDocument]: verify
that the assembly containing this type is loaded.

OK 2/2 Sound: Command ran without error


<details>
<summary>Full diagnostics output</summary>

(dán nguyên log diagnostic của anh vào đây)

</details>

## Cause

In Windows PowerShell 5.1, each WinRT type must be loaded with the
`[Type, Assembly, ContentType=WindowsRuntime]` syntax before first use.
The toast command in `lib/system-notification.js` only loads
`ToastNotificationManager`, so `New-Object Windows.Data.Xml.Dom.XmlDocument`
fails, which cascades into the two follow-up errors (`LoadXml` on null,
missing `ToastNotification` constructor).

This affects all Windows users of the extension, not a specific machine
configuration.

## Fix

Add the missing type-load statement for `Windows.Data.Xml.Dom.XmlDocument`
before it is instantiated. One line, no behavior change on macOS/Linux.

## Verified

Windows 11, Windows PowerShell 5.1:
- Reproduced the failure by running the original command manually — same
  three errors as the diagnostics.
- Ran the command with the added type-load line — the banner appears.
- (Side note: the snippet only works in Windows PowerShell 5.1; PowerShell 7
  cannot load WinRT types this way at all. The extension correctly invokes
  `powershell`, so this is fine — just worth knowing for future changes.)
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.

1 participant