* modify chat table & migrate * refactor layout * update layout * actions for chats & agents * refactor chat form * refactor chat form * update chat form * rename * refactor types & locales * refactor tts engine * refactor * fix config * refactor chat form * refactor chat member form * fixing * refactor ask agent * chat in conversation * fix chat message update * may update chat member * update chat member from message * refacto group propmt * chat member gpt settings * update ui * more config for chat * add locales * update chat agent form * add locales for agent form * update UI * auto reply for text input * update chat * update chat input * rename colomns * update chat * udpate agent message * add chat member * add/remove chat member * fix chat member * refactor * auto update chat name * fix chat update * refactor chat column * fix chat * add agent loading * use fresh new prompt when ask agent * add chat forwarder * refactor chat * fix * add copilot * toggle copilot * add copilot chat * avoid open the same chat at the same time * update copilot header * add agent introduction in the first place of chat * rename column * update style * refactor * invoke all agents in group after asking * chat sidebar collopse * may select chat in copilot * update ui * new chat from agent * upgrade deps * refactor chat & chatAgent * add limit for chat member create * update chat form * update db & migration * fix up * fix group chat * fix panel warning * display chat agent type * tts message * fit tts agent * refactor * chat fowarder * update UI * setup default values for tts agent * fix chat member add/remove * edit tts agent * display chat date * Fix UI * add system message * refactor * fix hook * refactor * touch chat&agent when new message created * fix auto reply * migrate conversation to chat * add migrate api * fix migrate * update migrate * refactor * refactor * refactor * fix delete agent * add hotkey for copilot * fix bugs * upgrade deps * refactor tts hook * stop auto playback when azure transcribed * refactor * clean up * fix UI * fix conversation migrate * handle error * update model * declare types * audo backup db file when started * fix db backup * refactor db migration * fix UI * refactor * fix chat auto update name * fix authorization lost when hot reload * refactor * refactor * fix tts form * keep agent avatar up to date * clean code
94 lines
3.0 KiB
TypeScript
94 lines
3.0 KiB
TypeScript
import { EllipsisIcon, MessageCircleIcon, SpeechIcon } from "lucide-react";
|
|
import dayjs from "@renderer/lib/dayjs";
|
|
import { useContext } from "react";
|
|
import { AppSettingsProviderContext } from "@renderer/context";
|
|
import {
|
|
Button,
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
toast,
|
|
} from "@renderer/components/ui";
|
|
import { t } from "i18next";
|
|
|
|
export const ConversationCard = (props: { conversation: ConversationType }) => {
|
|
const { conversation } = props;
|
|
const { EnjoyApp, learningLanguage } = useContext(AppSettingsProviderContext);
|
|
|
|
const handleDelete = () => {
|
|
EnjoyApp.conversations.destroy(conversation.id).then(() => {
|
|
toast.success(t("conversationDeleted"));
|
|
});
|
|
};
|
|
|
|
const handleMigrate = () => {
|
|
EnjoyApp.conversations
|
|
.migrate(conversation.id)
|
|
.then(() => {
|
|
toast.success(t("conversationMigrated"));
|
|
})
|
|
.catch((error) => {
|
|
toast.error(error.message);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className="bg-background hover:bg-muted hover:text-muted-foreground border rounded-full w-full mb-2 px-4 py-2 cursor-pointer flex items-center"
|
|
style={{
|
|
borderLeftColor: `#${conversation.id.replaceAll("-", "").slice(0, 6)}`,
|
|
borderLeftWidth: 3,
|
|
}}
|
|
>
|
|
<div className="">
|
|
{conversation.type === "gpt" && <MessageCircleIcon className="mr-2" />}
|
|
|
|
{conversation.type === "tts" && <SpeechIcon className="mr-2" />}
|
|
</div>
|
|
<div className="flex-1 flex items-center justify-between space-x-4">
|
|
<div className="">
|
|
<div className="line-clamp-1 text-sm">{conversation.name}</div>
|
|
<div className="text-xs text-muted-foreground">
|
|
{conversation.engine} |{" "}
|
|
{conversation.type === "tts"
|
|
? conversation.configuration?.tts?.model
|
|
: conversation.model}{" "}
|
|
| {conversation.language || learningLanguage}
|
|
</div>
|
|
</div>
|
|
<div className="flex items-center space-x-1">
|
|
<div className="min-w-fit text-sm text-muted-foreground">
|
|
{dayjs(conversation.createdAt).format("HH:mm l")}
|
|
</div>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" size="icon">
|
|
<EllipsisIcon className="w-4 h-4" />
|
|
</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
<DropdownMenuItem
|
|
onClick={(event) => {
|
|
event.stopPropagation();
|
|
handleMigrate();
|
|
}}
|
|
>
|
|
<span>{t("migrateToChat")}</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem
|
|
onClick={(event) => {
|
|
event.stopPropagation();
|
|
handleDelete();
|
|
}}
|
|
>
|
|
<span className="text-destructive">{t("delete")}</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|