refactor: update title generation logic to improve user experience by generating titles in parallel with assistant responses

This commit is contained in:
Anish Sarkar 2026-03-09 01:28:53 +05:30
parent bd91b0bef2
commit e8cf677b25
5 changed files with 120 additions and 61 deletions

View file

@ -20,6 +20,7 @@ import {
} from "@/components/ui/dropdown-menu";
import { useLongPress } from "@/hooks/use-long-press";
import { useIsMobile } from "@/hooks/use-mobile";
import { useTypewriter } from "@/hooks/use-typewriter";
import { cn } from "@/lib/utils";
interface ChatListItemProps {
@ -44,6 +45,7 @@ export function ChatListItem({
const t = useTranslations("sidebar");
const isMobile = useIsMobile();
const [dropdownOpen, setDropdownOpen] = useState(false);
const animatedName = useTypewriter(name);
const { handlers: longPressHandlers, wasLongPress } = useLongPress(
useCallback(() => setDropdownOpen(true), [])
@ -69,7 +71,7 @@ export function ChatListItem({
)}
>
<MessageSquare className="h-4 w-4 shrink-0 text-muted-foreground" />
<span className="w-[calc(100%-3rem)] ">{name}</span>
<span className="w-[calc(100%-3rem)] ">{animatedName}</span>
</button>
{/* Actions dropdown - trigger hidden on mobile, long-press opens it instead */}