Skip to content

Update CLI Output Polling to Task.Run#62

Closed
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
cli-output-polling-update-11974610101210898048
Closed

Update CLI Output Polling to Task.Run#62
google-labs-jules[bot] wants to merge 2 commits into
mainfrom
cli-output-polling-update-11974610101210898048

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

The FUnit CLI was updated to use a more stable output capturing mechanism. Instead of relying on the Process.OutputDataReceived and Process.ErrorDataReceived events, which can be unstable, the tool now uses Task.Run to concurrently poll the standard output and error streams of the dotnet process. This ensures that all output is reliably captured and logged in real-time, while also improving the robustness of the log capture for diagnostic purposes in case of build or test failures. Additionally, the internal buffer capacity for captured output was increased to 4096 characters.


PR created automatically by Jules for task 11974610101210898048 started by @sator-imaging

Replaced event-based OutputDataReceived and ErrorDataReceived with
Task.Run polling of StandardOutput and StandardError streams in
RunDotnetAsync. This change improves stability as reported by the user.

- Increased capturedStdout capacity to 4096.
- Used AppendLine to preserve line structure in captured output.
- Ensured all output is drained by awaiting polling tasks after
  process exit.
- Preserved existing colorization and logging logic.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Implemented a more stable output capturing mechanism using a shared
`PollStreamReader` helper and a custom `Logger` class, as requested.

- Added `PollStreamReader` to handle `StreamReader` polling in background
  tasks.
- Introduced a `Logger` class to encapsulate real-time logging logic.
- Updated `RunDotnetAsync` to use these helpers, ensuring both stdout and
  stderr are correctly drained and processed.
- Maintained existing colorization, error counting, and failure reporting
  functionality.
- Addressed C# top-level statement constraints by properly placing type
  and method declarations.

Copilot AI left a comment

Copy link
Copy Markdown

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 updates the FUnit CLI’s dotnet process output handling to improve reliability by polling StandardOutput/StandardError concurrently via Task.Run, rather than relying on Process.OutputDataReceived/ErrorDataReceived events.

Changes:

  • Replaced event-based output capture with concurrent stream polling tasks for stdout/stderr.
  • Ensured stream polling tasks are awaited after WaitForExitAsync() to fully drain output.
  • Increased the initial StringBuilder capacity for captured output to 4096 characters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/Program.cs
proc.BeginOutputReadLine();
var tasks = new List<Task>();

var defaultLogger = new Logger(line => Console.Out.WriteLine(Colorize(line)));
Comment thread cli/Program.cs
Console.Error.WriteLine(Colorize(line)); // DO NOT use ConsoleLogger here!
});

var capturedStdout = PollStreamReader(proc.StandardOutput, stdoutLogger ?? defaultLogger, tasks);
Comment thread cli/Program.cs
Comment on lines +566 to +576
static StringBuilder PollStreamReader(StreamReader stream, Logger? logger, List<Task> tasks)
{
var sb = new StringBuilder(capacity: 4096);
var task = Task.Run(
() =>
{
string? line;
while ((line = stream.ReadLine()) != null)
{
sb.AppendLine(line);
logger?.Debug(line);
@sator-imaging
sator-imaging deleted the cli-output-polling-update-11974610101210898048 branch June 25, 2026 22:31
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.

2 participants