Skip to content

feat(bot): show recommendation reason tags in queue display - #275

Merged
LucasSantana-Dev merged 3 commits into
mainfrom
feat/recommendation-reason-tags
Mar 15, 2026
Merged

LucasSantana-Dev merged 3 commits into
mainfrom
feat/recommendation-reason-tags

Conversation

@LucasSantana-Dev

@LucasSantana-Dev LucasSantana-Dev commented Mar 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #266

  • /queue show upcoming tracks list appends an inline recommendation reason tag next to autoplay-sourced tracks (e.g. fresh artist rotation, similar title mood), making the autoplay decision transparent at a glance.
  • Now Playing section appends a Recommended because: line when the current track originated from autoplay.
  • Adds isAutoplay and recommendationReason fields to TrackDisplayInfo type, surfaced from track metadata set by markAsAutoplayTrack().
  • 4 new tests in queueDisplay.spec.ts (364 total bot tests pass, 61 suites).

Summary by CodeRabbit

  • New Features
    • Added inline recommendation reason tags next to autoplay-sourced tracks in the queue list (e.g., "fresh artist rotation", "similar title mood").
    • Added "Recommended because:" line in the Now Playing section for autoplay-sourced tracks to help users understand track selections.

@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 8:38pm

Request Review

@netlify

netlify Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit f828cab
🔍 Latest deploy log https://app.netlify.com/projects/regal-bunny-0c8efe/deploys/69b718b222d9320008f3722f
😎 Deploy Preview https://deploy-preview-275--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.

@github-actions github-actions Bot added the bot label Mar 15, 2026
@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 9 minutes and 44 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: 88cee98d-7bd0-4c05-8123-75196ac3d5cf

📥 Commits

Reviewing files that changed from the base of the PR and between be99ea6 and f828cab.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/queueEmbed.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📝 Walkthrough

Walkthrough

This PR extends the queue and now-playing display functionality to show recommendation reason tags for autoplay-sourced tracks. The changes add isAutoplay and recommendationReason optional fields to track metadata, update display logic to conditionally render reason information, introduce comprehensive test coverage, and document the feature in the changelog.

Changes

Cohort / File(s) Summary
Type Definitions
packages/bot/src/functions/music/commands/queue/types.ts
Added isAutoplay?: boolean and recommendationReason?: string optional fields to the exported TrackDisplayInfo type.
Queue Display Logic
packages/bot/src/functions/music/commands/queue/queueDisplay.ts, packages/bot/src/functions/music/commands/queue/queueEmbed.ts
Updated formatTrackForDisplay to extract and propagate isAutoplay and recommendationReason from track metadata; modified queue list rendering to append reason tags when applicable; updated now-playing embed to include "Recommended because:" line for autoplay tracks.
Test Coverage
packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
Added comprehensive Jest test suite covering formatTrackForDisplay, createTrackListDisplay, findSimilarTracksInQueue, and createQueueSummary with test cases for metadata propagation, conditional reason tag appending, and overflow messaging.
Documentation
CHANGELOG.md
Updated unreleased section for version 2.6.19 noting the addition of inline recommendation reason tags in queue list and "Recommended because:" lines in now-playing section for autoplay-sourced tracks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR partially implements issue #266 but lacks critical components: recommendation engine population of recommendationReason, snapshot save/restore validation, and reason tags per scoring path. Complete the technical scope by implementing recommendationReason population in recommendationEngine.ts and validating snapshot metadata propagation per scoring paths.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: displaying recommendation reason tags in the queue display, which aligns with the primary feature objective.
Out of Scope Changes check ✅ Passed All changes are in-scope and directly support the queue display feature; CHANGELOG addition documents the feature appropriately.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/recommendation-reason-tags
📝 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.

@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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/bot/src/functions/music/commands/queue/queueDisplay.ts (1)

15-16: Reuse the shared autoplay metadata type here.

This ad-hoc cast is now another copy of the autoplay metadata contract even though trackUtils/types.ts already owns it. Importing the shared type (or a tiny helper) keeps the queue views aligned when that metadata evolves.

♻️ Minimal refactor
 import type { Track } from 'discord-player'
 import { getTrackInfo } from '../../../../utils/music/trackUtils'
+import type { TrackMetadata } from '../../../../utils/music/trackUtils/types'
 import { isSimilarTitle } from '../../../../utils/music/titleComparison'
 import type { TrackDisplayInfo, QueueDisplayOptions } from './types'
@@
-    const metadata = (track.metadata ?? {}) as { isAutoplay?: boolean; recommendationReason?: string }
+    const metadata = (track.metadata ?? {}) as Partial<TrackMetadata>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/queue/queueDisplay.ts` around lines
15 - 16, Replace the ad-hoc cast for metadata in queueDisplay.ts with the shared
autoplay metadata type from the track utils: import the shared type (e.g.
AutoplayMetadata) from the trackUtils/types module and use it when typing
metadata (replace "(track.metadata ?? {}) as { isAutoplay?: boolean;
recommendationReason?: string }" with a properly typed expression like "const
metadata = (track.metadata ?? {}) as AutoplayMetadata" or annotate the variable
accordingly). This keeps the queue view aligned with trackUtils/types and
prevents duplicate contracts; update the import list to include the shared type
and remove the inline shape.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 17-21: Update the two 2.6.19 bullets in CHANGELOG.md (the `/queue
show` upcoming tracks bullet and the “Now Playing” recommended line) to include
the traceability suffix linking to issue `#266` and PR `#275` (e.g., append “(see
`#266`, `#275`)” or add a Markdown issue/PR link), ensuring both entries for `/queue
show` and `Now Playing` explicitly reference the related issue and PR.

In `@packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts`:
- Around line 41-160: Add a unit test that targets the embed layer: call
addCurrentTrackInfo (from queueEmbed.ts / createQueueEmbed flow) with a track
whose metadata includes isAutoplay: true and recommendationReason: 'fresh artist
rotation', then assert the returned/embed description contains the "Recommended
because:" label and the recommendation text; ensure you import or mock any
dependencies used by addCurrentTrackInfo (e.g., getTrackInfo or formatting
helpers) and place the test alongside the other queueDisplay specs so it runs
with the suite.

In `@packages/bot/src/functions/music/commands/queue/queueDisplay.ts`:
- Around line 44-48: The inline reason tag currently uses
trackInfo.recommendationReason raw; update the logic that builds reasonTag (the
ternary that checks trackInfo.isAutoplay && trackInfo.recommendationReason) to
truncate recommendationReason to a fixed max length (e.g., 30 chars) and append
an ellipsis when truncated, keeping the existing formatting (the " — _..._"
italics/underscores) so trackDisplay remains `${i + 1}.
[${trackInfo.title}](${trackInfo.url}) - ${trackInfo.author}
(${trackInfo.duration})${reasonTag}`; implement truncation either inline (using
slice/substring and length check) or via a small helper function (e.g.,
truncateReason) and use that helper when composing reasonTag.

---

Nitpick comments:
In `@packages/bot/src/functions/music/commands/queue/queueDisplay.ts`:
- Around line 15-16: Replace the ad-hoc cast for metadata in queueDisplay.ts
with the shared autoplay metadata type from the track utils: import the shared
type (e.g. AutoplayMetadata) from the trackUtils/types module and use it when
typing metadata (replace "(track.metadata ?? {}) as { isAutoplay?: boolean;
recommendationReason?: string }" with a properly typed expression like "const
metadata = (track.metadata ?? {}) as AutoplayMetadata" or annotate the variable
accordingly). This keeps the queue view aligned with trackUtils/types and
prevents duplicate contracts; update the import list to include the shared type
and remove the inline shape.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 271fda8f-1a52-496d-b532-69257e5bcd22

📥 Commits

Reviewing files that changed from the base of the PR and between 99f117a and be99ea6.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: SonarCloud Scan
  • GitHub Check: Quality Gates
🧰 Additional context used
📓 Path-based instructions (23)
**/*.{js,jsx,ts,tsx,vue,html}

📄 CodeRabbit inference engine (.cursor/rules/accessibility-openness.mdc)

Provide accessible UI components using semantic HTML and ARIA attributes where necessary

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/dependency-injection.mdc)

**/*.{ts,tsx,js,jsx}: Prefer constructor injection for classes that require dependencies
Avoid global mutable singletons unless necessary
Use explicit interfaces for external dependencies to make testing easier

**/*.{ts,tsx,js,jsx}: Include required references in PRs/code for non-trivial logic: TypeScript (official docs), MDN (JavaScript reference), and official docs for any runtime/framework/libraries used (e.g., Node.js, React) as applicable.
Before assuming behavior of an API, include the doc link and a ≤25-word quote when the change relies on it.

**/*.{ts,tsx,js,jsx}: Prefer named exports for clear usage and easier refactors in TypeScript/JavaScript
Keep import order consistent: external first, then internal modules
Remove dead code and unused imports

**/*.{ts,tsx,js,jsx}: Use PascalCase naming convention for React/UI components
Use camelCase naming convention for variables and functions
Use UPPER_SNAKE_CASE naming convention for constants
Maintain consistent import grouping and ordering within the project, keeping third-party imports separate from local imports
For external data sources (HTTP, database), always validate and sanitize input using type guards or schema validators

**/*.{ts,tsx,js,jsx}: Use Prettier with no semicolons, single quotes, 4-space indent, 80 character width
Files must not exceed 250 lines and this is enforced

Implement TypeScript typecheck and linter in CI quality checks

**/*.{ts,tsx,js,jsx}: Use TypeScript for enhanced type safety
Implement error handling and error logging
Avoid commenting code unless extremely necessary - code should explain itself with descriptive names
Leave NO todos, placeholders or missing pieces in the code
Variables and functions must use camelCase
Constants must use UPPER_SNAKE_CASE
Use arrow functions for methods and computed properties
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
Maintain consistent import grouping/order: external imports first, then...

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-handling.mdc)

**/*.{js,jsx,ts,tsx}: Never throw strings. Throw Error (or typed subclasses) with descriptive messages
Include causal error as cause when available for better debugging
Define clear, stable error codes (e.g., ERR_AUTH_EXPIRED, ERR_NETWORK_TIMEOUT)
Provide optional metadata (e.g., details, retryable, status, correlationId) in error objects
Use domain error classes per area (e.g., AuthenticationError, ValidationError, NetworkError)
Log errors with structure (message, code, stack, cause, correlationId, user context where appropriate)
Mark retryable vs nonRetryable errors where helpful for operations
Set timeouts and handle aborts/cancellations; avoid dangling requests in API/network code
Implement backoff for transient failures; avoid infinite retries
Map HTTP status → domain errors; 4xx vs 5xx behave differently (e.g., retry for 5xx/network)

**/*.{js,jsx,ts,tsx}: Use functional components with hooks in React/React Native. Avoid class components.
Keep components focused on a single responsibility; extract complex logic into custom hooks.
Keep state local when possible. Use Context/Zustand/Redux only when necessary for state management.
If props or state traverse more than 3 levels, consider using context or a feature-scoped store instead of prop drilling.
Use performance optimization techniques: React.memo, useMemo, useCallback, Suspense (web), and virtualization for long lists; avoid unnecessary re-renders.
Web accessibility: use semantic HTML, labels, focus management, keyboard navigation, and aria-* attributes as needed.
React Native accessibility: use accessibility props (accessible, accessibilityLabel), proper roles and labels.
Identify and extract repetitive UI components proactively to components/ with clear props and minimal coupling.
Web styles: prefer co-located styles or design system tokens; avoid global style leakage.
React Native styles: prefer StyleSheet.create, design tokens, and theme providers; avoid in...

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

Introduce interfaces at module boundaries to enable testing and substitutions

**/*.{ts,tsx}: Avoid using any type in TypeScript. If unavoidable, use unknown with type guards and justify with a code comment
Prefer interface for defining public object shapes in TypeScript, use type for unions and utility types
Use TypeScript utility types such as Partial, Pick, Omit, Readonly, and Record when appropriate
Use I{Name} naming convention for interfaces in TypeScript
Use T{Name} naming convention for type aliases and utility types in TypeScript

**/*.{ts,tsx}: Functions must be less than 50 lines with cyclomatic complexity less than 10
Do not use any types - ESLint enforces this at error level

**/*.{ts,tsx}: Prefer types over interfaces for most cases
Don't ever use any - type safety always
Avoid enums; use const objects instead
For complex types, create a separate file to declare them and import them
Avoid using any type; if unavoidable, use unknown with type guards and justify with code comment
Prefer interface for public API shapes; use type for unions and utility types
Use TypeScript utility types (Partial, Pick, Omit, Readonly, Record)

Use the prisma-redis-lucky skill when adding or modifying database schema, migrations, or Redis operations in the shared package

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/documentation.mdc)

**/*.{js,ts,tsx,jsx}: Minimize comments in code; explain the 'why' when non-obvious, let code express the 'what' through clear naming
Document trade-offs briefly when deviating from ideal patterns

**/*.{js,ts,tsx,jsx}: Store secrets, ports, and hosts in environment variables (.env, .env.example) and never hardcode them
Avoid redundant or decorative AI comments; code should be self-explanatory and only commented when logic is non-obvious; prefer refactoring over lengthy comments

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/functions/*/commands/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/src/functions/*/commands/**/*.{ts,tsx}: Command model must include data (slash builder), execute, and category properties exported from packages/bot/src/models/Command.ts
Use @discordjs/builders for building the data (SlashCommandBuilder) in command definitions
Command execute function must receive { interaction, client } parameters from CommandExecuteParams type
Use interactionReply and createUserFriendlyError utilities from @lucky/shared/general utils for command replies and error handling
Use existing validators from packages/bot/src/utils/command/ for voice channel, queue, and guild validations in commands

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/lucky-discord-bot.mdc)

packages/bot/**/*.{ts,tsx}: Use useMainPlayer() from discord-player to access the player instance; do not instantiate player directly
Do not duplicate queue or player state outside Discord Player; use shared services from @lucky/shared for persistent data like track history and session information
Use errorLog and debugLog from @lucky/shared/utils for logging throughout the bot package
Use embed and reply utilities from @lucky/shared for consistent message formatting and error sanitization across the bot
Use services from @lucky/shared (DatabaseService, Redis client) for database and cache access; do not instantiate Prisma or Redis directly in the bot package

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/**

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

The bot package depends on shared and contains Discord bot commands and player handlers using Discord.js and Discord Player

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{js,mjs,ts,mts}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Use Node.js version ≥22 with ESM (ECMAScript modules) only; no CommonJS

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/functions/{general,music,download}/commands/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

packages/bot/src/functions/{general,music,download}/commands/**/*.ts: Apply .cursor/rules/lucky-discord-bot.mdc rules for Discord bot commands and player implementation
Use .cursor/skills/discord-commands/SKILL.md for implementing slash commands

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/functions/music/commands/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use .cursor/skills/music-queue-player/SKILL.md for play, queue, skip, volume commands and player lifecycle management

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use @lucky/shared for database, Redis, logging, and embed utilities instead of implementing them locally

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/functions/music/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)

Use existing voice/queue/guild validators before manipulating player or queue state

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: Use Discord.js and Discord Player for Discord bot commands and music queue/player functionality; use the discord-commands skill for slash command additions or changes
Use the typescript-advanced-types skill when working with TypeScript types, removing as any casts, and improving type safety
Do not hardcode secrets, IPs, or ports; use .env and docs/ for required environment variables
Add or adjust unit and integration tests when changing behavior; follow patterns in packages/*/tests and root tests/

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
packages/bot/**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

packages/bot/**/*.ts: Use the moderation-automod skill for moderation commands and AutoModService implementation; use event-handlers skill for bot event wiring (messageCreate, memberAdd, etc.)
Use the management-features skill for embed builder, custom commands, and auto-messages implementation

Files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/frontend.mdc)

**/*.{test,spec}.{js,jsx,ts,tsx}: Test behavior, not implementation. Prefer Testing Library utilities for testing React/React Native components.
For React Native tests: mock native modules and test component interactions and accessibility labels.

Files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
**/*.{test,spec}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/pattern.mdc)

**/*.{test,spec}.{ts,tsx,js,jsx}: Test behavior, not implementation details
Prefer unit tests for core logic; add integration tests at meaningful boundaries

Files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
**/*.{test,spec}.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/testing-quality.mdc)

**/*.{test,spec}.{js,ts,jsx,tsx}: Use Jest + a React testing library for unit and component tests as applicable
Test behavior, not implementation details

Files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
**/*.{spec,test}.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/quality.mdc)

**/*.{spec,test}.{ts,tsx,js,jsx}: Use Jest for unit and integration tests
Test behavior, not implementation details
Run unit, integration tests, and coverage report in CI quality checks

Files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (.cursor/rules/quality.mdc)

Unit tests must use naming convention *.spec.ts

Files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
{CHANGELOG.md,README.md}

📄 CodeRabbit inference engine (.cursor/rules/agent-rules.mdc)

ALWAYS update CHANGELOG.md and README.md as changes are made.

Files:

  • CHANGELOG.md
CHANGELOG.md

📄 CodeRabbit inference engine (.cursor/rules/templates-examples.mdc)

CHANGELOG.md must be updated with all changes in pull requests

Always update CHANGELOG.md with all code changes

Update CHANGELOG.md with all changes, include breaking changes documentation, and reference issues and PRs

Update CHANGELOG.md when behavior or setup changes; use Angular-style commit messages with scope

Files:

  • CHANGELOG.md
{CHANGELOG.md,docs/**}

📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)

Update CHANGELOG.md and relevant docs/ files when behavior or setup changes

Files:

  • CHANGELOG.md
🧠 Learnings (14)
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/music/commands/**/*.ts : Use `.cursor/skills/music-queue-player/SKILL.md` for play, queue, skip, volume commands and player lifecycle management

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/music/**/*.ts : Use existing voice/queue/guild validators before manipulating player or queue state

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📚 Learning: 2026-03-15T14:34:47.397Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T14:34:47.397Z
Learning: Applies to **/*.ts : Use Discord.js and Discord Player for Discord bot commands and music queue/player functionality; use the `discord-commands` skill for slash command additions or changes

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📚 Learning: 2026-03-09T20:20:47.877Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-discord-bot.mdc:0-0
Timestamp: 2026-03-09T20:20:47.877Z
Learning: Applies to packages/bot/**/*.{ts,tsx} : Do not duplicate queue or player state outside Discord Player; use shared services from `lucky/shared` for persistent data like track history and session information

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueEmbed.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts
  • packages/bot/src/functions/music/commands/queue/types.ts
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to {packages/*/tests/**/*.test.{js,ts},tests/**/*.test.{js,ts}} : Add or adjust unit and integration tests when changing behavior; follow existing patterns in `packages/*/tests` and root `tests/` directories

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to **/*.{spec,test}.{ts,tsx,js,jsx} : Test behavior, not implementation details

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-15T14:34:47.397Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T14:34:47.397Z
Learning: Applies to **/*.ts : Add or adjust unit and integration tests when changing behavior; follow patterns in `packages/*/tests` and root `tests/`

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-09T20:21:38.098Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-backend.mdc:0-0
Timestamp: 2026-03-09T20:21:38.098Z
Learning: Applies to packages/backend/tests/**/*.ts : Follow existing patterns for unit and integration tests in `packages/backend/tests/`

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to **/*.{spec,test}.{ts,tsx,js,jsx} : Use Jest for unit and integration tests

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-09T20:21:31.459Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/quality.mdc:0-0
Timestamp: 2026-03-09T20:21:31.459Z
Learning: Applies to tests/**/*.test.{ts,tsx,js,jsx} : Add integration tests where appropriate

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts
📚 Learning: 2026-03-09T20:22:25.255Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/workflow.mdc:0-0
Timestamp: 2026-03-09T20:22:25.255Z
Learning: Applies to CHANGELOG.md : Update CHANGELOG.md with all changes, include breaking changes documentation, and reference issues and PRs

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-03-15T14:34:47.397Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T14:34:47.397Z
Learning: Applies to CHANGELOG.md : Update CHANGELOG.md when behavior or setup changes; use Angular-style commit messages with scope

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-03-09T20:21:08.612Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-project.mdc:0-0
Timestamp: 2026-03-09T20:21:08.612Z
Learning: Applies to {CHANGELOG.md,docs/**} : Update `CHANGELOG.md` and relevant `docs/` files when behavior or setup changes

Applied to files:

  • CHANGELOG.md
📚 Learning: 2026-03-09T20:21:52.065Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-discord.mdc:0-0
Timestamp: 2026-03-09T20:21:52.065Z
Learning: Applies to packages/bot/src/functions/{general,music,download}/commands/**/*.ts : Apply `.cursor/rules/lucky-discord-bot.mdc` rules for Discord bot commands and player implementation

Applied to files:

  • packages/bot/src/functions/music/commands/queue/queueDisplay.ts

Comment thread CHANGELOG.md
Comment on lines +17 to +21
- `/queue show` upcoming tracks list now appends an inline **recommendation
reason tag** (e.g. `fresh artist rotation`, `similar title mood`) next to
autoplay-sourced tracks, making the autoplay decision transparent at a glance.
- **Now Playing** section in `/queue show` appends a `Recommended because:`
line when the current track originated from autoplay.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add the linked issue/PR reference to these changelog bullets.

These are the only new 2.6.19 entries without a traceability suffix, which makes it harder to tie the behavior back to issue #266 / PR #275.

📝 Suggested changelog tweak
 - `/queue show` upcoming tracks list now appends an inline **recommendation
   reason tag** (e.g. `fresh artist rotation`, `similar title mood`) next to
-  autoplay-sourced tracks, making the autoplay decision transparent at a glance.
+  autoplay-sourced tracks, making the autoplay decision transparent at a glance. (`#266`, PR `#275`)
 - **Now Playing** section in `/queue show` appends a `Recommended because:`
-  line when the current track originated from autoplay.
+  line when the current track originated from autoplay. (`#266`, PR `#275`)

Based on learnings, "Update CHANGELOG.md with all changes, include breaking changes documentation, and reference issues and PRs."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 17 - 21, Update the two 2.6.19 bullets in
CHANGELOG.md (the `/queue show` upcoming tracks bullet and the “Now Playing”
recommended line) to include the traceability suffix linking to issue `#266` and
PR `#275` (e.g., append “(see `#266`, `#275`)” or add a Markdown issue/PR link),
ensuring both entries for `/queue show` and `Now Playing` explicitly reference
the related issue and PR.

Comment on lines +41 to +160
describe('queueDisplay', () => {
beforeEach(() => {
jest.clearAllMocks()
getTrackInfoMock.mockResolvedValue({ duration: '3:30' })
isSimilarTitleMock.mockResolvedValue(false)
})

describe('formatTrackForDisplay', () => {
it('returns basic display info without recommendation reason for normal tracks', async () => {
const track = createTrack()

const result = await formatTrackForDisplay(track as any, 1, defaultOptions)

expect(result.title).toBe('Test Track')
expect(result.author).toBe('Test Artist')
expect(result.isAutoplay).toBeUndefined()
expect(result.recommendationReason).toBeUndefined()
})

it('surfaces isAutoplay and recommendationReason from track metadata', async () => {
const track = createTrack({
metadata: { isAutoplay: true, recommendationReason: 'fresh artist rotation' },
})

const result = await formatTrackForDisplay(track as any, 1, defaultOptions)

expect(result.isAutoplay).toBe(true)
expect(result.recommendationReason).toBe('fresh artist rotation')
})
})

describe('createTrackListDisplay', () => {
it('renders plain track entry without reason tag for non-autoplay tracks', async () => {
const track = createTrack()
const result = await createTrackListDisplay([track as any], defaultOptions)

expect(result).toContain('[Test Track]')
expect(result).not.toContain('_')
})

it('appends recommendation reason tag for autoplay tracks', async () => {
const track = createTrack({
metadata: { isAutoplay: true, recommendationReason: 'fresh artist rotation' },
})

const result = await createTrackListDisplay([track as any], defaultOptions)

expect(result).toContain('fresh artist rotation')
expect(result).toContain('_fresh artist rotation_')
})

it('does not append reason tag when isAutoplay is true but reason is empty', async () => {
const track = createTrack({
metadata: { isAutoplay: true, recommendationReason: '' },
})

const result = await createTrackListDisplay([track as any], defaultOptions)

expect(result).not.toContain('_')
})

it('shows overflow message when tracks exceed maxTracksToShow', async () => {
const tracks = Array.from({ length: 15 }, (_, i) =>
createTrack({ title: `Track ${i}` }),
)
const options = { ...defaultOptions, maxTracksToShow: 10 }
const result = await createTrackListDisplay(tracks as any[], options)

expect(result).toContain('5 more tracks')
})
})

describe('findSimilarTracksInQueue', () => {
it('returns tracks whose titles are similar to the current track', async () => {
const current = createTrack({ title: 'Amazing Song' })
const similar = createTrack({ title: 'Amazing Song (Remix)' })
const different = createTrack({ title: 'Something Else' })

isSimilarTitleMock
.mockResolvedValueOnce(true)
.mockResolvedValueOnce(false)

const result = await findSimilarTracksInQueue(
current as any,
[similar as any, different as any],
)

expect(result).toHaveLength(1)
expect(result[0]).toBe(similar)
})

it('returns empty array when no tracks are similar', async () => {
const current = createTrack({ title: 'Amazing Song' })
const unrelated = createTrack({ title: 'Completely Different' })

isSimilarTitleMock.mockResolvedValue(false)

const result = await findSimilarTracksInQueue(current as any, [unrelated as any])

expect(result).toHaveLength(0)
})
})

describe('createQueueSummary', () => {
it('returns total tracks and duration without position when currentPosition is 0', () => {
const result = createQueueSummary(10, '45:00', 0)

expect(result).toContain('**Total Tracks:** 10')
expect(result).toContain('**Total Duration:** 45:00')
expect(result).not.toContain('Current Position')
})

it('includes current position formatted as M:SS when currentPosition is greater than 0', () => {
const result = createQueueSummary(5, '20:00', 90)

expect(result).toContain('**Total Tracks:** 5')
expect(result).toContain('**Total Duration:** 20:00')
expect(result).toContain('**Current Position:** 1:30')
})
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search the bot test tree for coverage of the new now-playing recommendation branch.
rg -n --glob '*.{spec,test}.ts' "createQueueEmbed|Recommended because:" packages/bot

Repository: LucasSantana-Dev/Lucky

Length of output: 708


🏁 Script executed:

#!/bin/bash
# Search for queueEmbed spec files and check the implementation
fd -e 'spec.ts' -e 'test.ts' 'queueEmbed' packages/bot

# Also check if queueEmbed.ts exists and see its structure
fd -e 'ts' -e 'tsx' 'queueEmbed' packages/bot | head -20

Repository: LucasSantana-Dev/Lucky

Length of output: 127


🏁 Script executed:

#!/bin/bash
# Read the queueEmbed.ts file
cat -n packages/bot/src/functions/music/commands/queue/queueEmbed.ts

Repository: LucasSantana-Dev/Lucky

Length of output: 5090


Add unit test for the new autoplay recommendation branch in createQueueEmbed().

The queueDisplay.spec.ts suite covers queue-row display helpers but not the embed layer. The new Recommended because: branch in queueEmbed.ts (lines 23–26) is untested in isolation. Add a focused test for addCurrentTrackInfo() that verifies the recommendation reason is rendered when metadata.isAutoplay and metadata.recommendationReason are both set.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/queue/queueDisplay.spec.ts` around
lines 41 - 160, Add a unit test that targets the embed layer: call
addCurrentTrackInfo (from queueEmbed.ts / createQueueEmbed flow) with a track
whose metadata includes isAutoplay: true and recommendationReason: 'fresh artist
rotation', then assert the returned/embed description contains the "Recommended
because:" label and the recommendation text; ensure you import or mock any
dependencies used by addCurrentTrackInfo (e.g., getTrackInfo or formatting
helpers) and place the test alongside the other queueDisplay specs so it runs
with the suite.

Comment on lines +44 to +48
const reasonTag =
trackInfo.isAutoplay && trackInfo.recommendationReason
? ` — _${trackInfo.recommendationReason}_`
: ''
const trackDisplay = `${i + 1}. [${trackInfo.title}](${trackInfo.url}) - ${trackInfo.author} (${trackInfo.duration})${reasonTag}`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Truncate the inline reason tag before rendering it.

Issue #266 calls for a truncated queue tag, but this prints the full recommendationReason. Longer labels will quickly take over the queue row instead of behaving like a compact tag.

✂️ Suggested fix
-        const reasonTag =
-            trackInfo.isAutoplay && trackInfo.recommendationReason
-                ? ` — _${trackInfo.recommendationReason}_`
-                : ''
+        const normalizedReason = trackInfo.recommendationReason?.trim()
+        const truncatedReason =
+            normalizedReason && normalizedReason.length > 24
+                ? `${normalizedReason.slice(0, 23)}…`
+                : normalizedReason
+        const reasonTag =
+            trackInfo.isAutoplay && truncatedReason
+                ? ` — _${truncatedReason}_`
+                : ''
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bot/src/functions/music/commands/queue/queueDisplay.ts` around lines
44 - 48, The inline reason tag currently uses trackInfo.recommendationReason
raw; update the logic that builds reasonTag (the ternary that checks
trackInfo.isAutoplay && trackInfo.recommendationReason) to truncate
recommendationReason to a fixed max length (e.g., 30 chars) and append an
ellipsis when truncated, keeping the existing formatting (the " — _..._"
italics/underscores) so trackDisplay remains `${i + 1}.
[${trackInfo.title}](${trackInfo.url}) - ${trackInfo.author}
(${trackInfo.duration})${reasonTag}`; implement truncation either inline (using
slice/substring and length check) or via a small helper function (e.g.,
truncateReason) and use that helper when composing reasonTag.

LucasSantana-Dev and others added 3 commits March 15, 2026 17:38
Cover createQueueEmbed, createEmptyQueueEmbed, and createQueueErrorEmbed.
Key cases: now-playing field with/without autoplay reason line, thumbnail
set/skip, upcoming tracks populated/empty, stats fields, option flags.
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 1565542 into main Mar 15, 2026
15 checks passed
LucasSantana-Dev added a commit that referenced this pull request Mar 15, 2026
- Clamp recommendationReason to 40 chars with ellipsis before rendering
  in queueDisplay.ts to prevent long tags from dominating queue row
- Append (#266, #275) traceability to both CHANGELOG entries for the
  recommendation reason tag feature

Resolves CodeRabbit feedback on PR #275
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* feat(bot): show recommendation reason tags in queue display (#266)

* test(bot): add coverage for findSimilarTracksInQueue and createQueueSummary

* test(bot): add queueEmbed unit tests for reason-tag coverage

Cover createQueueEmbed, createEmptyQueueEmbed, and createQueueErrorEmbed.
Key cases: now-playing field with/without autoplay reason line, thumbnail
set/skip, upcoming tracks populated/empty, stats fields, option flags.

---------

Co-authored-by: LucasSantana-Dev <LucasSantana-Dev@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — f828cabd 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): recommendation reason tags ("why this track")

1 participant