Skip to content

feat(music): cover and re-enable collaborative playlist mode (#825) - #929

Merged
LucasSantana-Dev merged 1 commit into
release/v2.14.0from
feat/collaborative-playlist-tests-825
May 21, 2026
Merged

LucasSantana-Dev merged 1 commit into
release/v2.14.0from
feat/collaborative-playlist-tests-825

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented May 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

This PR implements issue #825, expanding test coverage for the collaborative playlist feature and re-enabling it via feature toggle.

Changes:

  • Added 30 comprehensive tests for collaborativePlaylistService (setMode, getState, resetContributions, recordContribution, canAddTracks, edge cases)
  • Added 21 tests for the /playlist collaborative command (metadata, all 4 actions: enable/disable/status/reset, per_user_limit option handling, guild validation)
  • Added COLLABORATIVE_PLAYLIST to the feature toggle union type and enabled it in config
  • Tests ensure proper state isolation using unique guild IDs per test case
  • Integration coverage confirmed via existing play/index.spec.ts which validates queue enforcement

Test Count:

  • Bot suite: 2940 (baseline) → 3042 (51 new tests added, meets ≥2940 requirement)
  • Shared suite: 414 passing (pre-existing 3 failures unrelated to changes)
  • Coverage maintained: ≥65% across both packages

Per-Test Breakdown (51 total):

collaborativePlaylistService (30 tests):

  • setMode: enables with default/custom limit, disables, ignores invalid limits, floors fractional limits, updates timestamp, preserves contributions
  • getState: returns default for new guild, returns copy (not reference), reflects recent changes
  • resetContributions: clears contributions, updates timestamp, preserves settings
  • recordContribution: increments by 1 or specified amount, enforces minimum 1, respects disabled mode, tracks multiple users, updates timestamp
  • canAddTracks: allows all when disabled, allows under limit, rejects at/exceeding limit, returns zero remaining when used=limit, treats missing users as zero, uses default count=1
  • Edge cases: empty contributions map, guild isolation, large track counts

playlistCommand (21 tests):

  • Metadata: correct name/description, has collaborative subcommand
  • Enable action: calls setMode with true, passes custom per_user_limit, returns success embed
  • Disable action: calls setMode with false, returns warning embed
  • Status action: retrieves state, displays limit and contributions, shows "No contributions yet" when empty, marks reply as ephemeral
  • Reset action: calls resetContributions, returns warning embed
  • Guild validation: rejects interaction without guild, returns early if guildId null
  • per_user_limit option: passes when provided with enable, passes undefined when not provided, ignores with disable/status/reset

UX Confidence:
Collaborative mode allows guild members to share a per-user track quota in the queue with predictable state isolation and contribution tracking. Service maintains state reliably across concurrent operations, enforces limits correctly, and rejects/allows appropriately. Command properly handles all four subcommand actions with correct embed types and option parsing. Integration with the play command queue enforcement is tested and working.

Feature Toggle Flip:

  • Type: COLLABORATIVE_PLAYLIST added to FeatureToggleName union
  • Config: enabled: true, description: 'Enable collaborative queue mode (/playlist collaborative)'

Verification:

  • All 51 new tests pass individually
  • Shared package tests pass with pre-existing baseline
  • Feature toggle properly gates the command in production
  • Commit SHA: 834408c

Summary by CodeRabbit

  • New Features

    • Introduced collaborative playlist mode enabling users to enable or disable collaborative contributions with configurable per-user limits, view contribution status, and reset contributions as needed.
  • Tests

    • Comprehensive test suites added for collaborative playlist functionality and command operations.
  • Chores

    • Added feature toggle for collaborative playlist mode.

Review Change Stack

- Added 30 tests to collaborativePlaylist.spec.ts covering setMode, getState, resetContributions, contribution tracking, per-user limit enforcement, and edge cases
- Added 21 tests to playlist.spec.ts covering all actions (enable/disable/status/reset), per_user_limit option handling, and guild validation
- Feature toggle COLLABORATIVE_PLAYLIST re-enabled in packages/shared/src/config/featureToggles.ts
- Play command integration already covers queue-add enforcement with per-user limits
- Collaborative mode allows guild members to share a per-user track quota in the queue with predictable state isolation and contribution tracking

This feature has stable test coverage (51 new tests) and correctly enforces per-user queue limits when enabled.
@vercel

vercel Bot commented May 21, 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 May 21, 2026 11:35pm

Request Review

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR adds comprehensive Jest test coverage for the collaborative playlist feature and enables its feature toggle. Two test suites exercise the collaborativePlaylistService state management and the /playlist bot command integration, while the feature toggle type and configuration are updated to include the COLLABORATIVE_PLAYLIST toggle enabled by default.

Changes

Collaborative Playlist Tests and Feature Toggle

Layer / File(s) Summary
Feature toggle type and configuration
packages/shared/src/types/featureToggle.ts, packages/shared/src/config/featureToggles.ts
FeatureToggleName union and defaultToggles map are updated to include COLLABORATIVE_PLAYLIST with enabled: true and a description for the /playlist collaborative mode.
Collaborative playlist service tests
packages/bot/src/utils/music/collaborativePlaylist.spec.ts
Complete test suite covering setMode (enable/disable with default and custom per-user limits, invalid limit handling, fractional flooring), getState (defensive copies, new-guild defaults), resetContributions (clears contributions, preserves settings), recordContribution (default/custom increments, minimum increment enforcement, disabled-mode ignore, per-user isolation), and canAddTracks (disabled-mode allow-all, limit calculations, boundary conditions, missing-user defaults, guild isolation, large-count handling).
Playlist command test suite
packages/bot/src/functions/music/commands/playlist.spec.ts
Test suite with mocked dependencies covering command metadata (name/description, collaborative subcommand), action behaviors (enable/disable/status/reset), guild validation early-exit, ephemeral replies, embed selection, and per_user_limit option handling (forwarded to setMode only on enable, ignored for other actions).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

  • #825: Direct implementation of test coverage for the collaborative playlist feature and feature toggle enablement.

Possibly related PRs

  • LucasSantana-Dev/Lucky#135: Introduces the collaborative playlist service and command that are now being comprehensively tested in this PR.

Suggested labels

bot, shared, enhancement, size/l

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding test coverage for and re-enabling the collaborative playlist feature, which aligns with the substantial test additions and feature toggle changes.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/collaborative-playlist-tests-825

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/bot/src/functions/music/commands/playlist.spec.ts (1)

342-442: ⚡ Quick win

Add an explicit disabled-toggle test for /playlist collaborative.

The suite validates guild/action routing well, but it does not assert behavior when COLLABORATIVE_PLAYLIST is disabled (including no collaborative service calls on that path). Adding this case will lock in the feature-gate contract and prevent regressions.

As per coding guidelines, "For feature toggles, check both global and guild-specific toggles using FeatureToggleService.isEnabledForGuild() rather than checking them separately".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/bot/src/functions/music/commands/playlist.spec.ts` around lines 342
- 442, Add a new test in playlist.spec.ts that simulates COLLABORATIVE_PLAYLIST
being disabled by mocking FeatureToggleService.isEnabledForGuild() to return
false (and keep requireGuildMock resolving true), then call
playlistCommand.execute with a collaborative action (e.g., 'enable') using
createInteraction and assert that no collaborativePlaylistServiceMock methods
(setMode, getState, resetContributions) are called and that interactionReplyMock
is invoked to inform the user; ensure the test checks the feature toggle via
FeatureToggleService.isEnabledForGuild() rather than separate global/guild
checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/bot/src/functions/music/commands/playlist.spec.ts`:
- Around line 342-442: Add a new test in playlist.spec.ts that simulates
COLLABORATIVE_PLAYLIST being disabled by mocking
FeatureToggleService.isEnabledForGuild() to return false (and keep
requireGuildMock resolving true), then call playlistCommand.execute with a
collaborative action (e.g., 'enable') using createInteraction and assert that no
collaborativePlaylistServiceMock methods (setMode, getState, resetContributions)
are called and that interactionReplyMock is invoked to inform the user; ensure
the test checks the feature toggle via FeatureToggleService.isEnabledForGuild()
rather than separate global/guild checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 275d9211-e709-4682-aa3f-a5f9c5e666e1

📥 Commits

Reviewing files that changed from the base of the PR and between 15a04bb and 834408c.

📒 Files selected for processing (4)
  • packages/bot/src/functions/music/commands/playlist.spec.ts
  • packages/bot/src/utils/music/collaborativePlaylist.spec.ts
  • packages/shared/src/config/featureToggles.ts
  • packages/shared/src/types/featureToggle.ts

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit aaebb74 into release/v2.14.0 May 21, 2026
29 of 30 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the feat/collaborative-playlist-tests-825 branch May 21, 2026 23:40
LucasSantana-Dev added a commit that referenced this pull request May 22, 2026
…929)

## Summary

This PR implements issue #825, expanding test coverage for the
collaborative playlist feature and re-enabling it via feature toggle.

**Changes:**
- Added 30 comprehensive tests for `collaborativePlaylistService`
(setMode, getState, resetContributions, recordContribution,
canAddTracks, edge cases)
- Added 21 tests for the `/playlist collaborative` command (metadata,
all 4 actions: enable/disable/status/reset, per_user_limit option
handling, guild validation)
- Added `COLLABORATIVE_PLAYLIST` to the feature toggle union type and
enabled it in config
- Tests ensure proper state isolation using unique guild IDs per test
case
- Integration coverage confirmed via existing `play/index.spec.ts` which
validates queue enforcement

**Test Count:**
- Bot suite: 2940 (baseline) → 3042 (51 new tests added, meets ≥2940
requirement)
- Shared suite: 414 passing (pre-existing 3 failures unrelated to
changes)
- Coverage maintained: ≥65% across both packages

**Per-Test Breakdown (51 total):**

`collaborativePlaylistService` (30 tests):
- setMode: enables with default/custom limit, disables, ignores invalid
limits, floors fractional limits, updates timestamp, preserves
contributions
- getState: returns default for new guild, returns copy (not reference),
reflects recent changes
- resetContributions: clears contributions, updates timestamp, preserves
settings
- recordContribution: increments by 1 or specified amount, enforces
minimum 1, respects disabled mode, tracks multiple users, updates
timestamp
- canAddTracks: allows all when disabled, allows under limit, rejects
at/exceeding limit, returns zero remaining when used=limit, treats
missing users as zero, uses default count=1
- Edge cases: empty contributions map, guild isolation, large track
counts

`playlistCommand` (21 tests):
- Metadata: correct name/description, has collaborative subcommand
- Enable action: calls setMode with true, passes custom per_user_limit,
returns success embed
- Disable action: calls setMode with false, returns warning embed
- Status action: retrieves state, displays limit and contributions,
shows "No contributions yet" when empty, marks reply as ephemeral
- Reset action: calls resetContributions, returns warning embed
- Guild validation: rejects interaction without guild, returns early if
guildId null
- per_user_limit option: passes when provided with enable, passes
undefined when not provided, ignores with disable/status/reset

**UX Confidence:**
Collaborative mode allows guild members to share a per-user track quota
in the queue with predictable state isolation and contribution tracking.
Service maintains state reliably across concurrent operations, enforces
limits correctly, and rejects/allows appropriately. Command properly
handles all four subcommand actions with correct embed types and option
parsing. Integration with the play command queue enforcement is tested
and working.

**Feature Toggle Flip:**
- Type: `COLLABORATIVE_PLAYLIST` added to `FeatureToggleName` union
- Config: enabled: true, description: 'Enable collaborative queue mode
(/playlist collaborative)'

**Verification:**
- All 51 new tests pass individually
- Shared package tests pass with pre-existing baseline
- Feature toggle properly gates the command in production
- Commit SHA: 834408c

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Introduced collaborative playlist mode enabling users to enable or
disable collaborative contributions with configurable per-user limits,
view contribution status, and reset contributions as needed.

* **Tests**
* Comprehensive test suites added for collaborative playlist
functionality and command operations.

* **Chores**
  * Added feature toggle for collaborative playlist mode.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/LucasSantana-Dev/Lucky/pull/929?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
LucasSantana-Dev added a commit that referenced this pull request May 22, 2026
10 PRs accumulated since v2.13.0 (cut 2026-05-21, shipped same-day).

## Added
- feat(bot): autoplay closed-loop telemetry writers (Phase B) #933
- feat(backend): /recommendations/history read path (Phase C) #935
- feat(download): cover + re-enable /download command #930
- feat(music): cover + re-enable collaborative playlist #929
- feat(management): /customcommand coverage #928
- feat(management): cover + re-enable /embed builder #927
- test(bot/recommendation): cover 4 untested handlers #926

## Changed
- refactor(bot): Cycle C closure of #889 — runtime cycles 2 to 1 #931
- refactor(bot/autoplay): Cycles A + B residuals — 4 to 2 #925
- chore(prisma): Recommendation model repurposed for telemetry #932

Roadmap status: Phase A+B+C of the autoplay recommendation roadmap
shipped in this release. Phase D (session-coherence layer) gated on
7 days of production baseline -- revisit 2026-05-29.

Also bundled via release-branch-autosync: fix(ci): v-prefix
trivy-action tag (#934) -- unblocks production Docker image
republishing.
LucasSantana-Dev added a commit that referenced this pull request May 22, 2026
v2.14.0 — 10 PRs since v2.13.0 (cut 2026-05-21).

## Highlights

**Autoplay recommendation telemetry (3-phase roadmap, ADR
\`2026-05-21-autoplay-recommendation-roadmap\`):**
- Phase A (#932) — Prisma \`Recommendation\` model repurposed for
closed-loop autoplay telemetry. New \`RecommendationSource\` enum,
\`signals: Jsonb\`, \`discordUserId\`, aggregation index.
- Phase B (#933) — non-throwing writers. Every autoplay pick writes a
row; \`playerFinish\` and \`playerSkip\` flip the outcome flags using
30% / 5s thresholds (exported constants for tuning).
- Phase C (#935) — read path. \`GET
/api/guilds/:guildId/recommendations/history?days=<n>\` returns
per-source acceptance rate + global summary aggregated over the window
(default 7d, clamped [1, 30]).
- **Phase D deferred.** Gated on 7 days of production baseline starting
after this release deploys. If per-source acceptance \u2265 85%, Phase D
becomes optional. Revisit 2026-05-29.

**bot/autoplay circular-dependency closure (#889 done):**
- #925 — Cycles A+B (queueMarkers, candidateContracts) — madge 4 → 2.
- #931 — Cycle C (audioFeatures, vcWeights) — madge 2 → 1 (only the
deferred type-only \`types/CustomClient\` cycle remains). Unblocks
promoting \`madge.yml\` to a blocking CI gate.

**Feature toggle re-enables (each with full test coverage):**
- \`/download\` (#930), collaborative playlist (#929), \`/embed\`
builder (#927).
- Test-only coverage adds: \`/customcommand\` (#928), 4 recommendation
handlers (#926).

**Bundled via release-branch-autosync:** \`fix(ci): v-prefix
trivy-action tag\` (#934) — unblocks production Docker image
republishing on main.

## Verification

- All 10 PRs passed CI (Quality Gates, SonarCloud, CodeQL, semgrep,
knip, lint, madge, security) before merging to release/v2.14.0.
- Bot suite: 3109+ tests passing across the autoplay + queue +
replenisher + recommendation + trackHandlers surface.
- Backend suite: 343+ integration tests passing including the new
\`/recommendations/history\` route.
- Shared suite: 12 new tests on \`recommendationTelemetryReadService\`.

## Deploy checklist

After merge:
1. Tag \`v2.14.0\` on the merge commit.
2. Verify the Docker publish workflow succeeds on the merge commit (was
the original failure mode pre-#934; now fixed).
3. Confirm homelab pulls the new images.
4. Begin 7-day baseline collection for the autoplay recommendation
telemetry.

## Migrations

One Prisma migration in this release:
\`20260521000000_recommendation_telemetry_phase_a\`. Repurposes the
unused \`recommendations\` table:
- Drops \`algorithm: String\` (was scaffolded, never written by any
service).
- Adds \`recommendationSource\` enum + \`signals\` Jsonb +
\`discordUserId\` + indexed by \`(guildId, source, createdAt)\`.
- \`confidence\` made nullable.

Safe to deploy: no production rows exist in the table prior to this
release.



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added recommendation history endpoint to retrieve past recommendations
and acceptance rates by source
* Telemetry recording now tracks recommendation outcomes
(accepted/rejected) based on listening behavior
* New feature toggles for Embed Builder and Collaborative Playlist
support

* **Chores**
  * Bumped all package versions to 2.14.0
* Updated database schema to support recommendation source tracking and
telemetry

* **Tests**
* Added comprehensive test coverage for download and autoplay features,
collaborative playlist, and recommendation handlers

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/LucasSantana-Dev/Lucky/pull/936?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

This branch was successfully deployed

1 active deployment
Preview — 834408c5 Deployed May 21, 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