Skip to content

Add wslc system info command - #41408

Open
beena352 wants to merge 1 commit into
microsoft:masterfrom
beena352:users/beenachauhan/system-info-command
Open

Add wslc system info command#41408
beena352 wants to merge 1 commit into
microsoft:masterfrom
beena352:users/beenachauhan/system-info-command

Conversation

@beena352

@beena352 beena352 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds wslc system info (and wslc info as a root alias) that shows client version details and session manager state in both table and JSON formats. The command does not start a VM, it queries the session manager service the same way session list does.

PR Checklist

  • Closes: Link to issue wslc: support wslc system info #41282
  • 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

What it shows:

  • Client block: the same version info as wsl --version (package version, kernel, wslg, msrdc, direct3d, dxcore, Windows version), plus the settings file path. Dev builds also show the compiler version, commit hash, and build time.
  • Server block: session manager version and the list of active sessions (reuses the same table as session list).
    Design choices:
  • No VM boot. The command only calls IWSLCSessionManager::GetVersion and ListSessions, which don't take a lease. This is the same pattern as session list
  • --format json builds the full document before writing, so a service failure fails the whole command. Table mode streams the client block first, then flushes stdout before querying the service- a stopped service still shows the client info
  • The session table is hidden when there are no sessions (no empty header row). session list keeps showing the header - that's intentional, they serve different purposes
  • Terminal::Flush was added to handle a CRT buffering issue: when stdout is redirected it's fully buffered, but stderr is not, so a later error can appear before earlier output in the same file. The flush after the client block prevents that
  • The WriteSessionTable helper is shared between ListSessions and ShowSystemInfo in SessionTasks.cpp, which is why there's no separate SystemTasks file
  • JSON session entries use "ID" (not "Id") to match the convention in ContainerTasks and NetworkTasks.

What this doesn't do:

  • No Docker engine version or container runtime info. That would need a running VM and HTTP client plumbing-separate work
  • --session is a global argument and is silently accepted. This matches how other non-session commands behave.

Validation Steps Performed

  • Ran wslc system info and wslc info with 0 and 1 active sessions - output is correct in both cases
  • Ran wslc system info --format json and verified valid JSON with Client and Server sections, correct key casing ("ID", not "Id")
  • Ran wslc system info --format invalid - clean error message, exit code 1, nothing on stdout
  • CLI parse tests: 12 new cases for system info and info with valid/invalid args
  • Structural unit tests: 5 new tests covering command name, subcommands, format argument, and registration under both system and root
  • E2E tests: 5 new tests (table output, invalid format, JSON validation with key assertions, root alias equivalence, does-not-create-session check)
  • Terminal unit test: 1 new test for Flush - verified it goes red when Flush is stubbed out, green with the real implementation

Copilot AI lite review requested due to automatic review settings August 21, 2026 07:22

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

Adds wslc system info and the top-level wslc info alias, providing client, server, and session details in table or JSON formats.

Changes:

  • Added system information command and session-manager version retrieval.
  • Added localized output and terminal flushing.
  • Added parser, unit, and end-to-end test coverage.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/windows/wslc/WSLCCLITerminalUnitTests.cpp Tests terminal output flushing.
test/windows/wslc/WSLCCLICommandUnitTests.cpp Tests command structure and registration.
test/windows/wslc/e2e/WSLCE2EGlobalTests.cpp Tests table, JSON, alias, and session behavior.
test/windows/wslc/CommandLineTestCases.h Adds command-line parser cases.
src/windows/wslc/tasks/SessionTasks.h Declares system information task support.
src/windows/wslc/tasks/SessionTasks.cpp Implements system information output.
src/windows/wslc/services/SessionService.h Declares session-manager version retrieval.
src/windows/wslc/services/SessionService.cpp Retrieves the session-manager version.
src/windows/wslc/core/Terminal.h Declares terminal output flushing.
src/windows/wslc/core/Terminal.cpp Implements terminal output flushing.
src/windows/wslc/commands/SystemCommand.h Defines the system information command interface.
src/windows/wslc/commands/SystemCommand.cpp Implements the system information command.
src/windows/wslc/commands/RootCommand.cpp Registers the top-level info alias.
localization/strings/en-US/Resources.resw Adds localized system information strings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

@beena352
beena352 marked this pull request as ready for review August 21, 2026 17:05
@beena352
beena352 requested review from a team as code owners August 21, 2026 17:05
@beena352
beena352 requested a lite review from Copilot August 21, 2026 17:05

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

@beena352
beena352 marked this pull request as draft August 21, 2026 17:25
@beena352
beena352 requested a lite review from Copilot August 21, 2026 17:37

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

Suppressed comments (2)

src/windows/wslc/tasks/SessionTasks.cpp:177

  • The new sessions.empty() branch changes the table contract by suppressing the session-table header, but the E2E additions do not assert this zero-session case: the table test only checks section/version strings and the session state is environment-dependent. Add a deterministic zero-session test that verifies Sessions: 0 is present while the session-table ID header is absent.
        if (!sessions.empty())
        {
            WriteSessionTable(context.Terminal, sessions);
        }

test/windows/wslc/WSLCCLICommandUnitTests.cpp:261

  • This unit test searches only by Name(), so it also passes if the root-level registration is removed because system already contains an info child. That means it does not pin the second registration as the comment claims; also check the command's FullName() (for example, root:info) or count the registrations.
            if (subcmd->Name() == SystemInfoCommand::CommandName)

@beena352
beena352 marked this pull request as ready for review August 21, 2026 17:45
auto& client = root["Client"];
client["Version"] = std::string{WSL_PACKAGE_VERSION};
client["KernelVersion"] = std::string{KERNEL_VERSION};
client["WslgVersion"] = std::string{WSLG_VERSION};

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.

We shouldn't display wslg and msrdc versions, since they're irrelevant to wslc

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.

(Same for the below bloc)

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