Skip to content

Fix: Chat page requires manual username entry β€” should auto-fill from logged-in user sessionΒ #255

Description

@Ananya-CM

πŸ› Bug Report

Area: Chat Page β€” Username Input
Type: Bug β€” Poor Authentication UX
Priority: High


πŸ“Œ Description

The Chat page (/chat) shows a plain text input
asking users to manually type their name before
they can chat. This is broken UX because:

  1. The app already has a full authentication
    system (Supabase login)
  2. The logged-in user's name is already
    available in the session
  3. Asking authenticated users to type their
    name again is confusing and amateur

This is a real authentication integration
gap that affects every user of the chat feature.


πŸ” Proof β€” Manual Input in Source Code

In frontend/app/chat/page.tsx:

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

And in the JSX:

<input
  value={username}
  onChange={(e) => setUsername(e.target.value)}
  placeholder="Enter name"
  className="w-full rounded-2xl border..."
/>

The username is completely empty by default
and requires manual entry even though the
user is already authenticated via Supabase.


❌ Current Behaviour

  1. User logs in successfully
  2. Navigates to /chat
  3. Sees an empty "Enter name" input box
  4. Must manually type their name to use chat
  5. If they type wrong name, messages appear
    under wrong identity

βœ… Expected Behaviour

  1. User logs in successfully
  2. Navigates to /chat
  3. Username is automatically filled from
    Supabase session (user_metadata.full_name
    or email)
  4. User can start chatting immediately
  5. Username input can be hidden or shown
    as read-only display

πŸ’‘ Proposed Fix

In frontend/app/chat/page.tsx:

Replace empty useState("") with session fetch:

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

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();
}, []);

This auto-fills the username from the
authenticated session so users don't need
to type their name manually.


πŸ“‚ File to Change

frontend/app/chat/page.tsx β€” only this file


@Shriii19
I'd like to work on this issue.
Could you please assign it to me?

nsoc26

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions