refactor(ui): remove unused UI elements and commented code

clean up UI by removing unused text spans and commented out code
remove unused timer functionality from AgentModal
This commit is contained in:
icarus 2025-09-18 19:00:41 +08:00
parent ec82eb2881
commit 2fc1df8793
5 changed files with 6 additions and 10 deletions

View File

@ -20,8 +20,6 @@ import { loggerService } from '@logger'
import ClaudeIcon from '@renderer/assets/images/models/claude.png'
import { useAddAgent } from '@renderer/hooks/agents/useAddAgent'
import { useUpdateAgent } from '@renderer/hooks/agents/useUpdateAgent'
import { useTimer } from '@renderer/hooks/useTimer'
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
import { AddAgentForm, AgentEntity, AgentType, BaseAgentForm, isAgentType, UpdateAgentForm } from '@renderer/types'
import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -85,7 +83,7 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
const { isOpen, onClose, onOpen } = useDisclosure({ isOpen: _isOpen, onClose: _onClose })
const { t } = useTranslation()
const loadingRef = useRef(false)
const { setTimeoutTimer } = useTimer()
// const { setTimeoutTimer } = useTimer()
const { addAgent } = useAddAgent()
const { updateAgent } = useUpdateAgent()
const isEditing = (agent?: AgentEntity) => agent !== undefined
@ -245,7 +243,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
updateAgent(updatePayload)
logger.debug('Updated agent', updatePayload)
window.toast.success(t('common.update_success'))
} else {
const newAgent = {
type: form.type,
@ -257,12 +254,11 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
} satisfies AddAgentForm
addAgent(newAgent)
logger.debug('Added agent', newAgent)
window.toast.success(t('common.add_success'))
}
loadingRef.current = false
setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
// setTimeoutTimer('onCreateAgent', () => EventEmitter.emit(EVENT_NAMES.SHOW_ASSISTANTS), 0)
onClose()
},
[
@ -273,7 +269,6 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
form.instructions,
form.accessible_paths,
agent,
setTimeoutTimer,
onClose,
t,
updateAgent,

View File

@ -1,10 +1,12 @@
import { AddAgentForm } from '@renderer/types'
export const useAddAgent = () => {
// const { t } = useTranslation()
return {
// oxlint-disable-next-line no-unused-vars
addAgent: (payload: AddAgentForm) => {
window.toast.info('Not implemented')
// window.toast.success(t('common.add_success'))
}
}
}

View File

@ -5,6 +5,7 @@ export const useUpdateAgent = () => {
// oxlint-disable-next-line no-unused-vars
updateAgent: (payload: UpdateAgentForm) => {
window.toast.info('Not implemented')
// window.toast.success(t('common.update_success'))
}
}
}

View File

@ -29,8 +29,7 @@ export const AgentsTab: FC<AssistantsTabProps> = () => {
)
return (
<div className="agents-tab h-full w-full">
<span className="mb-2 text-foreground-400 text-xs">{t('common.agent_other')}</span>
<div className="agents-tab h-full w-full p-2">
{agents.map((agent) => (
<AgentItem
key={agent.id}

View File

@ -135,7 +135,6 @@ const Assistants: FC<AssistantsTabProps> = ({
return (
<Container className="assistants-tab" ref={containerRef}>
<span className="mb-2 text-foreground-400 text-xs">{t('common.assistant_other')}</span>
<DraggableList
list={assistants}
onUpdate={updateAssistants}