Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redraw glitch when list of task is long #7

Open
bobylito opened this issue Nov 30, 2021 · 2 comments
Open

Redraw glitch when list of task is long #7

bobylito opened this issue Nov 30, 2021 · 2 comments

Comments

@bobylito
Copy link

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

  • tasuku version: 1.0.2
  • Operating System: MacOS 12.0.1 with ITerm2 3.4.12
  • Node version: 14.18.0 and 15.14.0 (inside docker)
@privatenumber
Copy link
Owner

privatenumber commented Dec 16, 2021

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
Copy link
Author

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

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

No branches or pull requests

2 participants