From 46aea2b49970cce3e918557fc17994c22312e234 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Tue, 25 Aug 2026 11:54:59 +0800 Subject: [PATCH] feat(web): unify processor detail workbench --- .../app/home/agents/AgentDetailContent.tsx | 88 ++-- .../agents/components/AgentDebugPanel.tsx | 283 ++++++------- .../agents/components/AgentFormComponent.tsx | 383 +++++++++++------- .../ProcessorDetailWorkbench.tsx | 149 +++++++ .../home/pipelines/PipelineDetailContent.tsx | 157 +++---- .../components/debug-dialog/DebugDialog.tsx | 32 +- .../pipeline-form/PipelineFormComponent.tsx | 61 ++- .../app/infra/websocket/WebSocketClient.ts | 12 +- .../e2e/processor-detail-workbench.spec.ts | 82 ++++ .../unit/processor-detail-workbench.test.mjs | 65 +++ 10 files changed, 835 insertions(+), 477 deletions(-) create mode 100644 web/src/app/home/components/processor-detail/ProcessorDetailWorkbench.tsx create mode 100644 web/tests/e2e/processor-detail-workbench.spec.ts create mode 100644 web/tests/unit/processor-detail-workbench.test.mjs diff --git a/web/src/app/home/agents/AgentDetailContent.tsx b/web/src/app/home/agents/AgentDetailContent.tsx index 92dd009bb..e4eb2d2ac 100644 --- a/web/src/app/home/agents/AgentDetailContent.tsx +++ b/web/src/app/home/agents/AgentDetailContent.tsx @@ -1,13 +1,11 @@ import { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import { Bug, Settings } from 'lucide-react'; -import { Button } from '@/components/ui/button'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { httpClient } from '@/app/infra/http/HttpClient'; import { useCurrentWorkspace } from '@/app/infra/http'; import { Agent } from '@/app/infra/entities/api'; import { useSidebarData } from '@/app/home/components/home-sidebar/SidebarDataContext'; +import ProcessorDetailWorkbench from '@/app/home/components/processor-detail/ProcessorDetailWorkbench'; import PipelineDetailContent from '@/app/home/pipelines/PipelineDetailContent'; import AgentCreateContent from './components/AgentCreateContent'; import AgentDebugPanel from './components/AgentDebugPanel'; @@ -18,6 +16,8 @@ export default function AgentDetailContent({ id }: { id: string }) { const navigate = useNavigate(); const { t } = useTranslation(); const currentWorkspace = useCurrentWorkspace(); + const canManage = + currentWorkspace?.permissions.includes('resource.manage') ?? false; const canOperate = currentWorkspace?.permissions.includes('runtime.operate') ?? false; const { refreshPipelines, pipelines, setDetailEntityName } = useSidebarData(); @@ -25,7 +25,6 @@ export default function AgentDetailContent({ id }: { id: string }) { const [loading, setLoading] = useState(!isCreateMode); const [formDirty, setFormDirty] = useState(false); const [formSaving, setFormSaving] = useState(false); - const [activeTab, setActiveTab] = useState('config'); useEffect(() => { if (isCreateMode) { @@ -79,42 +78,17 @@ export default function AgentDetailContent({ id }: { id: string }) { } return ( -
-
-

{t('agents.editAgent')}

- -
- - - - - - {t('pipelines.configuration')} - - {canOperate && ( - - - {t('agents.debugTab')} - - )} - - - + { @@ -127,23 +101,21 @@ export default function AgentDetailContent({ id }: { id: string }) { onDirtyChange={setFormDirty} onSavingChange={setFormSaving} /> - - - {canOperate && ( - - - - )} - -
+ + } + debugTitle={canOperate ? t('agents.debugTab') : undefined} + debugContent={ + canOperate ? ( + + ) : undefined + } + unsavedLabel={t('pipelines.unsavedChanges')} + /> ); } diff --git a/web/src/app/home/agents/components/AgentDebugPanel.tsx b/web/src/app/home/agents/components/AgentDebugPanel.tsx index 014ead258..882eff404 100644 --- a/web/src/app/home/agents/components/AgentDebugPanel.tsx +++ b/web/src/app/home/agents/components/AgentDebugPanel.tsx @@ -1,25 +1,11 @@ import { useMemo, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { toast } from 'sonner'; -import { - AlertTriangle, - Braces, - LoaderCircle, - MessageSquare, - Play, - RotateCcw, -} from 'lucide-react'; +import { AlertTriangle, LoaderCircle, Play, RotateCcw } from 'lucide-react'; import { httpClient } from '@/app/infra/http/HttpClient'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from '@/components/ui/card'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { @@ -205,162 +191,149 @@ export default function AgentDebugPanel({ } return ( -
- - -
-
- - {isMessageEvent ? ( - - ) : ( - - )} - {t('agents.debugTitle')} - - {t('agents.debugDescription')} -
- +
+
+
+
+ +
- - - - - {t('agents.debugActualRun')} - - {t('agents.debugActualRunDescription')} - - + +
-
-
- - -
- {preset === 'custom' && ( -
- - setCustomEventType(event.target.value)} - placeholder="custom.event" - /> -
- )} -
- -
-