Skip to content

feat: implement patch#42

Merged
mehdiasadli merged 1 commit into
mainfrom
v26-05-07
May 6, 2026
Merged

feat: implement patch#42
mehdiasadli merged 1 commit into
mainfrom
v26-05-07

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented May 6, 2026

Summary by CodeRabbit

New Features

  • Added an in-app notification center accessible via a bell icon on the home screen and a dedicated notifications page with filtering and infinite scrolling
  • New notification preferences settings page enabling granular per-category controls, master mute switch, and email quiet hours with timezone support
  • Implemented real-time notifications with cross-tab badge synchronization to keep unread counts consistent across open tabs
  • Added Cmd/Ctrl+B keyboard shortcut to quickly open the notifications page

@vercel
Copy link
Copy Markdown

vercel Bot commented May 6, 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 6, 2026 5:56am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces a comprehensive in-app notification system with real-time updates via Ably, a notification center UI with filtering and grouping, granular user preferences with email quiet hours, and integrations for mentions, reactions, comments, follows, and game events across the platform.

Changes

In-App Notification System

Layer / File(s) Summary
Database & Type Definitions
packages/db/prisma/migrations/..., packages/db/prisma/schema/notification.prisma, packages/db/prisma/schema/auth.prisma, packages/db/prisma/schema/post.prisma, packages/db/prisma/schema/pack.prisma, packages/db/prisma/schema/game.prisma, packages/schemas/src/db/schemas/enums/Notification*.schema.ts, packages/schemas/src/db/schemas/models/Notification.schema.ts, packages/schemas/src/db/schemas/models/UserNotificationPreference.schema.ts
Migration adds notification and user_notification_preference tables with enums for type and delivery level. Prisma schema adds relations across User, Post, Comment, Pack, Topic, Game. Zod schemas define validation for all notification and preference structures.
Ably Real-time Channel Setup
packages/ably/src/channels.ts, packages/ably/src/server.ts
Introduces userInbox(userId) channel accessor and four NOTIFICATION_* events (new, seen, read, removed). Defines Zod schemas for inbox message payloads. Token capability grants per-user inbox subscription.
Core Notification Infrastructure
packages/api/src/modules/notification/create.ts, packages/api/src/modules/notification/delete.ts, packages/api/src/modules/notification/email-gate.ts, packages/api/src/modules/notification/quiet-hours.ts, packages/api/src/modules/notification/prefs.ts
Core utilities for creating notifications with deduplication, deleting unseen notifications, checking email eligibility by category and follow relationships, computing timezone-aware quiet hours, and managing user preferences.
Notification Service & Dispatchers
packages/api/src/modules/notification/service.ts, packages/api/src/modules/notification/dispatchers.ts
Service layer provides list, count, mark-seen/read operations with grouping and filtering. Dispatchers (notifyMention, notifyReaction, notifyCommentOnPost, notifyReply, notifyFollow, notifyPackPublished, notifyGameStarted, notifyGameFinished) route notifications through create with preference checks.
API Router & Schemas
packages/api/src/modules/notification/router.ts, packages/schemas/src/modules/notification.ts, packages/api/src/router.ts
API procedures for listing, counting, marking seen/read, and managing preferences. Comprehensive input/output schemas for all operations. Router wired into main appRouter.
Integration with Existing Services
packages/api/src/modules/comment/service.ts, packages/api/src/modules/post/service.ts, packages/api/src/modules/reaction/service.ts, packages/api/src/modules/user/service.ts, packages/api/src/modules/game/service.ts, packages/api/src/modules/pack/service.ts, packages/api/src/lib/mention-notifications.ts, packages/api/src/lib/post-engagement-notifications.ts, packages/api/src/modules/game/notify-game-winner-email.ts
Service methods dispatch in-app notifications on create/update (comments, posts, reactions, follows, games, packs). Email sending gated by shouldSendCategoryEmail. Mention and engagement emails check preferences before sending.
Frontend Real-time Sync Hook
apps/web/src/hooks/use-user-inbox-channel.ts
Hook subscribes to per-user Ably inbox channel, validates incoming messages, and updates react-query cache for unread counts and notification lists on notification lifecycle events. Enables cross-tab synchronization.
Frontend Notification Components
apps/web/src/components/notifications/notification-bell.tsx, apps/web/src/components/notifications/notification-row.tsx, apps/web/src/components/notifications/user-inbox-channel-mount.tsx
NotificationBell fetches unread count and recent notifications with popover UI. NotificationRow renders individual notifications with avatars, type icons, and read/click actions. UserInboxChannelMount initializes per-user subscription and wires Cmd/Ctrl+B shortcut.
Notification Pages
apps/web/src/routes/notifications.tsx, apps/web/src/routes/settings/notifications.tsx
/notifications page with infinite scroll, filtering (all, unread, mention, social, gameplay), and optimistic mark-all-read/mark-read mutations. /settings/notifications page provides granular per-feature delivery level controls, binary toggles, master mute switch, and email quiet hours with timezone selection.
Navigation & Routing
apps/web/src/routeTree.gen.ts, apps/web/src/routes/__root.tsx, apps/web/src/components/settings-nav.tsx, apps/web/src/components/home/home-global-search.tsx
Generated route tree updated with /notifications and /settings/notifications routes. Root layout mounts UserInboxChannelMount. SettingsNav adds Notifications tab. HomeGlobalSearch conditionally renders NotificationBell when signed in.
Release Notes & Roadmap
packages/utils/src/app-releases.ts, roadmap.md, apps/web/src/lib/roadmap-content.ts
Bump to v26.05.07 with release highlights. Roadmap updated with seven notification-related features: in-app center, per-user Ably channel, granular preferences, master mute, email quiet hours, grouping with optimistic updates, cross-tab sync.

Sequence Diagrams

sequenceDiagram
    participant User as User Action
    participant API as API Service
    participant DB as Database
    participant Ably as Ably
    participant Frontend as Frontend

    User->>API: Mention User / React / Comment / etc.
    API->>API: Validate preferences, check mute, deliverability
    API->>DB: Create notification row
    DB-->>API: Return notification id
    API->>Ably: Publish to user:recipientId:inbox
    Ably-->>Frontend: Broadcast NOTIFICATION_NEW
    Frontend->>Frontend: Update unread count & list cache
    Frontend-->>User: Update bell badge & list
Loading
sequenceDiagram
    participant Frontend1 as Tab 1
    participant Frontend2 as Tab 2
    participant Ably as Ably Channel
    participant API as API (preferences check)

    Frontend1->>Frontend1: useUserInboxChannel mounted
    Frontend1->>Ably: Subscribe to user:userId:inbox
    Frontend2->>Frontend2: useUserInboxChannel mounted
    Frontend2->>Ably: Subscribe to user:userId:inbox
    
    Frontend1->>API: Mark notification as read
    API->>Ably: Publish NOTIFICATION_READ event
    Ably-->>Frontend1: Receive event
    Ably-->>Frontend2: Receive event (cross-tab)
    Frontend1->>Frontend1: Update cache
    Frontend2->>Frontend2: Update cache (synced)
Loading
sequenceDiagram
    participant Service as API Service
    participant Prefs as Preferences Cache
    participant Follow as Follow Check
    participant QuietHours as Quiet Hours

    Service->>Service: Before sending email
    Service->>Prefs: Load user notification preferences
    Prefs-->>Service: Return prefs
    Service->>Service: Check if category is muted
    alt Category muted or muteAllExceptSecurity
        Service-->>Service: Skip email
    else Category enabled
        Service->>Follow: Check if delivery level requires follower
        alt Level is "followers" and not following
            Service-->>Service: Skip email
        else Delivery allowed
            Service->>QuietHours: Check if in email quiet hours
            QuietHours-->>Service: isInQuietHours?
            alt In quiet hours
                Service-->>Service: Skip email
            else Not in quiet hours
                Service-->>Service: Send email
            end
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • asmelabs/xamsa#30: Both PRs directly modify apps/web/src/components/home/home-global-search.tsx—this PR adds NotificationBell and auth-aware rendering while the related PR updates the search prompt text.
  • asmelabs/xamsa#37: Both PRs touch the mention notification codepath, modifying packages/api/src/lib/mention-notifications.ts and related mention dispatch logic.

Suggested labels

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

Poem

A bell that rings across the tabs so bright,
Preferences whisper through the quiet night,
Timezones wrap, quiet hours flow,
Ably channels let the updates grow,
Real-time notifications bloom in sight! 🔔✨

✨ 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-07

@mehdiasadli mehdiasadli merged commit ac29bee into main May 6, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-05-07 branch May 6, 2026 06:00
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