ui: prevent progress bar capacity overflow#341
Conversation
Signed-off-by: OllieinCanada <73385593+OllieinCanada@users.noreply.github.com>
|
Hi Ollie, Thanks for the PR! at a glance, this looks good. thank you for subbing in the "safer" just for fun, I also ran it through the /review-pr skill: LGTM! |
If you feel this approach is better, feel free to close #342 . I opened it just because I can't test Ollama without having a fix for this issue ;-) |
I had planned to post your PR review and this comment at the same time, but my finger slipped ;) thanks! |
|
IMO, a separate PR should try to solve the root cause of the issue, e.g. to ensure that total_stages is incremented when there is the need to run additional stages (for instance, on retries - not sure if are there other cases as well). |
|
Is this ready to be merged? If not, what needs to be done? |
LGTM |
|
Hi @OllieinCanada - please remove this PR from "draft" once it is ready so that it may be merged. |
|
Merged, thanks! |
Summary
Prevent the CLI progress renderer from panicking with
capacity overflowwhenits completed-stage count exceeds the planned-stage total.
This is independent of #339; that review command exposed an existing progress
display bug, but the V4L2 prompt change does not modify
src/main.rs.Root cause
render_progress()derived a filled bar width directly fromcompleted_stages / total_stagesand then allocated the remainder with:If an inconsistent or duplicated progress event makes
completed_stageslarger than
total_stages,filledexceedswidth. The subtractionunderflows in release builds, and
repeat()attempts an impossible allocation.The same input could also display a percentage above 100% and a completed
count larger than the total.
Fix
along with normal and zero-total cases.
Testing
cargo fmt --all -- --checkcargo test --all-features --bin sashiko(14 passed)cargo clippy --all-targets --all-features -- -D warningsgit diff --check