Skip to content

fix: Auto-fill chat username from Supabase session instead of manual entry#426

Open
Ananya-CM wants to merge 1 commit into
Shriii19:masterfrom
Ananya-CM:fix/chat-auto-fill-username
Open

fix: Auto-fill chat username from Supabase session instead of manual entry#426
Ananya-CM wants to merge 1 commit into
Shriii19:masterfrom
Ananya-CM:fix/chat-auto-fill-username

Conversation

@Ananya-CM

Copy link
Copy Markdown
Contributor

Summary

Fixed the Chat page which required users to
manually type their name before chatting, even
though they were already authenticated via Supabase.

Root Cause

In frontend/app/chat/page.tsx:

const [username, setUsername] = useState("");

Username was initialized as empty string with
no connection to the authenticated user session.

Fix

Added a useEffect that fetches the real
username from Supabase session on mount:

useEffect(() => {
  const getUsername = async () => {
    if (!supabase) return;
    const { data: { session } } = 
      await supabase.auth.getSession();
    if (session?.user) {
      const name =
        session.user.user_metadata?.full_name ||
        session.user.email?.split("@")[0] ||
        "User";
      setUsername(name);
    }
  };
  getUsername();
}, []);

Priority order for username:

  1. user_metadata.full_name (real name)
  2. Email prefix before @ (fallback)
  3. "User" (final fallback)

Before

  • Username input was empty on page load
  • User had to manually type their name
  • Messages could appear under wrong identity

After

  • ✅ Username auto-filled from Supabase session
  • ✅ User can start chatting immediately
  • ✅ Username input still editable if needed

Screenshots

image

Files Changed

  • frontend/app/chat/page.tsx — only file modified

Issue

Closes #255

nsoc26

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@Ananya-CM is attempting to deploy a commit to the shreemp194-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown

👋 Thank you for opening this pull request! I will review your changes and assist you soon.

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.

Fix: Chat page requires manual username entry — should auto-fill from logged-in user session

1 participant