DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(windows): unblock first NSIS notification permission check (#815)
Mao Mr287f0a640a32
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 6ddf8bff..743bc40c 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -260,6 +260,11 @@ jobs:# 同上:PR 只读缓存,避免每轮生成新条目挤掉 main 的暖缓存。save-if: ${{ github.ref == 'refs/heads/main' }}+ - name: Run Windows native notification tests+ if: runner.os == 'Windows'+ run: cargo test -p tauri-plugin-notifications --lib --no-default-features --locked+ working-directory: src-tauri+- name: Run testsrun: cargo test --all-features --lockedworking-directory: src-tauridiff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex 6630106d..084eba49 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -2,6 +2,15 @@# It is not intended for manual editing.version = 4+[[package]]+name = "addr2line"+version = "0.25.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"+dependencies = [+ "gimli",+]+[[package]]name = "adler2"version = "2.0.1"@@ -352,6 +361,21 @@ dependencies = ["tracing",]+[[package]]+name = "backtrace"+version = "0.3.76"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"+dependencies = [+ "addr2line",+ "cfg-if",+ "libc",+ "miniz_oxide",+ "object",+ "rustc-demangle",+ "windows-link 0.2.1",+]+[[package]]name = "base64"version = "0.21.7"@@ -705,6 +729,16 @@ dependencies = ["objc",]+[[package]]+name = "color-backtrace"+version = "0.7.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "01fd62bba8d0ebaacae8e3faf5c05d3c80b215ea6a5dfe6069619bcd8d72451d"+dependencies = [+ "backtrace",+ "termcolor",+]+[[package]]name = "combine"version = "4.6.7"@@ -979,6 +1013,16 @@ dependencies = ["dtor",]+[[package]]+name = "ctor"+version = "1.0.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d"+dependencies = [+ "link-section",+ "linktime-proc-macro",+]+[[package]]name = "ctor-proc-macro"version = "0.0.7"@@ -1850,6 +1894,12 @@ dependencies = ["wasm-bindgen",]+[[package]]+name = "gimli"+version = "0.32.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"+[[package]]name = "gio"version = "0.18.4"@@ -2786,6 +2836,18 @@ dependencies = ["libc",]+[[package]]+name = "link-section"+version = "0.19.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39c29a617ce3df32c08497bdc1ab6e2376e0b17948ac166a2fbe5977c5954cd9"++[[package]]+name = "linktime-proc-macro"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616"+[[package]]name = "linux-raw-sys"version = "0.12.1"@@ -2848,6 +2910,12 @@ dependencies = ["libc",]+[[package]]+name = "maplit"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"+[[package]]name = "markup5ever"version = "0.38.0"@@ -3357,6 +3425,15 @@ dependencies = ["objc2-security",]+[[package]]+name = "object"+version = "0.37.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"+dependencies = [+ "memchr",+]+[[package]]name = "once_cell"version = "1.21.4"@@ -4239,6 +4316,12 @@ dependencies = ["ordered-multimap",]+[[package]]+name = "rustc-demangle"+version = "0.1.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb"+[[package]]name = "rustc-hash"version = "2.1.3"@@ -5305,7 +5388,10 @@ dependencies = [name = "tauri-plugin-notifications"version = "0.5.0-rc.14"dependencies = [+ "color-backtrace",+ "ctor 1.0.13","log",+ "maplit","notify-rust","nt-time","rand 0.10.2",@@ -5318,10 +5404,12 @@ dependencies = ["tauri-plugin","thiserror 2.0.20","time",+ "tokio","url","uuid","windows","windows-core 0.61.2",+ "zbus",][[package]]@@ -5488,7 +5576,7 @@ dependencies = ["anyhow","brotli","cargo_metadata",- "ctor",+ "ctor 0.8.0","dom_query","dunce","glob",@@ -5561,6 +5649,15 @@ dependencies = ["new_debug_unreachable",]+[[package]]+name = "termcolor"+version = "1.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"+dependencies = [+ "winapi-util",+]+[[package]]name = "thiserror"version = "1.0.69"@@ -5702,6 +5799,7 @@ dependencies = ["signal-hook-registry","socket2","tokio-macros",+ "tracing","windows-sys 0.61.2",]@@ -6184,6 +6282,7 @@ checksum = "bf3923a6f5c4c6382e0b653c4117f48d631ea17f38ed86e2a828e6f7412f5239"dependencies = ["getrandom 0.4.3","js-sys",+ "rand 0.10.2","serde_core","wasm-bindgen",]@@ -7216,6 +7315,7 @@ dependencies = ["rustix","serde","serde_repr",+ "tokio","tracing","uds_windows","uuid",diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.tomlindex 01e66932..8e8558e4 100644--- a/src-tauri/Cargo.toml+++ b/src-tauri/Cargo.toml@@ -5,6 +5,10 @@ description = "Desktop application for DeepSeek Harness (dsh)"authors = [ "deepseek-harness-desktop contributors" ]edition = "2021"+[workspace]+members = [ "vendor/tauri-plugin-notifications" ]+resolver = "2"+[lib]# The `_lib` suffix may seem redundant but it is necessary# to make the lib name unique and wouldn't conflict with the bin name.diff --git a/src-tauri/vendor/tauri-plugin-notifications/PATCH.md b/src-tauri/vendor/tauri-plugin-notifications/PATCH.mdindex 2e4b8e8c..e5c562af 100644--- a/src-tauri/vendor/tauri-plugin-notifications/PATCH.md+++ b/src-tauri/vendor/tauri-plugin-notifications/PATCH.md@@ -1,4 +1,4 @@-# Vendored patch: toast text input + unpackaged click delivery (Windows)+# Vendored patch: toast input, activation and permissions (Windows)`tauri-plugin-notifications` **0.5.0-rc.14**, copied verbatim from crates.io and wired in via`[patch.crates-io]` in `src-tauri/Cargo.toml`. Every change is confined to@@ -40,6 +40,11 @@ and it never activates at all in an unpackaged build.attached only when a `notificationClicked` listener existed — so a subscriber that onlylistened for `actionPerformed` (the reply button) got no handler at all.+5. **Permission checks block the first unpackaged toast (desktop issue #812).**+ `ToastNotifier::Setting()` can return `ERROR_NOT_FOUND` (`0x80070490`) before Windows+ creates per-app notification settings for an unpackaged AUMID. The pre-send permission+ check then drops every toast, so the settings profile never gets created.+One toast click also reaches Windows through *two* independent routes — the in-process`Activated` handler and the out-of-proc COM activator — so a naive fix delivers every clicktwice.@@ -52,6 +57,10 @@ twice.`ToastActivatedEventArgs::UserInput`), `Win32_Security` (required by `RegCreateKeyExW`) and`Win32_System_Registry` / `Win32_UI_WindowsAndMessaging`.- `src/windows.rs`+ - `notification_permission()` — allows the first toast attempt only when an unpackaged+ notifier's settings query returns `ERROR_NOT_FOUND`. Explicit disabled settings remain+ denied; packaged apps and other failures still propagate their errors. Windows still+ controls actual delivery, and `show()` errors are not suppressed.- `input_element_id()` / `action_arguments()` — helpers for the `<input id>` naming scheme(`input-<action id>`) and for the JSON `arguments=` payload.- `build_toast_xml()` — emits one `<input id="input-<action id>" type="text"@@ -89,12 +98,25 @@ The CLSID itself comes from `src-tauri/tauri.conf.json`(`plugins.notifications.windows.toastActivatorClsid`) and must stay in sync with any MSIXmanifest's `ToastActivatorCLSID` / `com:Class Id`.+## Tests++The crate is a member of the `src-tauri` workspace so its native unit tests share the+application's lockfile. Windows CI runs from `src-tauri`:++```sh+cargo test -p tauri-plugin-notifications --lib --no-default-features --locked+```++Disabling default features is required: `notify-rust` selects the alternative desktop+backend and excludes `src/windows.rs`, including its permission regression tests.+## Removal-Delete this directory and the `[patch.crates-io]` block plus its comment in-`src-tauri/Cargo.toml`. `Cargo.lock` regains the `source` + `checksum` lines for the registry-copy. Drop the `plugins.notifications` block in `src-tauri/tauri.conf.json` if upstream also-ships unpackaged registration.+Delete this directory and its `[patch.crates-io]` entry plus its comment and workspace+membership in `src-tauri/Cargo.toml`. Remove the Windows native notification test step from+`.github/workflows/ci.yml`. `Cargo.lock` regains the `source` + `checksum` lines for the+registry copy. Drop the `plugins.notifications` block in `src-tauri/tauri.conf.json` if+upstream also ships unpackaged registration.Upstream issue: <https://github.com/Choochmeque/tauri-plugin-notifications/issues>(text-box support and unpackaged activation; drop this directory once they ship).diff --git a/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs b/src-tauri/vendor/tauri-plugin-notifications/src/windows.rsindex 2103281b..c8dadca8 100644--- a/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs+++ b/src-tauri/vendor/tauri-plugin-notifications/src/windows.rs@@ -32,7 +32,9 @@ use windows::UI::Notifications::{NotificationSetting, ScheduledToastNotification, ToastActivatedEventArgs, ToastNotification,ToastNotificationManager, ToastNotifier,};-use windows::Win32::Foundation::{CLASS_E_NOAGGREGATION, E_FAIL, E_INVALIDARG, S_FALSE, S_OK};+use windows::Win32::Foundation::{+ CLASS_E_NOAGGREGATION, E_FAIL, E_INVALIDARG, ERROR_NOT_FOUND, S_FALSE, S_OK,+};use windows::Win32::System::Com::{CLSCTX_LOCAL_SERVER, COINIT_APARTMENTTHREADED, CoInitializeEx, CoRegisterClassObject,CoUninitialize, IClassFactory, IClassFactory_Impl, REGCLS_MULTIPLEUSE,@@ -67,6 +69,27 @@ fn is_packaged() -> bool {Package::Current().is_ok()}+fn notification_permission(+ setting: windows::core::Result<NotificationSetting>,+ packaged: bool,+) -> crate::Result<PermissionState> {+ let setting = match setting {+ // Issue #812: an unpackaged AUMID may have no settings until its first toast.+ Err(error) if !packaged && error.code() == ERROR_NOT_FOUND.to_hresult() => {+ return Ok(PermissionState::Granted);+ }+ result => result?,+ };+ match setting {+ NotificationSetting::Enabled => Ok(PermissionState::Granted),+ NotificationSetting::DisabledForApplication+ | NotificationSetting::DisabledForUser+ | NotificationSetting::DisabledByGroupPolicy+ | NotificationSetting::DisabledByManifest => Ok(PermissionState::Denied),+ _ => Ok(PermissionState::Prompt),+ }+}+/// Resolve a user-supplied image string into a URI scheme Windows toast/// notifications can actually load.///@@ -1296,14 +1319,7 @@ impl<R: Runtime> Notifications<R> {#[allow(unknown_lints, clippy::unused_async, clippy::unused_async_trait_impl)]pub async fn permission_state(&self) -> crate::Result<PermissionState> {- match self.plugin.notifier.Setting()? {- NotificationSetting::Enabled => Ok(PermissionState::Granted),- NotificationSetting::DisabledForApplication- | NotificationSetting::DisabledForUser- | NotificationSetting::DisabledByGroupPolicy- | NotificationSetting::DisabledByManifest => Ok(PermissionState::Denied),- _ => Ok(PermissionState::Prompt),- }+ notification_permission(self.plugin.notifier.Setting(), self.plugin.packaged)}pub fn register_action_types(&self, types: Vec<ActionType>) -> crate::Result<()> {@@ -1522,6 +1538,55 @@ mod tests {const POWERSHELL_APP_ID: &str ="{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe";+ #[test]+ fn notification_permission_allows_missing_unpackaged_profile() {+ let error = windows::core::Error::from(ERROR_NOT_FOUND.to_hresult());+ assert_eq!(+ notification_permission(Err(error), false).unwrap(),+ PermissionState::Granted+ );+ }++ #[test]+ fn notification_permission_preserves_missing_packaged_profile_error() {+ let error = windows::core::Error::from(ERROR_NOT_FOUND.to_hresult());+ let error = notification_permission(Err(error), true).unwrap_err();+ assert!(error.to_string().contains("0x80070490"));+ }++ #[test]+ fn notification_permission_preserves_other_errors() {+ for packaged in [false, true] {+ let error = notification_permission(Err(E_FAIL.into()), packaged).unwrap_err();+ assert!(error.to_string().contains("0x80004005"));+ }+ }++ #[test]+ fn notification_permission_respects_windows_settings() {+ for packaged in [false, true] {+ assert_eq!(+ notification_permission(Ok(NotificationSetting::Enabled), packaged).unwrap(),+ PermissionState::Granted+ );+ for setting in [+ NotificationSetting::DisabledForApplication,+ NotificationSetting::DisabledForUser,+ NotificationSetting::DisabledByGroupPolicy,+ NotificationSetting::DisabledByManifest,+ ] {+ assert_eq!(+ notification_permission(Ok(setting), packaged).unwrap(),+ PermissionState::Denied+ );+ }+ assert_eq!(+ notification_permission(Ok(NotificationSetting(-1)), packaged).unwrap(),+ PermissionState::Prompt+ );+ }+ }+// ==================== Time Conversion Tests ====================/// Windows FILETIME epoch (1601-01-01) offset from Unix epoch (1970-01-01),