Skip to content

refactor: extract replenisher (phase 3.6 - final) - #670

Merged
LucasSantana-Dev merged 3 commits into
mainfrom
refactor/replenisher
Apr 17, 2026
Merged

LucasSantana-Dev merged 3 commits into
mainfrom
refactor/replenisher

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Phase 3.6 Summary - Final Refactor

Extracted the core autoplay orchestrator _replenishQueue (350 LOC) to a dedicated module, completing Phase 3 of the queueManipulation refactor.

Changes:

  • New: packages/bot/src/utils/music/autoplay/replenisher.ts (458 LOC)

    • Exports public replenishQueue() wrapper with concurrency locks
    • Contains core _replenishQueue orchestration logic
    • Manages replenish counters for query diversity
    • Includes helper functions: getRequestedBy, buildRecentArtists, buildArtistFrequency, getAllHistoryTracks
  • Updated: packages/bot/src/utils/music/queueManipulation.ts (1354 LOC, down from 1757)

    • Removed: 403 LOC (replenish logic + helpers)
    • Exported: 7 helper functions for replenisher imports
    • Re-exports replenishQueue for caller compatibility
  • New: packages/bot/src/utils/music/autoplay/replenisher.spec.ts (183 LOC)

    • 7 tests covering core replenish flow
    • Tests: serialization, early returns, error handling, candidate collection
    • Coverage: 42.62% (focus on orchestration logic)

Phase 3 Totals (3.1-3.6):

  • 372 LOC removed from queueManipulation (1757 → 1354)
  • 5 modules extracted: candidateScorer, diversitySelector, spotifyRecommender, lastFmSeeder, candidateCollector, replenisher
  • 138+ tests passing (queueManipulation + replenisher suites)

Verification:

  • npm run type:check ✓ clean
  • npm test -- --testPathPatterns='queueManipulation|replenisher' ✓ 138 tests pass
  • Concurrency locks + counters preserved
  • Behavior identical to pre-refactor

@vercel

vercel Bot commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Apr 17, 2026 0:22am

Request Review

@LucasSantana-Dev
LucasSantana-Dev enabled auto-merge (squash) April 17, 2026 00:12
@coderabbitai

coderabbitai Bot commented Apr 17, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 8 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 8 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 387ca5fd-8715-4254-8461-ee6e0c5e0d6a

📥 Commits

Reviewing files that changed from the base of the PR and between 0b37965 and fc1e4d7.

📒 Files selected for processing (3)
  • packages/bot/src/utils/music/autoplay/replenisher.spec.ts
  • packages/bot/src/utils/music/autoplay/replenisher.ts
  • packages/bot/src/utils/music/queueManipulation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/replenisher

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Post-merge cleanup: queueManipulation.ts had inline defs of collectLastFmCandidates
and searchLastFmQuery left from the pre-#668 base. Both are now imported from
autoplay/lastFmSeeder. Re-exported collectLastFmCandidates for back-compat.
@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit cd7540d into main Apr 17, 2026
12 checks passed
This was referenced Apr 17, 2026
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* refactor: extract replenisher from queueManipulation (phase 3.6 - final)

* fix(bot): remove duplicate lastFmSeeder defs after main merge

Post-merge cleanup: queueManipulation.ts had inline defs of collectLastFmCandidates
and searchLastFmQuery left from the pre-#668 base. Both are now imported from
autoplay/lastFmSeeder. Re-exported collectLastFmCandidates for back-compat.

* fix: correct imports after merge resolution - export collectLastFmCandidates from queueManipulation
@LucasSantana-Dev
LucasSantana-Dev deleted the refactor/replenisher branch May 23, 2026 02:21

This branch was successfully deployed

1 active deployment
Preview — fc1e4d78 Deployed Apr 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant