Skip to content

Ask for user consent if wsl is active during store updates.#40786

Open
chemwolf6922 wants to merge 2 commits into
masterfrom
user/chemwolf6922/defer-auto-update-if-wsl-is-active
Open

Ask for user consent if wsl is active during store updates.#40786
chemwolf6922 wants to merge 2 commits into
masterfrom
user/chemwolf6922/defer-auto-update-if-wsl-is-active

Conversation

@chemwolf6922

@chemwolf6922 chemwolf6922 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Check if WSL is active before installing the msi during a msix installation. If so, ask the user if they would like to shutdown wsl and apply the update. If declined or there is no active user session, the updated will be deferred to the next wslinstaller service start, likely next boot.

PR Checklist

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Add headless test without the user prompt:
InstallerTests::MsixUpgradeDefer

User prompt manually tested:
image

@chemwolf6922 chemwolf6922 requested a review from a team as a code owner June 12, 2026 05:10
Copilot AI review requested due to automatic review settings June 12, 2026 05:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Comment thread src/windows/wslinstaller/exe/WslInstaller.cpp
Comment thread localization/strings/en-US/Resources.resw
Comment thread test/windows/InstallerTests.cpp
return {};
}

if (wsl::windows::common::WslActivityMarker::IsWslActive() && !PromptUserToUpgradeWhileActive())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're holding the install lock across this prompt, and WTSSendMessageW blocks for up to 60s. Any other Install call will sit on the lock that whole time, and we won't react to g_stopEvent if the service is trying to stop. Worth deciding consent before taking the lock (or try_lock and bail).

if (wsl::windows::common::WslActivityMarker::IsWslActive() && !PromptUserToUpgradeWhileActive())
{
wsl::windows::common::install::WriteInstallLog("WSL is active; deferring MSI upgrade until WSL is idle.");
return {};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferring returns {} here, which Install() turns into S_OK / exit code 0, the same as 'nothing to install'. So if someone runs an update interactively and clicks No, they get told it succeeded. Can we return a distinct 'deferred' result so callers can tell the difference?


const auto commandLine = LxssGenerateWslCommandLine(L"sleep infinity");
wsl::windows::common::SubProcess process(nullptr, commandLine.c_str());
auto processHandle = process.Start();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sleep infinity never gets killed. SubProcess just closes the handle on destruction, it doesn't terminate the child, and the cleanup only reinstalls the MSI. If that reinstall doesn't actually tear the distro down, it stays Running (and keeps the activity marker set), which can bleed into later installer tests. A wsl --shutdown or TerminateProcess in the scope_exit would make it deterministic.

@OneBlue OneBlue left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting idea. I think having some prompt with a timeout during a WSL upgrade while WSL is being in use could help improve the UX.

However, I don't think we should do it at the WSLInstaller.cpp level. That class is only involved when WSL is being upgraded with MSIX package, which is a path that we want to deprecate.

If we wanted to do this, I think the best way would be to declare a new COM interface that wslservice implements that the MSI can call to ask to "are there any WSL containers / distributions in use ? And then if the answer is yes we can display a notification with a timeout (we should also have an MSI variable to bypass the prompt, so that it doesn't trigger if the user calls wsl --update for instance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants