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

View File

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

View File

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

View File

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