feat(chat): add agent creation button with placeholder implementation

Add a new button for creating agents in the chat interface. The button is currently a placeholder with a "Not implemented" toast message. Includes necessary i18n translations and component props.
This commit is contained in:
icarus 2025-09-13 21:49:24 +08:00
parent 0d2dc2c257
commit ee82b23886
3 changed files with 25 additions and 1 deletions

View File

@ -132,7 +132,6 @@
},
"title": "API 服务器"
},
"assistants": {
"abbr": "助手",
"clear": {
@ -263,6 +262,9 @@
},
"chat": {
"add": {
"agent": {
"title": "添加 Agent"
},
"assistant": {
"title": "添加助手"
},

View File

@ -18,12 +18,14 @@ interface AssistantsTabProps {
activeAssistant: Assistant
setActiveAssistant: (assistant: Assistant) => void
onCreateAssistant: () => void
onCreateAgent: () => void
onCreateDefaultAssistant: () => void
}
const Assistants: FC<AssistantsTabProps> = ({
activeAssistant,
setActiveAssistant,
onCreateAssistant,
onCreateAgent,
onCreateDefaultAssistant
}) => {
const { assistants, removeAssistant, copyAssistant, updateAssistants } = useAssistants()
@ -83,6 +85,19 @@ const Assistants: FC<AssistantsTabProps> = ({
)
}, [onCreateAssistant, t])
const AddAgentButton = useCallback(() => {
return (
<AssistantAddItem onClick={onCreateAgent}>
<AddItemWrapper>
<Plus size={16} style={{ marginRight: 4, flexShrink: 0 }} />
<Typography.Text style={{ color: 'inherit' }} ellipsis={{ tooltip: t('chat.add.agent.title') }}>
{t('chat.add.agent.title')}
</Typography.Text>
</AddItemWrapper>
</AssistantAddItem>
)
}, [onCreateAgent, t])
if (assistantsTabSortType === 'tags') {
return (
<Container className="assistants-tab" ref={containerRef}>
@ -132,6 +147,7 @@ const Assistants: FC<AssistantsTabProps> = ({
))}
</div>
{renderAddAssistantButton}
<AddAgentButton />
</Container>
)
}
@ -159,6 +175,7 @@ const Assistants: FC<AssistantsTabProps> = ({
)}
</DraggableList>
{!dragging && renderAddAssistantButton}
{!dragging && <AddAgentButton />}
<div style={{ minHeight: 10 }}></div>
</Container>
)

View File

@ -62,6 +62,10 @@ const HomeTabs: FC<Props> = ({
assistant && setActiveAssistant(assistant)
}
const onCreateAgent = async () => {
window.toast.info('Not implemented')
}
const onCreateDefaultAssistant = () => {
const assistant = { ...defaultAssistant, id: uuid() }
addAssistant(assistant)
@ -133,6 +137,7 @@ const HomeTabs: FC<Props> = ({
activeAssistant={activeAssistant}
setActiveAssistant={setActiveAssistant}
onCreateAssistant={onCreateAssistant}
onCreateAgent={onCreateAgent}
onCreateDefaultAssistant={onCreateDefaultAssistant}
/>
)}