refactor(AssistantsTab): remove agent-related code and imports

This commit is contained in:
icarus 2025-09-18 17:40:12 +08:00
parent 6e89d0037f
commit db58762a13

View File

@ -1,21 +1,18 @@
import { DownOutlined, RightOutlined } from '@ant-design/icons'
import { Button, Divider } from '@heroui/react'
import { Button } from '@heroui/react'
import { DraggableList } from '@renderer/components/DraggableList'
import { AgentModal } from '@renderer/components/Popups/AgentModal'
import Scrollbar from '@renderer/components/Scrollbar'
import { useAgents } from '@renderer/hooks/agents/useAgents'
import { useAssistants } from '@renderer/hooks/useAssistant'
import { useAssistantPresets } from '@renderer/hooks/useAssistantPresets'
import { useAssistantsTabSortType } from '@renderer/hooks/useStore'
import { useTags } from '@renderer/hooks/useTags'
import { AgentEntity, Assistant, AssistantsSortType } from '@renderer/types'
import { Assistant, AssistantsSortType } from '@renderer/types'
import { Tooltip } from 'antd'
import { Plus } from 'lucide-react'
import { FC, useCallback, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import styled from 'styled-components'
import AgentItem from './components/AgentItem'
import AssistantItem from './components/AssistantItem'
interface AssistantsTabProps {
@ -37,7 +34,6 @@ const Assistants: FC<AssistantsTabProps> = ({
const { getGroupedAssistants, collapsedTags, toggleTagCollapse } = useTags()
const { assistantsTabSortType = 'list', setAssistantsTabSortType } = useAssistantsTabSortType()
const containerRef = useRef<HTMLDivElement>(null)
const { agents } = useAgents()
const onDelete = useCallback(
(assistant: Assistant) => {
@ -51,14 +47,6 @@ const Assistants: FC<AssistantsTabProps> = ({
[activeAssistant, assistants, removeAssistant, setActiveAssistant, onCreateDefaultAssistant]
)
const onDeleteAgent = useCallback(
(agent: AgentEntity) => {
// removeAgent(agent.id)
window.toast.success(t('common.delete_success'))
},
[t]
)
const handleSortByChange = useCallback(
(sortType: AssistantsSortType) => {
setAssistantsTabSortType(sortType)
@ -141,31 +129,12 @@ const Assistants: FC<AssistantsTabProps> = ({
))}
</div>
{renderAddAssistantButton}
{/* <AddAgentButton /> */}
</Container>
)
}
return (
<Container className="assistants-tab" ref={containerRef}>
<span className="mb-2 text-foreground-400 text-xs">{t('common.agent_other')}</span>
{agents.map((agent) => (
<AgentItem key={agent.id} agent={agent} isActive={false} onDelete={onDeleteAgent} />
))}
<AgentModal
trigger={{
content: (
<Button
onPress={(e) => e.continuePropagation()}
className="w-full justify-start bg-transparent text-foreground-500 hover:bg-accent">
<Plus size={16} className="mr-1 shrink-0" />
{t('agent.add.title')}
</Button>
)
}}
/>
<Divider className="my-2" />
<span className="mb-2 text-foreground-400 text-xs">{t('common.assistant_other')}</span>
<DraggableList
list={assistants}