From 6b40c2cf665501bee61604a4a15274cbfbe522e4 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Thu, 27 Aug 2026 14:39:56 +0800 Subject: [PATCH] refactor(agents): polish processor creation layout --- .../agents/components/AgentCreateContent.tsx | 282 ++++---- .../components/ProcessorTypeDiagram.tsx | 674 +++++++++++------- 2 files changed, 554 insertions(+), 402 deletions(-) diff --git a/web/src/app/home/agents/components/AgentCreateContent.tsx b/web/src/app/home/agents/components/AgentCreateContent.tsx index aa2c8cd88..8e6371e49 100644 --- a/web/src/app/home/agents/components/AgentCreateContent.tsx +++ b/web/src/app/home/agents/components/AgentCreateContent.tsx @@ -113,84 +113,153 @@ export default function AgentCreateContent({
-
-
-
-
-

- {t('agents.chooseType')} -

-

- {t('agents.chooseTypeDescription')} -

-
+
+
+
+
+
+

+ {t('agents.chooseType')} +

+

+ {t('agents.chooseTypeDescription')} +

+
-
- {typeOptions.map((option) => { - const Icon = option.icon; - const selected = kind === option.kind; - return ( - - - - - - ); - })} -
-
+ + + + {option.title} + + {selected && ( + + )} + + + {option.badge} + + + {option.description} + + + + + + ); + })} +
+
- + + + {t('agents.basicInfo')} + + {t('agents.basicInfoDescription')} + + + +
+ +
+ ( + + + {t('common.name')} + * + + + + + + + )} + /> + ( + + {t('common.icon')} + + + + + + )} + /> +
+ + ( + + {t('common.description')} + + + + + + )} + /> + + +
+
+
+ +
@@ -210,7 +279,7 @@ export default function AgentCreateContent({
- + @@ -220,73 +289,6 @@ export default function AgentCreateContent({
- - - - {t('agents.basicInfo')} - - {t('agents.basicInfoDescription')} - - - -
- -
- ( - - - {t('common.name')} - * - - - - - - - )} - /> - ( - - {t('common.icon')} - - - - - - )} - /> -
- - ( - - {t('common.description')} - - - - - - )} - /> - - -
-
diff --git a/web/src/app/home/agents/components/ProcessorTypeDiagram.tsx b/web/src/app/home/agents/components/ProcessorTypeDiagram.tsx index 7441dd8d1..9830a93f4 100644 --- a/web/src/app/home/agents/components/ProcessorTypeDiagram.tsx +++ b/web/src/app/home/agents/components/ProcessorTypeDiagram.tsx @@ -2,29 +2,81 @@ import { useId } from 'react'; import { useTranslation } from 'react-i18next'; import type { AgentKind } from '@/app/infra/entities/api'; -function DiagramArrow({ id }: { id: string }) { +type DiagramIds = { + accent: string; + arrow: string; + glow: string; + grid: string; + surface: string; +}; + +function useDiagramIds(prefix: string): DiagramIds { + const id = useId().replace(/:/g, ''); + return { + accent: `${prefix}-accent-${id}`, + arrow: `${prefix}-arrow-${id}`, + glow: `${prefix}-glow-${id}`, + grid: `${prefix}-grid-${id}`, + surface: `${prefix}-surface-${id}`, + }; +} + +function DiagramDefinitions({ ids }: { ids: DiagramIds }) { return ( - - - + + + + + + + + + + + + + + + + + + + + + ); } function AgentDiagram() { const { t } = useTranslation(); - const arrowId = `agent-arrow-${useId().replace(/:/g, '')}`; + const ids = useDiagramIds('agent'); + const events = [ + { label: t('agents.diagramMessages'), y: 154 }, + { label: t('agents.diagramMembers'), y: 270 }, + { label: t('agents.diagramFeedback'), y: 386 }, + ]; + const capabilities = [ + { label: t('agents.diagramModel'), y: 154 }, + { label: t('agents.diagramTools'), y: 270 }, + { label: t('agents.diagramActions'), y: 386 }, + ]; return ( {t('agents.agentDiagramTitle')} {t('agents.agentDiagramDescription')} - - - - - - - + + + + + + + {events.map((event) => ( + + ))} + {capabilities.map((capability) => ( + + ))} + + {t('agents.diagramEvents')} - {[ - { - y: 98, - label: t('agents.diagramMessages'), - icon: 'M44 116h12l8 8v-8h28v-24H44z', - }, - { - y: 160, - label: t('agents.diagramMembers'), - icon: 'M51 167a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm-11 14c1-8 6-12 11-12s10 4 11 12m8-22a6 6 0 1 0 0-12m5 28c-1-6-4-9-9-10', - }, - { - y: 222, - label: t('agents.diagramFeedback'), - icon: 'M52 213l4 9 10 1-7 7 2 10-9-5-9 5 2-10-7-7 10-1z', - }, - ].map((item) => ( - + {events.map((event, index) => ( + + + {index === 0 && ( + + )} + {index === 1 && ( + + + + + + )} + {index === 2 && ( + + )} + + {event.label} + + + + ))} + + + + + + + + + + + + + + {t('agents.agentType')} + + + {t('agents.diagramDecide')} + + + + {capabilities.map((capability, index) => ( + + + + - {item.label} + {capability.label} ))} - - - - - - - - {t('agents.agentType')} - - - {t('agents.diagramDecide')} - - - - {[ - { y: 70, label: t('agents.diagramModel') }, - { y: 145, label: t('agents.diagramTools') }, - { y: 220, label: t('agents.diagramActions') }, - ].map((item, index) => ( - - - - - - {item.label} - - - ))} ); } function PipelineDiagram() { const { t } = useTranslation(); - const arrowId = `pipeline-arrow-${useId().replace(/:/g, '')}`; - const stages = [ - t('agents.diagramPreprocess'), - t('agents.diagramAI'), - t('agents.diagramPostprocess'), - t('agents.diagramOutput'), + const ids = useDiagramIds('pipeline'); + const stations = [ + { x: 198, y: 312, label: t('agents.diagramPreprocess') }, + { x: 338, y: 242, label: t('agents.diagramAI') }, + { x: 478, y: 312, label: t('agents.diagramPostprocess') }, + { x: 618, y: 242, label: t('agents.diagramOutput') }, ]; return ( {t('agents.pipelineDiagramTitle')} {t('agents.pipelineDiagramDescription')} - - - - - - - - + + + + + {t('agents.pipelineDiagramFlow')} - - - {t('agents.diagramMessage')} - - + - {stages.map((stage, index) => { - const x = 178 + index * 128; - return ( - - + + + + + {t('agents.diagramMessage')} + + + + {stations.map((station, index) => ( + + + + + {index + 1} + + + + {station.label} + + + ))} + + + + + + + + {[0, 1, 2, 3].map((step) => ( + - - {index + 1} - - - {stage} - - {index < stages.length - 1 && ( + {step < 3 && ( )} - ); - })} + ))} + ); }