privatenumber / tasuku

✅ タスク — The minimal task visualizer for Node.js
MIT License
1.91k stars 30 forks source link

Redraw glitch when list of task is long #7

Open bobylito opened 2 years ago

bobylito commented 2 years ago

Bug description

This is a visual bug. When the list of items is bigger than the screen height, the list starts glitching.

2021-11-30 09 55 01

Reproduction

const task = require("tasuku");

(async function test() {
  let iteration = 0;
  while (true) {
    await task(
      `Run ${iteration} -- with long text it is more visible`,
      () => new Promise((resolve) => setTimeout(() => resolve(), 100))
    );
    iteration++;
  }
})();

Environment

privatenumber commented 2 years ago

This is a known limitation in Ink, the renderer tasuku is using. It might be by design since only re-rendering what's in the viewport could break native scrolling.

To work around this, I recommend limiting your list so that it's not longer than your viewport. This leads to better UI/UX anyway, so it's an overall plus.

If your processing flow is in series, run clear() on each completed task so it's removed. If in async, use a concurrency manager like p-map so it only does n number of tasks at once. I have also consolidated a large list of tasks to one and updated the count of completed ones via setStatus or setOutput instead.

I will leave this open until I add a "Best practices" section in the README recommending this.

bobylito commented 2 years ago

Thanks for following up on this issue. Your recommendations are great.