From e570246bfc0b4921fab61f80d8dbafff67d8fc05 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Tue, 3 Mar 2026 13:37:20 -0600 Subject: [PATCH 1/2] send notifications even when we're unpackaged --- doc/cascadia/profiles.schema.json | 4 +++- .../TerminalApp/DesktopNotification.cpp | 20 ++++++++++++++++--- .../WindowsTerminal/WindowEmperor.cpp | 15 ++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 45385fa4e67..e7524928879 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -60,7 +60,8 @@ "enum": [ "audible", "window", - "taskbar" + "taskbar", + "notification" ] } }, @@ -70,6 +71,7 @@ "audible", "taskbar", "window", + "notification", "all", "none" ] diff --git a/src/cascadia/TerminalApp/DesktopNotification.cpp b/src/cascadia/TerminalApp/DesktopNotification.cpp index 573dc5a461f..7abe3b2771c 100644 --- a/src/cascadia/TerminalApp/DesktopNotification.cpp +++ b/src/cascadia/TerminalApp/DesktopNotification.cpp @@ -4,6 +4,8 @@ #include "pch.h" #include "DesktopNotification.h" +#include + using namespace winrt::Windows::UI::Notifications; using namespace winrt::Windows::Data::Xml::Dom; @@ -88,9 +90,21 @@ namespace winrt::TerminalApp::implementation } // For packaged apps, CreateToastNotifier() uses the package identity automatically. - // For unpackaged apps, we need to provide an AUMID, but that case is less common - // and toast notifications may not be supported without additional setup. - auto notifier = ToastNotificationManager::CreateToastNotifier(); + // For unpackaged apps, we must pass the explicit AUMID that was registered + // at startup via SetCurrentProcessExplicitAppUserModelID. + auto notifier = IsPackaged() + ? ToastNotificationManager::CreateToastNotifier() + : ToastNotificationManager::CreateToastNotifier( +#if defined(WT_BRANDING_RELEASE) + L"Microsoft.WindowsTerminal" +#elif defined(WT_BRANDING_PREVIEW) + L"Microsoft.WindowsTerminalPreview" +#elif defined(WT_BRANDING_CANARY) + L"Microsoft.WindowsTerminalCanary" +#else + L"Microsoft.WindowsTerminalDev" +#endif + ); notifier.Show(toast); } catch (...) diff --git a/src/cascadia/WindowsTerminal/WindowEmperor.cpp b/src/cascadia/WindowsTerminal/WindowEmperor.cpp index b6b0c18baa1..4b83dd2c9fd 100644 --- a/src/cascadia/WindowsTerminal/WindowEmperor.cpp +++ b/src/cascadia/WindowsTerminal/WindowEmperor.cpp @@ -383,6 +383,21 @@ void WindowEmperor::HandleCommandlineArgs(int nCmdShow) __assume(false); } + // When running without package identity, set an explicit AppUserModelID so + // that toast notifications (and other shell features) work correctly. + if (!IsPackaged()) + { +#if defined(WT_BRANDING_RELEASE) + LOG_IF_FAILED(SetCurrentProcessExplicitAppUserModelID(L"Microsoft.WindowsTerminal")); +#elif defined(WT_BRANDING_PREVIEW) + LOG_IF_FAILED(SetCurrentProcessExplicitAppUserModelID(L"Microsoft.WindowsTerminalPreview")); +#elif defined(WT_BRANDING_CANARY) + LOG_IF_FAILED(SetCurrentProcessExplicitAppUserModelID(L"Microsoft.WindowsTerminalCanary")); +#else + LOG_IF_FAILED(SetCurrentProcessExplicitAppUserModelID(L"Microsoft.WindowsTerminalDev")); +#endif + } + _app = winrt::TerminalApp::App{}; _app.Logic().ReloadSettings(); From 63149e352ddc15b824d9c159d5c4290c75d4dd17 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 5 Mar 2026 10:55:15 -0600 Subject: [PATCH 2/2] format --- src/cascadia/TerminalApp/DesktopNotification.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cascadia/TerminalApp/DesktopNotification.cpp b/src/cascadia/TerminalApp/DesktopNotification.cpp index 7abe3b2771c..92bc2097dd4 100644 --- a/src/cascadia/TerminalApp/DesktopNotification.cpp +++ b/src/cascadia/TerminalApp/DesktopNotification.cpp @@ -92,19 +92,17 @@ namespace winrt::TerminalApp::implementation // For packaged apps, CreateToastNotifier() uses the package identity automatically. // For unpackaged apps, we must pass the explicit AUMID that was registered // at startup via SetCurrentProcessExplicitAppUserModelID. - auto notifier = IsPackaged() - ? ToastNotificationManager::CreateToastNotifier() - : ToastNotificationManager::CreateToastNotifier( + auto notifier = IsPackaged() ? ToastNotificationManager::CreateToastNotifier() : ToastNotificationManager::CreateToastNotifier( #if defined(WT_BRANDING_RELEASE) - L"Microsoft.WindowsTerminal" + L"Microsoft.WindowsTerminal" #elif defined(WT_BRANDING_PREVIEW) - L"Microsoft.WindowsTerminalPreview" + L"Microsoft.WindowsTerminalPreview" #elif defined(WT_BRANDING_CANARY) - L"Microsoft.WindowsTerminalCanary" + L"Microsoft.WindowsTerminalCanary" #else - L"Microsoft.WindowsTerminalDev" + L"Microsoft.WindowsTerminalDev" #endif - ); + ); notifier.Show(toast); } catch (...)