Skip to content

feat: implement new patch#32

Merged
mehdiasadli merged 2 commits into
mainfrom
v26-04-25
Apr 30, 2026
Merged

feat: implement new patch#32
mehdiasadli merged 2 commits into
mainfrom
v26-04-25

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented Apr 30, 2026

Summary by CodeRabbit

  • New Features

    • Profile photo upload with interactive cropping and zoom adjustment
    • Support for JPEG, PNG, and WebP formats (max 8MB file size)
    • Option to remove your profile photo from settings
  • Documentation

    • Updated setup guide with additional configuration requirements

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

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

Project Deployment Actions Updated (UTC)
xamsa-web Ready Ready Preview, Comment Apr 30, 2026 11:48am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@mehdiasadli has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 46 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14132ff1-0c26-433a-9d6e-9213781f7672

📥 Commits

Reviewing files that changed from the base of the PR and between 1b21b6c and ce80b37.

📒 Files selected for processing (1)
  • packages/utils/src/app-releases.ts
📝 Walkthrough

Walkthrough

This PR introduces a complete profile avatar management system integrating Cloudinary backend storage with frontend image cropping using react-easy-crop, including new API endpoints, upload/removal service functions, schema validation, and all necessary environment configuration.

Changes

Cohort / File(s) Summary
Frontend Avatar Components
apps/web/src/components/profile-avatar-crop-dialog.tsx, apps/web/src/lib/square-avatar-canvas.ts, apps/web/src/routes/settings/index.tsx
New modal dialog for cropping profile photos with 1:1 aspect ratio and zoom slider; utility function converts cropped area to 512px JPEG base64; settings page integrates image selection, validation, cropping workflow, and upload/removal mutations with state refresh.
Upload Package
packages/upload/package.json, packages/upload/tsconfig.json, packages/upload/src/index.ts, packages/upload/src/cloudinary-url.ts, packages/upload/src/destroy-image.ts, packages/upload/src/env-segment.ts, packages/upload/src/paths.ts, packages/upload/src/upload-profile-image.ts
New @xamsa/upload workspace package provides Cloudinary integration: upload profile images with MIME/size validation and magic-number verification; destroy images by public ID; extract public IDs and determine managed profile image URLs; build storage path prefixes and user-specific avatar public IDs.
API Router & Service
packages/api/src/modules/user/router.ts, packages/api/src/modules/user/service.ts
New protected endpoints setAvatar and removeAvatar validate input and delegate to service functions; service functions perform user lookup, convert base64 to buffer, upload via Cloudinary, update database, cleanup prior images, and handle error cases with logging.
Schema & Validation
packages/schemas/src/modules/user.ts
New avatar upload/removal schemas define allowed MIME types (JPEG/PNG/WebP), constrain base64 size, normalize data URLs into clean base64, and provide input/output types for set and remove operations.
Environment & Configuration
packages/env/src/server.ts, turbo.json, docs/SETUP.md, apps/web/package.json, packages/api/package.json
Add required Cloudinary environment variables (CLOUDINARY_CLOUD_NAME, CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET) to server env schema and Turbo global tracking; update documentation; add react-easy-crop web dependency and @xamsa/upload API dependency.
Release & Roadmap
packages/utils/src/app-releases.ts, draft.md
Version bump to 2026-04-25; add release entry documenting profile photo experience with Cloudinary integration; extend roadmap with Google auth plans and social features.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Web as Web (Frontend)
    participant Dialog as Avatar Crop Dialog
    participant Canvas as Canvas Utils
    participant API as API Endpoint
    participant Service as Avatar Service
    participant Cloudinary as Cloudinary
    participant DB as Database

    User->>Web: Click Change Avatar
    Web->>Web: Show file input (JPEG/PNG/WebP, 8MB max)
    User->>Web: Select image file
    Web->>Dialog: Open crop dialog with image
    Dialog->>Dialog: Display image with zoom slider
    User->>Dialog: Adjust crop area & zoom
    Dialog->>Dialog: Track crop coordinates
    User->>Dialog: Click "Use this photo"
    Dialog->>Canvas: Convert cropped area to JPEG base64
    Canvas->>Canvas: Load image, draw to canvas (512×512)
    Canvas->>Canvas: Convert to JPEG (quality 0.9)
    Canvas->>Dialog: Return imageBase64 + mimeType
    Dialog->>API: POST /user/setAvatar {imageBase64, mimeType}
    API->>Service: setUserAvatar(input, userId)
    Service->>Service: Validate base64 & convert to Buffer
    Service->>Cloudinary: Upload via upload_stream
    Cloudinary->>Service: Return secureUrl & publicId
    Service->>DB: Update user.image = secureUrl
    Service->>Cloudinary: Delete prior image (if different publicId)
    Service->>API: Return {image: secureUrl}
    API->>Web: Success response + toast
    Web->>Web: Refresh session & router data
    Web->>User: Display updated avatar
    Dialog->>Dialog: Close & reset state
Loading
sequenceDiagram
    participant User as User
    participant Web as Web (Frontend)
    participant API as API Endpoint
    participant Service as Avatar Service
    participant Cloudinary as Cloudinary
    participant DB as Database

    User->>Web: Click Remove Avatar
    Web->>API: POST /user/removeAvatar
    API->>Service: removeUserAvatar(userId)
    Service->>DB: Lookup user by ID
    DB->>Service: User data with current image URL
    Service->>Service: Extract publicId from Cloudinary URL
    Service->>Cloudinary: Delete image by publicId (invalidate cache)
    Cloudinary->>Service: Deletion complete (or not_found treated as success)
    Service->>DB: Update user.image = null
    Service->>API: Return {image: null}
    API->>Web: Success response + toast
    Web->>Web: Refresh session & router data
    Web->>User: Display default initials
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

app:web, dependencies, config, size:xl, pkg:api, pkg:env, docs

Poem

🐰 A fuzzy rabbit hops with glee,
New avatars for all to see!
With Cloudinary in the fold,
Crop and upload, sharp and bold!
Profiles shine, from dev to prod,
A feature fit for any squad! 📸

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.00% 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 new patch' is generic and vague, not clearly summarizing the main changes in the changeset which involve implementing profile photo management with Cloudinary integration. Consider using a more specific title like 'feat: implement profile photo upload and cropping with Cloudinary' to better describe the primary changes in this patch.
✅ 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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v26-04-25

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 47 minutes and 46 seconds.

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

@mehdiasadli mehdiasadli merged commit b6fad4b into main Apr 30, 2026
4 checks passed
@mehdiasadli mehdiasadli deleted the v26-04-25 branch April 30, 2026 11:54
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