Skip to content

CLI: Update all non-help output to use Reporter - #41010

Merged
David Bennett (dkbennett) merged 9 commits into
masterfrom
user/dkbennett/adoptreporter
Jul 17, 2026
Merged

David Bennett (dkbennett) merged 9 commits into
masterfrom
user/dkbennett/adoptreporter

Conversation

@dkbennett

@dkbennett David Bennett (dkbennett) commented Jul 6, 2026 •

Copy link
Copy Markdown
Member

Summary of the Pull Request

Migrates every non-help, user-facing output path in the WSLC CLI (src/windows/wslc) to the Reporter class, replacing direct stdio writes (WriteTerminal, fputws, raw printf-style emits). Routing through Reporter gives us one consistent output layer that honors the global output state (e.g. --no-color strips embedded SGR/VT sequences when arguments are vt::Sequence-derived), formats narrow strings, and — most importantly — sends each message to the correct stream so stdout/stderr redirection behaves like Docker.

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

  • Thread Reporter& through service/task APIs — ConsoleService, SessionService, ContainerService, and the tasks/* entry points now receive a Reporter& 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 a Reporter::Level:
    • Standalone pull / push → Output (stdout)
    • Implicit pull during run / create → Info (stderr), keeping stdout reserved for the container id/output
  • ImageProgressCallback — 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 — so wslc pull … 2> file produced no output on the console or in the file. The redirected path also guards a null console width and null progress Status (the interface is pointer_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 to Info (stderr), matching modern docker build — BuildKit sends progress to stderr and leaves stdout empty (only -q prints the image id). The "Building image from directory: …" header was removed: docker build prints no such line, so non-quiet builds now produce empty stdout. Cursor hide/restore uses scope_exit_log so the noexcept destructor path can't std::terminate during unwinding.
  • Tests
    • Strengthened WSLCE2E_Image_PushPull to positively assert push/pull progress lands on stdout with empty stderr, locking in the routing.
    • Build success tests (WSLCE2EImageBuildTests, plus the build step in WSLCE2E_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_Success now looks for the base-image @sha256: digest on stderr (it is part of the FROM progress) instead of stdout.
    • WSLCE2E_Image_Push_NonExistentImage no longer asserts empty stdout — push emits its The 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 push send all progress + the final Status: line to stdout (matching docker pull / docker push), so 2> redirection leaves them on the console.
  • wslc build sends all build progress to stderr and nothing to stdout (matching docker build / BuildKit; only -q would put an image id on stdout), so a 1> capture stays empty on success.
  • wslc run / wslc create send the implicit pull stream to stderr (matching Docker), reserving stdout for the container id in detached mode.
  • Redirected (non-TTY) invocations now emit log-style progress on the correct stream instead of silently producing nothing.

Validation Steps Performed

Manual validation of redirection behavior with image commands — confirmed stdout vs stderr for pull, push, run, and build matches Docker.
Relying on E2E tests to ensure functional equivalency; build/push E2E stream expectations were updated to match the Docker-aligned streams.

Copilot AI review requested due to automatic review settings July 6, 2026 23:48

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

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.Reporter instead of PrintMessage.
  • 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.
Comment thread src/windows/wslc/services/ImageProgressCallback.cpp Outdated
Comment thread src/windows/wslc/services/BuildImageCallback.cpp Outdated
Comment thread src/windows/wslc/commands/RegistryCommand.cpp Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 22:49

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

Comment thread src/windows/wslc/services/ImageProgressCallback.cpp
Comment thread src/windows/wslc/commands/RegistryCommand.cpp Outdated
Comment thread src/windows/wslc/services/ImageProgressCallback.cpp Outdated
Copilot AI review requested due to automatic review settings July 13, 2026 23:02

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 23 out of 23 changed files in this pull request and generated 1 comment.

Comment thread src/windows/wslc/services/ImageProgressCallback.cpp
Copilot AI review requested due to automatic review settings July 15, 2026 00:55

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

Comment thread src/windows/wslc/services/ImageProgressCallback.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EPushPullTests.cpp Outdated
Comment thread test/windows/wslc/e2e/WSLCE2EPushPullTests.cpp Outdated
Copilot AI review requested due to automatic review settings July 16, 2026 19:42

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

Comment thread src/windows/wslc/services/ImageProgressCallback.cpp
Comment thread src/windows/wslc/services/ImageProgressCallback.cpp
Comment thread src/windows/wslc/services/BuildImageCallback.cpp
Comment thread src/windows/wslc/services/BuildImageCallback.cpp
Copilot AI review requested due to automatic review settings July 16, 2026 19:49

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

Copilot AI review requested due to automatic review settings July 16, 2026 23:04

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.

@dkbennett
David Bennett (dkbennett) marked this pull request as ready for review July 16, 2026 23:26
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
@dkbennett

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 41010 in repo microsoft/WSL
@benhillis

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@AmelBawa-msft AmirMS (AmelBawa-msft) 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.

LGTM 🥳🙌

@dkbennett
David Bennett (dkbennett) merged commit f642f80 into master Jul 17, 2026
10 of 11 checks passed
@dkbennett
David Bennett (dkbennett) deleted the user/dkbennett/adoptreporter branch July 17, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants