diff --git a/frontend/src/components/chatMessage/index.tsx b/frontend/src/components/chatMessage/index.tsx index 9da940b2..77e043bd 100644 --- a/frontend/src/components/chatMessage/index.tsx +++ b/frontend/src/components/chatMessage/index.tsx @@ -1,58 +1,49 @@ import { Remark } from 'react-remark'; +import { Avatar } from 'reshaped'; type ChatMessageProps = { index: number; + userName?: string; + userPicture?: string; refresh: (_: number) => void; deleteMessage: (_: number) => void; convertToComment: (_: number) => void; }; export default function ChatMessage(props: ChatMessage & ChatMessageProps) { + const getAvatarSrc = () => { + if (props.role === 'user') { + // Use Auth0 picture if available, otherwise use initials avatar + if (props.userPicture) { + return props.userPicture; + } + const userName = props.userName || 'User'; + return `https://api.dicebear.com/9.x/initials/svg?seed=${encodeURIComponent(userName)}&backgroundColor=1e88e5`; + } else { + // AI assistant avatar + return 'https://api.dicebear.com/9.x/bottts/svg?seed=AI&backgroundColor=10b981'; + } + }; + return (
- {/* - props.role !== 'assistant' ? ( -
- props.refresh(props.index)} - /> -
- ) : ( -
- props.deleteMessage(props.index)} - /> - - props.convertToComment(props.index)} - /> -
- )*/}
- {props.role === 'user' ? ( - - ) : ( -
- )} +
-
+
{props.content}
diff --git a/frontend/src/pages/chat/index.tsx b/frontend/src/pages/chat/index.tsx index ca5caacf..a42608be 100644 --- a/frontend/src/pages/chat/index.tsx +++ b/frontend/src/pages/chat/index.tsx @@ -1,7 +1,9 @@ import { useState, useContext, useEffect } from 'react'; +import { useAuth0 } from '@auth0/auth0-react'; import { AiOutlineSend } from 'react-icons/ai'; import { fetchEventSource } from '@microsoft/fetch-event-source'; +import { Button, TextField } from 'reshaped'; import ChatMessage from '@/components/chatMessage'; @@ -20,6 +22,7 @@ export default function Chat() { const username = useAtomValue(usernameAtom); const editorAPI = useContext(EditorContext); const { getAccessToken, authErrorType } = useAccessToken(); + const { user } = useAuth0(); const docContext = useDocContext(editorAPI); @@ -137,14 +140,16 @@ export default function Chat() { } return ( -
-
+
+
{messagesWithCurDocContext.slice(2).map((message, index) => ( { void regenMessage(index); }} @@ -154,35 +159,43 @@ export default function Chat() { ))}
-
{ - void sendMessage(e); - }} - > -