Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Input } from "@/components/ui/input";
interface RenameDialogProps {
open: boolean;
title: string;
dialogTitle: string;
description: string;
placeholder: string;
onCancel: () => void;
onConfirm: (title: string) => void;
}
export function RenameDialog({
open,
title,
dialogTitle,
description,
placeholder,
onCancel,
onConfirm,
}: RenameDialogProps) {
const { t } = useTranslation();
const [value, setValue] = useState(title);
useEffect(() => {
if (open) setValue(title);
}, [open, title]);
const trimmed = value.trim();
return (
<Dialog open={open} onOpenChange={(next) => {
if (!next) onCancel();
}}>
<DialogContent className="max-w-sm">
<form
className="grid gap-4"
onSubmit={(event) => {
event.preventDefault();
if (!trimmed) return;
onConfirm(trimmed);
}}
>
<DialogHeader className="text-left">
<DialogTitle>{dialogTitle}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
</DialogHeader>
<Input
value={value}
onChange={(event) => setValue(event.target.value)}
placeholder={placeholder}
autoFocus
maxLength={160}
/>
<DialogFooter>
<Button
className="min-w-20"
type="button"
variant="outline"
onClick={onCancel}
>
{t("deleteConfirm.cancel")}
</Button>
<Button className="min-w-20" type="submit" disabled={!trimmed}>
{t("chat.renameSave")}
</Button>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
);
}