Skip to content

Commit 2c2865c

Browse files
committed
Consume cached output from current pipe on timeout response
1 parent 08edc8a commit 2c2865c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

PowerShell.MCP.Proxy/Tools/PowerShellTools.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,13 @@ public static async Task<string> InvokeExpression(
424424
// Mark this pipe as busy for tracking
425425
if (jsonResponse.Pid > 0) sessionManager.MarkPipeBusy(jsonResponse.Pid);
426426

427+
// Consume cached output from current pipe (if any)
428+
var currentPipeCachedOutput = await powerShellService.ConsumeOutputFromPipeAsync(readyPipeName, cancellationToken);
429+
427430
// Collect completed outputs and busy status from other pipes
428431
var (timeoutCompletedOutput, timeoutBusyStatusInfo) = await CollectAllCachedOutputsAsync(powerShellService, readyPipeName, cancellationToken);
429432

430-
// Build timeout response: busy status first + closedConsoleInfo + completedOutput + scopeWarning + timeout message
433+
// Build timeout response: busy status first + closedConsoleInfo + cachedOutput + completedOutput + scopeWarning + timeout message
431434
var timeoutResponse = new StringBuilder();
432435
if (timeoutBusyStatusInfo.Length > 0)
433436
{
@@ -438,6 +441,11 @@ public static async Task<string> InvokeExpression(
438441
timeoutResponse.AppendLine(allPipesStatusInfo);
439442
timeoutResponse.AppendLine();
440443
}
444+
if (!string.IsNullOrEmpty(currentPipeCachedOutput))
445+
{
446+
timeoutResponse.AppendLine(currentPipeCachedOutput);
447+
timeoutResponse.AppendLine();
448+
}
441449
if (timeoutCompletedOutput.Length > 0)
442450
{
443451
timeoutResponse.Append(timeoutCompletedOutput);

0 commit comments

Comments
 (0)