mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
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:
parent
dbf01652f8
commit
231a923c9d
@ -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>
|
||||
|
||||
@ -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
|
||||
// ------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user