Skip to content

Commit a648819

Browse files
committed
refactor(status-line): omit Errors/Warnings/Info tags when the count is zero
The happy-path status line always carried `| Errors: 0 | Warnings: 0 | Info: 0 |` even for a clean command with nothing to report. Those nine tokens per call paid for zero information — if the AI needed to know "was there an error", the status icon (✓ vs ✗) already answered that. The tags only earn their keep when the count is > 0. Match the discipline the same format already uses for `| Pipeline: ...` (which is omitted when the pipeline summary is empty): each of the three counters is now only emitted when its value is positive. Before (happy path): ✓ Pipeline executed successfully | Window: #12345 Cat | Status: Ready | Pipeline: Get-Date | Duration: 0.20s | Errors: 0 | Warnings: 0 | Info: 0 | Location [FileSystem]: C:\... After (happy path): ✓ Pipeline executed successfully | Window: #12345 Cat | Status: Ready | Pipeline: Get-Date | Duration: 0.20s | Location [FileSystem]: C:\... Before (1 error, 0 warnings, 0 info): ✗ ... | Duration: 0.20s | Errors: 1 | Warnings: 0 | Info: 0 | Location ... After (1 error, 0 warnings, 0 info): ✗ ... | Duration: 0.20s | Errors: 1 | Location ... Before (0 errors, 1 warning, 3 info): ✓ ... | Duration: 0.20s | Errors: 0 | Warnings: 1 | Info: 3 | Location ... After (0 errors, 1 warning, 3 info): ✓ ... | Duration: 0.20s | Warnings: 1 | Info: 3 | Location ... Parser impact: consumers that currently pattern-match `Errors: N` are unaffected (the pattern still matches when N > 0, and the case that was silently satisfied by "Errors: 0" is now silently satisfied by tag absence — which any sensible parser was already treating as 0). No tests in the repo asserted literal `Errors: 0` / `Warnings: 0` / `Info: 0` on a status line, so the existing 251-test suite needs no changes.
1 parent df839ff commit a648819

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

PowerShell.MCP/Resources/MCPPollingEngine.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,17 @@ if (-not (Test-Path Variable:global:McpTimer)) {
351351
$windowTitle = $Host.UI.RawUI.WindowTitle
352352

353353
$pipelineInfo = if ($pipelineSummary) { " | Pipeline: $pipelineSummary" } else { "" }
354-
$statusLine = "$statusIcon Pipeline $statusText | Window: $windowTitle | Status: $Status$pipelineInfo | Duration: $durationText | Errors: $errorCount | Warnings: $warningCount | Info: $infoCount | $LocationInfo"
354+
# Zero-count tags (Errors: 0 / Warnings: 0 / Info: 0) are
355+
# silent on the happy path — a clean run produces a
356+
# shorter status line and a run with actual events
357+
# produces a line where every count listed is non-zero
358+
# by construction. This follows the same "omit what
359+
# equals zero" discipline the status line already uses
360+
# for `$pipelineInfo`.
361+
$errInfo = if ($errorCount -gt 0) { " | Errors: $errorCount" } else { "" }
362+
$warnInfo = if ($warningCount -gt 0) { " | Warnings: $warningCount" } else { "" }
363+
$infoInfo = if ($infoCount -gt 0) { " | Info: $infoCount" } else { "" }
364+
$statusLine = "$statusIcon Pipeline $statusText | Window: $windowTitle | Status: $Status$pipelineInfo | Duration: $durationText$errInfo$warnInfo$infoInfo | $LocationInfo"
355365

356366
# Generate structured output strings
357367
$structuredOutput = @{

0 commit comments

Comments
 (0)