import { Dialog, DialogContent } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { X, Check } from "lucide-react"; import { useState, useRef, useEffect } from "react"; import { useMobile } from "@/hooks/useMobile"; interface EditSessionTitleDialogProps { isOpen: boolean; currentTitle: string; onClose: () => void; onSave: (newTitle: string) => void; } export function EditSessionTitleDialog({ isOpen, currentTitle, onClose, onSave }: EditSessionTitleDialogProps) { const [editTitle, setEditTitle] = useState(currentTitle); const inputRef = useRef(null); const isMobile = useMobile(); useEffect(() => { if (isOpen) { setEditTitle(currentTitle); } }, [isOpen, currentTitle]); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Escape') { setEditTitle(currentTitle); onClose(); } else if (e.key === 'Enter') { if (editTitle.trim() && editTitle !== currentTitle) { onSave(editTitle.trim()); } onClose(); } }; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (editTitle.trim() && editTitle !== currentTitle) { onSave(editTitle.trim()); } onClose(); }; const handleCancel = () => { setEditTitle(currentTitle); onClose(); }; return (

Change session title

setEditTitle(e.target.value)} onKeyDown={handleKeyDown} className="text-base font-semibold bg-background border border-border rounded px-3 py-2.5 pr-10 outline-none w-full focus:border-primary focus:ring-2 focus:ring-primary/20" autoFocus /> {editTitle && ( )}
); }