Commit 6faeb6d
feat(web): add /api/avatar resolver (#1159)
* feat(web): add /api/avatar resolver and use it in UserAvatar
Adds a new `/api/avatar?email=<email>` endpoint that resolves an email
to either the matching Sourcebot user's profile image (302 redirect with
short cache) or a deterministic minidenticon SVG (long-lived immutable
cache). Falls back to the identicon on auth or lookup failure so avatars
never break for anonymous viewers.
Updates `UserAvatar` to compute its src from this resolver instead of
generating an inline minidenticon data URI client-side. Every existing
call site automatically picks up real profile pictures where the email
matches a Sourcebot user — no consumer changes needed.
Also swaps Radix's `<AvatarImage>` for a raw `<img>`. AvatarImage delays
painting until its internal `new Image().onload` fires (async even from
HTTP cache), which manifests as a flicker every time the avatar mounts
under aggressive churn (e.g., in a CodeMirror gutter). The browser
paints cached `<img>` synchronously.
Adds a native `title` tooltip to the displayed avatars in
`AuthorsAvatarGroup` and removes the unused `MessageAvatar` wrapper.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(web): add CHANGELOG entry for /api/avatar resolver
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* chore(web): validate /api/avatar query params with Zod
Replaces the manual `searchParams.get('email')` + plain-text 400 response
with the Zod safeParse + queryParamsSchemaValidationError pattern used
elsewhere in the API. Errors now return structured JSON consistent with
the rest of the public API surface.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* feedback
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cbf50e7 commit 6faeb6d
5 files changed
Lines changed: 92 additions & 44 deletions
File tree
- packages/web/src
- app
- (app)/browse/components
- api/(server)/avatar
- components
- features/chat/components/chatThread
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
| |||
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
15 | | - | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | | - | |
| 18 | + | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
25 | 39 | | |
26 | 40 | | |
27 | 41 | | |
| |||
Lines changed: 0 additions & 39 deletions
This file was deleted.
0 commit comments