feat(types): add AgentForm type and move from component to types file

Centralize the AgentForm type definition in the types file for better maintainability and reuse across components
This commit is contained in:
icarus 2025-09-18 14:03:10 +08:00
parent dbf01652f8
commit 231a923c9d
2 changed files with 11 additions and 15 deletions

View File

@ -21,7 +21,7 @@ import ClaudeIcon from '@renderer/assets/images/models/claude.png'
import { useAgents } from '@renderer/hooks/agents/useAgents'
import { useTimer } from '@renderer/hooks/useTimer'
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
import { AgentEntity, AgentType, isAgentType } from '@renderer/types'
import { AgentEntity, AgentForm, isAgentType } from '@renderer/types'
import { uuid } from '@renderer/utils'
import { ChangeEvent, FormEvent, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
@ -44,15 +44,6 @@ interface AgentTypeOption extends Option {
type ModelOption = Option
type AgentForm = {
type: AgentType
name: string
description?: string
instructions?: string
model: string
accessible_paths: string[]
}
const buildAgentForm = (existing?: AgentEntity): AgentForm => ({
type: existing?.type ?? 'claude-code',
name: existing?.name ?? 'Claude Code',
@ -359,11 +350,7 @@ export const AgentModal: React.FC<Props> = ({ agent, trigger, isOpen: _isOpen, o
value={form.description ?? ''}
onValueChange={onDescChange}
/>
<Textarea
label={t('common.prompt')}
value={form.instructions ?? ''}
onValueChange={onInstChange}
/>
<Textarea label={t('common.prompt')} value={form.instructions ?? ''} onValueChange={onInstChange} />
</ModalBody>
<ModalFooter className="w-full">
<Button onPress={onClose}>{t('common.close')}</Button>

View File

@ -112,6 +112,15 @@ export interface SessionMessageContent {
agentType: string // The type of agent that generated this message (e.g., 'claude-code', 'openai', etc.)
}
export type AgentForm = {
type: AgentType
name: string
description?: string
instructions?: string
model: string
accessible_paths: string[]
}
// ------------------------
// API Data Transfer Object
// ------------------------