diff --git a/surfsense_backend/app/tasks/chat/stream_new_chat.py b/surfsense_backend/app/tasks/chat/stream_new_chat.py index 5f8cd638b..85a524108 100644 --- a/surfsense_backend/app/tasks/chat/stream_new_chat.py +++ b/surfsense_backend/app/tasks/chat/stream_new_chat.py @@ -423,9 +423,9 @@ async def stream_new_chat( title = title[:27] + "..." doc_names.append(title) if len(doc_names) == 1: - processing_parts.append(f"[📖 {doc_names[0]}]") + processing_parts.append(f"[{doc_names[0]}]") else: - processing_parts.append(f"[📖 {len(doc_names)} docs]") + processing_parts.append(f"[{len(doc_names)} docs]") last_active_step_items = [f"{action_verb}: {' '.join(processing_parts)}"] diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx index 9f844ba2b..d8e0d55b9 100644 --- a/surfsense_web/components/assistant-ui/thread.tsx +++ b/surfsense_web/components/assistant-ui/thread.tsx @@ -124,14 +124,23 @@ const ThreadScrollToBottom: FC = () => { ); }; -const getTimeBasedGreeting = (userEmail?: string): string => { +const getTimeBasedGreeting = (user?: { display_name?: string | null; email?: string }): string => { const hour = new Date().getHours(); - // Extract first name from email if available - const firstName = userEmail - ? userEmail.split("@")[0].split(".")[0].charAt(0).toUpperCase() + - userEmail.split("@")[0].split(".")[0].slice(1) - : null; + // Extract first name: prefer display_name, fall back to email extraction + let firstName: string | null = null; + + if (user?.display_name?.trim()) { + // Use display_name if available and not empty + // Extract first name from display_name (take first word) + const nameParts = user.display_name.trim().split(/\s+/); + firstName = nameParts[0].charAt(0).toUpperCase() + nameParts[0].slice(1).toLowerCase(); + } else if (user?.email) { + // Fall back to email extraction if display_name is not available + firstName = + user.email.split("@")[0].split(".")[0].charAt(0).toUpperCase() + + user.email.split("@")[0].split(".")[0].slice(1); + } // Array of greeting variations for each time period const morningGreetings = ["Good morning", "Fresh start today", "Morning", "Hey there"]; @@ -172,7 +181,7 @@ const ThreadWelcome: FC = () => { const { data: user } = useAtomValue(currentUserAtom); // Memoize greeting so it doesn't change on re-renders (only on user change) - const greeting = useMemo(() => getTimeBasedGreeting(user?.email), [user?.email]); + const greeting = useMemo(() => getTimeBasedGreeting(user), [user]); return (
@@ -149,8 +146,8 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS className={cn( "w-full flex items-start gap-2.5 px-2.5 py-2 rounded-md transition-all", "hover:bg-accent/50 cursor-pointer", - "focus:outline-none focus:ring-2 focus:ring-primary/20", - isSelected && "bg-accent/80 ring-1 ring-primary/20" + "focus:outline-none", + isSelected && "bg-accent/80" )} >
- {currentVisibility === "PRIVATE" - ? "This chat is private. Only you can view and interact with it." - : "This chat is shared. All search space members can view, continue the conversation, and delete it."} -
-