Resolve issue with buttons on notifications not working correctly (#13921)

* Resolve issue with buttons on notifications not working correctly * pr feedback --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

Ben Hillis committed Dec 15, 2025 at 20:50 UTC e24df7e0d1b072994c8f5070509e2f1759c43bdf
5 files changed +20 -24
src/windows/common/notifications.cpp
+6 -6
@@ -86,8 +86,8 @@ try
86 </binding>
87 </visual>
88 <actions>
89 - <action arguments='--{}' content='{}'/>
90 - <action arguments='--{}' content='{}'/>
89 + <action arguments='{}' content='{}'/>
90 + <action arguments='{}' content='{}'/>
91 </actions>
92 </toast>)",
93 Localization::MessageNewWslVersionAvailable(Localization::Options::DontImpersonate),
@@ -118,8 +118,8 @@ try
118 </binding>
119 </visual>
120 <actions>
121 - <action arguments='--{} {}' content='{}'/>
122 - <action arguments='--{} {}' content="{}"/>
121 + <action arguments='{} {}' content='{}'/>
122 + <action arguments='{} {}' content="{}"/>
123 </actions>
124 </toast>)",
125 Localization::MessagePerformanceTip(Localization::Options::DontImpersonate),
@@ -151,7 +151,7 @@ try
151 </binding>
152 </visual>
153 <actions>
154 - <action arguments='--{}' content='{}'/>
154 + <action arguments='{}' content='{}'/>
155 </actions>
156 </toast>)",
157 Localization::MessageWarningDuringStartup(),
@@ -176,7 +176,7 @@ try
176 </binding>
177 </visual>
178 <actions>
179 - <action arguments='--{}' content='{}'/>
179 + <action arguments='{}' content='{}'/>
180 </actions>
181 </toast>)",
182 Localization::MessageMissingOptionalComponents(),
src/windows/inc/wslhost.h
+1 -1
@@ -33,5 +33,5 @@ LPCWSTR const handle_option = L"--handle";
33 LPCWSTR const event_option = L"--event";
34 LPCWSTR const parent_option = L"--parent";
35 LPCWSTR const vm_id_option = L"--vm-id";
36 -LPCWSTR const embedding_option = L"--Embedding";
36 +LPCWSTR const embedding_option = L"-Embedding";
37 } // namespace wslhost
\ No newline at end of file
src/windows/service/exe/LxssUserSession.cpp
+11 -10
@@ -2172,13 +2172,22 @@ HRESULT LxssUserSessionImpl::Shutdown(_In_ bool PreventNewInstances, ShutdownBeh
2172 return S_OK;
2173 }
2174
2175 -void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const
2175 +void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket) const
2176 try
2177 {
2178 wsl::windows::common::wslutil::SetThreadDescription(L"Telemetry");
2179
2180 wsl::shared::SocketChannel channel(std::move(socket), "Telemetry", m_vmTerminating.get());
2181
2182 + // Check if drvfs notifications are enabled for the user.
2183 + bool drvFsNotifications{};
2184 + {
2185 + auto impersonate = wil::impersonate_token(m_userToken.get());
2186 + const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
2187 + drvFsNotifications =
2188 + wsl::windows::common::registry::ReadDword(lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
2189 + }
2190 +
2191 // Aggregate information about what is running inside the VM. This is logged
2192 // periodically because logging each event individually would be too noisy.
2193 for (;;)
@@ -2852,17 +2861,9 @@ void LxssUserSessionImpl::_CreateVm()
2861 // If the telemetry is enabled, launch the telemetry agent inside the VM.
2862 if (m_utilityVm->GetConfig().EnableTelemetry && TraceLoggingProviderEnabled(g_hTraceLoggingProvider, WINEVENT_LEVEL_INFO, 0))
2863 {
2855 - bool drvFsNotifications = false;
2856 - {
2857 - auto impersonate = wil::impersonate_token(m_userToken.get());
2858 - const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
2859 - drvFsNotifications = wsl::windows::common::registry::ReadDword(
2860 - lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
2861 - }
2862 -
2864 LPCSTR Arguments[] = {LX_INIT_TELEMETRY_AGENT, nullptr};
2865 auto socket = m_utilityVm->CreateRootNamespaceProcess(LX_INIT_PATH, Arguments);
2865 - m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket), drvFsNotifications);
2866 + m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket));
2867 }
2868
2869 m_pluginManager.OnVmStarted(&m_session, &userSettings);
src/windows/service/exe/LxssUserSession.h
+1 -1
@@ -503,7 +503,7 @@ public:
503 /// <summary>
504 /// Worker thread for logging telemetry about processes running inside of WSL.
505 /// </summary>
506 - void TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const;
506 + void TelemetryWorker(_In_ wil::unique_socket&& socket) const;
507
508 /// <summary>
509 /// Terminates a distribution by it's client identifier.
src/windows/wslhost/main.cpp
+1 -6
@@ -74,12 +74,7 @@ public:
74 // Log telemetry when a WSL notification is activated, used to determine user engagement for notifications
75 WSL_LOG_TELEMETRY("NotificationActivate", PDT_ProductAndServicePerformance, TraceLoggingValue(invokedArgs, "Arguments"));
76
77 - // Prepend the executable name to the arguments so getopt can be used to parse the arguments.
78 - auto commandLine = wil::GetModuleFileNameW<std::wstring>(wil::GetModuleInstanceHandle());
79 - commandLine += L" ";
80 - commandLine += invokedArgs;
81 -
82 - ArgumentParser parser(GetCommandLineW(), wslhost::binary_name);
77 + ArgumentParser parser(invokedArgs, wslhost::binary_name, 0);
78 parser.AddArgument(
79 []() {
80 std::wstring path;