refactor(timers): route the timer bars through the shared progress helper - #543
Open
zachthedev wants to merge 1 commit into
Open
refactor(timers): route the timer bars through the shared progress helper#543zachthedev wants to merge 1 commit into
zachthedev wants to merge 1 commit into
Conversation
…lper BlockTimer, BlockResetTimer and WeeklyResetTimer each carried a private makeTimerProgressBar that filled with Math.floor. The shared helper in shared/progress-bar.ts fills with Math.round, as do makeSliderBar and makeUsageProgressBar, so floor was the only outlier in the repo and BlockTimer applied both rules across its own display modes. The three copies are gone and all six call sites use the shared helper. This shifts the rendered bar by one cell for roughly half of all percentages, whenever the fill lands past the half-cell mark. BlockTimer's own preview at 73.9% of 32 cells is 23.648, so it goes from 23 filled cells to 24. Each widget gains a case pinning a value where the two rounding rules disagree.
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.
shared/progress-bar.tsfills withMath.round.BlockTimer.ts,BlockResetTimer.tsandWeeklyResetTimer.tseach carried a byte-identicalprivate
makeTimerProgressBarthat fills withMath.floor. Six other widgetsalready use the shared helper, as do
makeSliderBarandmakeUsageProgressBar,so floor was the only outlier in the repo.
The three copies are gone and all six call sites use the shared helper.
This changes rendered output. The bar shifts by one cell for roughly half of
all percentages, whenever the fill lands past the half-cell mark. BlockTimer's
own preview value is the clearest example: 73.9% of 32 cells is 23.648, so it
goes from 23 filled cells to 24. That widget already called the round-based
makeSliderBarfor slider mode, so it was applying two rounding rules across itsown display modes.
Each of the three widgets gains a case pinning a value where floor and round
disagree (10% of 16, 73.9% of 32, 35% of 16). Putting
Math.floorback in theshared helper fails all three, so they are not retrofitted to current output.
Every pre-existing bar assertion is invariant under both rules, which is why none
of them needed touching.
The shared helper's cursor option stays inert here: all six timer call sites pass
no options, so
cursorPosis-1and the loop reproduces the old'█'.repeat(filled) + '░'.repeat(width - filled)exactly. Bar length is stillexactly
width, so truncation, powerline width math and flex separators see nochange.
Tested:
bun run lintclean;bun test1870 pass, plus the oneglobal-command-resolutionfailuremainalready has on this host.