CLI: Update all non-help output to use Reporter - #41010
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes WSLC CLI output by routing most non-help, non-table output through the centralized Reporter, aiming to keep stdout predictable for scripting while using consistent formatting and VT/no-color handling.
Changes:
- Updated multiple CLI tasks/commands to emit output via
context.Reporterinstead ofPrintMessage. - Threaded
Reporter&through session/container service APIs and console attach paths to unify interactive/non-interactive messaging. - Refactored image build/pull progress callbacks to write via the reporter’s Info channel (stderr) and use reporter-derived console width/VT state.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/windows/wslc/tasks/VolumeTasks.cpp | Route volume task output/errors through Reporter. |
| src/windows/wslc/tasks/SessionTasks.cpp | Use Reporter and pass it into SessionService calls. |
| src/windows/wslc/tasks/RegistryTasks.cpp | Use Reporter for registry login/logout success output. |
| src/windows/wslc/tasks/NetworkTasks.cpp | Route network task output/errors through Reporter. |
| src/windows/wslc/tasks/InspectTasks.cpp | Use Reporter for not-found errors and JSON output. |
| src/windows/wslc/tasks/ImageTasks.cpp | Use Reporter and pass it into progress callbacks. |
| src/windows/wslc/tasks/ContainerTasks.cpp | Use Reporter and pass it into ContainerService calls. |
| src/windows/wslc/services/SessionService.h | Add Reporter dependency and update method signatures. |
| src/windows/wslc/services/SessionService.cpp | Emit session messages via Reporter; pass reporter into console attach. |
| src/windows/wslc/services/ImageProgressCallback.h | Require Reporter&; adjust width handling types. |
| src/windows/wslc/services/ImageProgressCallback.cpp | Write progress via reporter Info channel; use reporter console width. |
| src/windows/wslc/services/ContainerService.h | Add Reporter dependency and update method signatures. |
| src/windows/wslc/services/ContainerService.cpp | Emit container messages via Reporter; pass reporter into console attach. |
| src/windows/wslc/services/ConsoleService.h | Add Reporter& to AttachToCurrentConsole API. |
| src/windows/wslc/services/ConsoleService.cpp | Emit detach message via Reporter. |
| src/windows/wslc/services/BuildImageCallback.h | Require Reporter& and gate console behavior off reporter VT state. |
| src/windows/wslc/services/BuildImageCallback.cpp | Route build display output through reporter Info channel; use reporter width. |
| src/windows/wslc/commands/VersionCommand.h | Update PrintVersion to take Reporter&. |
| src/windows/wslc/commands/VersionCommand.cpp | Print version via Reporter instead of PrintMessage. |
| src/windows/wslc/commands/SettingsCommand.cpp | Route settings reset confirmation through Reporter. |
| src/windows/wslc/commands/RootCommand.cpp | Pass reporter into version printing. |
| src/windows/wslc/commands/RegistryCommand.cpp | Route interactive prompts/newlines through Reporter. |
David Bennett (dkbennett)
marked this pull request as ready for review
July 16, 2026 23:26
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
/azp run |
|
Commenter does not have sufficient privileges for PR 41010 in repo microsoft/WSL |
Member
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
6 tasks
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
Migrates every non-help, user-facing output path in the WSLC CLI (
src/windows/wslc) to theReporterclass, replacing direct stdio writes (WriteTerminal,fputws, rawprintf-style emits). Routing throughReportergives us one consistent output layer that honors the global output state (e.g.--no-colorstrips embedded SGR/VT sequences when arguments arevt::Sequence-derived), formats narrow strings, and — most importantly — sends each message to the correct stream so stdout/stderr redirection behaves like Docker.PR Checklist
Detailed Description of the Pull Request / Additional comments
Reporter&through service/task APIs —ConsoleService,SessionService,ContainerService, and thetasks/*entry points now receive aReporter&instead of writing to stdio directly, so all progress, status, and result text flows through it.ImageProgressCallback— Docker-aligned stream routing. The callback is now parameterized with aReporter::Level:pull/push→Output(stdout)run/create→Info(stderr), keeping stdout reserved for the container id/outputImageProgressCallback— redirected-output fix. The in-place progress display needs cursor movement, so when output is redirected (non-VT) it now falls back to a plain log stream (one line per status transition, deduping repeated byte-progress callbacks). Previously it emitted nothing when redirected — sowslc pull … 2> fileproduced no output on the console or in the file. The redirected path also guards a null console width and null progressStatus(the interface ispointer_default(unique)).BuildImageCallback— routed through Reporter and Docker-aligned to stderr. All build progress (stage steps,exporting to image,writing image sha256:…,naming to …) now goes toInfo(stderr), matching moderndocker build— BuildKit sends progress to stderr and leaves stdout empty (only-qprints the image id). The"Building image from directory: …"header was removed:docker buildprints no such line, so non-quiet builds now produce empty stdout. Cursor hide/restore usesscope_exit_logso the noexcept destructor path can'tstd::terminateduring unwinding.WSLCE2E_Image_PushPullto positively assert push/pull progress lands on stdout with empty stderr, locking in the routing.WSLCE2EImageBuildTests, plus the build step inWSLCE2E_Image_Inspect_ConfigExtras) now assert the deterministic empty stdout (.Stdout = L"") instead of the old empty-stderr expectation, since build progress now legitimately lands on stderr.WSLCE2E_Image_Build_Pull_Successnow looks for the base-image@sha256:digest on stderr (it is part of theFROMprogress) instead of stdout.WSLCE2E_Image_Push_NonExistentImageno longer asserts empty stdout — push emits itsThe push refers to repository …status to stdout (Docker parity) before the local-existence check fails; the error is still asserted on stderr + exit code.Docker alignment (redirected output)
Output stream selection now matches the Docker CLI exactly, which matters when redirecting:
wslc pull/wslc pushsend all progress + the finalStatus:line to stdout (matchingdocker pull/docker push), so2>redirection leaves them on the console.wslc buildsends all build progress to stderr and nothing to stdout (matchingdocker build/ BuildKit; only-qwould put an image id on stdout), so a1>capture stays empty on success.wslc run/wslc createsend the implicit pull stream to stderr (matching Docker), reserving stdout for the container id in detached mode.Validation Steps Performed
Manual validation of redirection behavior with image commands — confirmed stdout vs stderr for
pull,push,run, andbuildmatches Docker.Relying on E2E tests to ensure functional equivalency; build/push E2E stream expectations were updated to match the Docker-aligned streams.