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>
This commit is contained in:
Ben Hillis 2025-12-15 20:50:49 -08:00 committed by GitHub
parent 180d811099
commit e24df7e0d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 24 deletions

View File

@ -86,8 +86,8 @@ try
</binding> </binding>
</visual> </visual>
<actions> <actions>
<action arguments='--{}' content='{}'/> <action arguments='{}' content='{}'/>
<action arguments='--{}' content='{}'/> <action arguments='{}' content='{}'/>
</actions> </actions>
</toast>)", </toast>)",
Localization::MessageNewWslVersionAvailable(Localization::Options::DontImpersonate), Localization::MessageNewWslVersionAvailable(Localization::Options::DontImpersonate),
@ -118,8 +118,8 @@ try
</binding> </binding>
</visual> </visual>
<actions> <actions>
<action arguments='--{} {}' content='{}'/> <action arguments='{} {}' content='{}'/>
<action arguments='--{} {}' content="{}"/> <action arguments='{} {}' content="{}"/>
</actions> </actions>
</toast>)", </toast>)",
Localization::MessagePerformanceTip(Localization::Options::DontImpersonate), Localization::MessagePerformanceTip(Localization::Options::DontImpersonate),
@ -151,7 +151,7 @@ try
</binding> </binding>
</visual> </visual>
<actions> <actions>
<action arguments='--{}' content='{}'/> <action arguments='{}' content='{}'/>
</actions> </actions>
</toast>)", </toast>)",
Localization::MessageWarningDuringStartup(), Localization::MessageWarningDuringStartup(),
@ -176,7 +176,7 @@ try
</binding> </binding>
</visual> </visual>
<actions> <actions>
<action arguments='--{}' content='{}'/> <action arguments='{}' content='{}'/>
</actions> </actions>
</toast>)", </toast>)",
Localization::MessageMissingOptionalComponents(), Localization::MessageMissingOptionalComponents(),

View File

@ -33,5 +33,5 @@ LPCWSTR const handle_option = L"--handle";
LPCWSTR const event_option = L"--event"; LPCWSTR const event_option = L"--event";
LPCWSTR const parent_option = L"--parent"; LPCWSTR const parent_option = L"--parent";
LPCWSTR const vm_id_option = L"--vm-id"; LPCWSTR const vm_id_option = L"--vm-id";
LPCWSTR const embedding_option = L"--Embedding"; LPCWSTR const embedding_option = L"-Embedding";
} // namespace wslhost } // namespace wslhost

View File

@ -2172,13 +2172,22 @@ HRESULT LxssUserSessionImpl::Shutdown(_In_ bool PreventNewInstances, ShutdownBeh
return S_OK; return S_OK;
} }
void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const void LxssUserSessionImpl::TelemetryWorker(_In_ wil::unique_socket&& socket) const
try try
{ {
wsl::windows::common::wslutil::SetThreadDescription(L"Telemetry"); wsl::windows::common::wslutil::SetThreadDescription(L"Telemetry");
wsl::shared::SocketChannel channel(std::move(socket), "Telemetry", m_vmTerminating.get()); wsl::shared::SocketChannel channel(std::move(socket), "Telemetry", m_vmTerminating.get());
// Check if drvfs notifications are enabled for the user.
bool drvFsNotifications{};
{
auto impersonate = wil::impersonate_token(m_userToken.get());
const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
drvFsNotifications =
wsl::windows::common::registry::ReadDword(lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
}
// Aggregate information about what is running inside the VM. This is logged // Aggregate information about what is running inside the VM. This is logged
// periodically because logging each event individually would be too noisy. // periodically because logging each event individually would be too noisy.
for (;;) for (;;)
@ -2852,17 +2861,9 @@ void LxssUserSessionImpl::_CreateVm()
// If the telemetry is enabled, launch the telemetry agent inside the VM. // If the telemetry is enabled, launch the telemetry agent inside the VM.
if (m_utilityVm->GetConfig().EnableTelemetry && TraceLoggingProviderEnabled(g_hTraceLoggingProvider, WINEVENT_LEVEL_INFO, 0)) if (m_utilityVm->GetConfig().EnableTelemetry && TraceLoggingProviderEnabled(g_hTraceLoggingProvider, WINEVENT_LEVEL_INFO, 0))
{ {
bool drvFsNotifications = false;
{
auto impersonate = wil::impersonate_token(m_userToken.get());
const auto lxssKey = wsl::windows::common::registry::OpenLxssUserKey();
drvFsNotifications = wsl::windows::common::registry::ReadDword(
lxssKey.get(), LXSS_NOTIFICATIONS_KEY, LXSS_NOTIFICATION_DRVFS_PERF_DISABLED, 0) == 0;
}
LPCSTR Arguments[] = {LX_INIT_TELEMETRY_AGENT, nullptr}; LPCSTR Arguments[] = {LX_INIT_TELEMETRY_AGENT, nullptr};
auto socket = m_utilityVm->CreateRootNamespaceProcess(LX_INIT_PATH, Arguments); auto socket = m_utilityVm->CreateRootNamespaceProcess(LX_INIT_PATH, Arguments);
m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket), drvFsNotifications); m_telemetryThread = std::thread(&LxssUserSessionImpl::TelemetryWorker, this, std::move(socket));
} }
m_pluginManager.OnVmStarted(&m_session, &userSettings); m_pluginManager.OnVmStarted(&m_session, &userSettings);

View File

@ -503,7 +503,7 @@ public:
/// <summary> /// <summary>
/// Worker thread for logging telemetry about processes running inside of WSL. /// Worker thread for logging telemetry about processes running inside of WSL.
/// </summary> /// </summary>
void TelemetryWorker(_In_ wil::unique_socket&& socket, _In_ bool drvFsNotifications) const; void TelemetryWorker(_In_ wil::unique_socket&& socket) const;
/// <summary> /// <summary>
/// Terminates a distribution by it's client identifier. /// Terminates a distribution by it's client identifier.

View File

@ -74,12 +74,7 @@ public:
// Log telemetry when a WSL notification is activated, used to determine user engagement for notifications // Log telemetry when a WSL notification is activated, used to determine user engagement for notifications
WSL_LOG_TELEMETRY("NotificationActivate", PDT_ProductAndServicePerformance, TraceLoggingValue(invokedArgs, "Arguments")); WSL_LOG_TELEMETRY("NotificationActivate", PDT_ProductAndServicePerformance, TraceLoggingValue(invokedArgs, "Arguments"));
// Prepend the executable name to the arguments so getopt can be used to parse the arguments. ArgumentParser parser(invokedArgs, wslhost::binary_name, 0);
auto commandLine = wil::GetModuleFileNameW<std::wstring>(wil::GetModuleInstanceHandle());
commandLine += L" ";
commandLine += invokedArgs;
ArgumentParser parser(GetCommandLineW(), wslhost::binary_name);
parser.AddArgument( parser.AddArgument(
[]() { []() {
std::wstring path; std::wstring path;