Skip to content

feat(walkthrough): post-download loop — download more without restarting (#163)#166

Merged
malaquiasdev merged 1 commit into
mainfrom
feat/163-post-download-loop
Jul 3, 2026
Merged

feat(walkthrough): post-download loop — download more without restarting (#163)#166
malaquiasdev merged 1 commit into
mainfrom
feat/163-post-download-loop

Conversation

@malaquiasdev

Copy link
Copy Markdown
Owner

What this PR does

After a download completes, the walkthrough no longer exits. It offers:

Done. What next?
  › Same manga — pick another volume/range
    New manga — search again
    Quit
  • Same manga → re-enters at mode/range selection reusing the in-memory chapter/volume listing — no second search, no second chapter-list fetch. Grabbing vol 1, 2, 3… is now a fast sequence.
  • New manga → back to title/search, keeping the already-chosen source + auth (no re-pick, no re-auth).
  • Quit / Ctrl+C → clean exit with the existing cancelled/return semantics.

Why it exists

The walkthrough was one-shot: downloading another volume of the same manga meant restarting the CLI, re-typing the title, re-searching, and reloading the whole chapter list. Painful for multi-volume downloads.

How it works internally

runWalkthrough resolves source, auth (checkAuth/doRefresh), and adapter once outside an outer loop. A per-manga ChapterListingCache { chapters, volumes } holds the resolved listing. pickRange gained optional preloadedChapters/preloadedVolumes and returns { bundles, chapters?, volumes? }, fetching (listChapters/listVolumes) only when the needed slice is absent — so "same manga" reuses the cache and a mode switch (chapter↔volume) fetches only the missing listing once. "New manga" resets hit/cache to null; source/auth/adapter persist.

Partial-failure resilient: runDownloadFlow reads { failed } and emits walkthrough.download_summary_failed when failed > 0, but the loop still offers next-action.

What did not change

  • executeWalkthrough signature unchanged.
  • src/index.ts return handling (cancelled vs ok) unchanged; loop returns the final iteration's result (per-iteration outputs are logged by executeWalkthrough).

Test checklist

  • bun test — 513 pass, 0 fail
  • bun run typecheck — clean
  • bun run check — clean
  • Same/New/Quit prompt after download
  • "Same manga" reuses cache — search/listChapters each called exactly once across iterations (asserted)
  • "New manga" re-searches without re-picking source or re-auth — call counts asserted, no stale-cache leak
  • Quit + Ctrl+C at the next-action prompt → cancelled/return semantics
  • chapter→volume, volume→chapter, and 3-iteration chapter→volume→chapter (no cross-contamination)
  • Partial failure → loop still reaches next-action + failure summary warn

Reviewer notes

Closes

Closes #163

✅ Checklist

  • Tested locally
  • Self-review complete
  • No console errors
  • Code follows project conventions
  • Docs updated in docs/ (if applicable)

@malaquiasdev malaquiasdev force-pushed the feat/163-post-download-loop branch from de6bebe to 0af5082 Compare July 3, 2026 13:14
@malaquiasdev malaquiasdev merged commit 9f215a5 into main Jul 3, 2026
9 checks passed
@malaquiasdev malaquiasdev deleted the feat/163-post-download-loop branch July 3, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(walkthrough): post-download loop — download more from the same manga without restarting

1 participant