Skip to content

Initial wslc settings support#14548

Merged
yao-msft merged 29 commits intofeature/wsl-for-appsfrom
user/yaosun/wslcsettings
Mar 27, 2026
Merged

Initial wslc settings support#14548
yao-msft merged 29 commits intofeature/wsl-for-appsfrom
user/yaosun/wslcsettings

Conversation

@yao-msft
Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Initial settings support. Still need localization as current wslc does not have localization framework hooked up yet.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Added tests. Also manually verified settings commands work and settings values do get populated to session objects defaults.

@yao-msft yao-msft requested a review from a team as a code owner March 26, 2026 21:04
Copilot AI review requested due to automatic review settings March 26, 2026 21:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds initial user-settings support to wslc, backed by a YAML file, and wires those settings into session default options and a new wslc settings command.

Changes:

  • Introduces UserSettings singleton + SettingsMap for loading/validating settings from UserSettings.yaml with .bak fallback.
  • Updates session default options to read CPU/memory/storage defaults from settings.
  • Adds wslc settings / wslc settings reset commands, plus unit tests and a new yaml-cpp dependency.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
test/windows/wslc/WSLCCLISettingsUnitTests.cpp Adds unit tests for settings parsing, fallback, and validation.
test/windows/wslc/CMakeLists.txt Adds settings include directory for tests.
src/windows/wslc/settings/UserSettings.h Declares settings enums/mappings, SettingsMap, warnings, and UserSettings API.
src/windows/wslc/settings/UserSettings.cpp Implements YAML loading/validation, defaults template, and reset/prepare behaviors.
src/windows/wslc/services/SessionModel.cpp Switches session defaults (CPU/memory/storage) to come from UserSettings.
src/windows/wslc/core/Main.cpp Emits settings load warnings at startup.
src/windows/wslc/commands/SettingsCommand.h Declares settings and settings reset CLI commands.
src/windows/wslc/commands/SettingsCommand.cpp Implements opening the settings file and resetting it.
src/windows/wslc/commands/RootCommand.cpp Registers settings under the root command.
src/windows/wslc/CMakeLists.txt Adds settings subdir and links yaml-cpp into wslclib.
CMakeLists.txt Fetches/builds yaml-cpp via FetchContent.

Comment thread src/windows/wslc/settings/UserSettings.cpp
Comment thread src/windows/wslc/services/SessionModel.cpp Outdated
Comment thread test/windows/wslc/WSLCCLISettingsUnitTests.cpp
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/commands/RootCommand.cpp
Comment thread src/windows/wslc/core/Main.cpp Outdated
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp
Copilot AI review requested due to automatic review settings March 27, 2026 00:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 4 comments.

Comment thread src/windows/wslc/settings/UserSettings.cpp
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Copilot AI review requested due to automatic review settings March 27, 2026 00:22
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Comment thread src/windows/wslc/services/SessionModel.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.h Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/core/Main.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 4 comments.

Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/services/SessionModel.cpp
Comment thread src/windows/wslc/core/Main.cpp Outdated
Comment thread src/windows/wslc/commands/SettingsCommand.cpp Outdated
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

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

LGTM. Minor comments

Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Comment thread CMakeLists.txt
Comment thread src/windows/wslc/settings/UserSettings.cpp Outdated
Copilot AI review requested due to automatic review settings March 27, 2026 20:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 14 out of 14 changed files in this pull request and generated 4 comments.

Comment thread src/windows/wslc/settings/UserSettings.cpp
Comment thread src/windows/wslc/settings/UserSettings.cpp
Comment thread src/windows/wslc/services/SessionModel.cpp
Comment thread src/windows/wslc/services/SessionModel.cpp
Copy link
Copy Markdown
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

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

LGTM.

I think in the longer term we might want to add more advanced defaults for CPU & memory like we do in WSL (by default we use all the CPU cores, and half of the available memory), but I think this is something that we should spec and definitely not required for selfhost.

Thank you for doing this !

std::optional<uint32_t> ParseSettingsMemoryValue(const std::string& value)
{
auto parsed = wsl::shared::string::ParseMemorySize(value.c_str());
auto converted = parsed.has_value() ? *parsed / 1048576 : 0; // To Mb, and anything less than 1Mb is considered invalid.
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.

nit: We can use the _1MB macro for this (in helpers.hpp)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll update in the followup pr for networkMode setting

@yao-msft yao-msft merged commit d853104 into feature/wsl-for-apps Mar 27, 2026
11 checks passed
@yao-msft yao-msft deleted the user/yaosun/wslcsettings branch March 27, 2026 21:46
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.

3 participants