Skip to content

fix(web): sync avatar changes immediately after profile update#5903

Merged
boojack merged 4 commits into
usememos:mainfrom
wally-an:fix/profile-avatar-not-updating
Apr 28, 2026
Merged

fix(web): sync avatar changes immediately after profile update#5903
boojack merged 4 commits into
usememos:mainfrom
wally-an:fix/profile-avatar-not-updating

Conversation

@wally-an

Copy link
Copy Markdown
Contributor

Summary

Fixes #5878 - Profile picture changes are not reflected in the UI after the initial change. Users must reload the page to see updated avatars.

Root Cause

The v0.28.0 "redesign account and SSO management" migrated from MobX to React Context + React Query. The migration broke the reactivity chain because AuthContext.currentUser was never updated after the initial initialize() - only React Query cache was updated. Components reading from useCurrentUser() continued showing stale avatar data.

Changes

After a successful profile update, AuthContext.currentUser is now synced with the updated user data, triggering immediate UI updates across all components consuming useCurrentUser().

  • Added setCurrentUser function to AuthContext that updates both the context state and React Query cache
  • UpdateAccountDialog calls setCurrentUser(updatedUser) after successful profile save

Validation

  • pnpm test — all tests pass
  • Manual testing: avatar updates immediately in user menu and settings header after save

@wally-an wally-an requested a review from a team as a code owner April 28, 2026 11:34
@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 26583abc-555d-47bf-8625-7a4be8e57ff6

📥 Commits

Reviewing files that changed from the base of the PR and between 3b930e4 and 71af95e.

📒 Files selected for processing (2)
  • web/src/components/UpdateAccountDialog.tsx
  • web/src/contexts/AuthContext.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/src/components/UpdateAccountDialog.tsx
  • web/src/contexts/AuthContext.tsx

📝 Walkthrough

Walkthrough

Adds a new setCurrentUser API to the auth context to update current-user state and React Query cache; UpdateAccountDialog now captures the result of updateUser and calls setCurrentUser(updatedUser) immediately after a successful update, before showing success feedback and closing.

Changes

Cohort / File(s) Summary
Auth context update
web/src/contexts/AuthContext.tsx
Adds setCurrentUser: (user: User | undefined) => void to the context value and implementation. Updates state.currentUser and synchronizes React Query cache for the current-user and user-detail queries, including removal when undefined.
Account update flow
web/src/components/UpdateAccountDialog.tsx
Imports useAuth, captures the resolved updateUser result as updatedUser, and invokes setCurrentUser(updatedUser) immediately after update succeeds and before toast.success, onSuccess, and closing the dialog.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: syncing avatar changes immediately after profile update, which directly addresses the core issue.
Description check ✅ Passed The description is clearly related to the changeset, explaining the root cause, solution, and validation for the avatar sync issue.
Linked Issues check ✅ Passed The PR successfully addresses issue #5878 by syncing AuthContext.currentUser and React Query cache after profile updates, ensuring avatars update immediately without requiring a page reload.
Out of Scope Changes check ✅ Passed All changes (adding setCurrentUser to AuthContext and calling it in UpdateAccountDialog) are directly scoped to fixing the avatar sync issue described in #5878.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/contexts/AuthContext.tsx`:
- Around line 159-165: The setCurrentUser callback updates context state but
does not clear React Query's cached user data when passed undefined; update
setCurrentUser so that when user is undefined it also synchronizes the cache by
clearing or resetting the relevant queries (e.g., call
queryClient.setQueryData(userKeys.currentUser(), undefined) and remove or set to
undefined the userKeys.detail(...) entry or use queryClient.removeQueries for
those keys) while keeping the existing behavior when user is present; locate the
logic in the setCurrentUser function and update the branch that handles user
falsy values to mirror the cache update performed in the user-present branch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49981afd-a4e7-4046-b2d1-5ad18549e17f

📥 Commits

Reviewing files that changed from the base of the PR and between 616487f and 3b930e4.

📒 Files selected for processing (2)
  • web/src/components/UpdateAccountDialog.tsx
  • web/src/contexts/AuthContext.tsx

Comment thread web/src/contexts/AuthContext.tsx Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Chyna <68607983+chyna-gvng@users.noreply.github.com>
@boojack

boojack commented Apr 28, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@boojack boojack merged commit 328396a into usememos:main Apr 28, 2026
3 checks passed
dgalanberasaluce pushed a commit to dgalanberasaluce/infra-personal that referenced this pull request Jun 13, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [neosmemo/memos](https://github.com/usememos/memos) | minor | `0.28.0` → `0.29.0` |

---

### Release Notes

<details>
<summary>usememos/memos (neosmemo/memos)</summary>

### [`v0.29.0`](https://github.com/usememos/memos/blob/HEAD/CHANGELOG.md#0290-2026-05-27)

[Compare Source](usememos/memos@v0.28.0...v0.29.0)

##### Features

- **about:** add about page with bird sprites ([411ba7b](usememos/memos@411ba7b))
- **activity-calendar:** aggregate by ViewContext.timeBasis ([8daef1d](usememos/memos@8daef1d))
- add \<Placeholder> component with ASCII bird states ([#&#8203;5949](usememos/memos#5949)) ([8c16ffa](usememos/memos@8c16ffa))
- add configurable `--log-level` flag ([#&#8203;5934](usememos/memos#5934)) ([f1e2a06](usememos/memos@f1e2a06))
- add dedicated shortcuts page ([#&#8203;5942](usememos/memos#5942)) ([1df6479](usememos/memos@1df6479))
- add link metadata endpoints ([9c5c604](usememos/memos@9c5c604))
- **frontend:** add pixel bird tilemaps ([cf55f11](usememos/memos@cf55f11))
- **memo:** add task list quick actions ([#&#8203;5983](usememos/memos#5983)) ([648b3bd](usememos/memos@648b3bd))
- **memo:** create memos on the selected calendar date ([#&#8203;5925](usememos/memos#5925)) ([ef55013](usememos/memos@ef55013))
- **notification:** add smtp email settings ([cd4f28a](usememos/memos@cd4f28a))
- **placeholder:** add woodpecker tilemap ([638e4f3](usememos/memos@638e4f3))
- render link metadata cards ([0bc5669](usememos/memos@0bc5669))
- **stats:** admin instance resource statistics ([ea0625d](usememos/memos@ea0625d))
- **stats:** support filtered all-user stats ([88ac3ec](usememos/memos@88ac3ec))
- **transcription:** explicit STT settings with provider, model, prompt ([#&#8203;5926](usememos/memos#5926)) ([238f27d](usememos/memos@238f27d))

##### Bug Fixes

- avoid update event on memo create attachments ([#&#8203;5961](usememos/memos#5961)) ([3c3382a](usememos/memos@3c3382a))
- delete user cleanup ([#&#8203;5981](usememos/memos#5981)) ([e53b7d9](usememos/memos@e53b7d9))
- **editor:** wrap selected text when pasting URL ([e0bb3a2](usememos/memos@e0bb3a2))
- **fileserver:** preserve HDR image metadata in thumbnails ([c724232](usememos/memos@c724232))
- **frontend:** correct static cache headers ([084f40b](usememos/memos@084f40b))
- **frontend:** use correct url path for memos in sitemap.xml ([#&#8203;5921](usememos/memos#5921)) ([603781f](usememos/memos@603781f))
- **httpgetter:** prevent DNS rebinding in link metadata fetch ([078488c](usememos/memos@078488c))
- **markdown:** align list items with checkboxes ([e008b1a](usememos/memos@e008b1a))
- **memo:** enforce parent visibility for comments ([4a1e401](usememos/memos@4a1e401))
- **s3presign:** preserve motion media payload ([7f1f53f](usememos/memos@7f1f53f))
- **security:** enforce attachment ownership on memo updates ([35bf761](usememos/memos@35bf761))
- **sse:** stream initial response and refresh tokens ([21303e8](usememos/memos@21303e8))
- **user:** omit internal settings from list responses ([#&#8203;5917](usememos/memos#5917)) ([1df3fe7](usememos/memos@1df3fe7))
- **web:** sync avatar changes immediately after profile update ([#&#8203;5903](usememos/memos#5903)) ([328396a](usememos/memos@328396a))

##### Performance Improvements

- lazy load heavy first-screen dependencies ([#&#8203;5947](usememos/memos#5947)) ([a6024ee](usememos/memos@a6024ee))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43My4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=-->

Reviewed-on: https://forgejo.internal/forgejo_admin/infra-personal/pulls/96
Co-authored-by: Renovate Bot <renovatebot@forgejo.internal>
Co-committed-by: Renovate Bot <renovatebot@forgejo.internal>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Profile picture changes are not applied after the initial change

2 participants