Repository navigation
feat(bot): named music session save/restore/list/delete - #489
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Size Change: 0 B Total Size: 319 kB ℹ️ View Unchanged
|
|
Warning Rate limit exceeded
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 15 minutes and 10 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThe pull request migrates the music session system from snapshot-based storage to a named-session service backed by Redis. It introduces a new Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Discord API
participant Command Handler
participant Named Session Service
participant Redis
participant Queue Player
User->>Discord API: /session save [name]
Discord API->>Command Handler: execute session save subcommand
Command Handler->>Named Session Service: save(queue, name, userId)
Named Session Service->>Redis: check session count via smembers
Redis-->>Named Session Service: existing sessions
Named Session Service->>Named Session Service: validate name format & snapshot tracks
Named Session Service->>Queue Player: extract current & upcoming tracks
Queue Player-->>Named Session Service: track data
Named Session Service->>Redis: setex(session_key, TTL, JSON)
Redis-->>Named Session Service: stored
Named Session Service->>Redis: sadd(guild_index, session_name)
Redis-->>Named Session Service: added to index
Named Session Service-->>Command Handler: saved session with metadata
Command Handler->>Discord API: reply with session details
Discord API-->>User: session saved confirmation
sequenceDiagram
actor User
participant Discord API
participant Handler (Autocomplete)
participant Named Session Service
participant Redis
participant Command Handler
participant Queue Player
participant Voice Connection
User->>Discord API: focus 'name' option in /session restore
Discord API->>Handler (Autocomplete): InteractionCreate (autocomplete)
Handler (Autocomplete)->>Named Session Service: list(guildId)
Named Session Service->>Redis: smembers(guild_index)
Redis-->>Named Session Service: session names
Named Session Service->>Redis: get(session_key) for each name
Redis-->>Named Session Service: sessions with metadata
Named Session Service-->>Handler (Autocomplete): sorted summaries
Handler (Autocomplete)->>Discord API: respond with name choices (max 25)
Discord API-->>User: autocomplete suggestions
User->>Discord API: select session name & execute /session restore
Discord API->>Command Handler: execute session restore subcommand
Command Handler->>Named Session Service: restore(queue, name, user)
Named Session Service->>Redis: get(session_key)
Redis-->>Named Session Service: stored snapshot
Named Session Service->>Queue Player: search(track_query) for each snapshot track
Queue Player-->>Named Session Service: resolved tracks with metadata
Named Session Service->>Queue Player: addTrack() for each resolved track
Queue Player-->>Named Session Service: tracks enqueued
Named Session Service->>Queue Player: play() if not already playing
Queue Player-->>Voice Connection: begin playback
Named Session Service-->>Command Handler: { restoredCount }
Command Handler->>Discord API: reply with restored track count
Discord API-->>User: restore confirmation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
- Added srem() to RedisClient interface, operations, and string ops - Fixed namedSessions.ts: use smembers().length instead of scard() - Fixed del() return type (boolean not number) - Fixed test mocks: hoisting, boolean return types, isAutocomplete mock
Adds coverage for the autocomplete path introduced alongside named sessions: - responds with session name choices for restore and delete subcommands - caps responses at the Discord 25-choice limit - returns empty list when guildId is missing - returns empty list for unrelated commands - swallows and logs errors from namedSessionService.list
7203a33 to
e00f290
Compare
|
* feat(bot): export toSnapshotTrack for reuse * feat(bot): add NamedSessionService for named queue sessions * feat(bot): enhance /session with named save/restore/list/delete * test(bot): add named session service and command tests * fix(shared): add srem to redis client and fix named session type errors - Added srem() to RedisClient interface, operations, and string ops - Fixed namedSessions.ts: use smembers().length instead of scard() - Fixed del() return type (boolean not number) - Fixed test mocks: hoisting, boolean return types, isAutocomplete mock * test(bot): cover handleAutocomplete branches for session name lookup Adds coverage for the autocomplete path introduced alongside named sessions: - responds with session name choices for restore and delete subcommands - caps responses at the Discord 25-choice limit - returns empty list when guildId is missing - returns empty list for unrelated commands - swallows and logs errors from namedSessionService.list
* feat(bot): export toSnapshotTrack for reuse * feat(bot): add NamedSessionService for named queue sessions * feat(bot): enhance /session with named save/restore/list/delete * test(bot): add named session service and command tests * fix(shared): add srem to redis client and fix named session type errors - Added srem() to RedisClient interface, operations, and string ops - Fixed namedSessions.ts: use smembers().length instead of scard() - Fixed del() return type (boolean not number) - Fixed test mocks: hoisting, boolean return types, isAutocomplete mock * test(bot): cover handleAutocomplete branches for session name lookup Adds coverage for the autocomplete path introduced alongside named sessions: - responds with session name choices for restore and delete subcommands - caps responses at the Discord 25-choice limit - returns empty list when guildId is missing - returns empty list for unrelated commands - swallows and logs errors from namedSessionService.list



Summary
NamedSessionServicewith Redis-backed named session storage (max 10 per guild, 30-day TTL)/sessioncommand with 4 subcommands:save <name>,restore <name>,list,delete <name>restoreanddeletesubcommandssrem()to shared Redis client interface for Set member removaltoSnapshotTrack()from sessionSnapshots for reuseTest plan
npm run test:bot— 1449 tests pass (27 new)npm run build— compiles without errors/session save party-mix→/session list→/stop→/session restore party-mix→ queue restored/session delete party-mixremoves session🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
/sessioncommandsave,list,delete, andrestoresubcommands for managing named sessionsrestoreanddeletesubcommandsTests