feat: make the renderer run in an async context#101
Open
MaximSrour wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR decouples console rendering from task execution by introducing a dedicated render scheduler, so runs (including watch mode reruns) manage rendering independently and still guarantee a final render at the end of each run.
Changes:
- Introduces
startRenderer(interval-based in TTY) and updates the CLI entrypoint to start/stop rendering around each run. - Removes direct rendering calls from
runTasks, keeping execution focused on scheduling and task completion. - Updates duration handling to support “live” durations for in-progress tasks and adjusts rendering logic/tests accordingly.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Wraps each run with startRenderer/cleanup and wires watcher reruns through a callback. |
| src/renderers/index.ts | Switches public renderer export to startRenderer. |
| src/renderers/renderScheduler.ts | Adds the render scheduler (initial render + interval in TTY + final render on cleanup). |
| src/renderers/renderScheduler.test.ts | Adds scheduler tests (timers/TTY behavior). |
| src/renderers/render.ts | Computes suite timing using a single Date.now() snapshot and supports unfinished runs. |
| src/renderers/render.test.ts | Adds/updates tests for unfinished-duration behavior and suite timing changes. |
| src/task/execute.ts | Removes render coupling from task execution; tasks now execute without lifecycle render hooks. |
| src/task/execute.test.ts | Updates execution tests to reflect decoupled rendering. |
| src/task/task.ts | Changes getDuration() to return a live duration while running. |
| src/task/task.test.ts | Updates tests to assert live duration behavior using mocked time. |
| src/task/watcher.ts | Refactors watcher to invoke a provided async onChange handler instead of calling runTasks directly. |
| src/task/watcher.test.ts | Updates watcher tests for the new callback-driven API. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary
Move rendering into an async scheduler so task execution no longer drives UI refreshes directly. This keeps task runners focused on execution while the renderer updates independently and still performs a final render when a run ends.
Reasoning
Why is this change needed?
Rendering was coupled to task lifecycle callbacks, which mixed presentation concerns into task execution and made the flow harder to reason about. Watch mode also benefits from a single entry point that can start, stop, and restart rendering cleanly around each run.
What are the benefits?