Skip to content

feat: make the renderer run in an async context#101

Open
MaximSrour wants to merge 3 commits into
masterfrom
decouple-render-logic-from-task-runners
Open

feat: make the renderer run in an async context#101
MaximSrour wants to merge 3 commits into
masterfrom
decouple-render-logic-from-task-runners

Conversation

@MaximSrour

Copy link
Copy Markdown
Owner

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?

  • Separates rendering from task execution responsibilities.
  • Adds a dedicated render scheduler for TTY output with a guaranteed final render.
  • Simplifies task execution code and updates duration handling for in-progress runs.

Copilot AI review requested due to automatic review settings March 29, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread src/index.ts
Comment thread src/task/watcher.ts
Comment thread src/renderers/renderScheduler.test.ts Outdated
MaximSrour and others added 2 commits March 29, 2026 18:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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