Skip to content

feat: implement patch#38

Merged
mehdiasadli merged 1 commit into
mainfrom
v26-05-03
May 4, 2026
Merged

feat: implement patch#38
mehdiasadli merged 1 commit into
mainfrom
v26-05-03

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented May 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added post bookmarking with "Saved" section in user profiles
    • Added feed switching between "Everyone" and "Following" timelines
    • Added discussion sections to packs, topics, and questions
    • Added posts to global search results
    • Added tabbed navigation to pack and topic pages (Content, Analytics, Discussion)
    • Redesigned profile page with tabbed sections (Feed, Saved, Badges, Stats, Packs, Games)
    • Added character counter and limits to post composer
    • Improved post reactions UI with click-based interaction
  • Improvements

    • Enhanced post page styling and layout
    • Better comment section UX
  • Chores

    • Updated roadmap

@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 11:32am

@mehdiasadli mehdiasadli merged commit dbdbe4a into main May 4, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-05-03 branch May 4, 2026 11:32
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6e5d9c40-d5aa-4403-979a-008b357c88b5

📥 Commits

Reviewing files that changed from the base of the PR and between f8b922b and 8823a85.

📒 Files selected for processing (35)
  • apps/web/src/components/global-search-provider.tsx
  • apps/web/src/components/home/home-create-post.tsx
  • apps/web/src/components/home/home-feed.tsx
  • apps/web/src/components/home/home-post-reactions.tsx
  • apps/web/src/components/pack-topic-discussion-section.tsx
  • apps/web/src/lib/home-post-feed-query.ts
  • apps/web/src/lib/roadmap-content.ts
  • apps/web/src/routes/index.tsx
  • apps/web/src/routes/p/$postSlug.tsx
  • apps/web/src/routes/packs/$packSlug/index.tsx
  • apps/web/src/routes/packs/$packSlug/topics/$topicSlug/index.tsx
  • apps/web/src/routes/packs/$packSlug/topics/$topicSlug/questions/$questionSlug/index.tsx
  • apps/web/src/routes/u/$username.tsx
  • packages/api/src/modules/comment/router.ts
  • packages/api/src/modules/comment/service.ts
  • packages/api/src/modules/pack/service.ts
  • packages/api/src/modules/post/router.ts
  • packages/api/src/modules/post/service.ts
  • packages/api/src/modules/question/service.ts
  • packages/api/src/modules/topic/service.ts
  • packages/api/src/modules/user/home-search.ts
  • packages/db/prisma/migrations/20260504104348_post_bookmarks/migration.sql
  • packages/db/prisma/schema/auth.prisma
  • packages/db/prisma/schema/post.prisma
  • packages/schemas/src/db/schemas/enums/PostBookmarkScalarFieldEnum.schema.ts
  • packages/schemas/src/db/schemas/models/PostBookmark.schema.ts
  • packages/schemas/src/db/schemas/models/index.ts
  • packages/schemas/src/modules/comment.ts
  • packages/schemas/src/modules/pack.ts
  • packages/schemas/src/modules/post.ts
  • packages/schemas/src/modules/question.ts
  • packages/schemas/src/modules/search.ts
  • packages/schemas/src/modules/topic.ts
  • packages/utils/src/app-releases.ts
  • roadmap.md

📝 Walkthrough

Walkthrough

This PR introduces post bookmarking, discussion threads on packs/topics/questions with tabbed navigation, post search integration, comprehensive feed/post-card improvements, home timeline selection between "everyone" and "following", and a tabified profile page with feed/saved/badges/stats/packs/games tabs.

Changes

Post Bookmarking Feature

Layer / File(s) Summary
Database & Schema
packages/db/prisma/migrations/20260504104348_post_bookmarks/migration.sql, packages/db/prisma/schema/post.prisma, packages/db/prisma/schema/auth.prisma
New post_bookmark table with composite primary key (user_id, post_id), index on (user_id, created_at DESC), and cascade deletes. User and Post models gain postBookmarks and bookmarks relations.
Validation Schemas
packages/schemas/src/db/schemas/models/PostBookmark.schema.ts, packages/schemas/src/db/schemas/enums/PostBookmarkScalarFieldEnum.schema.ts, packages/schemas/src/db/schemas/models/index.ts
New PostBookmarkSchema with createdAt, userId, postId and scalar field enum; exported for DB type inference.
Post Row & API Schemas
packages/schemas/src/modules/post.ts
PostRowSchema gains optional myBookmarked field; new ListPostsFeedSchema enum ("everyone" | "following"), SetPostBookmarkInputSchema/SetPostBookmarkOutputSchema, and ListBookmarkedPostsInputSchema for bookmark operations.
Comment Thread Schemas
packages/schemas/src/modules/comment.ts
New input/output schemas for listing comment threads by pack, topic, or question (mirroring post-thread shape).
Pack/Topic/Question Schemas
packages/schemas/src/modules/pack.ts, packages/schemas/src/modules/topic.ts, packages/schemas/src/modules/question.ts
FindOnePack, FindOneTopic, FindOneQuestion output schemas now include id field.
Backend Service
packages/api/src/modules/post/service.ts
Bookmark cursor helpers (encodeBookmarkCursor/decodeBookmarkCursor), postIdsBookmarkedBy() to fetch user's bookmarked post IDs, updated toPostRow() to conditionally include myBookmarked, and refactored listPosts to precompute bookmarks; new listBookmarkedPosts with bookmark-cursor pagination.
Comment Service
packages/api/src/modules/comment/service.ts
assertTargetReferencesExist now validates pack status/visibility and author-only access for private packs; refactored thread listing to generic listCommentThreadsForTarget with new exports for pack/topic/question thread listing.
Pack/Topic/Question Service
packages/api/src/modules/pack/service.ts, packages/api/src/modules/topic/service.ts, packages/api/src/modules/question/service.ts
Each now includes id in returned Prisma select clause.
Router Endpoints
packages/api/src/modules/post/router.ts, packages/api/src/modules/comment/router.ts
Post router adds setBookmark and listBookmarked protected procedures; comment router adds listThreadsByPack, listThreadsByTopic, listThreadsByQuestion public procedures.
Feed Query Helpers
apps/web/src/lib/home-post-feed-query.ts
Refactored to support multiple feeds via baseHomeListInput(feed) and updated homePostListInfiniteOptions(feed); added bookmarkedPostsInfiniteOptions, profilePostsInfiniteOptions, new touchesPostRowInfiniteCache predicate, and new setPostBookmarkedInCaches helper for cache updates.
Feed UI Integration
apps/web/src/components/home/home-feed.tsx
PostCardInner adds setBookmarkMutation with optimistic updates, rollback on error, and success toast; bookmark button rendered only for authenticated users; reflects post.myBookmarked state in icon fill and styling.

Discussion System & Tabbed Architecture

Layer / File(s) Summary
Discussion Component
apps/web/src/components/pack-topic-discussion-section.tsx
New PackTopicDiscussionSection renders threaded comments for pack/topic/question targets, supporting compose, reply (up to depth 3), collapse/expand branches, and infinite pagination via useInfiniteQuery and useMutation.
Pack Page Tabs
apps/web/src/routes/packs/$packSlug/index.tsx
Introduces tab query state (content/analytics/discussion), conditionally renders PublicAnalyticsSection, PackTopicsList, and PackTopicDiscussionSection based on tab and pack status.
Topic Page Tabs
apps/web/src/routes/packs/$packSlug/topics/$topicSlug/index.tsx
Adds tab query state, conditionally renders analytics/discussion/questions sections; discussion shown only for published packs with sessionUserId passed and login redirect.
Question Page Tabs
apps/web/src/routes/packs/$packSlug/topics/$topicSlug/questions/$questionSlug/index.tsx
Adds tab query state for analytics/discussion; discussion section conditionally rendered only when pack is published.

Home Feed Enhancements & Timeline Selection

Layer / File(s) Summary
Post Reactions Redesign
apps/web/src/components/home/home-post-reactions.tsx
ReactionBreakdownDialog now shows only non-zero reactions with percentage bars and "You" indicator; PostReactionBar refactored from pointer-hold to click-driven chips + dedicated "add reaction" button with picker overlay; local optimistic updates retained.
Post Card & Comments
apps/web/src/components/home/home-feed.tsx
CommentTreeNode restructured with new layout; PostCommentsSection changed to controlled API (open/onOpenChange props, variant option); PostCardInner manages comments via local state and adds attachment fallback UI ("link unavailable yet").
Composer Improvements
apps/web/src/components/home/home-create-post.tsx
Adds user avatar/initials header, introduces MAX_BODY = 1000 character limit, derives canSubmit state, displays character remaining counter (near limit), and disables submit button when limit exceeded.
Home Route Feed Selection
apps/web/src/routes/index.tsx
Signed-in home now uses useQueryState to toggle feed between "everyone" and "following", passes homeFeed={feed} to HomeMixedFeed, and renders tab buttons for timeline selection.
Post Page Layout
apps/web/src/routes/p/$postSlug.tsx
Wraps post content in relative container with decorative gradient/background, adds "Back to feed" navigation link with ChevronLeft icon, and restructures max-width/padding layout.
Feed Props & Query Options
apps/web/src/components/home/home-feed.tsx
HomeMixedFeed now accepts homeFeed: ListPostsFeedType prop and uses it to parameterize homePostListInfiniteOptions(feed) for multi-feed support.

Post Search Integration

Layer / File(s) Summary
Search Service
packages/api/src/modules/user/home-search.ts
Added snippetText helper for whitespace normalization and truncation; expanded interleave routine to include posts bucket; updated homeSearch to fetch and map post rows into HomeSearchItemType entries with title/description derived from snippet/author.
Search Schemas
packages/schemas/src/modules/search.ts
New HomeSearchPostItemSchema with kind: "post", slug, title, description; extended HomeSearchItemSchema discriminated union to include post items.
Global Search UI
apps/web/src/components/global-search-provider.tsx
Added MessageSquareQuoteIcon import; extended itemIconAndLabel with "post" case; added "post" rendering branch in HomeSearchRow linking to /p/$postSlug; updated openItemRoute with "post" navigation; updated list-item key generation to include post-${item.slug}-${i} branch.

Profile Page Refactor

Layer / File(s) Summary
Profile Tabification
apps/web/src/routes/u/$username.tsx
Introduces profileTab URL query state with tabs: Feed, Saved (owner-only), Badges, Stats, Packs, Games; gates queries (packs, publicStats, gameActivity) to enabled-only-when-active; adds infinite queries for profile feed (profilePostsInfiniteOptions) and saved posts (bookmarkedPostsInfiniteOptions); adds intersection-observer effects for auto-pagination; replaces always-rendered sections with tab-conditional rendering.

Content & Infrastructure Updates

Layer / File(s) Summary
Roadmap Updates
roadmap.md, apps/web/src/lib/roadmap-content.ts
Version v26.05.03 marked implemented: true; v26.05.04 adds new item "Player presence on the game"; roadmap markdown expanded with scope for post cards, following tab, discussion threads, bookmarking, profile tabs, and analytics/content/discussion page layouts.
Release Metadata
packages/utils/src/app-releases.ts
Incremented current patch to v2026-05-03; prepended new release entry for 2026-05-04 with updated highlights.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant UI as Post Feed UI
    participant API as Post Service
    participant DB as Database
    participant Cache as React Query Cache

    User->>UI: Click bookmark button on post
    UI->>Cache: Apply optimistic update (myBookmarked=true)
    UI->>API: setPostBookmark(postId, bookmarked=true)
    API->>DB: Insert post_bookmark record
    DB-->>API: Success
    API-->>UI: Return bookmarked=true
    UI->>Cache: Confirm optimistic update
    UI->>User: Show "Saved" toast & filled icon
    
    Note over User,Cache: Bookmark persisted across feed, profile Saved tab, and other caches
Loading
sequenceDiagram
    actor User
    participant DiscussionUI as Discussion Section
    participant API as Comment Service
    participant DB as Database
    participant Cache as Query Cache

    User->>DiscussionUI: Scroll into view (pack/topic/question discussion)
    DiscussionUI->>API: listThreadsByPack/Topic/Question(cursor)
    API->>DB: Query root comments, then tree members, build reply forest
    DB-->>API: Thread hierarchy
    API-->>DiscussionUI: Paginated root threads with nested replies
    DiscussionUI->>User: Render comment tree (collapsible branches)
    
    User->>DiscussionUI: Click Reply on comment (depth < 3)
    DiscussionUI->>DiscussionUI: Set replyToId, focus composer
    User->>DiscussionUI: Submit reply text
    DiscussionUI->>API: createComment(body, parentId, targetId)
    API->>DB: Insert comment, link to parent
    DB-->>API: New comment created
    API-->>Cache: Invalidate thread list query
    Cache->>DiscussionUI: Refetch threads
    DiscussionUI->>User: Display reply in tree, clear draft
Loading
sequenceDiagram
    actor User
    participant Nav as Route/Tabs
    participant HomeFeed as Home Feed
    participant API as Post Service
    participant Cache as Query Cache

    User->>Nav: Click "Everyone" / "Following" timeline toggle
    Nav->>Nav: setFeed("everyone" | "following"), update URL ?feed=...
    HomeFeed->>HomeFeed: Derive homeFeed prop from route state
    HomeFeed->>API: homePostListInfiniteOptions(feed="everyone" or "following")
    API->>Cache: Query/invalidate feed cache by feed type
    Cache-->>HomeFeed: Load posts from correct feed
    HomeFeed->>User: Render timeline for selected audience
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes


Possibly related PRs

  • feat: implement patch #36: Introduces the underlying post feature and post creation/upload; this PR builds on top with bookmarking, search, and display improvements for posts.
  • Feat/topic-deletion #12: Modifies pack/topic pages and comment-related components; this PR extends similar page structure with tabbed discussion and analytics.
  • feat: implement new patch #35: Extends global-search-provider to handle additional search item kinds; this PR adds post kind support with similar icon/link patterns.

Suggested labels

pkg:api, pkg:db, pkg:schemas, feature/bookmarks, feature/discussion-threads, feature/timeline-selection, feature/post-search


Poem

🐰 Posts now bookmark and converse,
Tabs organize each universe,
"Follow" or "Everyone" choose your view,
Discussion threads for packs run true,
Reactions click, searches find,
A feed refreshed for wandering mind! ✨

✨ 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 v26-05-03

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.

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