Skip to content

feat: allow editing user avatars - #26652

Merged
aslilac merged 4 commits into
mainfrom
lilac/edit-user-avatar
Jun 26, 2026
Merged

feat: allow editing user avatars#26652
aslilac merged 4 commits into
mainfrom
lilac/edit-user-avatar

Conversation

@aslilac

@aslilac aslilac commented Jun 24, 2026

Copy link
Copy Markdown
Member

Adds an avatar URL field to the admin Edit user page, available only for users whose login type is password or none.

For identity-provider login types (github, oidc) the avatar is synced from the IdP on every login, so the field is hidden and the API ignores any submitted avatar to avoid confusing overwrites.

The field reuses the same emoji picker + URL input (IconField) already used for template, group, and organization icons.

A follow-up PR will add the same control to the self-service Account settings page.

Implementation plan & decisions

Goal: Let an admin set/clear a user's avatar from the Edit user page, gated to password/none login types.

Backend

  • Add avatar_url to codersdk.UpdateUserProfileRequest.
  • putUserProfile applies the submitted avatar only for password/none; otherwise it preserves the existing (IdP-synced) value.
  • Regenerated TS types and API docs via make gen.

Frontend

  • EditUserForm renders an IconField ("Avatar URL") when the login type allows it.
  • EditUserPage passes the avatar value and a canEditAvatar flag.
  • AccountPage round-trips avatar_url so the shared request type doesn't wipe avatars on the self-service path.

Gating is enforced in both the UI (field hidden) and the backend (submitted value ignored for IdP login types).

Tests/stories: backend TestUpdateUserProfile covers apply (password) and ignore (SSO); EditUserForm stories cover the shown/hidden states with interaction tests.


Generated by Coder Agents on behalf of @aslilac.

Add an avatar URL field to the admin edit user page for users whose
login type is password or none. Identity-provider avatars are synced
on login, so the field is hidden for those users and the API ignores a
submitted avatar.
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

📖 View docs preview for docs/reference/api/schemas.md

getExternalImageStylesFromUrl threw "Invalid URL" while a user typed an
avatar URL (e.g. once the value reached "https:"), crashing the edit user
page preview. Treat unparseable URLs as having no special styles.
Comment thread site/src/pages/EditUserPage/EditUserForm.tsx Outdated
Comment on lines +10 to +11
// The avatar is not edited by the form here, so it round-trips the value
// from the authenticated user.

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.

Do we need this comment

error?: unknown;
isLoading: boolean;
initialValues: UpdateUserProfileRequest;
/** Allows hiding the avatar setting when it would be overwritten later by the user's identity provider. */

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.

Do we need this one?

Comment thread site/src/pages/UserSettingsPage/AccountPage/AccountPage.test.tsx Outdated
@aslilac
aslilac merged commit efd9302 into main Jun 26, 2026
34 of 37 checks passed
@aslilac
aslilac deleted the lilac/edit-user-avatar branch June 26, 2026 22:35
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants