import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog'; export function CodingConversationRenameDialog({ title, onSave, onClose }: { title: string; onSave(title: string): Promise; onClose(): void; }) { const [draft, setDraft] = useState(title); const [saving, setSaving] = useState(false); const [error, setError] = useState(null); return ( { if (!open && !saving) onClose(); }}> { event.preventDefault(); const input = document.getElementById('coding-rename-title') as HTMLInputElement | null; input?.focus(); input?.select(); }}>
{ event.preventDefault(); if (!draft.trim() || saving) return; setSaving(true); setError(null); void onSave(draft.trim()).then(onClose).catch((reason) => { setError(reason instanceof Error ? reason.message : String(reason)); }).finally(() => setSaving(false)); }}> 修改对话标题 手动命名后,标题不会再自动更新。 setDraft(event.target.value)} /> {error &&

{error}

}
); }