feat(downloader): stderr progress indicator for long-running fetches (#108)#165
Merged
Conversation
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.
What this PR does
Adds a single-line stderr progress bar for chapter/page downloads, so long throttled sessions show real progress instead of a wall of
retrying after Xmslines.src/walkthrough/progress.ts(new):createProgress({ enabled, totalChapters, write?, now? })→updateChapter/updatePage/finish. Single-line\rredraw, throttled to ~5/sec (200ms),finish()forces the true final frame then a newline. ETA = moving average of page durations; shows~--until a sample exists; percent clamped [0,100].src/downloader/{types,service}.ts: additive optionalonPageProgress(totalPages)callback, fired once per completed page.src/walkthrough/steps/execute.ts: threads aprogresshandle —updateChapterper bundle,updatePageper completed page,finish()at the end.src/index.ts:--progressflag +resolveProgressEnabled = json ? false : (progress || isTTY).Why it exists
Real session: ~50 min downloading Zom 100 with zero aggregate feedback. Users couldn't tell how many pages/chapters remained or the ETA.
How it works internally (progress is completion-counted, not index-based)
updatePage()increments an internal completion counter (reset per chapter), independent of dispatch order. This matters: the downloader fetches pages concurrently (imageConcurrency), so callbacks fire in completion order — trusting a dispatch-order index made the bar jump backward and never reach 100%. Counting completions guarantees the Nth completed page renders aspage N, and the final completion of the last chapter lands onpage N/N= 100% regardless of resolution order.What did not change
Test checklist
bun test— 524 pass, 0 failbun run typecheck— cleanbun run check— clean--jsonsuppresses the bar (NDJSON only)--progressforces the bar on non-TTYfinish()flushes the true final 100% framepage N/N/ 100% (progress + downloader + execute tests, all asserting real content, no sorted-tautology)~--until first sample; percent clamped [0,100]; no NaN/div-by-zeroReviewer notes
finish()no-flush bug; inspector then caught a deeper P0 — the progress counter ran backward under concurrency and the "concurrency" test was a sorted tautology. Both fixed (completion-counter model,pageIndexparam dropped from the callback chain, real out-of-order tests). Final inspector: APPROVED.src/walkthrough/index.tswith feat(walkthrough): post-download loop — download more from the same manga without restarting #163 (post-download loop) — expect a rebase; changes here are additive.onPageProgresspassestotalPageseach call though the renderer counts internally.Closes
Closes #108
✅ Checklist
docs/(if applicable)