tasktree icon indicating copy to clipboard operation
tasktree copied to clipboard

ProgressBar ETA is rendered as "infinity"

Open danielvy opened this issue 8 months ago • 0 comments

When using :eta in a template, like: ':bar :rate/bps :percent :etas'

When the bar is started and current value is still zero, the :eta token is rendered as Infinity. This happens because the division by current zero in ProgressBar.ts:

/** Progress ETA (estimated time of arrival) */
  get ETA(): number {
    return this.percent === ProgressBar.MAX_PERCENT
      ? ProgressBar.MIN_PERCENT
      : this.elapsed * (this.total / this.#current - ProgressBar.MAX_RATIO);
  }

ProgressBar should not render eta value in this case, probably best to replace by constant zero.

I'm trying to replace Listr2 with tasktree (because Listr2 doesn't handle terminal height well, losing output - listr2/listr2#296). Thanks for the work on this library!

danielvy avatar Jun 10 '24 19:06 danielvy