Skip to content

feat: implement patch#39

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

feat: implement patch#39
mehdiasadli merged 1 commit into
mainfrom
v26-05-04

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented May 4, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Live presence indicators showing player online/away/offline status in games
    • QR code for quick lobby joins via phone camera scan
    • Comment reactions with emoji counts and breakdown view
    • Admin dashboard for moderating posts and comments with filtering
    • Duplicate question policy explainer with inline guidance
  • Improvements

    • Enhanced game share sheet with scannable QR code
    • Clearer post-game replay option labels
    • Comment reaction bars integrated throughout discussions

@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 2:01pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR implements a comprehensive admin dashboard for posts and comments, adds reaction capabilities to posts and comments with a reusable ReactionBar component, introduces real-time game presence indicators (online/away/offline) for players and hosts, enhances duplicate policy communication with an explainer component, and adds QR code invites via a new HostLobbyQr component. Schema, service, and routing updates support these features throughout the stack.

Changes

Admin Dashboard for Posts & Comments

Layer / File(s) Summary
Schema Definitions
packages/schemas/src/modules/admin.ts, packages/schemas/src/modules/listings/admin.ts
New Zod schemas for admin post/comment listing inputs, filters, and outputs. Post filters include author, image/attachment flags, and reaction/comment ranges. Comment filters add target kind selection and depth ranges. Admin user schema gains totalPosts and totalComments. Sort/search/period resolvers added for both posts and comments.
Backend Service & Query Builders
packages/api/src/modules/admin/service.ts, packages/api/src/modules/admin/build-where.ts
listAdminPosts and listAdminComments functions fetch and format data with excerpts and metadata. buildAdminPostsWhere and buildAdminCommentsWhere construct Prisma filters from input (search, period, author, ranges). Comment service resolves target references (post/pack/topic/question) in parallel.
API Router
packages/api/src/modules/admin/router.ts
Moderator-gated listPosts and listComments endpoints added to admin router with schema validation.
Frontend Routes & UI
apps/web/src/routes/dashboard/posts/index.tsx, apps/web/src/routes/dashboard/comments/index.tsx, apps/web/src/routes/dashboard/index.tsx, apps/web/src/routeTree.gen.ts, apps/web/src/routes/dashboard.tsx
New dashboard pages for posts and comments with sortable/filterable admin data tables. Dashboard navigation updated. TanStack router configuration regenerated for new routes.
Frontend Filters & Tooling
apps/web/src/components/admin/filters/admin-posts-filters.tsx, apps/web/src/components/admin/filters/admin-comments-filters.tsx
useAdminPostsFilterUI and useAdminCommentsFilterUI hooks manage URL query state for filters and render dialog-based filter UI with clear-all actions.
User Admin Integration
apps/web/src/routes/dashboard/users/index.tsx
User list dashboard extended with totalPosts and totalComments columns and corresponding sort options.

Comment Reactions & Enrichment

Layer / File(s) Summary
Schema Definitions
packages/schemas/src/modules/comment.ts, packages/api/src/modules/reaction/sort.ts
CommentRowSchema adds myReactionType and reactionsByType fields. New ReactionByType type and sortedReactionsByTypeFromGrouped helper for stable per-emoji breakdowns.
API Service Enrichment
packages/api/src/modules/comment/service.ts, packages/api/src/modules/comment/router.ts
Comment listing functions (listPostCommentThreads, listPackCommentThreads, etc.) now accept optional viewerUserId and batch-fetch viewer reactions and aggregated reaction counts. reactionsForComments helper builds per-comment reaction state. Router handlers pass context.session?.user?.id to service functions.
Shared Reaction Sorting
packages/api/src/modules/post/service.ts
Post service now imports sortedReactionsByTypeFromGrouped instead of defining locally, removing duplicate code.
Reaction UI Components
apps/web/src/components/reactions/reaction-bar.tsx, apps/web/src/components/reactions/comment-reaction-bar.tsx
ReactionBar renders interactive emoji chips, an add-reaction picker with optimistic updates via React Query mutation, and a breakdown dialog showing per-emoji counts. Handles login prompts and query invalidation. CommentReactionBar wraps ReactionBar with comment-specific density and thread query invalidation.
Comment Thread Rendering
apps/web/src/components/home/home-feed.tsx, apps/web/src/components/pack-topic-discussion-section.tsx
Comment tree nodes now render CommentReactionBar and accept threadQueryKey / loginRedirect props for reaction wiring. Props plumbed through recursive comment rendering.
Post Reaction Refactor
apps/web/src/components/home/home-post-reactions.tsx
PostReactionBar now delegates all reaction logic to shared ReactionBar component, removing 420+ lines of local state/mutation/picker code.

Game Presence Display System

Layer / File(s) Summary
Presence Schema & Types
packages/ably/src/channels.ts
New GamePresenceDataSchema discriminated union for Ably presence payloads: host and player variants with visible boolean and optional playerId.
Presence Hook & Provider
apps/web/src/hooks/use-game-presence.tsx
New GamePresenceProvider manages real-time presence state (online/away/offline) for game host and players via Ably channel subscriptions. Seeded from existing members, updated on visibility changes, and re-entered on reconnect. useGamePresence consumer hook returns presence context or default offline state. Removed presence lifecycle from useGameChannel.
Updated Game Channel Hook
apps/web/src/hooks/use-game-channel.ts
Presence enter/leave lifecycle removed; commented to indicate GamePresenceProvider now owns it. Host-disconnect detection still uses presence enter/leave events.
Presence UI Component
apps/web/src/components/presence-dot.tsx
New PresenceDot component renders a colored circular indicator (green/yellow/gray) with tooltip showing online/away/offline status and accompanying text. Supports size variants and custom className.
Header & Player Integration
apps/web/src/components/game-header.tsx, apps/web/src/components/player-row.tsx
Game header renders presence dot and host/player status inline with topic progress. Player row displays presence dot next to player name. Both use useGamePresence() to fetch real-time state.
Route Provider Wrapping
apps/web/src/routes/g/$code/index.tsx
Game session UI wrapped in GamePresenceProvider to enable presence features for all components within.

Duplicate Policy & Invite UX

Layer / File(s) Summary
Policy Definition & Options
apps/web/src/lib/duplicate-policy-options.ts
New DuplicatePolicyOption type and DUPLICATE_POLICY_OPTIONS constant centralize copy for none, block_individuals, and block_room policies with labels, descriptions, who-is-blocked info, and when-to-pick guidance.
Explainer Component
apps/web/src/components/duplicate-policy-explainer.tsx
New DuplicatePolicyExplainer displays a grid of policy options with conditional highlighting and mode-specific details. DuplicatePolicyExplainerLink wraps it in a popover triggered by an info icon (icon-only or with underlined label).
Component & Dialog Integration
apps/web/src/components/buzz-button.tsx, apps/web/src/components/start-game-card.tsx
BuzzButton adds inline "Why am I muted?" explainer link. StartGameCard imports centralized DUPLICATE_POLICY_OPTIONS and adds policy explainer link to the replay/duplicate question label.
QR Invite & Share
apps/web/src/components/host-lobby-qr.tsx, apps/web/src/components/game-share-sheet.tsx
New HostLobbyQr component renders scannable QR code with optional caption. Share sheet removes social-platform targets and adds "Scan to join" QR section.

Polish & Metadata Updates

Layer / File(s) Summary
Release Notes & Roadmap
packages/utils/src/app-releases.ts, apps/web/src/lib/roadmap-content.ts
App release version bumped to v26.05.04 with new player/host feature highlights (QR, presence, reactions). Roadmap version marked implemented: true with description updates noting Ably suitability for presence.
End-Game Polish
apps/web/src/components/end-game-screen.tsx
Host "Play again" button text changed to "Play again with this pack".
Dependency Reordering
apps/web/package.json
Dependencies reordered for consistency (no version/package changes).

Sequence Diagram(s)

sequenceDiagram
    actor Player
    participant GameHeader as Game Header
    participant Presence as GamePresenceProvider
    participant Ably as Ably Channel
    participant Context as Presence Context

    Player ->> GameHeader: Render game session
    GameHeader ->> Presence: Initialize GamePresenceProvider
    Presence ->> Ably: Subscribe to presence channel
    Ably ->> Presence: Emit existing members (seed state)
    Presence ->> Context: Update host/player presence state
    
    Player ->> GameHeader: Page becomes visible
    GameHeader ->> Presence: Document visibility changes
    Presence ->> Ably: Update presence payload (visible: true)
    Ably ->> Presence: Broadcast update
    Presence ->> Context: Update state (online)
    GameHeader ->> GameHeader: Render PresenceDot (green)
    
    Player ->> GameHeader: Page hidden/backgrounded
    GameHeader ->> Presence: Document visibility changes
    Presence ->> Ably: Update presence payload (visible: false)
    Ably ->> Presence: Broadcast update
    Presence ->> Context: Update state (away)
    GameHeader ->> GameHeader: Render PresenceDot (yellow)
Loading
sequenceDiagram
    actor User
    participant CommentRow as Comment Row
    participant ReactionBar as ReactionBar
    participant Picker as Reaction Picker
    participant Mutation as React Query Mutation
    participant Server as API Server
    participant Query as Thread Query Cache

    User ->> CommentRow: View comment with reactions
    CommentRow ->> ReactionBar: Render with comment data
    ReactionBar ->> ReactionBar: Initialize local optimistic state
    ReactionBar ->> ReactionBar: Render reaction chips + add button
    
    User ->> Picker: Click add-reaction button
    Picker ->> Picker: Open emoji picker
    User ->> Picker: Select emoji
    Picker ->> ReactionBar: Commit reaction selection
    
    ReactionBar ->> ReactionBar: Apply optimistic update (my, total, byType)
    ReactionBar ->> ReactionBar: Render updated chips immediately
    ReactionBar ->> Mutation: Trigger setReaction mutation
    
    Mutation ->> Server: POST set reaction
    alt Mutation succeeds
        Server ->> Server: Persist reaction
        Mutation ->> Query: Invalidate thread query
        Query ->> CommentRow: Refetch and re-render with server state
    else Mutation fails
        Mutation ->> ReactionBar: Rollback optimistic state
        ReactionBar ->> ReactionBar: Restore previous reactions
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • PR #10: Both add the staff dashboard (routes/pages), admin list APIs/schemas/services, and admin UI components/filters with overlapping files like admin router, service, and build-where functions.
  • PR #3: Both modify the game real-time stack (Ably channels/schemas in packages/ably/src/channels.ts and game presence/channel hooks), with direct code-level overlap.
  • PR #36: Both implement the same posts and reactions feature set (post reactions UI, comment reaction fields, reaction APIs/services, and home feed integration).

Suggested labels

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

Poem

🐰 Reactions bloom where comments live,
Presence dots now gently give,
A glimpse of who's away or near,
With QR codes, invites appear!
Admin dashboards help us see,
All the posts and comments—wheee!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% 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 PR title 'feat: implement patch' is vague and overly generic. It does not clearly convey what specific feature or patch is being implemented, given the substantial changeset spanning presence indicators, comment reactions, admin filtering, QR codes, and multiple new components. Provide a more specific title that highlights the primary feature or domain (e.g., 'feat: add game presence indicators and comment reactions' or 'feat: implement player presence and reaction systems').
✅ 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 v26-05-04

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 7661e4f into main May 4, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-05-04 branch May 4, 2026 14:05
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