release 1.13.1: global progress done/total stable across phases
Phase summary no longer resets PROGRESS_TOTAL to local done (which made bars like 34/34 then 38/47). Total is fixed at run start; only grows if short; progress_finish snaps once at the end of the whole run.
This commit is contained in:
parent
2848ad8ef7
commit
d53af9a466
5 changed files with 70 additions and 23 deletions
60
lib.sh
60
lib.sh
|
|
@ -590,20 +590,38 @@ add_progress_total() {
|
|||
PROGRESS_TOTAL=$((PROGRESS_TOTAL + n))
|
||||
_mon_state_save
|
||||
}
|
||||
# When estimate was short, grow total so we never print done>total (e.g. 224/205).
|
||||
# Keeps ~10% headroom so the bar is not stuck at 100% while checks continue.
|
||||
# When the global estimate was short, grow total just enough so done≤total.
|
||||
# Never shrink. Mid-run headroom is small and monotonic (stable N in done/N).
|
||||
_progress_rebalance() {
|
||||
[ "${PROGRESS_TOTAL:-0}" -gt 0 ] || return 0
|
||||
[ "${PROGRESS_DONE:-0}" -gt 0 ] || return 0
|
||||
if [ "$PROGRESS_DONE" -gt "$PROGRESS_TOTAL" ]; then
|
||||
local head=$((PROGRESS_DONE / 10))
|
||||
[ "$head" -lt 12 ] && head=12
|
||||
# + max(8, 5% of done) so we do not snap to 100% then jump again next check
|
||||
local head=$((PROGRESS_DONE / 20))
|
||||
[ "$head" -lt 8 ] && head=8
|
||||
PROGRESS_TOTAL=$((PROGRESS_DONE + head))
|
||||
_mon_state_save
|
||||
fi
|
||||
}
|
||||
# Snap total to actual done — only at whole-run end (not after each phase).
|
||||
progress_finish() {
|
||||
[ "${PROGRESS_OFF:-0}" = "1" ] && return 0
|
||||
[ "${PROGRESS_DONE:-0}" -gt 0 ] || return 0
|
||||
if [ "${PROGRESS_TOTAL:-0}" -ne "$PROGRESS_DONE" ]; then
|
||||
PROGRESS_TOTAL=$PROGRESS_DONE
|
||||
_mon_state_save
|
||||
fi
|
||||
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
|
||||
if [ "${GLOBAL_N:-0}" -gt 0 ]; then
|
||||
printf -- '%s %s %d/%d (#001…#%03d)%s\n' \
|
||||
"$D" "$(i18n_text 'global checks:')" \
|
||||
"$PROGRESS_DONE" "$PROGRESS_TOTAL" "$GLOBAL_N" "$N"
|
||||
fi
|
||||
}
|
||||
_progress_bar_line() {
|
||||
# Format (grows left → right; badge = percent, not "PROG"):
|
||||
# Format (grows left → right; badge = percent):
|
||||
# ┌ 42% ┐ ████████░░░░░░░░░░░░░░░░ 31/74
|
||||
# done/total = global numbered checks so far / global expected total
|
||||
local done="$1" total="$2" width=28 pct=0 filled empty i bar pct_lab
|
||||
# Defensive: never display done > total
|
||||
if [ "$total" -gt 0 ] && [ "$done" -gt "$total" ]; then
|
||||
|
|
@ -636,7 +654,7 @@ _progress_bar_line() {
|
|||
while [ "$i" -lt "$empty" ]; do bar="${bar}░"; i=$((i + 1)); done
|
||||
pct_lab=$(printf '%3d%%' "$pct")
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
# badge = percent (clearer than "PROG"); bar grows ░→█ left to right
|
||||
# badge = percent; bar grows ░→█ left to right; N/M = global check count
|
||||
printf '%s┌%s┐%s %s%s%s %s%d/%d%s\n' \
|
||||
"$BG_PROG" "$pct_lab" "$N" \
|
||||
"$C" "$bar" "$N" \
|
||||
|
|
@ -647,10 +665,10 @@ _progress_bar_line() {
|
|||
fi
|
||||
else
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
printf '%s┌ … ┐%s %sdone=%d%s (set PROGRESS_TOTAL= for %%)\n' \
|
||||
printf '%s┌ … ┐%s %s%d/?%s (set PROGRESS_TOTAL= for global %%)\n' \
|
||||
"$BG_PROG" "$N" "$D" "$done" "$N"
|
||||
else
|
||||
printf -- '%sdone=%d%s (set PROGRESS_TOTAL= for %%)\n' "$D" "$done" "$N"
|
||||
printf -- '%s%d/?%s (set PROGRESS_TOTAL= for global %%)\n' "$D" "$done" "$N"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
|
@ -811,17 +829,29 @@ section() {
|
|||
summary() {
|
||||
local blk_n=${#BLOCKERS[@]}
|
||||
echo ""
|
||||
# final progress line (no _take_tid — plain printf)
|
||||
if [ "${PROGRESS_OFF:-0}" != "1" ] && [ "$PROGRESS_DONE" -gt 0 ]; then
|
||||
# Snap total to actual so last line is exact N/N 100%
|
||||
if [ "$PROGRESS_TOTAL" -gt 0 ] && [ "$PROGRESS_DONE" -ne "$PROGRESS_TOTAL" ]; then
|
||||
PROGRESS_TOTAL=$PROGRESS_DONE
|
||||
_mon_state_save
|
||||
# Phase progress snapshot — keep GLOBAL total (do not snap N to phase-local done).
|
||||
# Snapping here made mid-run bars like 34/34 then 38/47. Whole-run snap: progress_finish.
|
||||
if [ "${PROGRESS_OFF:-0}" != "1" ] && [ "${PROGRESS_DONE:-0}" -gt 0 ]; then
|
||||
if [ "${PROGRESS_FINAL:-0}" = "1" ]; then
|
||||
# last phase / explicit final: done/total exact
|
||||
if [ "$PROGRESS_TOTAL" -gt 0 ] && [ "$PROGRESS_DONE" -ne "$PROGRESS_TOTAL" ]; then
|
||||
PROGRESS_TOTAL=$PROGRESS_DONE
|
||||
_mon_state_save
|
||||
fi
|
||||
fi
|
||||
_progress_rebalance
|
||||
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
|
||||
fi
|
||||
if [ "$GLOBAL_N" -gt 0 ]; then
|
||||
printf -- '%s %s #001…#%03d%s\n' "$D" "$(i18n_text 'numbered checks this run:')" "$GLOBAL_N" "$N"
|
||||
# Always show global position: current # / expected total (if known)
|
||||
if [ "${PROGRESS_TOTAL:-0}" -gt 0 ]; then
|
||||
printf -- '%s %s #001…#%03d · %d/%d %s%s\n' \
|
||||
"$D" "$(i18n_text 'numbered checks:')" "$GLOBAL_N" \
|
||||
"$PROGRESS_DONE" "$PROGRESS_TOTAL" \
|
||||
"$(i18n_text '(global done/total)')" "$N"
|
||||
else
|
||||
printf -- '%s %s #001…#%03d%s\n' "$D" "$(i18n_text 'numbered checks this run:')" "$GLOBAL_N" "$N"
|
||||
fi
|
||||
fi
|
||||
if [ "$blk_n" -gt 0 ]; then
|
||||
if [ "${BOX:-0}" = "1" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue