Skip to content

feat: implement patch#37

Merged
mehdiasadli merged 1 commit into
mainfrom
v25-05-02
May 4, 2026
Merged

feat: implement patch#37
mehdiasadli merged 1 commit into
mainfrom
v25-05-02

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented May 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added dedicated post pages with shareable links for direct post viewing
    • Introduced threaded comments with reply capabilities and collapsible branches
    • Enabled user mentions in posts and comments with autocomplete suggestions
    • Added "Copy link" feature for easy post sharing
    • Enhanced post previews when sharing links with rich metadata
  • Improvements

    • Comments section now opens by default on post pages
    • Mentioned users receive notifications about being tagged in posts and replies

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xamsa-web Ready Ready Preview, Comment May 4, 2026 10:15am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A comprehensive implementation of @mention support enabling users to tag other users in posts and comments, with cascading features including threaded comment views, individual post pages with Open Graph previews, and email notifications for mentioned users.

Changes

Mention Feature — Frontend, Backend, Database, and Routing

Layer / File(s) Summary
Data Shape & Database
packages/db/prisma/migrations/..., packages/db/prisma/schema/{post,auth,pack}.prisma
Added mention and mention_email_notification tables with relations from users/posts/comments. Extended User, Post, and Comment models with mention relations.
Schema & Type Definitions
packages/schemas/src/db/schemas/{enums,models}/{Mention,MentionEmailNotification}*, packages/schemas/src/modules/{post,comment,user}.ts
Defined Zod schemas for mention/notification records, MentionUsernameSchema for post/comment mention arrays, CommentThreadNodeSchema for threaded replies, and MentionCandidatesInputSchema/OutputSchema for suggestion queries.
Backend Mention Extraction & Persistence
packages/utils/src/mentions.ts, packages/api/src/lib/{mention-write,mention-notifications}.ts
Implemented extractMentionUsernames() regex extractor, insertMentionsForPost()/insertMentionsForCommentOnPost() transaction helpers, and notifyMentionedUsersForContent() deduped email notification dispatch.
Backend API Services
packages/api/src/modules/post/service.ts, packages/api/src/modules/comment/service.ts, packages/api/src/modules/user/service.ts
Added findOnePost() service to fetch posts by slug with mentions/reactions; enriched createPost() and createComment() to insert mentions and trigger notifications; added listPostCommentThreads() for cursor-paginated threaded comments; added mentionCandidates() for mention autocomplete (following/followers/all users by prefix).
Backend API Routers & Endpoints
packages/api/src/modules/{post,comment,user}/router.ts
Wired new public postRouter.findOne, public commentRouter.listThreadsByPost, and protected userRouter.mentionCandidates endpoints.
Email Notification Template
packages/mail/src/notifications.ts
Added sendMentionEmail() transactional mailer with recipient alert body, dedupe comment, and conditional send gating.
OG Preview Infrastructure
packages/api/src/og-data.ts, apps/web/src/lib/og/templates/post.tsx, apps/web/src/routes/api/og/post/$postSlug/og[.]png.tsx
Defined PostOgPayload interface and getPostOgData() fetcher; created PostOg template component rendering author, engagement counts, body preview, and optional media chip; added OG PNG route handler.
OG Development Mocks
apps/web/src/lib/og/dev-mocks.ts, apps/web/src/routes/api/dev/og-preview/$kind/og[.]png.tsx
Added mockPostOg dev fixture and extended preview kind support to include "post" preview in dev OG preview routes.
Mention-Aware Input Components
apps/web/src/components/home/mention-textarea.tsx, apps/web/src/components/home/mention-rich-text.tsx
Implemented MentionTextarea with caret tracking, mention context detection (@ before letter with alphanumeric prefix), real-time candidate querying, dropdown keyboard navigation (↑/↓/Enter/Tab), and mention insertion with caret positioning; implemented MentionRichText to parse and render @mention tokens as navigable links to user profiles or plain text when not found.
Home Feed & Comment UI
apps/web/src/components/home/home-feed.tsx
Refactored comments from flat list to threaded tree; added CommentTreeNode component with nested reply rendering, per-thread collapse/expand state, and depth-based reply control visibility; updated PostCommentsSection to use listThreadsByPost, manage reply targeting (replyToId), composed drafts, and collapsed thread IDs; enhanced PostCard to accept commentsInitiallyOpen flag, render body as clickable interactive region (feed only), add "Copy link" action with toast feedback, and use MentionRichText for body display.
Post Composer & Creation
apps/web/src/components/home/home-create-post.tsx
Switched textarea input from plain Textarea to MentionTextarea for mention-aware composition.
Post Detail Route & Page
apps/web/src/routes/p/$postSlug.tsx
Added /p/$postSlug route with async loader fetching post via orpc.post.findOne, dynamic SEO head metadata (title, description, OG image), and page component rendering centered PostCard with commentsInitiallyOpen and current session user context.
Nested Post Route & Redirect
apps/web/src/routes/u/$username.tsx, apps/web/src/routes/u/$username/p/$postSlug.tsx
Updated u/$username profile route to detect and outlet nested /p/$postSlug child routes; added /u/$username/p/$postSlug legacy route that redirects to canonical /p/$postSlug.
Route Generation & Configuration
apps/web/tsr.config.json, apps/web/src/routeTree.gen.ts
Added TanStack Router config file; updated generated route tree to include new routes (/p/$postSlug, /u/$username/p/$postSlug, /api/og/post/$postSlug/og.png) with updated file route type maps and module augmentation.
Version & Release Manifest
packages/utils/src/app-releases.ts
Updated app release manifest to patch version 2 for May 2026 with new release title and highlights.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant MentionTextarea
    participant API as API Server
    participant DB as Database

    User->>Browser: Types "@john" in textarea
    Browser->>MentionTextarea: onChange / caret position
    MentionTextarea->>MentionTextarea: Detect mention context (`@john`)
    MentionTextarea->>API: orpc.user.mentionCandidates({prefix:"john"})
    API->>DB: Query users where username startsWith "john"
    DB-->>API: [john_doe, johnny_smith, ...]
    API-->>MentionTextarea: Candidates dropdown
    MentionTextarea->>Browser: Render dropdown list
    User->>MentionTextarea: Arrow Down + Enter to select "john_doe"
    MentionTextarea->>MentionTextarea: Apply mention (`@john_doe`)
    MentionTextarea->>Browser: Update textarea value + move caret
    Browser-->>User: Textarea updated with "@john_doe "
Loading
sequenceDiagram
    participant User
    participant Browser
    participant PostAPI as Post API
    participant CommentAPI as Comment API
    participant DB as Database
    participant Mail as Mail Service

    User->>Browser: Create post with "@john" mention
    Browser->>PostAPI: orpc.post.create({body:"Check this `@john`"})
    PostAPI->>DB: Create post in transaction
    PostAPI->>PostAPI: Extract mentions (`@john`)
    PostAPI->>DB: Insert mention record (post→john)
    DB-->>PostAPI: ✓
    PostAPI->>DB: Fetch mentioned usernames
    DB-->>PostAPI: [{username:"john"}]
    PostAPI->>Mail: notifyMentionedUsersForContent(...) (async)
    Mail->>DB: Check 15min dedupe window
    DB-->>Mail: No recent notification
    Mail->>Mail: sendMentionEmail(john@example.com)
    Mail-->>User: Email sent (async)
    PostAPI-->>Browser: Post created with mentions
Loading
sequenceDiagram
    participant User
    participant Browser
    participant PostRoute as /p/$postSlug Route
    participant PostAPI as Post API
    participant DB as Database
    participant OGRoute as /api/og/post/$postSlug/og.png

    User->>Browser: Navigate to /p/post-slug
    Browser->>PostRoute: Load route
    PostRoute->>PostAPI: orpc.post.findOne({slug:"post-slug"})
    PostAPI->>DB: Fetch post + author + mentions
    DB-->>PostAPI: {body, author, mentions:[...], reactions, comments}
    PostAPI-->>PostRoute: Post data loaded
    PostRoute->>PostRoute: Build SEO metadata + OG image URL
    Browser->>OGRoute: Prefetch /api/og/post/post-slug/og.png
    OGRoute->>PostAPI: getPostOgData("post-slug")
    PostAPI->>DB: Fetch post preview + author + counts
    DB-->>PostAPI: {bodyPreview, author, hasImage, reactionCount, commentCount}
    OGRoute->>OGRoute: Render PostOg template
    OGRoute-->>Browser: OG image PNG
    PostRoute->>Browser: Render PostCard with mentions
    Browser-->>User: Post page with OG preview
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested labels

app:web, pkg:api, database, size:xl

Poem

🐰 A rabbit hops through mentions now,
Tagging friends with @ and how!
Threads collapse and posts take flight,
OG images shining bright—
Notifications hop away,
Xamsa grows a better day! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.89% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: implement patch' is vague and does not convey the specific nature of changes. The PR implements substantial features including @mentions, comment threading, post pages, and OG previews, but the title uses a generic placeholder term 'patch' without describing any of these key features. Replace with a descriptive title that captures the main feature(s), such as 'feat: add mention support with threaded comments and post pages' or break into more specific commit messages.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 v25-05-02

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@mehdiasadli mehdiasadli merged commit a34c5fa into main May 4, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v25-05-02 branch May 4, 2026 10:17
@coderabbitai coderabbitai Bot mentioned this pull request May 6, 2026
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