Repository navigation
feat(bot): show recommendation reason tags in queue display - #275
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for regal-bunny-0c8efe ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Rate limit exceeded
⌛ 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 (6)
📝 WalkthroughWalkthroughThis PR extends the queue and now-playing display functionality to show recommendation reason tags for autoplay-sourced tracks. The changes add Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
bd10e6a to
be99ea6
Compare
There was a problem hiding this comment.
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.tsalready 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
📒 Files selected for processing (5)
CHANGELOG.mdpackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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 enforcedImplement 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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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. ThrowError(or typed subclasses) with descriptive messages
Include causal error ascausewhen 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)
MarkretryablevsnonRetryableerrors 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, andaria-*attributes as needed.
React Native accessibility: use accessibility props (accessible,accessibilityLabel), proper roles and labels.
Identify and extract repetitive UI components proactively tocomponents/with clear props and minimal coupling.
Web styles: prefer co-located styles or design system tokens; avoid global style leakage.
React Native styles: preferStyleSheet.create, design tokens, and theme providers; avoid in...
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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 usinganytype in TypeScript. If unavoidable, useunknownwith type guards and justify with a code comment
Preferinterfacefor defining public object shapes in TypeScript, usetypefor unions and utility types
Use TypeScript utility types such asPartial,Pick,Omit,Readonly, andRecordwhen appropriate
UseI{Name}naming convention for interfaces in TypeScript
UseT{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 useanytypes - ESLint enforces this at error level
**/*.{ts,tsx}: Prefer types over interfaces for most cases
Don't ever useany- type safety always
Avoid enums; use const objects instead
For complex types, create a separate file to declare them and import them
Avoid usinganytype; if unavoidable, useunknownwith type guards and justify with code comment
Preferinterfacefor public API shapes; usetypefor unions and utility types
Use TypeScript utility types (Partial, Pick, Omit, Readonly, Record)Use the
prisma-redis-luckyskill when adding or modifying database schema, migrations, or Redis operations in the shared package
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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 includedata(slash builder),execute, andcategoryproperties exported frompackages/bot/src/models/Command.ts
Use@discordjs/buildersfor building thedata(SlashCommandBuilder) in command definitions
Commandexecutefunction must receive{ interaction, client }parameters fromCommandExecuteParamstype
UseinteractionReplyandcreateUserFriendlyErrorutilities from@lucky/shared/generalutils for command replies and error handling
Use existing validators frompackages/bot/src/utils/command/for voice channel, queue, and guild validations in commands
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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}: UseuseMainPlayer()fromdiscord-playerto access the player instance; do not instantiate player directly
Do not duplicate queue or player state outside Discord Player; use shared services from@lucky/sharedfor persistent data like track history and session information
UseerrorLoganddebugLogfrom@lucky/shared/utilsfor logging throughout the bot package
Use embed and reply utilities from@lucky/sharedfor 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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/bot/src/functions/music/commands/queue/types.ts
packages/bot/**
📄 CodeRabbit inference engine (.cursor/rules/lucky-project.mdc)
The
botpackage depends onsharedand contains Discord bot commands and player handlers using Discord.js and Discord Player
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.mdcrules for Discord bot commands and player implementation
Use.cursor/skills/discord-commands/SKILL.mdfor implementing slash commands
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.mdfor play, queue, skip, volume commands and player lifecycle management
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/bot/src/functions/music/commands/queue/types.ts
packages/bot/src/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/subagent-discord.mdc)
Use
@lucky/sharedfor database, Redis, logging, and embed utilities instead of implementing them locally
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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 thediscord-commandsskill for slash command additions or changes
Use thetypescript-advanced-typesskill when working with TypeScript types, removingas anycasts, and improving type safety
Do not hardcode secrets, IPs, or ports; use.envanddocs/for required environment variables
Add or adjust unit and integration tests when changing behavior; follow patterns inpackages/*/testsand roottests/
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/bot/src/functions/music/commands/queue/types.ts
packages/bot/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
packages/bot/**/*.ts: Use themoderation-automodskill for moderation commands and AutoModService implementation; useevent-handlersskill for bot event wiring (messageCreate, memberAdd, etc.)
Use themanagement-featuresskill for embed builder, custom commands, and auto-messages implementation
Files:
packages/bot/src/functions/music/commands/queue/queueEmbed.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.mdand relevantdocs/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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.tspackages/bot/src/functions/music/commands/queue/queueDisplay.spec.tspackages/bot/src/functions/music/commands/queue/queueDisplay.tspackages/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
| - `/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. |
There was a problem hiding this comment.
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.
| 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') | ||
| }) | ||
| }) |
There was a problem hiding this comment.
🧩 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/botRepository: 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 -20Repository: 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.tsRepository: 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.
| const reasonTag = | ||
| trackInfo.isAutoplay && trackInfo.recommendationReason | ||
| ? ` — _${trackInfo.recommendationReason}_` | ||
| : '' | ||
| const trackDisplay = `${i + 1}. [${trackInfo.title}](${trackInfo.url}) - ${trackInfo.author} (${trackInfo.duration})${reasonTag}` |
There was a problem hiding this comment.
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.
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.
14277b8 to
f828cab
Compare
|
|
* 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>



Summary
Closes #266
/queue showupcoming 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.Recommended because:line when the current track originated from autoplay.isAutoplayandrecommendationReasonfields toTrackDisplayInfotype, surfaced from track metadata set bymarkAsAutoplayTrack().queueDisplay.spec.ts(364 total bot tests pass, 61 suites).Summary by CodeRabbit