mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 17:56:25 +02:00
refactor: improve chat UI and greeting logic
- Simplified chat document processing display by removing the book emoji for a cleaner look. - Enhanced the greeting function to prioritize user display names over email for a more personalized experience. - Adjusted the ChatShareButton component by removing unused imports and unnecessary elements for better clarity and performance. - Updated the title in the Electric SQL documentation for conciseness.
This commit is contained in:
parent
85ca04c641
commit
28aa4814bd
4 changed files with 24 additions and 30 deletions
|
|
@ -423,9 +423,9 @@ async def stream_new_chat(
|
||||||
title = title[:27] + "..."
|
title = title[:27] + "..."
|
||||||
doc_names.append(title)
|
doc_names.append(title)
|
||||||
if len(doc_names) == 1:
|
if len(doc_names) == 1:
|
||||||
processing_parts.append(f"[📖 {doc_names[0]}]")
|
processing_parts.append(f"[{doc_names[0]}]")
|
||||||
else:
|
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)}"]
|
last_active_step_items = [f"{action_verb}: {' '.join(processing_parts)}"]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
const hour = new Date().getHours();
|
||||||
|
|
||||||
// Extract first name from email if available
|
// Extract first name: prefer display_name, fall back to email extraction
|
||||||
const firstName = userEmail
|
let firstName: string | null = null;
|
||||||
? userEmail.split("@")[0].split(".")[0].charAt(0).toUpperCase() +
|
|
||||||
userEmail.split("@")[0].split(".")[0].slice(1)
|
if (user?.display_name?.trim()) {
|
||||||
: null;
|
// 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
|
// Array of greeting variations for each time period
|
||||||
const morningGreetings = ["Good morning", "Fresh start today", "Morning", "Hey there"];
|
const morningGreetings = ["Good morning", "Fresh start today", "Morning", "Hey there"];
|
||||||
|
|
@ -172,7 +181,7 @@ const ThreadWelcome: FC = () => {
|
||||||
const { data: user } = useAtomValue(currentUserAtom);
|
const { data: user } = useAtomValue(currentUserAtom);
|
||||||
|
|
||||||
// Memoize greeting so it doesn't change on re-renders (only on user change)
|
// 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 (
|
return (
|
||||||
<div className="aui-thread-welcome-root mx-auto flex w-full max-w-(--thread-max-width) grow flex-col items-center px-4 relative">
|
<div className="aui-thread-welcome-root mx-auto flex w-full max-w-(--thread-max-width) grow flex-col items-center px-4 relative">
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import { Globe, Loader2, Lock, Share2, Users } from "lucide-react";
|
import { Loader2, Lock, Share2, Users } from "lucide-react";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
@ -92,8 +92,7 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-7 md:h-9 gap-1.5 md:gap-2 px-2 md:px-3 rounded-lg md:rounded-xl",
|
"h-7 md:h-9 gap-1 md:gap-2 px-2 md:px-3 rounded-lg md:rounded-xl border border-border/80 bg-background/50 backdrop-blur-sm",
|
||||||
"border border-border/80 bg-background/50 backdrop-blur-sm",
|
|
||||||
"hover:bg-muted/80 hover:border-border/30 transition-all duration-200",
|
"hover:bg-muted/80 hover:border-border/30 transition-all duration-200",
|
||||||
"text-xs md:text-sm font-medium text-foreground",
|
"text-xs md:text-sm font-medium text-foreground",
|
||||||
"focus-visible:ring-0 focus-visible:ring-offset-0",
|
"focus-visible:ring-0 focus-visible:ring-offset-0",
|
||||||
|
|
@ -104,7 +103,6 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
<span className="hidden md:inline">
|
<span className="hidden md:inline">
|
||||||
{currentVisibility === "PRIVATE" ? "Private" : "Shared"}
|
{currentVisibility === "PRIVATE" ? "Private" : "Shared"}
|
||||||
</span>
|
</span>
|
||||||
<Share2 className="size-3 md:size-3.5 text-muted-foreground" />
|
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
|
|
||||||
|
|
@ -113,9 +111,8 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
align="end"
|
align="end"
|
||||||
sideOffset={8}
|
sideOffset={8}
|
||||||
>
|
>
|
||||||
<div className="p-3 md:p-4 border-b border-border/30">
|
<div className="p-3 md:p-4">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Share2 className="size-4 md:size-5 text-primary" />
|
|
||||||
<div>
|
<div>
|
||||||
<h4 className="text-sm font-semibold">Share Chat</h4>
|
<h4 className="text-sm font-semibold">Share Chat</h4>
|
||||||
<p className="text-xs text-muted-foreground">
|
<p className="text-xs text-muted-foreground">
|
||||||
|
|
@ -149,8 +146,8 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
className={cn(
|
className={cn(
|
||||||
"w-full flex items-start gap-2.5 px-2.5 py-2 rounded-md transition-all",
|
"w-full flex items-start gap-2.5 px-2.5 py-2 rounded-md transition-all",
|
||||||
"hover:bg-accent/50 cursor-pointer",
|
"hover:bg-accent/50 cursor-pointer",
|
||||||
"focus:outline-none focus:ring-2 focus:ring-primary/20",
|
"focus:outline-none",
|
||||||
isSelected && "bg-accent/80 ring-1 ring-primary/20"
|
isSelected && "bg-accent/80"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|
@ -185,18 +182,6 @@ export function ChatShareButton({ thread, onVisibilityChange, className }: ChatS
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Info footer */}
|
|
||||||
<div className="p-3 bg-muted/30 border-t border-border/30 rounded-b-xl">
|
|
||||||
<div className="flex items-start gap-2">
|
|
||||||
<Globe className="size-3.5 text-muted-foreground mt-0.5 shrink-0" />
|
|
||||||
<p className="text-[11px] text-muted-foreground leading-relaxed">
|
|
||||||
{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."}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: Electric SQL Setup
|
title: Electric SQL
|
||||||
description: Setting up Electric SQL for real-time data synchronization in SurfSense
|
description: Setting up Electric SQL for real-time data synchronization in SurfSense
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue