import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, List, ListItemButton } from '@mui/material';
import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { ListItem, ListItemText } from '@/components/ListItem';
import { Paper, SectionTitle } from '../PreferenceComponents';
import type { ISectionProps } from '../useSections';
export function AIAgent(props: ISectionProps): React.JSX.Element {
const { t } = useTranslation('agent');
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false);
const [agentInfo, setAgentInfo] = useState<{ exists: boolean; size?: number; path?: string }>({ exists: false });
useEffect(() => {
const fetchInfo = async () => {
try {
const info = await window.service.database.getDatabaseInfo('agent');
const path = await window.service.database.getDatabasePath('agent');
setAgentInfo({ ...info, path });
} catch (error) {
void window.service.native.log(
'error',
'AIAgent: fetch agent database info failed',
{
function: 'AIAgent.fetchInfo',
error,
},
);
}
};
void fetchInfo();
}, []);
return (
<>
{t('Preference.AIAgent')}
{
if (agentInfo.path) {
try {
await window.service.native.openPath(agentInfo.path, true);
} catch (error) {
void window.service.native.log(
'error',
'AIAgent: open database folder failed',
{
function: 'AIAgent.openDatabaseFolder',
error,
path: agentInfo.path,
},
);
}
}
}}
>
{
setDeleteDialogOpen(true);
}}
>
>
);
}