DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(windows): strip the verbatim prefix from the toast IconUri (#818)
Mao Mr6c1d3fd0019a
diff --git a/src-tauri/vendor/tauri-plugin-notifications/PATCH.md b/src-tauri/vendor/tauri-plugin-notifications/PATCH.mdindex e5c562af..45b91cfe 100644--- a/src-tauri/vendor/tauri-plugin-notifications/PATCH.md+++ b/src-tauri/vendor/tauri-plugin-notifications/PATCH.md@@ -89,6 +89,12 @@ twice.the toast header icon from an EXE. The resource is explicitly included in`bundle.resources`. Best-effort: failures are logged and the in-process pathstill works while the app is running.+ - `plain_icon_path()` — Tauri resolves `BaseDirectory::Resource` through+ `tauri_utils::platform::current_exe`, which canonicalizes the executable, and Windows+ canonicalization hands back the `\\?\` verbatim form. The toast platform silently ignores+ an `IconUri` in that form and renders the notification with no app logo, so the prefix is+ stripped (verbatim UNC mapped back to `\\server\share`) before the value is written.+ Without this, `iconPath` is configured correctly and still has no visible effect.- `spawn_toast_activator()` — register `ToastActivatorFactory` on a dedicatedsingle-threaded-apartment thread that then blocks in `GetMessageW` /`TranslateMessage` / `DispatchMessageW` for the life of the process, and is registereddiff --git a/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs b/src-tauri/vendor/tauri-plugin-notifications/src/windows.rsindex c8dadca8..cfd7300e 100644--- a/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs+++ b/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs@@ -710,6 +710,25 @@ fn write_registry_string(key: HKEY, name: Option<&str>, value: &str) -> windows:}}+/// Vendored patch: strip the `\\?\` verbatim prefix so `IconUri` is a plain+/// `C:\…` path.+///+/// Tauri resolves `BaseDirectory::Resource` through+/// `tauri_utils::platform::current_exe`, which canonicalizes the executable path,+/// and Windows canonicalization returns the verbatim form. The toast platform+/// silently ignores an `IconUri` in that form — the notification renders with no+/// app logo — while the identical path without the prefix works, spaces included.+fn plain_icon_path(path: &std::path::Path) -> std::borrow::Cow<'_, str> {+ let text = path.to_string_lossy();+ if let Some(rest) = text.strip_prefix(r"\\?\UNC\") {+ std::borrow::Cow::Owned(format!(r"\\{rest}"))+ } else if let Some(rest) = text.strip_prefix(r"\\?\") {+ std::borrow::Cow::Owned(rest.to_owned())+ } else {+ text+ }+}+/// Vendored patch: register the AUMID an unpackaged build needs for toast/// activation.///@@ -756,7 +775,7 @@ fn register_unpackaged_app_id(}let result = write_registry_string(aumid_key, Some("DisplayName"), display_name).and_then(|()| match icon_path {- Some(path) => write_registry_string(aumid_key, Some("IconUri"), &path.to_string_lossy()),+ Some(path) => write_registry_string(aumid_key, Some("IconUri"), &plain_icon_path(path)),None => Ok(()),}).and_then(|()| {@@ -1587,6 +1606,34 @@ mod tests {}}+ #[test]+ fn test_plain_icon_path_strips_verbatim_prefix() {+ assert_eq!(+ plain_icon_path(std::path::Path::new(r"\\?\C:\app\icons\32x32.png")),+ r"C:\app\icons\32x32.png"+ );+ assert_eq!(+ plain_icon_path(std::path::Path::new(r"\\?\D:\a b\icons\32x32.png")),+ r"D:\a b\icons\32x32.png"+ );+ }++ #[test]+ fn test_plain_icon_path_maps_verbatim_unc_prefix() {+ assert_eq!(+ plain_icon_path(std::path::Path::new(r"\\?\UNC\server\share\32x32.png")),+ r"\\server\share\32x32.png"+ );+ }++ #[test]+ fn test_plain_icon_path_keeps_plain_path_unchanged() {+ assert_eq!(+ plain_icon_path(std::path::Path::new(r"C:\app\icons\32x32.png")),+ r"C:\app\icons\32x32.png"+ );+ }+// ==================== Time Conversion Tests ====================/// Windows FILETIME epoch (1601-01-01) offset from Unix epoch (1970-01-01),diff --git a/test/notification-icon.test.ts b/test/notification-icon.test.tsindex d891bdb9..ba0781c9 100644--- a/test/notification-icon.test.ts+++ b/test/notification-icon.test.ts@@ -14,4 +14,15 @@ describe('windows notification app identity icon', () => {expect(icon.readUInt32BE(16)).toBe(32)expect(icon.readUInt32BE(20)).toBe(32)})++ it('writes a plain IconUri because the verbatim form is ignored by the toast platform', () => {+ const source = readFileSync(+ new URL('vendor/tauri-plugin-notifications/src/windows.rs', tauriRoot),+ 'utf8',+ )+ expect(source).toContain('Some("IconUri"), &plain_icon_path(path)')+ expect(source).not.toContain('Some("IconUri"), &path.to_string_lossy()')+ expect(source).toContain(String.raw`strip_prefix(r"\\?\")`)+ expect(source).toContain(String.raw`strip_prefix(r"\\?\UNC\")`)+ })})