Skip to content

feat(frontend): moderation stats panel and legal policy updates - #334

Merged
LucasSantana-Dev merged 2 commits into
mainfrom
feat/moderation-stats-panel
Mar 18, 2026
Merged

LucasSantana-Dev merged 2 commits into
mainfrom
feat/moderation-stats-panel

Conversation

@LucasSantana-Dev

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

Copy link
Copy Markdown
Owner

Summary

  • add a moderation stats section to the Moderation page using the existing /moderation/stats endpoint
  • add a deactivate action in the case detail modal using the existing /moderation/cases/:caseId/deactivate endpoint
  • expand Privacy Policy and Terms of Service from placeholder text to production-grade content and update CHANGELOG [Unreleased]

Verification

  • npx tsc --noEmit -p packages/frontend/tsconfig.json
  • npm run lint

Summary by CodeRabbit

  • New Features

    • Moderation stats panel showing live totals for total cases, active cases, warnings, and bans.
    • Deactivate cases directly from the case detail modal.
  • Documentation

    • Privacy Policy expanded with detailed scope, data collection, usage, third‑party integrations, retention, user rights, security, and update practices.
    • Terms of Service expanded with detailed service scope, acceptable use, third‑party dependencies, suspension/termination, disclaimers, and change policy.

@netlify

netlify Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit ecb7138
🔍 Latest deploy log https://app.netlify.com/projects/regal-bunny-0c8efe/deploys/69baf118d1f30300097b8b8d
😎 Deploy Preview https://deploy-preview-334--regal-bunny-0c8efe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Mar 18, 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: b0261c77-339e-42b1-83c1-2988050c52ed

📥 Commits

Reviewing files that changed from the base of the PR and between cb5d2f6 and ecb7138.

📒 Files selected for processing (1)
  • packages/backend/src/routes/starboard.ts
📜 Recent 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: SonarCloud Scan
  • GitHub Check: compressed-size
  • GitHub Check: Quality Gates
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{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/backend/src/routes/starboard.ts
**/*.{ts,tsx,js,jsx}

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

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

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

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

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

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

Implement TypeScript typecheck and linter in CI quality checks

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

Files:

  • packages/backend/src/routes/starboard.ts
**/*.{js,jsx,ts,tsx}

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

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

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

Files:

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

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

Introduce interfaces at module boundaries to enable testing and substitutions

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

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

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

Files:

  • packages/backend/src/routes/starboard.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/starboard.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/starboard.ts
**/*.{js,ts,tsx,jsx}

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

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

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

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

Files:

  • packages/backend/src/routes/starboard.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/starboard.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/starboard.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/starboard.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/starboard.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/backend/src/routes/starboard.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/starboard.ts
🧠 Learnings (3)
📚 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/backend/src/routes/starboard.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/backend/src/routes/**/*.ts : Backend route handlers must use `asyncHandler` wrapper and throw `AppError.xxx()` instead of manual try/catch blocks

Applied to files:

  • packages/backend/src/routes/starboard.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/backend/src/**/*.ts : Validation must use Zod schemas in `backend/src/schemas/` and be applied via `validateBody`, `validateParams`, or `validateQuery`

Applied to files:

  • packages/backend/src/routes/starboard.ts
🔇 Additional comments (3)
packages/backend/src/routes/starboard.ts (3)

84-87: Formatting-only change; no action needed.


6-6: Good standardization with AppError import.

This aligns the route with your backend error-handling convention and supports consistent JSON error responses downstream.

Based on learnings: Backend route handlers must use asyncHandler wrapper and throw AppError.xxx() instead of manual try/catch blocks.


45-60: Fallback + guard for channelId is solid.

The new flow correctly preserves existing channelId on partial updates and blocks invalid create paths with a clear 400.


📝 Walkthrough

Walkthrough

Adds moderation dashboard statistics and direct case deactivation, expands Privacy Policy and Terms of Service with production-grade content and updated dates, updates changelog, and ensures starboard upsert requires a channelId with fallback to existing config.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Documents unreleased entries: moderation stats panel and case deactivation endpoints; notes expanded Privacy Policy and Terms of Service.
Moderation Dashboard (frontend)
packages/frontend/src/pages/Moderation.tsx
Adds StatCard UI, stats state and loading handling, fetchStats; implements case deactivation flow with handleDeactivateCase, deactivation state, toast feedback, and refresh of cases and stats; extends CaseDetailModal props to support deactivation.
Legal Pages (frontend)
packages/frontend/src/pages/PrivacyPolicy.tsx, packages/frontend/src/pages/TermsOfService.tsx
Rewrites and expands Privacy Policy and Terms of Service sections (scope, data, third-party services, retention, rights, security, acceptable use, suspension/termination, disclaimers); updates effective dates to March 18, 2026.
Starboard route (backend)
packages/backend/src/routes/starboard.ts
Ensure channelId is present when upserting config: fall back to existing config's channelId and throw a Bad Request (AppError) if none found; minor formatting adjustments in retrieval logic.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant ModerationPage
  participant API_Server
  participant Database

  Browser->>ModerationPage: Open Moderation page
  ModerationPage->>API_Server: GET /api/guilds/:id/moderation/stats
  API_Server->>Database: Query moderation stats
  Database-->>API_Server: stats payload
  API_Server-->>ModerationPage: 200 {stats}
  ModerationPage-->>Browser: Render StatCard tiles

  Browser->>ModerationPage: Click "Deactivate Case" in CaseDetailModal
  ModerationPage->>API_Server: POST /api/guilds/:gId/moderation/cases/:caseId/deactivate
  API_Server->>Database: Update case: set deactivated
  Database-->>API_Server: update result
  API_Server-->>ModerationPage: 200 {case updated}
  ModerationPage->>ModerationPage: refresh cases list
  ModerationPage->>API_Server: GET /api/guilds/:id/moderation/stats
  API_Server->>Database: Query moderation stats
  Database-->>API_Server: updated stats
  API_Server-->>ModerationPage: 200 {updated stats}
  ModerationPage-->>Browser: Update UI, show toast
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

backend

🚥 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: moderation stats panel frontend feature and legal policy updates across multiple files.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/moderation-stats-panel
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel

vercel Bot commented Mar 18, 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 18, 2026 6:39pm

Request Review

@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 (3)
packages/frontend/src/pages/Moderation.tsx (3)

120-155: Mark StatCard props as read-only for type safety.

The props object should be marked as Readonly to prevent accidental mutations and align with React best practices for functional components.

♻️ Proposed fix
 function StatCard({
     label,
     value,
     icon: Icon,
     tone,
-}: {
+}: Readonly<{
     label: string
     value: number
     icon: React.ComponentType<{ className?: string }>
     tone: 'blue' | 'green' | 'yellow' | 'red'
-}) {
+}>) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/src/pages/Moderation.tsx` around lines 120 - 155, The
StatCard component's props should be made immutable: update the parameter type
annotation for the StatCard function to use Readonly for the props object (e.g.
Readonly<{ label: string; value: number; icon: React.ComponentType<{ className?:
string }>; tone: 'blue' | 'green' | 'yellow' | 'red' }>) so label, value, icon
and tone are protected from mutation; keep the same destructured names (label,
value, icon, tone) and leave the rest of the function (including toneClass and
usage of value.toLocaleString()) unchanged.

157-168: Mark CaseDetailModal props as read-only.

For consistency with the StatCard suggestion and React best practices, the props should be marked as Readonly.

♻️ Proposed fix
 function CaseDetailModal({
     caseData,
     open,
     onClose,
     onDeactivate,
     deactivating,
-}: {
+}: Readonly<{
     caseData: ModerationCase | null
     open: boolean
     onClose: () => void
     onDeactivate: (caseId: string) => Promise<void>
     deactivating: boolean
-}) {
+}>) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/src/pages/Moderation.tsx` around lines 157 - 168, The
CaseDetailModal component props should be marked read-only: update the function
parameter type for CaseDetailModal to use Readonly for the props object (e.g.,
Readonly<{ caseData: ModerationCase | null; open: boolean; onClose: () => void;
onDeactivate: (caseId: string) => Promise<void>; deactivating: boolean }>) or
extract a named Props type and declare it as Readonly<Props>; ensure you update
the signature of CaseDetailModal accordingly so all incoming props are
immutable.

419-455: Consider extracting the stats section into a separate component to reduce nesting.

The nested ternary for loading/loaded/null states is valid but can be harder to read. Extracting this into a StatsSection component would improve clarity and testability.

♻️ Proposed refactor
function StatsSection({
    stats,
    loading,
}: Readonly<{ stats: ModerationStats | null; loading: boolean }>) {
    if (loading) {
        return (
            <div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3'>
                {Array.from({ length: 4 }).map((_, index) => (
                    <Card key={index} className='p-4'>
                        <Skeleton className='h-3 w-20' />
                        <Skeleton className='h-8 w-16 mt-2' />
                    </Card>
                ))}
            </div>
        )
    }

    if (!stats) return null

    return (
        <div className='grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3'>
            <StatCard
                label='Total Cases'
                value={stats.totalCases}
                icon={BarChart3}
                tone='blue'
            />
            {/* ... other StatCards */}
        </div>
    )
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/frontend/src/pages/Moderation.tsx` around lines 419 - 455, Extract
the nested ternary block into a new StatsSection component: create a function
StatsSection({ stats, loading }: Readonly<{ stats: ModerationStats | null;
loading: boolean }>) that returns the loading skeleton grid when loading is
true, returns null if stats is null, and otherwise renders the same StatCard
elements (Total Cases, Active Cases, Warnings, Bans) using stats.totalCases,
stats.activeCases, stats.casesByType.warn, stats.casesByType.ban and the same
icon props (BarChart3, Shield, AlertTriangle, Ban) and tones; then replace the
inline ternary in Moderation.tsx with <StatsSection stats={stats}
loading={statsLoading} /> to simplify the JSX and improve testability.
🤖 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/pages/Moderation.tsx`:
- Around line 120-155: The StatCard component's props should be made immutable:
update the parameter type annotation for the StatCard function to use Readonly
for the props object (e.g. Readonly<{ label: string; value: number; icon:
React.ComponentType<{ className?: string }>; tone: 'blue' | 'green' | 'yellow' |
'red' }>) so label, value, icon and tone are protected from mutation; keep the
same destructured names (label, value, icon, tone) and leave the rest of the
function (including toneClass and usage of value.toLocaleString()) unchanged.
- Around line 157-168: The CaseDetailModal component props should be marked
read-only: update the function parameter type for CaseDetailModal to use
Readonly for the props object (e.g., Readonly<{ caseData: ModerationCase | null;
open: boolean; onClose: () => void; onDeactivate: (caseId: string) =>
Promise<void>; deactivating: boolean }>) or extract a named Props type and
declare it as Readonly<Props>; ensure you update the signature of
CaseDetailModal accordingly so all incoming props are immutable.
- Around line 419-455: Extract the nested ternary block into a new StatsSection
component: create a function StatsSection({ stats, loading }: Readonly<{ stats:
ModerationStats | null; loading: boolean }>) that returns the loading skeleton
grid when loading is true, returns null if stats is null, and otherwise renders
the same StatCard elements (Total Cases, Active Cases, Warnings, Bans) using
stats.totalCases, stats.activeCases, stats.casesByType.warn,
stats.casesByType.ban and the same icon props (BarChart3, Shield, AlertTriangle,
Ban) and tones; then replace the inline ternary in Moderation.tsx with
<StatsSection stats={stats} loading={statsLoading} /> to simplify the JSX and
improve testability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e8679030-9220-45a7-8922-264338e8dd44

📥 Commits

Reviewing files that changed from the base of the PR and between a8ebd5c and cb5d2f6.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/frontend/src/pages/Moderation.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/TermsOfService.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 (15)
{CHANGELOG.md,README.md}

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

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

Files:

  • CHANGELOG.md
CHANGELOG.md

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

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

Always update CHANGELOG.md with all code changes

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

Files:

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

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

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

Files:

  • CHANGELOG.md
**/*.{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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.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/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.tsx
**/[A-Z]*.{ts,tsx,jsx}

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

Components must use PascalCase naming

Files:

  • packages/frontend/src/pages/TermsOfService.tsx
  • packages/frontend/src/pages/PrivacyPolicy.tsx
  • packages/frontend/src/pages/Moderation.tsx
🧠 Learnings (2)
📚 Learning: 2026-03-09T20:22:25.255Z
Learnt from: CR
Repo: LucasSantana-Dev/Lucky PR: 0
File: .cursor/rules/workflow.mdc:0-0
Timestamp: 2026-03-09T20:22:25.255Z
Learning: Applies to CHANGELOG.md : Update CHANGELOG.md with all changes, include breaking changes documentation, and reference issues and PRs

Applied to files:

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

Applied to files:

  • CHANGELOG.md
🪛 GitHub Check: SonarCloud Code Analysis
packages/frontend/src/pages/Moderation.tsx

[warning] 120-130: Mark the props of the component as read-only.

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


[warning] 428-455: Extract this nested ternary operation into an independent statement.

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


[warning] 422-422: Do not use Array index in keys

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

🔇 Additional comments (5)
CHANGELOG.md (1)

10-19: LGTM!

The changelog entries accurately document the new moderation stats panel, case deactivation feature, and legal policy expansions. The format follows Keep a Changelog conventions and the API endpoint references are consistent with the PR objectives.

packages/frontend/src/pages/TermsOfService.tsx (1)

1-113: LGTM!

The Terms of Service page is well-structured with proper semantic HTML, consistent heading hierarchy, and design system tokens. The expanded content covers essential legal topics (acceptance, acceptable use, third-party services, disclaimers, etc.) appropriate for a production-grade policy.

packages/frontend/src/pages/PrivacyPolicy.tsx (1)

1-117: LGTM!

The Privacy Policy page is comprehensive and covers essential privacy topics including data collection, usage, third-party services, retention, user rights, and security. The structure uses proper semantic HTML with consistent heading hierarchy and design system tokens.

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

345-378: LGTM on the stats fetching and deactivation logic.

The implementation correctly:

  • Uses useCallback with appropriate dependencies
  • Handles loading states properly
  • Shows toast feedback for success/failure
  • Refreshes both cases and stats after deactivation
  • Optimistically updates the selected case's active status

270-291: Good accessibility: buttons are properly disabled during deactivation.

The Close and Deactivate buttons correctly disable during the deactivation operation, preventing double-submissions. The button text updates to "Deactivating..." to provide user feedback.

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 9e088ed into main Mar 18, 2026
14 of 20 checks passed
@github-actions

Copy link
Copy Markdown

Size Change: 0 B

Total Size: 319 kB

ℹ️ View Unchanged
Filename Size
packages/frontend/dist/assets/ActionPanel-B_Tg_zho.js 390 B
packages/frontend/dist/assets/AutoMessages-D3jl_Z7w.js 2.42 kB
packages/frontend/dist/assets/AutoMod-Ci8YVLu7.js 3.58 kB
packages/frontend/dist/assets/badge-DKWvCDbV.js 452 B
packages/frontend/dist/assets/Card-B8aw3NU_.js 484 B
packages/frontend/dist/assets/CommandsConfig-t6sOEllB.js 1.43 kB
packages/frontend/dist/assets/Config-BQY8S6mG.js 1.58 kB
packages/frontend/dist/assets/CustomCommands-BDXL0Rz4.js 2.1 kB
packages/frontend/dist/assets/DashboardOverview-DveIf6WA.js 3.07 kB
packages/frontend/dist/assets/EmbedBuilder-BhPLcGZJ.js 3.32 kB
packages/frontend/dist/assets/Features-DBSxj--Z.js 2.83 kB
packages/frontend/dist/assets/GuildAutomation-BNAqPwP1.js 2.89 kB
packages/frontend/dist/assets/index-Bn5EupNH.js 70.7 kB
packages/frontend/dist/assets/index-DAPai5H1.css 15.8 kB
packages/frontend/dist/assets/input-DqjN7IrZ.js 427 B
packages/frontend/dist/assets/label-DoJTrF1I.js 444 B
packages/frontend/dist/assets/LastFm-C583zWKN.js 1.69 kB
packages/frontend/dist/assets/Levels-DF3qgtYY.js 2.61 kB
packages/frontend/dist/assets/Login-IeV42HsO.js 2.77 kB
packages/frontend/dist/assets/Lyrics-3j-xx_lX.js 1.29 kB
packages/frontend/dist/assets/Moderation-De_inptY.js 4.32 kB
packages/frontend/dist/assets/Music-Bg0XApRs.js 6.34 kB
packages/frontend/dist/assets/MusicConfig-B1Wd-UD3.js 3.02 kB
packages/frontend/dist/assets/PrivacyPolicy-CGfM5s8O.js 1.38 kB
packages/frontend/dist/assets/ReactionRoles-DDKSqrsW.js 1.84 kB
packages/frontend/dist/assets/SectionHeader-ChjcuDaF.js 375 B
packages/frontend/dist/assets/select-D2SwoVlE.js 1.19 kB
packages/frontend/dist/assets/ServerLogs-BTE7Uy0T.js 2.84 kB
packages/frontend/dist/assets/ServerSettings-3Lq3v9hy.js 4.15 kB
packages/frontend/dist/assets/ServersPage-DvZVOSOI.js 2.67 kB
packages/frontend/dist/assets/Skeleton-DV9RoyMD.js 227 B
packages/frontend/dist/assets/Starboard-BI5WKaTI.js 2.04 kB
packages/frontend/dist/assets/switch-DoIIaXF6.js 515 B
packages/frontend/dist/assets/TermsOfService-3fBlJ-Hf.js 1.37 kB
packages/frontend/dist/assets/TrackHistory-C3c7ITHX.js 1.85 kB
packages/frontend/dist/assets/TwitchNotifications-BOZOS6lh.js 2.2 kB
packages/frontend/dist/assets/usePageMetadata-Dudc5JrX.js 287 B
packages/frontend/dist/assets/vendor-forms-Domvyw5O.js 21.1 kB
packages/frontend/dist/assets/vendor-radix-BTf9AecN.js 33.5 kB
packages/frontend/dist/assets/vendor-react-Bu1Oeml_.js 17.3 kB
packages/frontend/dist/assets/vendor-state-Szs8I3iE.js 25 kB
packages/frontend/dist/assets/vendor-ui-DRMcYAro.js 65.3 kB

compressed-size-action

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@LucasSantana-Dev
LucasSantana-Dev deleted the feat/moderation-stats-panel branch March 31, 2026 22:15
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
* feat(frontend): add moderation stats panel and legal policy updates

* fix(backend): require channelId fallback for starboard upsert

This branch was successfully deployed

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