fix(cli): sort jobs by stage completion ratio#1947
Open
QuakeWang wants to merge 2 commits into
Open
Conversation
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
coderfender
reviewed
Jul 5, 2026
| if job.num_stages == 0 { | ||
| (0_u128, 1_u128) | ||
| } else { | ||
| (job.completed_stages as u128, job.num_stages as u128) |
Contributor
There was a problem hiding this comment.
Nit : Perhaps 128bit int is an overkill here ?
Member
Author
There was a problem hiding this comment.
@coderfender Good point. I switched this to compare f64 completion ratios with total_cmp while keeping the zero-stage guard. The exact u128 fraction comparison was more defensive than this TUI sorting path needs.
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
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.
Which issue does this PR close?
Closes #.
Rationale for this change
The TUI jobs table sorted the stage completion column with integer division:
completed_stages / num_stagesThis could panic when
num_stageswas zero, and it also collapsed partial ratios such as1/4,2/4, and3/4to the same value.What changes are included in this PR?
This PR updates the jobs table stage-completion sorting to compare the actual completion ratio safely, treating zero-stage jobs as
0%complete. It also adds regression tests for ratio-based sorting and zero-stage jobs.Are there any user-facing changes?
Yes. Sorting the TUI jobs table by stage completion now reflects the real completion ratio and no longer panics for jobs with zero stages.