Skip to content

Conversation

@ameer2468
Copy link
Contributor

@ameer2468 ameer2468 commented Aug 8, 2025

This PR:

  • Fixes showing 2 lines of the comment or reply content.
  • if clicking on a reply notification, will put the comment first with the reply highlighted.
  • Fixes reply notifications.

Summary by CodeRabbit

  • New Features

    • Enhanced notifications to distinguish between comment and reply types, including improved handling and delivery of reply notifications.
    • Added visual highlighting for comments referenced by either "comment" or "reply" query parameters in the activity tab.
    • Updated notification links to direct users to the relevant comment or reply within the video activity.
  • Improvements

    • Refined comment scrolling behavior to prevent automatic scrolling when a specific comment or reply is referenced.
    • Improved notification display and animation for better visual clarity and responsiveness.
    • Adjusted comment ordering to prioritize top-level comments when viewing replies.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

This update introduces explicit handling for "reply" notifications throughout the comment and notification system. It adds a parentCommentId to notification creation, updates notification routing and display for replies, and modifies comment highlighting and scrolling logic to recognize both "comment" and "reply" query parameters. The notification infrastructure is refactored to distinctly process reply notifications and avoid duplicates.

Changes

Cohort / File(s) Change Summary
Notification Creation Logic
apps/web/lib/Notification.ts, apps/web/actions/videos/new-comment.ts
Adds parentCommentId to notification creation input; introduces explicit handling for reply notifications, including recipient determination, preference checks, and duplicate prevention.
Notification UI Updates
apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx, apps/web/app/(org)/dashboard/_components/Notifications/index.tsx
Updates notification item rendering and link logic to distinguish between "comment" and "reply" notifications; adjusts CSS classes and animation display properties.
Comment Highlighting and Scrolling
apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx, apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx
Extends comment highlighting and scroll suppression to respond to both "comment" and "reply" URL parameters.
Comment Page Logic
apps/web/app/s/[videoId]/page.tsx
Adds logic to extract and use top-level comment ID for reply highlighting and adjusts comment ordering accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant NotificationLib
    participant DB

    User->>WebApp: Submit new comment or reply
    WebApp->>NotificationLib: createNotification({type, commentId, parentCommentId, ...})
    alt type == "reply" and parentCommentId present
        NotificationLib->>DB: Fetch parent comment's author
        NotificationLib->>DB: Check for duplicate reply notification
        alt No duplicate and recipient valid
            NotificationLib->>DB: Insert reply notification for parent author
            NotificationLib->>WebApp: Trigger dashboard revalidation
        end
    else type == "comment" or "reaction"
        NotificationLib->>DB: Check notification preferences and duplicates
        alt No duplicate and recipient valid
            NotificationLib->>DB: Insert notification for video owner
            NotificationLib->>WebApp: Trigger dashboard revalidation
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇✨
In the warren of comments, replies now shine,
Parent links and highlights, all neatly align.
Notifications hop with purpose anew,
No duplicate thumps, just messages true.
With CSS and queries, the flow’s feeling right—
A rabbit’s delight, in the dashboard tonight!
✨🐾

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32e3f8c and 315635c.

📒 Files selected for processing (2)
  • apps/web/app/(org)/dashboard/_components/Notifications/index.tsx (2 hunks)
  • apps/web/app/s/[videoId]/page.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/web/app/s/[videoId]/page.tsx
  • apps/web/app/(org)/dashboard/_components/Notifications/index.tsx
⏰ 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: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
  • GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
  • GitHub Check: Clippy
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-notification-ui-display

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (4)
apps/web/lib/Notification.ts (1)

24-28: parentCommentId now leaks into every notification type

Adding parentCommentId un-conditionally to all author-based notifications means even top-level “comment”, “reaction”, or “view” rows will carry an empty / undefined field in notifications.data. If downstream code later assumes the presence of this key only for "reply" types you’ll get false positives.

Consider restricting the extra key to the "reply" branch only:

-: Omit<D, "author"> & { authorId: string } & { parentCommentId?: string }
+: D["type"] extends "reply"
+  ? Omit<D, "author"> & { authorId: string; parentCommentId: string }
+  : Omit<D, "author"> & { authorId: string }
apps/web/actions/videos/new-comment.ts (1)

52-58: Avoid persisting meaningless parentCommentId values

parentCommentId is forwarded even for root comments as an empty string, which ends up stored in notifications.data.
Prefer undefined / null so downstream "reply" logic (if (notification.parentCommentId) …) remains explicit and data stays clean.

-      parentCommentId,
+      ...(parentCommentId ? { parentCommentId } : {}),
apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx (1)

30-41: Collapse duplicate useSearchParams() calls

useSearchParams() is inexpensive but returns a stable instance; still, calling it twice per render is redundant and hurts readability.

-      const commentParams = useSearchParams().get("comment");
-      const replyParams   = useSearchParams().get("reply");
+      const searchParams  = useSearchParams();
+      const commentParams = searchParams.get("comment");
+      const replyParams   = searchParams.get("reply");
apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx (1)

70-78: Minor styling bug: unwanted leading space in colour string

backgroundColor fallback value has a leading space (" #F9F9F9").
This is benign in most browsers but technically invalid and may break minifiers.

-              backgroundColor: (commentParams || replyParams) === comment.id ? ["#F9F9F9", "#EDF6FF"] : " #F9F9F9",
+              backgroundColor: (commentParams || replyParams) === comment.id ? ["#F9F9F9", "#EDF6FF"] : "#F9F9F9",
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8e9406 and 32e3f8c.

📒 Files selected for processing (7)
  • apps/web/actions/videos/new-comment.ts (1 hunks)
  • apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx (3 hunks)
  • apps/web/app/(org)/dashboard/_components/Notifications/index.tsx (2 hunks)
  • apps/web/app/s/[videoId]/_components/tabs/Activity/Comment.tsx (2 hunks)
  • apps/web/app/s/[videoId]/_components/tabs/Activity/Comments.tsx (1 hunks)
  • apps/web/app/s/[videoId]/page.tsx (4 hunks)
  • apps/web/lib/Notification.ts (6 hunks)
🔇 Additional comments (3)
apps/web/app/s/[videoId]/page.tsx (1)

632-636: Comment ordering silently flips to oldest-first

Previous implementation used desc(comments.createdAt).
The new fallback comments.createdAt returns ascending order, changing UX and making the newest comments disappear off-screen.

Restore explicit ordering:

-          : comments.createdAt
+          : sql`${comments.createdAt} DESC`
apps/web/app/(org)/dashboard/_components/Notifications/NotificationItem.tsx (2)

65-70: Conditional render looks good

Grouping the comment and reply checks and adding h-fit + line-clamp-2 cleanly achieves the two-line preview.


97-101: Confirm URL format (& trailing slash) for reply links

Both the reply and comment paths include a slash right before the query string (/s/${id}/?reply=).
If the route is defined without the trailing slash (/s/[videoId]), this will redirect or 404 depending on Next.js config.
Double-check that the trailing slash is intentional and consistent across the app.

@ameer2468 ameer2468 merged commit a83ee6a into main Aug 8, 2025
6 of 7 checks passed
@ameer2468 ameer2468 deleted the fix-notification-ui-display branch August 8, 2025 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants