Skip to content

Add worker console messages (write/writeln) alongside ProgressBar - #28

Merged
hschimpf merged 22 commits into
mainfrom
devin/impl-console-messages
Jul 24, 2026
Merged

Add worker console messages (write/writeln) alongside ProgressBar#28
hschimpf merged 22 commits into
mainfrom
devin/impl-console-messages

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds write()/writeln() to ParallelWorker so workers can emit console messages while a ProgressBar is active, without the bar overwriting them.

How it works

  • ParallelWorker gains write()/writeln() via CommunicatesWithProgressBarWorker.
  • Calls are sent as a new WriteOutputMessage command to the Runner thread.
  • The Runner owns the Symfony ProgressBar and a StreamOutput on php://stderr.
  • When the bar is active, Runner does clear() → write the message → display(); otherwise it writes directly.
  • setMessage()/advance() keep working as before; memory and items-per-second stats continue to be updated on the same bar.

Why the Runner owns the output

The RFC originally explored a separate ConsoleWorker/progress thread, but routing everything through the existing Runner channel keeps the coordinator in one place and avoids sharing STDERR across threads. The Runner main thread is the only place that writes to php://stderr.

Tests

  • testThatWorkerCanWriteMessagesWithoutProgressBar spawns a separate PHP process and verifies Starting #n/Done #n messages.
  • testThatWorkerCanWriteMessagesWithProgressBar verifies the messages are interleaved with progress-bar redraws and the bar reaches 3 of 3:.

Notes

  • No BC break: Contracts\ParallelWorker is unchanged; the methods are added on the abstract ParallelWorker class.
  • CI opcache.jit is disabled because JIT + ext-parallel can deadlock.

Link to Devin session: https://app.devin.ai/sessions/aa44109acb6346c2abd6b14c45072be7
Requested by: @hschimpf

- Add ParallelWorker::write() and ParallelWorker::writeln() methods.
- Route messages through ProgressBarWorker when a progress bar is active (clear/write/display).
- Add a ConsoleWorker fallback for workers without a progress bar.
- Use a shared stderr OutputInterface so ProgressBar and messages share the same stream.
- Add WriteOutputMessage command and ConsoleWorker/HasChannels infrastructure.
- Update README and CHANGELOG.

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
@hschimpf hschimpf self-assigned this Jul 23, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

devin-ai-integration Bot and others added 2 commits July 23, 2026 21:10
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Comment thread src/Internals/Runner/ManagesTasks.php Outdated
Comment thread src/Internals/Runner/HasSharedConsole.php Outdated
Comment thread src/Internals/ConsoleWorker/HasChannels.php Outdated
Comment thread tests/ParallelTest.php
devin-ai-integration Bot and others added 6 commits July 23, 2026 21:19
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
…to STDERR

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
devin-ai-integration Bot and others added 10 commits July 23, 2026 22:49
…d ProgressBarWorker, avoid raw STDERR writes, disable opcache JIT in CI

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
…leWorker

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
…gressBarWorker

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>

@hschimpf hschimpf left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes pending a few cleanups:

  1. tests/ParallelTest.php still has debug fwrite(STDOUT, ...) in setUp/tearDown/runWorkerScript that should be removed or gated.
  2. testThatWorkerCanWriteMessagesWithProgressBar only asserts substring presence; add ordering/negative assertions to prove messages are not overwritten by the bar.
  3. The @file_put_contents('php://stderr', ...) fallback in CommunicatesWithProgressBarWorker should use fwrite(STDERR, ...) instead and drop @.
  4. Update docs/RFC-progressbar-console-messages.md implementation outline to match the final Runner-owned design.
  5. Please resolve/answer the open threads about ConsoleOutputStreamOutput and the trait name mismatch.

Once those are addressed, this looks good to merge.

Comment thread src/Internals/Runner/HasProgressBar.php
Comment thread src/Internals/Worker/CommunicatesWithProgressBarWorker.php Outdated
Comment thread src/Internals/Runner/ManagesTasks.php
Comment thread tests/ParallelTest.php Outdated
Comment thread src/Internals/Worker/CommunicatesWithProgressBarWorker.php Outdated
Comment thread src/Internals/Runner/HasSharedProgressBar.php
devin-ai-integration Bot and others added 2 commits July 24, 2026 02:26
- Remove debug timestamps from ParallelTest
- Strengthen progressbar message assertions with ordering checks
- Use fopen/fwrite for stderr fallback instead of @file_put_contents
- Update RFC implementation outline to final Runner-owned design
- Rename CommunicatesWithProgressBarWorker to CommunicatesWithRunner
- Only send progress/stats actions when progress is enabled
- Finish ProgressBar on shutdown to leave terminal clean
- Explain StreamOutput choice over ConsoleOutput

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
Comment thread src/Internals/Runner/ManagesTasks.php Outdated
…dler

Co-Authored-By: Hermann D. Schimpf <hschimpf@hds-solutions.net>
@hschimpf hschimpf added the enhancement New feature or request label Jul 24, 2026
@hschimpf
hschimpf merged commit d9ddb5b into main Jul 24, 2026
3 checks passed
@hschimpf
hschimpf deleted the devin/impl-console-messages branch July 24, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant