Skip to content

CLI: Route wslc warnings through Reporter#41111

Merged
dkbennett merged 2 commits into
masterfrom
user/dkbennett/warningreporter
Jul 18, 2026
Merged

CLI: Route wslc warnings through Reporter#41111
dkbennett merged 2 commits into
masterfrom
user/dkbennett/warningreporter

Conversation

@dkbennett

@dkbennett dkbennett commented Jul 17, 2026

Copy link
Copy Markdown
Member

Summary of the Pull Request

Follows up on #41010 (which routed all non-help wslc output through Reporter) by
routing service-layer warnings through the same Reporter sink. Previously the
warning callback wrote directly to stderr, bypassing Reporter and its
no-color / output-level handling. With this change warnings are now routed as warnings to stderr, colored yellow where supported, and non-colored when not supported or color is disabled.

image image

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

  • WarningCallback is now a Reporter adapter. It takes a Reporter& in its
    constructor and its OnWarning forwards the message to m_reporter.Warn(...)
    (verbatim, with color added only on a VT console, and a null-guard), instead of
    fputws(Message, stderr).
  • Services build the callback internally from a Reporter&. The methods that
    surface warnings now take a Reporter& and construct WarningCallback locally,
    replacing the Microsoft::WRL::Make<WarningCallback>() COM object that was
    created and passed around:
    • ContainerServiceRun / Create / Start (via CreateInternal)
    • ImageServiceLoad / Import / Pull / Push
    • NetworkServiceCreate
    • SessionServiceOpenOrCreateDefaultSession / Enter
    • VolumeServicePrune
  • Call sites simplified. Tasks pass context.Reporter; the floating
    IWarningCallback* parameter is gone.

Why

  • Reporter becomes the single output sink for warnings too, so warnings honor
    no-color (SGR stripping) and level-based routing consistently with all other
    CLI output.
  • Removes a floating callback pointer threaded through the task/service layers in
    favor of a Reporter&, cleaning up call sites.

Notes

  • No public/SDK ABI surface is affected — these are internal CLI service helpers.

Validation Steps Performed

  • Forced a test warning and did some manual validation of the output with its expected color, no-color, and redirected output, confirmed it looks as-expected (this is the attached images)
  • The E2E tests have WarningCallback for session warnings explicitly tested, which should verify no regressions with the warning plumbing, and these tests passed locally.

Copilot AI review requested due to automatic review settings July 17, 2026 22: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

Routes WSLC CLI service-layer warnings through the existing Reporter output sink so warnings consistently honor --no-color and output-level routing (stderr), instead of writing directly to stderr.

Changes:

  • Updated IWarningCallback implementation (WarningCallback) to forward warnings to Reporter::Warn.
  • Threaded Reporter& into multiple service entry points (image/network/session/volume/container) and updated task call sites accordingly.
  • Replaced direct construction/passing of warning callback COM objects with locally constructed adapters per operation.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/windows/wslc/tasks/VolumeTasks.cpp Passes context.Reporter into VolumeService::Prune.
src/windows/wslc/tasks/SessionTasks.cpp Passes context.Reporter into SessionService::OpenOrCreateDefaultSession.
src/windows/wslc/tasks/NetworkTasks.cpp Passes context.Reporter into NetworkService::Create.
src/windows/wslc/tasks/ImageTasks.cpp Passes context.Reporter into ImageService::{Pull,Push,Load,Import}.
src/windows/wslc/services/WarningCallback.h Converts warnings to Reporter::Warn output.
src/windows/wslc/services/VolumeService.h Adds Reporter& to Prune signature.
src/windows/wslc/services/VolumeService.cpp Constructs warning adapter and passes it into PruneVolumes.
src/windows/wslc/services/SessionService.h Adds Reporter& to OpenOrCreateDefaultSession signature.
src/windows/wslc/services/SessionService.cpp Constructs warning adapter for CreateSession/EnterSession.
src/windows/wslc/services/NetworkService.h Adds Reporter& to Create signature.
src/windows/wslc/services/NetworkService.cpp Constructs warning adapter and passes it into CreateNetwork.
src/windows/wslc/services/ImageService.h Adds Reporter& to Load/Import/Pull/Push signatures.
src/windows/wslc/services/ImageService.cpp Constructs warning adapter and passes it into image operations.
src/windows/wslc/services/ContainerService.h Adds wslc.h include to support warning callback usage.
src/windows/wslc/services/ContainerService.cpp Threads warning adapter into container create/start flows and implicit pull path.

Comment thread src/windows/wslc/services/WarningCallback.h
Copilot AI review requested due to automatic review settings July 17, 2026 23:17

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

@dkbennett
dkbennett marked this pull request as ready for review July 17, 2026 23:59
@dkbennett
dkbennett requested review from a team as code owners July 17, 2026 23:59
@dkbennett
dkbennett merged commit e6db566 into master Jul 18, 2026
12 checks passed
@dkbennett
dkbennett deleted the user/dkbennett/warningreporter branch July 18, 2026 04:32
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