Skip to content

fix(web): harden automod, twitch, and music regressions - #368

Merged
LucasSantana-Dev merged 7 commits into
mainfrom
chore/replit-changes
Mar 27, 2026
Merged

LucasSantana-Dev merged 7 commits into
mainfrom
chore/replit-changes

Conversation

@LucasSantana-Dev

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

Copy link
Copy Markdown
Owner

Summary

  • harden AutoMod against malformed successful settings/template payloads so the page no longer crashes on missing arrays
  • preserve backend Twitch error messages in the web UI and restore backend music route registration for /api/guilds/:guildId/music/*
  • make autoplay recommendation replenishment resilient when candidate tracks are missing a URL and replace the repeat-mode magic number with the enum

Verification

  • npm run test:frontend -- AutoMod
  • npm run test:frontend -- TwitchNotifications
  • npm run test --workspace=packages/backend -- tests/unit/routes/index.test.ts
  • npm run test --workspace=packages/backend -- musicState.test.ts
  • npm run test --workspace=packages/bot -- queueManipulation.spec.ts
  • npm run test --workspace=packages/bot -- trackHandlers.spec.ts

Notes

  • this branch intentionally includes only the runtime-fix files and excludes unrelated local edits from the dirty root checkout

Summary by CodeRabbit

  • New Features

    • Music backend routes are now registered and available.
  • Bug Fixes

    • Auto-Moderation page now falls back to safe default settings for malformed API responses.
    • Twitch Notifications surfaces backend error text when available.
  • Refactor

    • Autoplay/queue selection simplified: liked-share caps and duration‑similarity scoring removed, affecting recommendation mix.
  • Style

    • Various UI text, heading styles and accessibility labels refined across pages.

@vercel

vercel Bot commented Mar 26, 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 27, 2026 0:01am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad83a65f-d246-4127-a461-82f3015c6857

📥 Commits

Reviewing files that changed from the base of the PR and between 7d00d6c and d0d570b.

📒 Files selected for processing (4)
  • packages/frontend/src/pages/Login.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/ServersPage.test.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/frontend/src/pages/Login.test.tsx
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{jsx,tsx}

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

**/*.{jsx,tsx}: Use toasts/snackbars for transient errors; avoid blocking modals for non-critical issues in React/React Native UI
Debounce/suppress duplicate toasts to prevent spam
Provide retry/refresh actions when meaningful (e.g., network failure) in error UI
Use error boundaries for render-time exceptions; show fallback UI in React
Respect accessibility: toasts should be announced (aria-live on web; accessibility hints on React Native)

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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)

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
packages/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/frontend/src/**/*.{ts,tsx}: Frontend errors are created by Axios interceptor and should be of type ApiError with status and details from backend
Frontend uses path alias @/ mapped to src/ - use this alias for all imports from the src directory

Do not depend on @lucky/shared package in frontend code; make API calls to backend via configured base URL (env)

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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

Never hardcode secrets, IPs, or ports; use .env and docs/ for required configuration variables

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
packages/frontend/src/pages/**/*.{ts,tsx}

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

Organize pages in packages/frontend/src/pages/ directory (e.g., Login, Dashboard, Config, Features, ServersPage)

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
packages/frontend/src/{components,pages}/**/*.{ts,tsx}

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

Use React functional components and hooks; keep components small and focused

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
packages/frontend/src/{components,pages}/**/*.tsx

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

Follow existing styling approach (e.g., Tailwind if present); avoid inline styles for layout and theming

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
packages/frontend/**

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

The frontend package uses React with Vite and must not depend on the shared package

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/*.{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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
**/[A-Z]*.{ts,tsx,jsx}

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

Components must use PascalCase naming

Files:

  • packages/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
🧠 Learnings (11)
📓 Common learnings
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
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
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on music queue/player features (play/queue/skip/volume, player lifecycle), use the `music-queue-player` skill
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
📚 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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
📚 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/frontend/src/pages/ServersPage.test.tsx
  • packages/frontend/src/pages/Music.test.tsx
  • packages/frontend/src/pages/Moderation.test.tsx
📚 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/frontend/src/pages/Music.test.tsx
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on music queue/player features (play/queue/skip/volume, player lifecycle), use the `music-queue-player` skill

Applied to files:

  • packages/frontend/src/pages/Music.test.tsx
📚 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/frontend/src/pages/Music.test.tsx
📚 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/frontend/src/pages/Music.test.tsx
📚 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/frontend/src/pages/Moderation.test.tsx
📚 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/frontend/src/pages/Moderation.test.tsx
📚 Learning: 2026-03-09T20:20:56.356Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/tests/**/*.{ts,tsx,js} : Write tests in `packages/frontend/tests/` using existing test patterns (e.g., Playwright for e2e if configured)

Applied to files:

  • packages/frontend/src/pages/Moderation.test.tsx
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/tests/**/*.{ts,tsx} : Organize tests in `packages/backend/tests/` with unit tests under `unit/` and integration tests under `integration/`, following existing patterns with fixtures and setup

Applied to files:

  • packages/frontend/src/pages/Moderation.test.tsx
🔇 Additional comments (4)
packages/frontend/src/pages/ServersPage.test.tsx (1)

87-96: Good assertion tightening for the visible server summary.

This checks the full user-facing summary string and better protects against regressions in count/label output.

packages/frontend/src/pages/Music.test.tsx (2)

46-46: Line 46: Good mock-surface alignment with useMusicPlayer.

Adding moveTrack keeps the mocked player consistent with how MusicPage uses it and avoids undefined-method regressions in this test setup.


65-65: Line 65: Assertion now matches current empty-state copy.

Nice sync with MusicPage’s rendered no-server message, so this test now validates the intended user-facing behavior.

packages/frontend/src/pages/Moderation.test.tsx (1)

265-267: LGTM!

Using a regex matcher makes the pagination assertion more resilient to formatting variations (e.g., different dash characters or spacing), which aligns with the PR objective of hardening frontend tests. The pattern appropriately tests the behavior without being brittle to exact text formatting.


📝 Walkthrough

Walkthrough

Registers a new music route in the backend, removes liked-track and duration-similarity logic from the bot autoplay candidate selection (and replaces a magic repeat-mode value with an enum), and adds defensive normalization and improved error messaging in frontend AutoMod and Twitch notifications.

Changes

Cohort / File(s) Summary
Backend Route Registration
packages/backend/src/routes/index.ts, packages/backend/tests/unit/routes/index.test.ts
Imports and registers setupMusicRoutes in the route setup array and updates tests to mock and assert setupMusicRoutes(app) is called.
Bot autoplay / queue logic
packages/bot/src/handlers/player/trackHandlers.ts, packages/bot/src/utils/music/queueManipulation.ts, packages/bot/src/utils/music/queueManipulation.spec.ts
Replaces magic queue.repeatMode === 3 with QueueRepeatMode.AUTOPLAY; removes MAX_LIKED_TRACK_SHARE and all liked-track share selection logic; drops isLiked from scored candidates; removes duration-similarity scoring and session-novelty reason emissions; simplifies duplicate checks; test cases adjusted/removed and a new autoplay-candidate test added.
Frontend AutoMod validation & styling
packages/frontend/src/pages/AutoMod.tsx, packages/frontend/src/pages/AutoMod.test.tsx
Adds normalizeAutoModSettings() and normalizeStringArray() to defensively merge/validate settings with defaults; wiring updated to use normalization on load/apply; heading/className formatting adjusted and tests updated with a new malformed-payload fallback test.
Frontend Twitch error handling & styling
packages/frontend/src/pages/TwitchNotifications.tsx, packages/frontend/src/pages/TwitchNotifications.test.tsx
Introduces getErrorMessage() and ApiError use to display backend error messages; updated handlers to use the helper and a new test verifies backend 404 error text surface; minor styling/formatting tweaks.
Frontend tests & accessibility updates
packages/frontend/src/components/.../ServerCard.test.tsx, packages/frontend/src/components/Layout/Layout.test.tsx, packages/frontend/src/components/Layout/Sidebar.test.tsx, packages/frontend/src/pages/.../*.test.tsx
Multiple test updates to reflect changed accessible names/roles/aria attributes, badge text/variants, DOM structure, and copy (Login, Moderation, Music, ServersPage); some mocks extended (e.g., moveTrack, useGuildStore).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 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 changes: hardening AutoMod, Twitch, and music-related regressions across the codebase.

✏️ 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 chore/replit-changes

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/frontend/src/pages/TwitchNotifications.test.tsx (1)

374-375: ⚠️ Potential issue | 🔴 Critical

Missing closing parenthesis for describe block causes CI failure.

The describe block opened at line 86 with describe('TwitchNotificationsPage', () => { is missing its closing ). This is the direct cause of the pipeline failures: TS1005: ')' expected and ESLint parsing error: ')' expected.

🐛 Proposed fix
     })
-}
+})
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/src/pages/TwitchNotifications.test.tsx` around lines 374 -
375, The test file is missing the closing parenthesis and brace for the
top-level describe block opened as describe('TwitchNotificationsPage', () => { —
add the corresponding closing "});" to terminate that describe block so the
parser sees the final ")" and "}" for describe; locate the
describe('TwitchNotificationsPage', () => { block and append the matching
closing characters (});) at the end of the file or just after its inner tests to
restore valid syntax.
packages/frontend/src/pages/AutoMod.tsx (1)

1-897: ⚠️ Potential issue | 🟠 Major

File exceeds 250-line maximum and requires refactoring.

AutoMod.tsx is 897 lines, violating the explicit requirement that "Files must not exceed 250 lines." Extract helper components (FilterCard, NumberInput, TagList, ChannelPicker, RolePicker) into separate files within packages/frontend/src/components/, keeping the main AutoModPage component focused in the page file. This aligns with guidelines to identify and extract repetitive UI components proactively.

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

In `@packages/frontend/src/pages/AutoMod.tsx` around lines 1 - 897, The file
AutoMod.tsx exceeds the 250-line limit; extract the helper UI components
FilterCard, NumberInput, TagList, ChannelPicker, and RolePicker into individual
component files (e.g., ComponentName.tsx) under
packages/frontend/src/components/, export them as default (or named) components,
move only their local prop interfaces into those files or import shared types
(AutoModSettings, GuildChannelOption, GuildRoleOption) from the existing types,
and update AutoMod.tsx to import these components and their props/types; ensure
each extracted file preserves the same props (e.g., FilterCard props,
NumberInput props, TagList props, ChannelPicker
selectedIds/channels/onAdd/onRemove, RolePicker
selectedIds/roles/onAdd/onRemove) and any utility usages like cn and icons are
imported where needed so the main AutoModPage can be reduced below 250 lines.
🧹 Nitpick comments (1)
packages/frontend/src/pages/AutoMod.tsx (1)

398-410: Defensive optional chaining addresses backend/frontend type mismatch.

The use of res.data?.settings correctly handles the case where the backend returns null directly (per AutoModService.getSettings() returning AutoModSettings | null) while the frontend type declares a required settings field.

Consider aligning the frontend API type with the actual backend response shape to make this contract explicit rather than relying on defensive coding alone.

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

In `@packages/frontend/src/pages/AutoMod.tsx` around lines 398 - 410, The current
code defensively uses res.data?.settings in the promise chain for AutoMod
settings (in the setSettings(normalizeAutoModSettings(...)) call), masking a
mismatch between the frontend response type and the backend which can return
null; update the frontend API response type for AutoModService.getSettings() to
reflect the actual shape (e.g., allow settings: AutoModSettings | null) so
callers like the promise handler and normalizeAutoModSettings receive an
explicit nullable type, then fix any affected call sites (including the code
that currently uses res.data?.settings and setSettings) to handle the nullable
settings consistently rather than relying on optional chaining on an incorrectly
typed non-optional field.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/backend/tests/unit/routes/index.test.ts`:
- Line 196: The test file ends with a stray closing brace that closes the
describe block but leaves the describe callback arrow function unclosed; open
the file where the top-level "describe("..." , () => {" block is declared and
add the missing closing brace and parenthesis to properly terminate that
callback (i.e., ensure the matching "});" or "}" + ")" is present to close the
describe callback), fixing the unmatched describe(...) closure in the
tests/unit/routes/index.test.ts file.

In `@packages/frontend/src/pages/AutoMod.tsx`:
- Around line 369-377: The createdAt/updatedAt normalization uses instanceof
Date which fails for JSON strings; update the logic in the settings
normalization (references: createdAt, updatedAt, settings, DEFAULT_SETTINGS) to
detect string timestamps and parse them into Date objects (e.g., use new
Date(...) and validate with isNaN) and only fall back to DEFAULT_SETTINGS when
the value is missing or invalid; alternatively remove these fields if timestamps
are unused and document that choice.

---

Outside diff comments:
In `@packages/frontend/src/pages/AutoMod.tsx`:
- Around line 1-897: The file AutoMod.tsx exceeds the 250-line limit; extract
the helper UI components FilterCard, NumberInput, TagList, ChannelPicker, and
RolePicker into individual component files (e.g., ComponentName.tsx) under
packages/frontend/src/components/, export them as default (or named) components,
move only their local prop interfaces into those files or import shared types
(AutoModSettings, GuildChannelOption, GuildRoleOption) from the existing types,
and update AutoMod.tsx to import these components and their props/types; ensure
each extracted file preserves the same props (e.g., FilterCard props,
NumberInput props, TagList props, ChannelPicker
selectedIds/channels/onAdd/onRemove, RolePicker
selectedIds/roles/onAdd/onRemove) and any utility usages like cn and icons are
imported where needed so the main AutoModPage can be reduced below 250 lines.

In `@packages/frontend/src/pages/TwitchNotifications.test.tsx`:
- Around line 374-375: The test file is missing the closing parenthesis and
brace for the top-level describe block opened as
describe('TwitchNotificationsPage', () => { — add the corresponding closing
"});" to terminate that describe block so the parser sees the final ")" and "}"
for describe; locate the describe('TwitchNotificationsPage', () => { block and
append the matching closing characters (});) at the end of the file or just
after its inner tests to restore valid syntax.

---

Nitpick comments:
In `@packages/frontend/src/pages/AutoMod.tsx`:
- Around line 398-410: The current code defensively uses res.data?.settings in
the promise chain for AutoMod settings (in the
setSettings(normalizeAutoModSettings(...)) call), masking a mismatch between the
frontend response type and the backend which can return null; update the
frontend API response type for AutoModService.getSettings() to reflect the
actual shape (e.g., allow settings: AutoModSettings | null) so callers like the
promise handler and normalizeAutoModSettings receive an explicit nullable type,
then fix any affected call sites (including the code that currently uses
res.data?.settings and setSettings) to handle the nullable settings consistently
rather than relying on optional chaining on an incorrectly typed non-optional
field.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 982b16d1-0d84-4066-8b10-76c7bed2e9a8

📥 Commits

Reviewing files that changed from the base of the PR and between cf7b568 and 64cad6c.

📒 Files selected for processing (9)
  • packages/backend/src/routes/index.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/bot/src/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/AutoMod.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
📜 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). (1)
  • GitHub Check: SonarCloud Scan
🧰 Additional context used
📓 Path-based instructions (33)
**/*.{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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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)

Files:

  • packages/bot/src/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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

Never hardcode secrets, IPs, or ports; use .env and docs/ for required configuration variables

Files:

  • packages/bot/src/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.ts
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
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/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
packages/bot/src/handlers/player/**/*.{ts,tsx}

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

Track handling, errors, and lifecycle must be managed through dedicated handlers in packages/bot/src/handlers/player/ (trackHandlers, errorHandlers, lifecycleHandlers)

Files:

  • packages/bot/src/handlers/player/trackHandlers.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/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.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/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
**/index.ts

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

Use index.ts only to re-export a small, intentional surface per module

Files:

  • packages/backend/src/routes/index.ts
packages/backend/src/routes/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

packages/backend/src/routes/**/*.ts: Backend route handlers must use asyncHandler wrapper and throw AppError.xxx() instead of manual try/catch blocks
Rate limiting: use apiLimiter (100/min), authLimiter (20/15min), or writeLimiter (30/min) as appropriate

Place routes under packages/backend/src/routes/ directory

Files:

  • packages/backend/src/routes/index.ts
packages/backend/src/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

packages/backend/src/**/*.ts: Validation must use Zod schemas in backend/src/schemas/ and be applied via validateBody, validateParams, or validateQuery
Do not reassign req.query in Express middleware - it is read-only in Express 5

Files:

  • packages/backend/src/routes/index.ts
packages/backend/src/**/*.{ts,tsx}

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

packages/backend/src/**/*.{ts,tsx}: Use shared config and env from @lucky/shared when needed; avoid duplicating env parsing in backend code
Keep tokens and secrets in environment variables only; never hardcode or expose in code

Files:

  • packages/backend/src/routes/index.ts
packages/backend/src/{routes,middleware}/**/*.{ts,tsx}

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

Return consistent JSON error responses with appropriate HTTP status codes; do not expose stack traces or secrets in responses

Files:

  • packages/backend/src/routes/index.ts
packages/backend/src/routes/**/*.{ts,tsx}

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

Structure routes in packages/backend/src/routes/ directory with separate files for auth, guilds, toggles, and index routes

Files:

  • packages/backend/src/routes/index.ts
packages/backend/**

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

The backend package depends on shared and contains Express API with auth and guild routes

Files:

  • packages/backend/src/routes/index.ts
  • packages/backend/tests/unit/routes/index.test.ts
packages/backend/**/*.ts

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

packages/backend/**/*.ts: Apply .cursor/rules/lucky-backend-api.mdc for structure and conventions when acting as backend specialist
Use .cursor/skills/backend-express/SKILL.md for Express routes, middleware, and services when acting as backend specialist
Use @lucky/shared for config and DB/Redis when needed in backend code

Files:

  • packages/backend/src/routes/index.ts
  • packages/backend/tests/unit/routes/index.test.ts
**/*.{jsx,tsx}

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

**/*.{jsx,tsx}: Use toasts/snackbars for transient errors; avoid blocking modals for non-critical issues in React/React Native UI
Debounce/suppress duplicate toasts to prevent spam
Provide retry/refresh actions when meaningful (e.g., network failure) in error UI
Use error boundaries for render-time exceptions; show fallback UI in React
Respect accessibility: toasts should be announced (aria-live on web; accessibility hints on React Native)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
packages/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/frontend/src/**/*.{ts,tsx}: Frontend errors are created by Axios interceptor and should be of type ApiError with status and details from backend
Frontend uses path alias @/ mapped to src/ - use this alias for all imports from the src directory

Do not depend on @lucky/shared package in frontend code; make API calls to backend via configured base URL (env)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
packages/frontend/src/pages/**/*.{ts,tsx}

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

Organize pages in packages/frontend/src/pages/ directory (e.g., Login, Dashboard, Config, Features, ServersPage)

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
packages/frontend/src/{components,pages}/**/*.{ts,tsx}

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

Use React functional components and hooks; keep components small and focused

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
packages/frontend/src/{components,pages}/**/*.tsx

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

Follow existing styling approach (e.g., Tailwind if present); avoid inline styles for layout and theming

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
packages/frontend/**

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

The frontend package uses React with Vite and must not depend on the shared package

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.{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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
**/[A-Z]*.{ts,tsx,jsx}

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

Components must use PascalCase naming

Files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.tsx
  • packages/frontend/src/pages/AutoMod.tsx
**/*.spec.ts

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

Unit tests must use naming convention *.spec.ts

Files:

  • packages/bot/src/utils/music/queueManipulation.spec.ts
packages/backend/tests/**/*.{ts,tsx}

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

Organize tests in packages/backend/tests/ with unit tests under unit/ and integration tests under integration/, following existing patterns with fixtures and setup

Files:

  • packages/backend/tests/unit/routes/index.test.ts
{packages/*/tests/**/*.test.{js,ts},tests/**/*.test.{js,ts}}

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

Add or adjust unit and integration tests when changing behavior; follow existing patterns in packages/*/tests and root tests/ directories

Files:

  • packages/backend/tests/unit/routes/index.test.ts
packages/backend/tests/**/*.ts

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

Follow existing patterns for unit and integration tests in packages/backend/tests/

Files:

  • packages/backend/tests/unit/routes/index.test.ts
🧠 Learnings (30)
📓 Common learnings
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
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
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on music queue/player features (play/queue/skip/volume, player lifecycle), use the `music-queue-player` skill
📚 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/src/handlers/player/**/*.{ts,tsx} : Track handling, errors, and lifecycle must be managed through dedicated handlers in `packages/bot/src/handlers/player/` (trackHandlers, errorHandlers, lifecycleHandlers)

Applied to files:

  • packages/bot/src/handlers/player/trackHandlers.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/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
  • packages/backend/tests/unit/routes/index.test.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/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/handlers/player/trackHandlers.ts
  • packages/backend/src/routes/index.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.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} : Use `useMainPlayer()` from `discord-player` to access the player instance; do not instantiate player directly

Applied to files:

  • packages/bot/src/handlers/player/trackHandlers.ts
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on music queue/player features (play/queue/skip/volume, player lifecycle), use the `music-queue-player` skill

Applied to files:

  • packages/bot/src/handlers/player/trackHandlers.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/routes/**/*.{ts,tsx} : Structure routes in `packages/backend/src/routes/` directory with separate files for auth, guilds, toggles, and index routes

Applied to files:

  • packages/backend/src/routes/index.ts
  • packages/backend/tests/unit/routes/index.test.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/src/routes/**/*.ts : Place routes under `packages/backend/src/routes/` directory

Applied to files:

  • packages/backend/src/routes/index.ts
  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/{server,index}.{ts,tsx} : Backend entry point is `packages/backend/src/server.ts` which imports from `index.ts`

Applied to files:

  • packages/backend/src/routes/index.ts
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/tests/**/*.{ts,tsx} : Organize tests in `packages/backend/tests/` with unit tests under `unit/` and integration tests under `integration/`, following existing patterns with fixtures and setup

Applied to files:

  • packages/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/{services,middleware}/**/*.{ts,tsx} : Use SessionService in middleware for session handling; keep session and auth logic centralized

Applied to files:

  • packages/backend/src/routes/index.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/backend/src/routes/index.ts
  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.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/backend/** : The `backend` package depends on `shared` and contains Express API with auth and guild routes

Applied to files:

  • packages/backend/src/routes/index.ts
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/{services,middleware}/**/*.{ts,tsx} : Implement Discord OAuth for authentication in backend services

Applied to files:

  • packages/backend/src/routes/index.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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.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/frontend/src/pages/AutoMod.test.tsx
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.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/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-09T20:20:56.356Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/tests/**/*.{ts,tsx,js} : Write tests in `packages/frontend/tests/` using existing test patterns (e.g., Playwright for e2e if configured)

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: Add or adjust unit and integration tests when changing behavior; follow patterns in `packages/*/tests` and root `tests/` directories

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-09T20:21:58.991Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-frontend.mdc:0-0
Timestamp: 2026-03-09T20:21:58.991Z
Learning: Write unit and integration tests in `packages/frontend/tests`; use Playwright for E2E tests when changing user flows

Applied to files:

  • packages/frontend/src/pages/AutoMod.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📚 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/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-15T21:57:49.951Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on unit tests, Jest ESM mocks, or fixing disabled tests, use the `testing-lucky` skill

Applied to files:

  • packages/backend/tests/unit/routes/index.test.ts
📚 Learning: 2026-03-09T20:20:23.892Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-03-09T20:20:23.892Z
Learning: Applies to packages/frontend/src/**/*.{ts,tsx} : Frontend errors are created by Axios interceptor and should be of type `ApiError` with status and details from backend

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 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 src/**/*.{ts,tsx,jsx} : Implement error boundaries for render-time exceptions in frontend applications

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 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 src/**/*.{ts,tsx,js,jsx} : Use structured error reporting throughout the application

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 Learning: 2026-03-09T20:22:09.954Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/typescript.mdc:0-0
Timestamp: 2026-03-09T20:22:09.954Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Implement error handling and error logging

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 Learning: 2026-03-09T20:21:15.595Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-shared.mdc:0-0
Timestamp: 2026-03-09T20:21:15.595Z
Learning: Applies to packages/shared/**/*.ts : Use typed errors from `packages/shared/src/types/errors/` for domain failures; avoid using generic `Error` for application-specific failures

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/src/{routes,middleware}/**/*.{ts,tsx} : Return consistent JSON error responses with appropriate HTTP status codes; do not expose stack traces or secrets in responses

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
📚 Learning: 2026-03-09T20:20:56.356Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/src/{components,pages}/**/*.{ts,tsx} : Use React functional components and hooks; keep components small and focused

Applied to files:

  • packages/frontend/src/pages/TwitchNotifications.tsx
🪛 GitHub Actions: Bundle Size
packages/frontend/src/pages/TwitchNotifications.test.tsx

[error] 375-375: TypeScript compile error TS1005: ')' expected.

🪛 GitHub Actions: CI/CD Pipeline
packages/frontend/src/pages/AutoMod.test.tsx

[error] 1-1: Lint step failed: npm run lint --workspace=packages/frontend exited with code 1 (command: eslint . --config eslint.config.js --max-warnings 0).

packages/frontend/src/pages/TwitchNotifications.test.tsx

[error] 375-375: ESLint parsing error: ')' expected. Reported by ESLint while running eslint . --config eslint.config.js --max-warnings 0.


[error] 1-1: Lint step failed: npm run lint --workspace=packages/frontend exited with code 1 (command: eslint . --config eslint.config.js --max-warnings 0).

packages/frontend/src/pages/TwitchNotifications.tsx

[error] 1-1: Lint step failed: npm run lint --workspace=packages/frontend exited with code 1 (command: eslint . --config eslint.config.js --max-warnings 0).

packages/frontend/src/pages/AutoMod.tsx

[error] 1-1: Lint step failed: npm run lint --workspace=packages/frontend exited with code 1 (command: eslint . --config eslint.config.js --max-warnings 0).

🔇 Additional comments (16)
packages/bot/src/utils/music/queueManipulation.ts (3)

587-591: Good defensive fix for missing URLs.

The guard track.url && before checking excludedUrls.has(track.url) correctly allows tracks without a URL to pass through to the normalized key check. This aligns with the PR objective to make autoplay resilient when candidate tracks are missing a URL.


429-442: LGTM on the simplified selection loop.

The removal of liked-track share capping simplifies the logic while preserving artist and source diversity constraints. The iteration is straightforward and maintains the intended behavior.


398-414: Type consistency looks good.

The explicit object type { score: number; reason: string } for the recommendation parameter and matching return type in calculateRecommendationScore ensures type safety across the scoring pipeline.

packages/bot/src/handlers/player/trackHandlers.ts (1)

145-145: Good replacement of magic number with enum constant.

Using QueueRepeatMode.AUTOPLAY instead of the magic number 3 improves code readability and maintainability. This is consistent with usage elsewhere in the codebase (e.g., musicButtonHandler.ts).

packages/bot/src/utils/music/queueManipulation.spec.ts (1)

509-540: Good test coverage for URL-less track resilience.

This test directly validates the PR objective by ensuring tracks without a url property can still be added to the autoplay queue. The mock setup correctly omits url while providing id, title, and author, and the assertion verifies the track is added with proper autoplay metadata.

packages/frontend/src/pages/TwitchNotifications.test.tsx (1)

354-373: Good test coverage for backend error propagation.

This test properly validates that ApiError messages from the backend are surfaced to users. The mock setup and assertion pattern align well with existing tests in this file.

packages/frontend/src/pages/TwitchNotifications.tsx (4)

29-31: Clean error message extraction helper.

The getErrorMessage function correctly uses unknown type and instanceof check to safely extract ApiError.message or fall back to the provided default. This aligns with the project's ApiError design where the Axios interceptor creates ApiError instances with backend-provided messages.


192-194: Backend error messages now properly surfaced.

The updated catch block correctly extracts the backend error message (e.g., "Twitch user not found") via getErrorMessage, fulfilling the PR objective to preserve backend Twitch error messages in the UI.


204-206: Consistent error handling in handleRemove.

Same pattern applied correctly here. Both handlers now use the centralized getErrorMessage helper.


23-27: Good extraction of skeleton keys to a named constant.

Follows the UPPER_SNAKE_CASE convention for constants and improves readability of the renderNotifications function.

packages/frontend/src/pages/AutoMod.test.tsx (2)

206-213: Cleaner assertion pattern.

The refactored assertion with multi-line formatting and explicit payload extraction via mock.calls[0][1] is clearer than inline chaining.


467-482: Good coverage for malformed payload scenario.

This test validates the new normalizeAutoModSettings defensive behavior, ensuring the page gracefully falls back to defaults when the API returns a success response with settings: undefined.

Consider using expect(switches.every((s) => !s.ariaChecked)).toBe(true) or individual expect(switch).not.toBeChecked() assertions for more idiomatic Testing Library usage, though the current approach is consistent with the existing test at line 464.

packages/frontend/src/pages/AutoMod.tsx (2)

347-378: Solid defensive normalization approach.

The normalizeAutoModSettings function properly handles malformed API responses by merging with defaults and validating array fields. This addresses the PR objective to prevent page crashes when arrays are missing.


79-79: Styling class updates look consistent.

The replacement of type-* utilities with explicit text-sm font-semibold text-white / text-base font-semibold text-white / text-xl font-semibold text-white / text-2xl font-bold text-white classes is applied uniformly across headings.

Also applies to: 509-509, 544-544, 574-574, 606-606, 781-781

packages/backend/src/routes/index.ts (1)

17-17: Music route setup is correctly wired into bootstrap.

Importing and invoking setupMusicRoutes in routeSetups cleanly restores /api/guilds/:guildId/music/* route registration.

Also applies to: 71-71

packages/backend/tests/unit/routes/index.test.ts (1)

20-20: Good test coverage update for music route registration.

The added mock and assertion correctly extend setupRoutes coverage for setupMusicRoutes(app).

Also applies to: 91-94, 170-170

expect(featuresGuardCallOrder).toBeLessThan(firstRouteSetupOrder)
})
})
}

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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify whether the file ends with an unclosed describe() call.
tail -n 8 packages/backend/tests/unit/routes/index.test.ts

# Try parsing via ast-grep; syntax errors in TS/JS test file will fail parsing.
ast-grep --pattern 'describe($_, $_)' packages/backend/tests/unit/routes/index.test.ts

Repository: LucasSantana-Dev/Lucky

Length of output: 464


🏁 Script executed:

# Get line count and check context around line 196
wc -l packages/backend/tests/unit/routes/index.test.ts

# Show lines 185-196 with context
sed -n '185,196p' packages/backend/tests/unit/routes/index.test.ts

# Count describe blocks to verify matching
rg 'describe\(' packages/backend/tests/unit/routes/index.test.ts | wc -l
rg '^\s*}\)' packages/backend/tests/unit/routes/index.test.ts | wc -l

Repository: LucasSantana-Dev/Lucky

Length of output: 684


Fix unmatched describe(...) closure.

Line 196 ends the file with a bare } that closes only the describe block itself, but the describe callback arrow function () => { remains unclosed. The file ends with a syntax error.

🛠️ Proposed fix
-}
+})
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

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

In `@packages/backend/tests/unit/routes/index.test.ts` at line 196, The test file
ends with a stray closing brace that closes the describe block but leaves the
describe callback arrow function unclosed; open the file where the top-level
"describe("..." , () => {" block is declared and add the missing closing brace
and parenthesis to properly terminate that callback (i.e., ensure the matching
"});" or "}" + ")" is present to close the describe callback), fixing the
unmatched describe(...) closure in the tests/unit/routes/index.test.ts file.

Comment on lines +369 to +377
createdAt:
settings?.createdAt instanceof Date
? settings.createdAt
: DEFAULT_SETTINGS.createdAt,
updatedAt:
settings?.updatedAt instanceof Date
? settings.updatedAt
: DEFAULT_SETTINGS.updatedAt,
}

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

instanceof Date check will always fail for JSON-deserialized responses.

API responses deserialize createdAt/updatedAt as ISO 8601 strings, not Date objects. The instanceof Date check will always be false for real API responses, causing fallback to DEFAULT_SETTINGS.createdAt (which is new Date() at module load time, not the actual persisted timestamp).

If these timestamps are needed for display or logic, parse the string:

Proposed fix
         createdAt:
-            settings?.createdAt instanceof Date
-                ? settings.createdAt
+            settings?.createdAt
+                ? new Date(settings.createdAt)
                 : DEFAULT_SETTINGS.createdAt,
         updatedAt:
-            settings?.updatedAt instanceof Date
-                ? settings.updatedAt
+            settings?.updatedAt
+                ? new Date(settings.updatedAt)
                 : DEFAULT_SETTINGS.updatedAt,

If timestamps are intentionally ignored (not displayed in UI), consider removing them from the normalization and documenting the intent.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
createdAt:
settings?.createdAt instanceof Date
? settings.createdAt
: DEFAULT_SETTINGS.createdAt,
updatedAt:
settings?.updatedAt instanceof Date
? settings.updatedAt
: DEFAULT_SETTINGS.updatedAt,
}
createdAt:
settings?.createdAt
? new Date(settings.createdAt)
: DEFAULT_SETTINGS.createdAt,
updatedAt:
settings?.updatedAt
? new Date(settings.updatedAt)
: DEFAULT_SETTINGS.updatedAt,
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/src/pages/AutoMod.tsx` around lines 369 - 377, The
createdAt/updatedAt normalization uses instanceof Date which fails for JSON
strings; update the logic in the settings normalization (references: createdAt,
updatedAt, settings, DEFAULT_SETTINGS) to detect string timestamps and parse
them into Date objects (e.g., use new Date(...) and validate with isNaN) and
only fall back to DEFAULT_SETTINGS when the value is missing or invalid;
alternatively remove these fields if timestamps are unused and document that
choice.

@github-actions

github-actions Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

Size Change: +162 B (+0.05%)

Total Size: 318 kB

Filename Size Change
packages/frontend/dist/assets/AutoMessages-CbCQRuhw.js 0 B -2.68 kB (removed) 🏆
packages/frontend/dist/assets/AutoMod-iy1gwSQQ.js 0 B -3.64 kB (removed) 🏆
packages/frontend/dist/assets/CommandsConfig-D4iMPk-m.js 0 B -1.47 kB (removed) 🏆
packages/frontend/dist/assets/Config-9O-LJLTb.js 0 B -1.68 kB (removed) 🏆
packages/frontend/dist/assets/DashboardOverview-Bak4r0rZ.js 0 B -2.54 kB (removed) 🏆
packages/frontend/dist/assets/EmbedBuilder-Ch7-OXF8.js 0 B -3.34 kB (removed) 🏆
packages/frontend/dist/assets/Features-Bn6CVxJ6.js 0 B -2.85 kB (removed) 🏆
packages/frontend/dist/assets/GuildAutomation-Dl0csul9.js 0 B -2.92 kB (removed) 🏆
packages/frontend/dist/assets/index-C1kYHC0Q.css 0 B -14 kB (removed) 🏆
packages/frontend/dist/assets/index-DVwdFhhM.js 0 B -27.3 kB (removed) 🏆
packages/frontend/dist/assets/label-BUbVMLXt.js 0 B -488 B (removed) 🏆
packages/frontend/dist/assets/Levels-ByStePVk.js 0 B -2.63 kB (removed) 🏆
packages/frontend/dist/assets/Login-Bi2LqgTx.js 0 B -2.52 kB (removed) 🏆
packages/frontend/dist/assets/Lyrics-Bv2fB-O8.js 0 B -1.33 kB (removed) 🏆
packages/frontend/dist/assets/Moderation-B69kseK9.js 0 B -3.85 kB (removed) 🏆
packages/frontend/dist/assets/Music-CGRI-wuL.js 0 B -6.13 kB (removed) 🏆
packages/frontend/dist/assets/MusicConfig-BiVrrE53.js 0 B -1.6 kB (removed) 🏆
packages/frontend/dist/assets/ReactionRoles-CHriswr6.js 0 B -1.89 kB (removed) 🏆
packages/frontend/dist/assets/ServerLogs-C6rt2EcT.js 0 B -2.9 kB (removed) 🏆
packages/frontend/dist/assets/ServerSettings-jy3rjdVP.js 0 B -4.22 kB (removed) 🏆
packages/frontend/dist/assets/ServersPage-DSWlh4ZF.js 0 B -2.92 kB (removed) 🏆
packages/frontend/dist/assets/Starboard-D_NqyHwC.js 0 B -2.08 kB (removed) 🏆
packages/frontend/dist/assets/TrackHistory-AaSsvBX6.js 0 B -1.9 kB (removed) 🏆
packages/frontend/dist/assets/TwitchNotifications-BuCVAO44.js 0 B -2.26 kB (removed) 🏆
packages/frontend/dist/assets/AutoMessages-CAMvxMPS.js 2.68 kB +2.68 kB (new file) 🆕
packages/frontend/dist/assets/AutoMod-D0bdSLV-.js 3.79 kB +3.79 kB (new file) 🆕
packages/frontend/dist/assets/CommandsConfig-BPBPluhe.js 1.47 kB +1.47 kB (new file) 🆕
packages/frontend/dist/assets/Config-BLL7UvZ4.js 1.68 kB +1.68 kB (new file) 🆕
packages/frontend/dist/assets/DashboardOverview-CndaYeKM.js 2.54 kB +2.54 kB (new file) 🆕
packages/frontend/dist/assets/EmbedBuilder-DM5NVpft.js 3.34 kB +3.34 kB (new file) 🆕
packages/frontend/dist/assets/Features-AKnRSxYh.js 2.85 kB +2.85 kB (new file) 🆕
packages/frontend/dist/assets/GuildAutomation-CuySOZSk.js 2.92 kB +2.92 kB (new file) 🆕
packages/frontend/dist/assets/index-BetRVevx.css 14 kB +14 kB (new file) 🆕
packages/frontend/dist/assets/index-BwVa4ZRP.js 27.3 kB +27.3 kB (new file) 🆕
packages/frontend/dist/assets/label-DKzYZv00.js 490 B +490 B (new file) 🆕
packages/frontend/dist/assets/Levels-Cewf1wda.js 2.63 kB +2.63 kB (new file) 🆕
packages/frontend/dist/assets/Login-B6pKJtrI.js 2.52 kB +2.52 kB (new file) 🆕
packages/frontend/dist/assets/Lyrics-Bigxsynl.js 1.33 kB +1.33 kB (new file) 🆕
packages/frontend/dist/assets/Moderation-B2Do03No.js 3.85 kB +3.85 kB (new file) 🆕
packages/frontend/dist/assets/Music-BoCF7r_f.js 6.13 kB +6.13 kB (new file) 🆕
packages/frontend/dist/assets/MusicConfig-BrfPQtDO.js 1.6 kB +1.6 kB (new file) 🆕
packages/frontend/dist/assets/ReactionRoles-mNBInmp1.js 1.89 kB +1.89 kB (new file) 🆕
packages/frontend/dist/assets/ServerLogs-Cm3VKMow.js 2.9 kB +2.9 kB (new file) 🆕
packages/frontend/dist/assets/ServerSettings-kdW-hcoP.js 4.22 kB +4.22 kB (new file) 🆕
packages/frontend/dist/assets/ServersPage-lWDnv1qg.js 2.92 kB +2.92 kB (new file) 🆕
packages/frontend/dist/assets/Starboard-BShKUjte.js 2.08 kB +2.08 kB (new file) 🆕
packages/frontend/dist/assets/TrackHistory-sjdLpd1I.js 1.9 kB +1.9 kB (new file) 🆕
packages/frontend/dist/assets/TwitchNotifications-DWqUI-J3.js 2.29 kB +2.29 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
packages/frontend/dist/assets/ActionPanel-3_0PgOXq.js 402 B
packages/frontend/dist/assets/api-3qPvg92E.js 2.9 kB
packages/frontend/dist/assets/authStore-ChjcqfIB.js 557 B
packages/frontend/dist/assets/badge-CspLvx5p.js 499 B
packages/frontend/dist/assets/Card-8wz5ivnN.js 455 B
packages/frontend/dist/assets/CustomCommands-BZz5vFg7.js 2.16 kB
packages/frontend/dist/assets/dialog-BjohnkaC.js 948 B
packages/frontend/dist/assets/guildStore-BuJ9Xfyw.js 794 B
packages/frontend/dist/assets/input-cs-qnOBU.js 462 B
packages/frontend/dist/assets/LastFm-DrttiwyL.js 1.74 kB
packages/frontend/dist/assets/PrivacyPolicy-DUO0quHd.js 1.38 kB
packages/frontend/dist/assets/rolldown-runtime-COnpUsM8.js 467 B
packages/frontend/dist/assets/SectionHeader-zj4yO164.js 382 B
packages/frontend/dist/assets/select-GX-kiy8o.js 1.22 kB
packages/frontend/dist/assets/Skeleton-yy-5yIDL.js 234 B
packages/frontend/dist/assets/StatTile-DJZkmGlP.js 605 B
packages/frontend/dist/assets/switch-DAVOcxrK.js 542 B
packages/frontend/dist/assets/TermsOfService-B0ThRl8c.js 1.37 kB
packages/frontend/dist/assets/usePageMetadata-DNK___tM.js 326 B
packages/frontend/dist/assets/utils-FIhK1p0l.js 148 B
packages/frontend/dist/assets/vendor-forms-KXRApnAU.js 25.4 kB
packages/frontend/dist/assets/vendor-radix-Uy8m4UkR.js 33.5 kB
packages/frontend/dist/assets/vendor-react-DllCF3mE.js 55.6 kB
packages/frontend/dist/assets/vendor-state-BC0s6PNN.js 22 kB
packages/frontend/dist/assets/vendor-ui-BxUEu4Ht.js 64.2 kB

compressed-size-action

@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 (2)
packages/frontend/src/components/Layout/Sidebar.test.tsx (1)

415-417: Avoid class-chain selector for the mobile sidebar lookup.

This selector is brittle and style-coupled. Prefer the stable sidebar identifier already exposed by the component.

♻️ Suggested test refactor
-        const mobileSidebar = document.querySelector(
-            'aside.fixed.inset-y-0.left-0.z-50.w-64.bg-lucky-bg-secondary.lg\\:hidden',
-        )
+        const mobileSidebar = document.getElementById('mobile-sidebar')

As per coding guidelines, “Test behavior, not implementation details.”

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

In `@packages/frontend/src/components/Layout/Sidebar.test.tsx` around lines 415 -
417, Replace the brittle class-chain query for mobileSidebar with the
component's stable test identifier: stop using
document.querySelector('aside.fixed.inset-y-0.left-0.z-50.w-64.bg-lucky-bg-secondary.lg\\:hidden')
and instead query the exposed identifier (e.g., use
screen.getByTestId('mobile-sidebar') or
container.querySelector('[data-testid="mobile-sidebar"]') or the exact
data-testid/name the Sidebar component exports) in Sidebar.test.tsx so the test
targets behavior/stability rather than styling.
packages/frontend/src/components/Dashboard/ServerCard.test.tsx (1)

72-88: Avoid coupling badge tests to Tailwind class tokens.

toHaveClass('bg-lucky-success/10') / toHaveClass('bg-lucky-error/10') are brittle styling assertions. The accessible label + visible status text already validate behavior.

Suggested diff
 test('shows active badge when bot is in server', () => {
     renderCard(mockGuild)

     const badge = screen.getByLabelText('Bot installed')
     expect(badge).toBeInTheDocument()
     expect(screen.getByText(/bot active/i)).toBeInTheDocument()
-    expect(badge).toHaveClass('bg-lucky-success/10')
 })

 test('shows no bot badge when bot is not in server', () => {
     renderCard(mockGuildWithoutBot)

     const badge = screen.getByLabelText('Bot not installed')
     expect(badge).toBeInTheDocument()
     expect(screen.getByText(/no bot/i)).toBeInTheDocument()
-    expect(badge).toHaveClass('bg-lucky-error/10')
 })

As per coding guidelines, **/*.{test,spec}.{ts,tsx,js,jsx}: Test behavior, not implementation details.

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

In `@packages/frontend/src/components/Dashboard/ServerCard.test.tsx` around lines
72 - 88, The tests in ServerCard.test.tsx couple behavior to Tailwind class
names; update the two tests using renderCard(mockGuild) and
renderCard(mockGuildWithoutBot) to remove the brittle assertions expecting
'bg-lucky-success/10' and 'bg-lucky-error/10' on the badge; instead assert the
accessible label (screen.getByLabelText('Bot installed' / 'Bot not installed'))
and the visible status text (/bot active/i or /no bot/i) only, ensuring the
tests validate behavior not styling while keeping the existing use of
renderCard, mockGuild, mockGuildWithoutBot, and the badge variable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/frontend/src/components/Dashboard/ServerCard.test.tsx`:
- Around line 72-88: The tests in ServerCard.test.tsx couple behavior to
Tailwind class names; update the two tests using renderCard(mockGuild) and
renderCard(mockGuildWithoutBot) to remove the brittle assertions expecting
'bg-lucky-success/10' and 'bg-lucky-error/10' on the badge; instead assert the
accessible label (screen.getByLabelText('Bot installed' / 'Bot not installed'))
and the visible status text (/bot active/i or /no bot/i) only, ensuring the
tests validate behavior not styling while keeping the existing use of
renderCard, mockGuild, mockGuildWithoutBot, and the badge variable.

In `@packages/frontend/src/components/Layout/Sidebar.test.tsx`:
- Around line 415-417: Replace the brittle class-chain query for mobileSidebar
with the component's stable test identifier: stop using
document.querySelector('aside.fixed.inset-y-0.left-0.z-50.w-64.bg-lucky-bg-secondary.lg\\:hidden')
and instead query the exposed identifier (e.g., use
screen.getByTestId('mobile-sidebar') or
container.querySelector('[data-testid="mobile-sidebar"]') or the exact
data-testid/name the Sidebar component exports) in Sidebar.test.tsx so the test
targets behavior/stability rather than styling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1ec2d5c-118f-4ae8-a7c2-57413b1048b1

📥 Commits

Reviewing files that changed from the base of the PR and between 64cad6c and 7d00d6c.

📒 Files selected for processing (4)
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/frontend/src/pages/TwitchNotifications.test.tsx
📜 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). (3)
  • GitHub Check: Quality Gates
  • GitHub Check: compressed-size
  • GitHub Check: SonarCloud Scan
🧰 Additional context used
📓 Path-based instructions (16)
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{jsx,tsx}

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

**/*.{jsx,tsx}: Use toasts/snackbars for transient errors; avoid blocking modals for non-critical issues in React/React Native UI
Debounce/suppress duplicate toasts to prevent spam
Provide retry/refresh actions when meaningful (e.g., network failure) in error UI
Use error boundaries for render-time exceptions; show fallback UI in React
Respect accessibility: toasts should be announced (aria-live on web; accessibility hints on React Native)

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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)

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
packages/frontend/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/frontend/src/**/*.{ts,tsx}: Frontend errors are created by Axios interceptor and should be of type ApiError with status and details from backend
Frontend uses path alias @/ mapped to src/ - use this alias for all imports from the src directory

Do not depend on @lucky/shared package in frontend code; make API calls to backend via configured base URL (env)

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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

Never hardcode secrets, IPs, or ports; use .env and docs/ for required configuration variables

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
packages/frontend/src/components/**/*.{ts,tsx}

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

Organize UI components in packages/frontend/src/components/ directory

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
packages/frontend/src/{components,pages}/**/*.{ts,tsx}

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

Use React functional components and hooks; keep components small and focused

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
packages/frontend/src/{components,pages}/**/*.tsx

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

Follow existing styling approach (e.g., Tailwind if present); avoid inline styles for layout and theming

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
packages/frontend/**

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

The frontend package uses React with Vite and must not depend on the shared package

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/*.{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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
**/[A-Z]*.{ts,tsx,jsx}

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

Components must use PascalCase naming

Files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
🧠 Learnings (7)
📓 Common learnings
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
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
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-03-15T21:57:49.951Z
Learning: When working on music queue/player features (play/queue/skip/volume, player lifecycle), use the `music-queue-player` skill
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
📚 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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
📚 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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
📚 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/frontend/src/components/Layout/Layout.test.tsx
  • packages/frontend/src/components/Layout/Sidebar.test.tsx
  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
📚 Learning: 2026-03-09T20:20:56.356Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-frontend.mdc:0-0
Timestamp: 2026-03-09T20:20:56.356Z
Learning: Applies to packages/frontend/tests/**/*.{ts,tsx,js} : Write tests in `packages/frontend/tests/` using existing test patterns (e.g., Playwright for e2e if configured)

Applied to files:

  • packages/frontend/src/components/Layout/Layout.test.tsx
📚 Learning: 2026-03-09T20:20:38.694Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/lucky-backend-api.mdc:0-0
Timestamp: 2026-03-09T20:20:38.694Z
Learning: Applies to packages/backend/tests/**/*.{ts,tsx} : Organize tests in `packages/backend/tests/` with unit tests under `unit/` and integration tests under `integration/`, following existing patterns with fixtures and setup

Applied to files:

  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
📚 Learning: 2026-03-09T20:21:58.991Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/subagent-frontend.mdc:0-0
Timestamp: 2026-03-09T20:21:58.991Z
Learning: Write unit and integration tests in `packages/frontend/tests`; use Playwright for E2E tests when changing user flows

Applied to files:

  • packages/frontend/src/components/Dashboard/ServerCard.test.tsx
🪛 GitHub Check: SonarCloud Code Analysis
packages/frontend/src/components/Layout/Sidebar.test.tsx

[warning] 416-416: String.raw should be used to avoid escaping \.

See more on https://sonarcloud.io/project/issues?id=LucasSantana-Dev_Nexus&issues=AZ0sfLxV9Tz2Boh26KLb&open=AZ0sfLxV9Tz2Boh26KLb&pullRequest=368

🔇 Additional comments (4)
packages/frontend/src/components/Layout/Layout.test.tsx (1)

52-56: Accessibility-focused test updates look correct.

These assertions now validate the control through accessible role/name and properly check fallback absence without relying on fragile text-only queries.

Also applies to: 95-97

packages/frontend/src/components/Layout/Sidebar.test.tsx (1)

117-118: ARIA-based assertions are a good improvement.

These changes correctly test user-observable accessibility behavior (aria-current and accessible button names).

Also applies to: 165-165, 404-406

packages/frontend/src/components/Dashboard/ServerCard.test.tsx (2)

45-47: Hook-level store mocking is well-scoped.

Mocking useGuildStore and injecting selectGuild here keeps the test focused on component behavior rather than store internals.


103-111: Great interaction coverage on Manage action.

This test now verifies both side effects (selectGuild(guild) and navigate('/')), which matches the component contract well.

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 2db2dab into main Mar 27, 2026
13 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the chore/replit-changes branch March 27, 2026 00:20
@coderabbitai coderabbitai Bot mentioned this pull request Apr 22, 2026
2 of 4 tasks
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* fix(web): harden automod, twitch, and music routes

* fix(bot): keep autoplay recommendations resilient

* test(frontend): fix twitch notifications test syntax

* test(frontend): align sidebar assertions

* test(frontend): align layout and server card assertions

* test(frontend): align moderation and music assertions

* test(frontend): align login assertions

This branch was successfully deployed

1 active deployment
Preview — d0d570ba Deployed Mar 27, 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