From 145b0e84b70965cb4062023f7e733cfb809c9f65 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:29:29 +0100 Subject: [PATCH] fix: keep NoteIQ's taskbar icon and explain language errors in Tidy up - With the package identity Tidy up needs, the taskbar drew the package logo as a blank tile. Give the capture window its own app ID and relaunch properties so the taskbar uses the window icon again. - Windows rejects short lowercase notes full of abbreviations as an unknown language. Say so and suggest capitalizing acronyms or writing a full sentence, instead of claiming the language is unsupported. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- apps/noteiq-windows/Cargo.toml | 4 ++ apps/noteiq-windows/src/lib.rs | 3 ++ apps/noteiq-windows/src/local_ai.rs | 4 +- apps/noteiq-windows/src/taskbar.rs | 71 +++++++++++++++++++++++++++++ apps/noteiq-windows/src/ui.rs | 1 + docs/setup.md | 5 +- 6 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 apps/noteiq-windows/src/taskbar.rs diff --git a/apps/noteiq-windows/Cargo.toml b/apps/noteiq-windows/Cargo.toml index 072d716..19a1e25 100644 --- a/apps/noteiq-windows/Cargo.toml +++ b/apps/noteiq-windows/Cargo.toml @@ -48,6 +48,10 @@ windows = { version = "0.62", optional = true, features = [ "Data_Xml_Dom", "Foundation", "UI_Notifications", + "Win32_Storage_EnhancedStorage", + "Win32_System_Com_StructuredStorage", + "Win32_System_Variant", + "Win32_UI_Shell_PropertiesSystem", "Win32_Foundation", "Win32_Media_Audio", "Win32_System_Com", diff --git a/apps/noteiq-windows/src/lib.rs b/apps/noteiq-windows/src/lib.rs index e1f80fa..7e4ccf3 100644 --- a/apps/noteiq-windows/src/lib.rs +++ b/apps/noteiq-windows/src/lib.rs @@ -36,6 +36,9 @@ mod reminder; #[cfg(windows)] mod settings_ui; #[cfg(windows)] +#[allow(unsafe_code)] +mod taskbar; +#[cfg(windows)] mod toast; #[cfg(windows)] mod tray; diff --git a/apps/noteiq-windows/src/local_ai.rs b/apps/noteiq-windows/src/local_ai.rs index 2e26036..85c6d61 100644 --- a/apps/noteiq-windows/src/local_ai.rs +++ b/apps/noteiq-windows/src/local_ai.rs @@ -174,9 +174,11 @@ fn response_message(status: LanguageModelResponseStatus) -> &'static str { LanguageModelResponseStatus::PromptLargerThanContext => { "This note is too long for the on-device AI model." } + // Windows detects the language itself and rejects short lowercase notes full of + // abbreviations, such as "deal alm closed", even when they are English. LanguageModelResponseStatus::UnsupportedLanguage | LanguageModelResponseStatus::LanguageMismatch => { - "The on-device AI model doesn't support this note's language." + "Windows couldn't recognize this note's language. Short notes with abbreviations often fail; try capitalizing names and acronyms or writing a full sentence." } LanguageModelResponseStatus::BlockedByPolicy => { "Your organization's policy blocks the on-device AI model." diff --git a/apps/noteiq-windows/src/taskbar.rs b/apps/noteiq-windows/src/taskbar.rs new file mode 100644 index 0000000..c5115a0 --- /dev/null +++ b/apps/noteiq-windows/src/taskbar.rs @@ -0,0 +1,71 @@ +//! While NoteIQ has a package identity (needed for on-device AI), Windows groups its window +//! under the package and draws the taskbar button from the package logo, which shows as a blank +//! tile for a package with external location. Giving the window its own app ID makes the +//! taskbar use the window's icon again, as it does without the registration. + +use raw_window_handle::{HasWindowHandle, RawWindowHandle}; +use windows::{ + Win32::{ + Foundation::{HWND, PROPERTYKEY}, + Storage::EnhancedStorage::{ + PKEY_AppUserModel_ID, PKEY_AppUserModel_RelaunchCommand, + PKEY_AppUserModel_RelaunchDisplayNameResource, PKEY_AppUserModel_RelaunchIconResource, + }, + System::{ + Com::StructuredStorage::{PROPVARIANT, PropVariantClear}, + Variant::VT_LPWSTR, + }, + UI::Shell::{ + PropertiesSystem::{IPropertyStore, SHGetPropertyStoreForWindow}, + SHStrDupW, + }, + }, + core::HSTRING, +}; + +/// Not registered anywhere, so the taskbar draws the window's own icon. The notification app +/// ID can't be reused: the taskbar would look up its registration instead. +const WINDOW_APP_ID: &str = "DevSecNinja.NoteIQ.Capture"; + +/// Best-effort: on failure the taskbar keeps the package's blank tile. +pub fn use_own_taskbar_identity(window: &impl HasWindowHandle) { + if windows::ApplicationModel::Package::Current().is_err() { + return; + } + let Ok(handle) = window.window_handle() else { + return; + }; + let RawWindowHandle::Win32(handle) = handle.as_raw() else { + return; + }; + let hwnd = HWND(handle.hwnd.get() as *mut core::ffi::c_void); + let executable = std::env::current_exe().unwrap_or_default(); + let command = format!("\"{}\"", executable.display()); + let icon = format!("{},0", executable.display()); + // Pinning the button relaunches the executable, not the package. + let properties: [(&PROPERTYKEY, &str); 4] = [ + (&PKEY_AppUserModel_RelaunchCommand, &command), + (&PKEY_AppUserModel_RelaunchDisplayNameResource, "NoteIQ"), + (&PKEY_AppUserModel_RelaunchIconResource, &icon), + (&PKEY_AppUserModel_ID, WINDOW_APP_ID), + ]; + // SAFETY: `hwnd` belongs to the live winit window on this UI thread. Each string is copied + // into COM memory by `SHStrDupW`, which `PropVariantClear` frees after `SetValue` copies it. + let result = unsafe { + SHGetPropertyStoreForWindow::(hwnd).and_then(|store| { + for (key, value) in properties { + let mut variant = PROPVARIANT::default(); + let inner = &mut *variant.Anonymous.Anonymous; + inner.Anonymous.pwszVal = SHStrDupW(&HSTRING::from(value))?; + inner.vt = VT_LPWSTR; + let set = store.SetValue(key, &variant); + PropVariantClear(&mut variant)?; + set?; + } + store.Commit() + }) + }; + if let Err(error) = result { + tracing::warn!(code = ?error.code(), "Could not give the window its own taskbar identity"); + } +} diff --git a/apps/noteiq-windows/src/ui.rs b/apps/noteiq-windows/src/ui.rs index f688d9f..dd0d6d0 100644 --- a/apps/noteiq-windows/src/ui.rs +++ b/apps/noteiq-windows/src/ui.rs @@ -384,6 +384,7 @@ pub fn run( .await .map_err(|_| "native_window_unavailable")?; native.set_taskbar_icon(Some(icon)); + crate::taskbar::use_own_taskbar_identity(&*native); Ok::<_, &'static str>(()) } .await; diff --git a/docs/setup.md b/docs/setup.md index 4166ce5..0d62975 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -362,7 +362,10 @@ Selecting the **Tidy up** toolbar button never changes the note directly: OneDrive version history. Only notes up to 700 characters can be tidied: in testing, longer notes were -more likely to have facts merged or changed. Windows may add an invisible +more likely to have facts merged or changed. Windows detects the note's language +itself and can reject very short lowercase notes full of abbreviations, such as +"deal alm closed", even when they are English; capitalizing names and acronyms or +writing a full sentence usually helps. Windows may add an invisible AI-generated text marker (`U+200B U+034F U+2060 U+200B`) to the result; NoteIQ keeps it and ignores it when comparing.