Added keep alive setting#41109
Open
craigloewen-msft wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new WSL Settings UI toggle to keep the WSL VM running indefinitely by driving the existing wsl2.vmIdleTimeout setting into a negative value (which the service interprets as “do not idle-terminate”).
Changes:
- Add a “Keep WSL VM alive” toggle to Optional Features, and disable the VM idle timeout expander when keep-alive is active.
- Extend the Optional Features view model with keep-alive/enablement properties and related change notifications.
- Add en-US localized strings (header/description and accessibility text) for the new setting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/windows/wslsettings/Views/Settings/OptionalFeaturesPage.xaml | Adds keep-alive toggle and disables the idle-timeout expander based on view model state. |
| src/windows/wslsettings/ViewModels/Settings/OptionalFeaturesViewModel.cs | Adds computed properties for keep-alive and VM idle-timeout enablement, and updates change notification flow. |
| localization/strings/en-US/Resources.resw | Adds localized strings for the new keep-alive setting and toggle accessibility metadata. |
| <ToggleSwitch x:Uid="Settings_KeepVMAliveToggleSwitch" HorizontalAlignment="Right" MinWidth="0" IsOn="{x:Bind ViewModel.IsOnKeepVMAlive, Mode=TwoWay}"/> | ||
| </ctControls:SettingsCard> | ||
| <ctControls:SettingsExpander x:Name="VMIdleTimeoutExpander" x:Uid="Settings_VMIdleTimeout" IsEnabled="{x:Bind ViewModel.VMIdleTimeoutEnabled, Mode=OneWay}"> | ||
| <TextBlock Style="{StaticResource TextBlockSettingStyle}" Text="{x:Bind ViewModel.VMIdleTimeout, Mode=OneWay, Converter={StaticResource MillisecondsStringConverter}}"/> |
Comment on lines
+87
to
+90
| public bool VMIdleTimeoutEnabled | ||
| { | ||
| get { return _vMIdleTimeout!.Int32Value >= 0; } | ||
| } |
Comment on lines
+78
to
+84
| set | ||
| { | ||
| Set(ref _vMIdleTimeout!, value ? -1 : _defaultVMIdleTimeout, nameof(IsOnKeepVMAlive)); | ||
| OnPropertyChanged(nameof(VMIdleTimeout)); | ||
| OnPropertyChanged(nameof(VMIdleTimeoutEnabled)); | ||
| VMIdleTimeout_ResetEnabled = !Equals(_defaultVMIdleTimeout, _vMIdleTimeout!.Int32Value); | ||
| } |
Comment on lines
104
to
+106
| Set(ref _vMIdleTimeout!, parsedValue); | ||
| OnPropertyChanged(nameof(IsOnKeepVMAlive)); | ||
| OnPropertyChanged(nameof(VMIdleTimeoutEnabled)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Added a setting to WSL settings to keep the WSL VM alive at all times.
PR Checklist
Very simple change.

Detailed Description of the Pull Request / Additional comments
Did this in WSL settings only, no major code changes.
Validation Steps Performed
Validated settings loaded correctly.