Skip to content

feat(bot): restore all guild sessions on bot startup - #260

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
feat/session-startup-sweep
Mar 15, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
feat/session-startup-sweep

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

Closes #223 (wave 1 final slice — startup sweep deferred from #256).

What this adds

  • sessionStartupRestore.ts — new restoreSessionsOnStartup(client) function that runs on every bot startup:

    • Scans Redis for all music:session:* keys
    • For each key: resolves guild, validates voiceChannelId, checks snapshot age (≤ 30 min)
    • Deletes stale snapshots; rejoins voice channel and calls restoreSnapshot for fresh ones
    • Per-guild errors are isolated (one failure doesn't abort the sweep)
    • Gated by ENVIRONMENT_CONFIG.MUSIC.SESSION_RESTORE_ENABLED (default: enabled)
  • clientReady.ts — wires restoreSessionsOnStartup into the once ready event (async)

  • sessionStartupRestore.spec.ts — 8 targeted tests covering all code paths:

    • Feature flag disabled → no-op
    • No Redis keys → returns early
    • Guild not in cache → skipped
    • Missing voiceChannelId → skipped
    • Stale snapshot → deleted, no restore
    • Non-voice-based channel → skipped
    • Valid entry → creates queue, connects to voice, calls restoreSnapshot
    • Per-guild errors isolated → sweep continues

Test results

Test Suites: 60 passed, 60 total
Tests:       355 passed, 355 total

@vercel

vercel Bot commented Mar 15, 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 Mar 15, 2026 2:30pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 15, 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 11 minutes and 19 seconds before requesting another review.

⌛ 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: 5e4de3e9-d754-4f67-967a-e92871288a17

📥 Commits

Reviewing files that changed from the base of the PR and between 71cceca and 8bd040b.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/bot/src/events/clientReady.ts
  • packages/bot/src/utils/music/sessionStartupRestore.spec.ts
  • packages/bot/src/utils/music/sessionStartupRestore.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/session-startup-sweep
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@sonarqubecloud

Copy link
Copy Markdown

@netlify

netlify Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for regal-bunny-0c8efe ready!

Name Link
🔨 Latest commit 8bd040b
🔍 Latest deploy log https://app.netlify.com/projects/regal-bunny-0c8efe/deploys/69b6c2733b70ab0007fadd90
😎 Deploy Preview https://deploy-preview-260--regal-bunny-0c8efe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 7c0bb44 into main Mar 15, 2026
15 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the feat/session-startup-sweep branch March 15, 2026 20:16

This branch was successfully deployed

1 active deployment
Preview — 8bd040b6 Deployed Mar 15, 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.

feat(bot): deliver the music reliability roadmap wave 1

1 participant