Refactor chat shortcuts and notifications, fix linting issues - #1830
Refactor chat shortcuts and notifications, fix linting issues#1830TanCodeX wants to merge 5 commits into
Conversation
|
@TanCodeX is attempting to deploy a commit to the durdana3105's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThis PR standardizes application notifications on Sonner, removes the previous toast infrastructure, adds generated Supabase database typings, updates testimonial and activity data handling, relocates chat shortcut wiring, and applies lint-suppression cleanup automation. ChangesNotification migration
Supabase typing and targeted updates
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/pages/aipage.tsx (1)
7-14: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace
anywith a proper interface.Since the file-level
eslint-disableforanywas removed, please consider defining a proper type for yourmessagesarray to benefit from TypeScript's type safety and avoid lingering lint warnings.♻️ Proposed refactor
Define a type for the messages above the component and use it for the state:
+interface ChatMessage { + role: "assistant" | "user" | "system"; + content: string; +} + const AIPage = () => { - const [messages, setMessages] = useState<any[]>([ + const [messages, setMessages] = useState<ChatMessage[]>([ { role: "assistant",You can then remove the
anycasts from your state updater functions (e.g.,setMessages((prev) => ...)instead ofsetMessages((prev: any) => ...)) and mapping callbacks throughout the file.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/pages/aipage.tsx` around lines 7 - 14, Define a message interface above the AIPage component containing the fields used by message state and render logic, then type the messages useState with that interface instead of any. Update setMessages updater functions and message mapping callbacks to infer or explicitly use the new type, removing all remaining any annotations in AIPage.fix_lint.mjs (1)
15-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse syntax-aware or narrowly scoped rewrites.
These regexes can silently remove
toastfrom any matching array, or appendseedTestimonialsto unrelated[searchTerm, categoryFilter]arrays. Restrict replacements to verified dependency arrays and assert the expected replacement count.Also applies to: 39-43
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@fix_lint.mjs` around lines 15 - 20, Restrict the rewrite loop over toastFiles to verified dependency arrays rather than applying broad regexes to every array containing toast or related entries. Use syntax-aware parsing or narrowly targeted patterns tied to the intended dependency-array forms, and assert the expected replacement count so unrelated arrays remain unchanged and unexpected matches fail loudly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/FloatingAI.tsx`:
- Line 1: Remove all explicit any usages across the listed sites: replace
FloatingAI.tsx:1-1 useState<any[]>; NotificationsDropdown.tsx:1-1 Supabase casts
and payload; ChatBox.tsx:12-13 messages; InviteMenu.tsx:17-18 rpc cast;
pushNotifications.ts:1-1 and useNotifications.ts:1-1 Supabase casts;
useRoomChat.ts:7-13,33-34 state and cast; useRoomDetails.ts:8-16 state and cast;
and Discover.tsx:1-1 usages. Use the appropriate existing domain, component, or
generated Supabase types and preserve each current behavior without weakening
type safety.
In `@temp_types.ts`:
- Around line 1-9: Delete the unused Supabase type snapshot files temp_types.ts
(lines 1-9) and temp2_types.ts (lines 1-9); no application code changes are
needed.
---
Nitpick comments:
In `@fix_lint.mjs`:
- Around line 15-20: Restrict the rewrite loop over toastFiles to verified
dependency arrays rather than applying broad regexes to every array containing
toast or related entries. Use syntax-aware parsing or narrowly targeted patterns
tied to the intended dependency-array forms, and assert the expected replacement
count so unrelated arrays remain unchanged and unexpected matches fail loudly.
In `@src/pages/aipage.tsx`:
- Around line 7-14: Define a message interface above the AIPage component
containing the fields used by message state and render logic, then type the
messages useState with that interface instead of any. Update setMessages updater
functions and message mapping callbacks to infer or explicitly use the new type,
removing all remaining any annotations in AIPage.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 93279f14-30c5-470d-b65e-61b89c8b7049
⛔ Files ignored due to path filters (8)
uploads/profiles/profile-user-948-test-1784561617295-464135339.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561617302-351406894.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561651066-713364992.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561651074-10055956.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561670283-611470428.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561670289-914776455.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561692897-404468012.pngis excluded by!**/*.pnguploads/profiles/profile-user-948-test-1784561692905-19697109.pngis excluded by!**/*.png
📒 Files selected for processing (58)
fix_lint.mjssrc/App.tsxsrc/components/AvatarUpload.tsxsrc/components/FloatingAI.tsxsrc/components/FocusTimer.tsxsrc/components/GroupPomodoro.tsxsrc/components/NotificationsDropdown.tsxsrc/components/Room/ChatBox.tsxsrc/components/Room/InviteMenu.tsxsrc/components/Sparkles.tsxsrc/components/StudyRooms.tsxsrc/components/Whiteboard/Canvas.tsxsrc/components/dashboard/RecentActivity.tsxsrc/components/landing/Testimonials.tsxsrc/components/markdown/MarkdownRenderer.tsxsrc/components/mentor/MentorForm.tsxsrc/components/theme-provider.tsxsrc/components/ui/sonner.tsxsrc/components/ui/textarea.tsxsrc/components/ui/toast.tsxsrc/components/ui/toaster.tsxsrc/components/ui/use-toast.tssrc/features/notifications/pushNotifications.tssrc/features/notifications/useNotifications.tssrc/hooks/use-toast.tssrc/hooks/useAwardXP.tssrc/hooks/useCreateSession.tssrc/hooks/useMessages.tssrc/hooks/useResources.tssrc/hooks/useRoomChat.tssrc/hooks/useRoomDetails.tssrc/hooks/useRoomPresence.tssrc/hooks/useSessions.tssrc/hooks/useSkillEndorsements.test.tssrc/hooks/useSkillEndorsements.tssrc/integrations/supabase/types.tssrc/lib/http.tssrc/lib/rewardXP.tssrc/lib/streakSystem.tssrc/pages/Chat.tsxsrc/pages/Contact.test.tsxsrc/pages/Contact.tsxsrc/pages/ContributorDashboard.tsxsrc/pages/Dashboard.tsxsrc/pages/Discover.tsxsrc/pages/Leaderboard.tsxsrc/pages/Login.tsxsrc/pages/MentorDashboard.tsxsrc/pages/Notifications.tsxsrc/pages/Onboarding.tsxsrc/pages/Portfolio.tsxsrc/pages/ReviewSubmission.tsxsrc/pages/Signup.tsxsrc/pages/SubmitForReview.tsxsrc/pages/aipage.tsxtailwind.config.tstemp2_types.tstemp_types.ts
💤 Files with no reviewable changes (5)
- src/components/ui/toaster.tsx
- src/components/ui/use-toast.ts
- src/components/ui/toast.tsx
- src/App.tsx
- src/hooks/use-toast.ts
| @@ -1,4 +1,4 @@ | |||
| /* eslint-disable @typescript-eslint/no-explicit-any */ | |||
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
files=(
src/components/FloatingAI.tsx
src/components/NotificationsDropdown.tsx
src/components/Room/ChatBox.tsx
src/components/Room/InviteMenu.tsx
src/features/notifications/pushNotifications.ts
src/features/notifications/useNotifications.ts
src/hooks/useRoomChat.ts
src/hooks/useRoomDetails.ts
src/pages/Discover.tsx
)
for f in "${files[@]}"; do
echo "===== $f ====="
if [ -f "$f" ]; then
wc -l "$f"
sed -n '1,220p' "$f" | cat -n
else
echo "missing"
fi
echo
doneRepository: durdana3105/peer-learning
Length of output: 42061
Replace the remaining any usages
The no-explicit-any suppressions were removed, but these files still contain explicit any types/casts:
src/components/FloatingAI.tsx:useState<any[]>src/components/NotificationsDropdown.tsx:(supabase as any)/payload: anysrc/components/Room/ChatBox.tsx:messages: any[]src/components/Room/InviteMenu.tsx:(supabase.rpc as any)src/features/notifications/pushNotifications.ts:(supabase as any)src/features/notifications/useNotifications.ts:(supabase as any)src/hooks/useRoomChat.ts:useState<any[]>/as anysrc/hooks/useRoomDetails.ts:useState<any>/as anysrc/pages/Discover.tsx: multipleanyusages
📍 Affects 9 files
src/components/FloatingAI.tsx#L1-L1(this comment)src/components/NotificationsDropdown.tsx#L1-L1src/components/Room/ChatBox.tsx#L12-L13src/components/Room/InviteMenu.tsx#L17-L18src/features/notifications/pushNotifications.ts#L1-L1src/features/notifications/useNotifications.ts#L1-L1src/hooks/useRoomChat.ts#L7-L13src/hooks/useRoomChat.ts#L33-L34src/hooks/useRoomDetails.ts#L8-L16src/pages/Discover.tsx#L1-L1
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/FloatingAI.tsx` at line 1, Remove all explicit any usages
across the listed sites: replace FloatingAI.tsx:1-1 useState<any[]>;
NotificationsDropdown.tsx:1-1 Supabase casts and payload; ChatBox.tsx:12-13
messages; InviteMenu.tsx:17-18 rpc cast; pushNotifications.ts:1-1 and
useNotifications.ts:1-1 Supabase casts; useRoomChat.ts:7-13,33-34 state and
cast; useRoomDetails.ts:8-16 state and cast; and Discover.tsx:1-1 usages. Use
the appropriate existing domain, component, or generated Supabase types and
preserve each current behavior without weakening type safety.
| export type Json = | ||
| | string | ||
| | number | ||
| | boolean | ||
| | null | ||
| | { [key: string]: Json | undefined } | ||
| | Json[] | ||
|
|
||
| export type Database = { |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Confirm neither temp types file is referenced before deletion.
rg -n --type=ts -e 'temp_types' -e 'temp2_types' -g '!temp_types.ts' -g '!temp2_types.ts'Repository: durdana3105/peer-learning
Length of output: 163
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== tracked files ==\n'
git ls-files | rg '(^|/)(temp_types\.ts|temp2_types\.ts|src/integrations/supabase/types\.ts|client\.ts)$'
printf '\n== line counts ==\n'
wc -l temp_types.ts temp2_types.ts src/integrations/supabase/types.ts 2>/dev/null || true
printf '\n== temp_types.ts (head) ==\n'
sed -n '1,120p' temp_types.ts
printf '\n== temp2_types.ts (head) ==\n'
sed -n '1,120p' temp2_types.ts
printf '\n== canonical types (head) ==\n'
sed -n '1,120p' src/integrations/supabase/types.ts
printf '\n== imports of canonical types ==\n'
rg -n "src/integrations/supabase/types|from ['\"].*supabase/types['\"]|from ['\"].*temp_types|from ['\"].*temp2_types" .Repository: durdana3105/peer-learning
Length of output: 9920
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '== tracked files =='
git ls-files -- 'temp_types.ts' 'temp2_types.ts' 'src/integrations/supabase/types.ts' 'client.ts' || true
echo
echo '== references to temp files =='
rg -n --hidden --glob '!temp_types.ts' --glob '!temp2_types.ts' '\btemp_types\b|\btemp2_types\b' . || true
echo
echo '== reference to canonical types =='
rg -n --hidden "src/integrations/supabase/types" . || true
echo
echo '== compare hashes if files exist =='
for f in temp_types.ts temp2_types.ts src/integrations/supabase/types.ts; do
if [ -f "$f" ]; then
printf '%s %s\n' "$f" "$(sha256sum "$f" | awk '{print $1}')"
else
printf '%s MISSING\n' "$f"
fi
doneRepository: durdana3105/peer-learning
Length of output: 551
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
files = [Path('temp_types.ts'), Path('temp2_types.ts'), Path('src/integrations/supabase/types.ts')]
contents = [p.read_text() for p in files]
for i, a in enumerate(files):
for j, b in enumerate(files):
if i < j:
print(f'== {a} vs {b} ==')
print('same:', contents[i] == contents[j])
if contents[i] != contents[j]:
ai = contents[i].splitlines()
bi = contents[j].splitlines()
# find first differing line
for idx, (la, lb) in enumerate(zip(ai, bi), 1):
if la != lb:
print('first diff line:', idx)
print('A:', la)
print('B:', lb)
break
else:
if len(ai) != len(bi):
print('same prefix; lengths:', len(ai), len(bi))
print()
PYRepository: durdana3105/peer-learning
Length of output: 579
Remove the stray Supabase type snapshots. temp_types.ts and temp2_types.ts aren’t referenced by app code, and they’ve already drifted from src/integrations/supabase/types.ts; deleting them avoids further schema confusion.
📍 Affects 2 files
temp_types.ts#L1-L9(this comment)temp2_types.ts#L1-L9
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@temp_types.ts` around lines 1 - 9, Delete the unused Supabase type snapshot
files temp_types.ts (lines 1-9) and temp2_types.ts (lines 1-9); no application
code changes are needed.
|
RESOLVE MERGE CONFLICTS |
|
RESOLVE MERGE CONFLICTS |
@durdana3105 Done |
Description
Closes #1826
This Pull Request addresses duplicate toast providers by standardizing the application to use Sonner exclusively. It eliminates redundant toast infrastructure, reducing bundle size and ensuring a consistent notification API and UI across the application. Additionally, it resolves all outstanding ESLint errors and warnings across the codebase.
Changes Made
1. Standardized Toast Notifications
<Toaster />from@/components/ui/toasterinApp.tsx, retaining only<Sonner />.Portfolio,Contact,Signup,useSessions) to use thetoastfunction fromsonnerinstead of the legacyuseToasthook. Correctly mapped legacy parameters (likevariant: "destructive") to their Sonner equivalents (toast.error(),toast.success(), etc.).src/components/ui/toast.tsxsrc/components/ui/toaster.tsxsrc/components/ui/use-toast.tssrc/hooks/use-toast.tsContact.test.tsxanduseSkillEndorsements.test.tsto correctly mocksonnermethods and updated expectations.2. Linting & Code Quality Improvements
supabase_types.tsfrom the root directory, which incorrectly contained a Supabase CLI JSON error message, causing an ESLint parsing error.toastfromuseCallback,useMemo, anduseEffectdependency arrays across multiple files, as the Sonnertoastfunction is stable and does not require tracking./* eslint-disable react-refresh/only-export-components */to files legitimately exporting non-component items (likeMarkdownRenderer.tsxandtheme-provider.tsx).useMemoinTestimonials.tsx: Moved the staticseedTestimonialsarray outside of the component to prevent unnecessary re-renders and satisfy the exhaustive-deps rule.eslint-disabledirectives.Impact
Verification
npm run lintcompletes with zero errors or warnings.npm run test); all 260 tests pass successfully.Summary by CodeRabbit