Skip to content

feat(experience,account): add image crop for avatar upload#8914

Merged
wangsijie merged 1 commit into
masterfrom
sijie-avatar-image-crop-9965
Jun 2, 2026
Merged

feat(experience,account): add image crop for avatar upload#8914
wangsijie merged 1 commit into
masterfrom
sijie-avatar-image-crop-9965

Conversation

@wangsijie
Copy link
Copy Markdown
Contributor

@wangsijie wangsijie commented May 30, 2026

Summary

Add a square crop + zoom step to the avatar upload flow in Experience sign-up (Collect User Profile) and Account Center profile. Selecting an image opens a crop modal; the cropped result is exported as a JPEG blob before upload.

  • Shared useAvatarCropUpload hook for select → crop → upload orchestration
  • AvatarCropModal with square crop, zoom slider, and inline error display
  • Scoped blob: in img-src CSP for Experience and Account Center only
  • Persist failures show error_save in the modal and retry without re-uploading the asset

Testing

Tested locally
Unit tests

Open in Web Open in Cursor 

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

COMPARE TO master

Total Size Diff ⚠️ 📈 +31.54 KB

Diff by File
Name Diff
packages/account/package.json 📈 +33 Bytes
packages/account/src/components/AvatarUploadField/index.test.tsx 📈 +5.66 KB
packages/account/src/components/AvatarUploadField/index.tsx 📈 +1.96 KB
packages/account/src/pages/Profile/index.test.tsx 📈 +3.54 KB
packages/account/src/pages/Profile/index.tsx 📈 +90 Bytes
packages/core/src/middleware/koa-security-headers.ts 📈 +304 Bytes
packages/experience/jest.config.ts 📈 +131 Bytes
packages/experience/package.json 📈 +33 Bytes
packages/experience/src/components/AvatarCropModal/index.module.scss 📈 +1.39 KB
packages/experience/src/components/AvatarCropModal/index.tsx 📈 +6.63 KB
packages/experience/src/components/InputFields/AvatarUploadField/index.test.tsx 📈 +2.02 KB
packages/experience/src/components/InputFields/AvatarUploadField/index.tsx 📈 +1.83 KB
packages/experience/src/hooks/use-avatar-crop-upload.ts 📈 +6.58 KB
packages/experience/src/utils/avatar-upload.test.ts 📈 +1.16 KB
packages/experience/src/utils/avatar-upload.ts 📈 +797 Bytes
packages/experience/src/utils/image-crop.ts 📈 +2.28 KB
packages/phrases-experience/src/locales/ar/profile.ts 📈 +257 Bytes
packages/phrases-experience/src/locales/cs/profile.ts 📈 +216 Bytes
packages/phrases-experience/src/locales/de/profile.ts 📈 +236 Bytes
packages/phrases-experience/src/locales/en/profile.ts 📈 +180 Bytes
packages/phrases-experience/src/locales/es/profile.ts 📈 +190 Bytes
packages/phrases-experience/src/locales/fr/profile.ts 📈 +207 Bytes
packages/phrases-experience/src/locales/it/profile.ts 📈 +175 Bytes
packages/phrases-experience/src/locales/ja/profile.ts 📈 +266 Bytes
packages/phrases-experience/src/locales/ko/profile.ts 📈 +237 Bytes
packages/phrases-experience/src/locales/pl-pl/profile.ts 📈 +210 Bytes
packages/phrases-experience/src/locales/pt-br/profile.ts 📈 +187 Bytes
packages/phrases-experience/src/locales/pt-pt/profile.ts 📈 +202 Bytes
packages/phrases-experience/src/locales/ru/profile.ts 📈 +292 Bytes
packages/phrases-experience/src/locales/th/profile.ts 📈 +370 Bytes
packages/phrases-experience/src/locales/tr-tr/profile.ts 📈 +209 Bytes
packages/phrases-experience/src/locales/uk-ua/profile.ts 📈 +290 Bytes
packages/phrases-experience/src/locales/zh-cn/profile.ts 📈 +158 Bytes
packages/phrases-experience/src/locales/zh-hk/profile.ts 📈 +158 Bytes
packages/phrases-experience/src/locales/zh-tw/profile.ts 📈 +158 Bytes
pnpm-lock.yaml 📈 +820 Bytes

@github-actions github-actions Bot added size/xl and removed size/xl labels May 30, 2026
@wangsijie wangsijie marked this pull request as ready for review May 30, 2026 05:13
@cursor cursor Bot force-pushed the wangsijie-log-13217-avatar-in-account-center-profile-page branch from ada14e7 to ff24a42 Compare June 1, 2026 02:43
Comment thread packages/account/src/components/AvatarUploadField/index.tsx
Comment thread packages/account/src/components/AvatarUploadField/index.tsx Outdated
Comment thread packages/core/src/middleware/koa-security-headers.ts Outdated
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 1, 2026
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: handleRemove no longer clears stale upload error
    • Exposed clearUploadError from useAvatarCropUpload and call it in handleRemove so stale upload errors are cleared when the avatar is removed.

You can send follow-ups to the cloud agent here.

@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 1, 2026
Base automatically changed from wangsijie-log-13217-avatar-in-account-center-profile-page to master June 1, 2026 08:52
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 1, 2026
Copilot AI review requested due to automatic review settings June 1, 2026 09:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/experience/src/components/AvatarCropModal/index.tsx
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx Outdated
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx Outdated
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx
Comment thread packages/experience/src/components/AvatarCropModal/index.tsx
@cursor cursor Bot force-pushed the sijie-avatar-image-crop-9965 branch from 3edb4a6 to 880d235 Compare June 1, 2026 11:52
Copilot AI review requested due to automatic review settings June 1, 2026 11:52
@cursor cursor Bot force-pushed the sijie-avatar-image-crop-9965 branch from 880d235 to 65cced8 Compare June 1, 2026 11:52
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 1, 2026
@cursor cursor Bot force-pushed the sijie-avatar-image-crop-9965 branch from 65cced8 to 23ff9ad Compare June 1, 2026 11:53
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 35 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/experience/src/components/InputFields/AvatarUploadField/index.tsx Outdated
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 2, 2026
Comment thread packages/experience/src/hooks/use-avatar-crop-upload.ts Outdated
Copy link
Copy Markdown
Contributor

@simeng-li simeng-li left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall LGTM

Copilot AI review requested due to automatic review settings June 2, 2026 04:13
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 2, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/experience/src/utils/image-crop.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit be4d2c9. Configure here.

Comment thread packages/account/src/pages/Profile/index.tsx
Add a square crop and zoom step to the avatar upload flow in Experience
sign-up and Account Center profile. Selecting an image opens a crop modal;
the cropped result is exported as a JPEG blob before upload.

- Share select→crop→upload orchestration via useAvatarCropUpload
- Scope blob: img-src CSP to experience and account apps only
- Keep the crop modal open on upload or persist failure with inline errors
- Retry profile persist without re-uploading the asset
- Export square JPEGs using a single crop dimension
@cursor cursor Bot force-pushed the sijie-avatar-image-crop-9965 branch from be4d2c9 to 7da0e5c Compare June 2, 2026 04:43
@github-actions github-actions Bot added size/xl and removed size/xl labels Jun 2, 2026
@wangsijie wangsijie enabled auto-merge (squash) June 2, 2026 04:49
@wangsijie wangsijie merged commit c167ea5 into master Jun 2, 2026
36 of 39 checks passed
@wangsijie wangsijie deleted the sijie-avatar-image-crop-9965 branch June 2, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

5 participants