Fix #2: Add user avatar upload and display#3
Open
cosmo-coderbots[bot] wants to merge 1 commit into
Open
Conversation
Users can now upload a profile photo that's shown next to their username in the feed, composer, and site header. - New /profile page with an avatar upload form + remove button - New POST server actions: uploadAvatar (5MB image cap) and removeAvatar - New route handler /api/avatars/[username] serving the bytes from Postgres - users.avatar / avatar_type / avatar_updated_at columns (idempotent ALTER TABLE ADD COLUMN IF NOT EXISTS for existing databases) - Shared Avatar component with initial-letter fallback for users who haven't uploaded one yet; ?v=<timestamp> cache-bust so refreshed avatars appear immediately Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds user avatar support. Users can now upload a profile photo, which appears next to their username in the feed, composer, and site header. Users without an uploaded avatar keep the existing initial-letter placeholder.
Fixes #2
Changes
/profilepage with an avatar upload form (+ remove button)uploadAvatar(5 MB image cap, mime-type check) andremoveAvatarinapp/actions.tsapp/api/avatars/[username]/route.tsthat serves the image bytes straight from Postgres, matching the existing/api/images/[id]patternusers.avatar,users.avatar_type,users.avatar_updated_atcolumns added todb/schema.sql(ALTER TABLE … ADD COLUMN IF NOT EXISTSso existing DBs migrate cleanly)<Avatar>component with letter-fallback; renders with?v=<avatar_updated_at>so browsers pick up updated avatars without a hard refreshgetCurrentUserextended to returnavatar_updated_atTest plan
npm run lint— cleannpm run build— succeedstsc --noEmit— cleanalice, uploaded avatar via/profile→ avatar shows in header, composer, and every post authored by alicebob, uploaded a different avatar → both users' avatars render correctly, users without avatars still show initial-letter fallback/api/avatars/alicereturns the uploaded PNG with the correctContent-TypeBefore
After (feed with mixed avatars + fallbacks)
Profile page
🤖 Generated with Claude Code