From 87c501b55cc264f3bdf5049c64d0fcaba3cc4511 Mon Sep 17 00:00:00 2001 From: lintsinghua Date: Thu, 18 Dec 2025 23:11:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E5=AE=A1=E8=AE=A1=E9=A1=B5=E9=9D=A2UI=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E7=A7=BB=E9=99=A4=E5=A4=9A=E4=BD=99=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 清理代理树节点和日志条目的冗余样式和动画 - 统一颜色和间距设计,优化暗黑模式支持 - 移除背景特效和多余装饰元素,提升性能 --- .../AgentAudit/components/AgentTreeNode.tsx | 161 +++++++--------- .../pages/AgentAudit/components/LogEntry.tsx | 112 +++++------ frontend/src/pages/AgentAudit/index.tsx | 176 ++++++------------ 3 files changed, 175 insertions(+), 274 deletions(-) diff --git a/frontend/src/pages/AgentAudit/components/AgentTreeNode.tsx b/frontend/src/pages/AgentAudit/components/AgentTreeNode.tsx index 02554da..7cd1957 100644 --- a/frontend/src/pages/AgentAudit/components/AgentTreeNode.tsx +++ b/frontend/src/pages/AgentAudit/components/AgentTreeNode.tsx @@ -1,8 +1,6 @@ /** * Agent Tree Node Component - * Elegant tree visualization with enhanced visual design - * Features: Animated connection lines, status indicators, smooth transitions - * Premium visual effects with depth and hierarchy + * Clean tree visualization with simple connection lines */ import { useState, memo } from "react"; @@ -11,37 +9,29 @@ import { Badge } from "@/components/ui/badge"; import { AGENT_STATUS_CONFIG } from "../constants"; import type { AgentTreeNodeItemProps } from "../types"; -// Agent type icons with enhanced colors and styling +// Agent type icons const AGENT_TYPE_ICONS: Record = { - orchestrator: , - recon: , - analysis: , - verification: , + orchestrator: , + recon: , + analysis: , + verification: , }; -// Agent type background colors for icon container +// Agent type background colors const AGENT_TYPE_BG: Record = { - orchestrator: 'bg-violet-500/15 border-violet-500/30', - recon: 'bg-teal-500/15 border-teal-500/30', - analysis: 'bg-amber-500/15 border-amber-500/30', - verification: 'bg-emerald-500/15 border-emerald-500/30', -}; - -// Status colors for the glow effect -const STATUS_GLOW_COLORS: Record = { - running: 'shadow-[0_0_15px_rgba(52,211,153,0.3)]', - completed: 'shadow-[0_0_10px_rgba(52,211,153,0.15)]', - failed: 'shadow-[0_0_12px_rgba(244,63,94,0.25)]', - waiting: 'shadow-[0_0_8px_rgba(251,191,36,0.2)]', - created: '', + orchestrator: 'bg-violet-100 dark:bg-violet-500/15 border-violet-300 dark:border-violet-500/30', + recon: 'bg-teal-100 dark:bg-teal-500/15 border-teal-300 dark:border-teal-500/30', + analysis: 'bg-amber-100 dark:bg-amber-500/15 border-amber-300 dark:border-amber-500/30', + verification: 'bg-emerald-100 dark:bg-emerald-500/15 border-emerald-300 dark:border-emerald-500/30', }; export const AgentTreeNodeItem = memo(function AgentTreeNodeItem({ node, depth = 0, selectedId, - onSelect -}: AgentTreeNodeItemProps) { + onSelect, + isLast = false +}: AgentTreeNodeItemProps & { isLast?: boolean }) { const [expanded, setExpanded] = useState(true); const hasChildren = node.children && node.children.length > 0; const isSelected = selectedId === node.agent_id; @@ -49,65 +39,62 @@ export const AgentTreeNodeItem = memo(function AgentTreeNodeItem({ const isCompleted = node.status === 'completed'; const isFailed = node.status === 'failed'; - const statusConfig = AGENT_STATUS_CONFIG[node.status] || AGENT_STATUS_CONFIG.created; const typeIcon = AGENT_TYPE_ICONS[node.agent_type] || ; - const typeBg = AGENT_TYPE_BG[node.agent_type] || 'bg-muted/50 border-border/50'; + const typeBg = AGENT_TYPE_BG[node.agent_type] || 'bg-muted border-border'; + + const indent = depth * 24; return (
- {/* Connection line to parent - vertical line with gradient */} - {depth > 0 && ( -
- )} - - {/* Horizontal connector line with dot */} + {/* 树形连接线 */} {depth > 0 && ( <> + {/* 垂直线 - 从父节点延伸下来 */}
+ {/* 水平线 - 连接到当前节点 */}
)} - {/* Node item with enhanced styling */} + {/* Node item */}
onSelect(node.agent_id)} > - {/* Expand/collapse button with enhanced styling */} + {/* Expand/collapse button */} {hasChildren ? ( ) : ( - + )} - {/* Status indicator with enhanced glow */} + {/* Status indicator */}
{isRunning && ( - <> -
-
- +
)}
- {/* Agent type icon with background */} -
+ {/* Agent type icon */} +
{typeIcon}
- {/* Agent name with enhanced styling */} + {/* Agent name */} {node.agent_name} - {/* Metrics badges with enhanced styling */} -
- {/* Iterations with icon */} + {/* Metrics */} +
{(node.iterations ?? 0) > 0 && ( -
+
{node.iterations}
)} - {/* Findings count - Only show for Orchestrator (root agent) */} {!node.parent_agent_id && node.findings_count > 0 && ( - - {node.findings_count} findings + + {node.findings_count} )}
- {/* Children with animated reveal */} + {/* Children */} {expanded && hasChildren && ( -
- {/* Vertical connection line for children with gradient */} -
- - {node.children.map((child) => ( +
+ {node.children.map((child, index) => ( ))}
diff --git a/frontend/src/pages/AgentAudit/components/LogEntry.tsx b/frontend/src/pages/AgentAudit/components/LogEntry.tsx index 3dadfc8..0b0dad0 100644 --- a/frontend/src/pages/AgentAudit/components/LogEntry.tsx +++ b/frontend/src/pages/AgentAudit/components/LogEntry.tsx @@ -85,45 +85,36 @@ export const LogEntry = memo(function LogEntry({ item, isExpanded, onToggle }: L return (
- {/* Main card with enhanced styling */} + {/* Main card */}
- {/* Enhanced gradient overlay */} -
{/* Content */}
{/* Header row */}
- {/* Type icon with glow effect */} -
-
- {config.icon} -
- {item.isStreaming && ( -
- {config.icon} -
- )} + {/* Type icon */} +
+ {config.icon}
- {/* Type label with enhanced styling */} + {/* Type label */} - {/* Timestamp with subtle styling */} - + {/* Timestamp */} + {item.time} - {/* Separator with animation */} + {/* Separator */} {/* Status icon for info messages */} @@ -151,36 +142,36 @@ export const LogEntry = memo(function LogEntry({ item, isExpanded, onToggle }: L {/* Title - for non-thinking types */} {!isThinking && ( - + {formattedTitle} )} - {/* Streaming cursor with enhanced animation */} + {/* Streaming cursor */} {item.isStreaming && ( - + )} - {/* Tool status with enhanced styling */} + {/* Tool status */} {item.tool?.status === 'running' && (
- - Running + + Running
)} {item.tool?.status === 'completed' && (
- - Done + + Done
)} - {/* Agent badge with enhanced styling */} + {/* Agent badge */} {item.agentName && ( {item.agentName} @@ -188,14 +179,14 @@ export const LogEntry = memo(function LogEntry({ item, isExpanded, onToggle }: L {/* Right side info */}
- {/* Duration badge with enhanced styling */} + {/* Duration badge */} {item.tool?.duration !== undefined && ( - + {item.tool.duration}ms )} - {/* Severity badge with enhanced styling */} + {/* Severity badge */} {item.severity && ( )} - {/* Expand indicator with enhanced styling */} + {/* Expand indicator */} {isCollapsible && (
{isExpanded ? ( ) : ( - + )}
)}
- {/* Thinking content - always visible with enhanced styling */} + {/* Thinking content - always visible */} {isThinking && item.content && (
-
-
+
+
{item.content}
)} - {/* Collapsible content with enhanced styling */} + {/* Collapsible content */} {!isThinking && showContent && item.content && ( -
-
- {/* Mini header with enhanced styling */} -
+
+
+ {/* Mini header */} +
- + {isTool ? 'Output' : 'Details'}
{item.tool?.status === 'completed' && (
- - Complete + + Complete
)}
- {/* Content with enhanced styling */} -
+                {/* Content */}
+                
                   {item.content}
                 
@@ -262,13 +253,6 @@ export const LogEntry = memo(function LogEntry({ item, isExpanded, onToggle }: L
- {/* Inline styles for cursor blink */} -
); }); diff --git a/frontend/src/pages/AgentAudit/index.tsx b/frontend/src/pages/AgentAudit/index.tsx index 7422321..c9840e6 100644 --- a/frontend/src/pages/AgentAudit/index.tsx +++ b/frontend/src/pages/AgentAudit/index.tsx @@ -772,17 +772,6 @@ function AgentAuditPageContent() { return (
- {/* Animated gradient background */} -
- {/* Subtle grid background with animation */} -
- {/* Scanline effect */} -
- {/* Corner accent lines */} -
-
-
-
{/* Header */}
{/* Left Panel - Activity Log */} -
- {/* Panel glow effect */} -
+
{/* Log header */} -
- {/* Header accent line */} -
-
+
+
-
- - {isConnected && ( -
- )} -
- Activity Log + + Activity Log
{isConnected && (
- - - - - Live + + Live
)} - + {filteredLogs.length}{!showAllLogs && logs.length !== filteredLogs.length ? ` / ${logs.length}` : ''} entries
@@ -831,36 +808,30 @@ function AgentAuditPageContent() {
{/* Log content */} -
+
{/* Filter indicator */} {selectedAgentId && !showAllLogs && ( -
+
-
- -
- Filtering logs for selected agent + + Filtering logs for selected agent
@@ -890,7 +861,7 @@ function AgentAuditPageContent() {
) : ( -
+
{filteredLogs.map(item => ( +
{/* Progress bar background */}
- {/* Top accent line */} -
{isRunning ? ( - - - - - - {statusVerb}{'.'.repeat(statusDots)} + + + {statusVerb}{'.'.repeat(statusDots)} ) : isComplete ? ( - + AUDIT {task.status?.toUpperCase()} ) : ( - READY + READY )}
@@ -938,16 +904,16 @@ function AgentAuditPageContent() { {task.progress_percentage?.toFixed(0) || 0} %
-
+
{task.analyzed_files} / {task.total_files} - files + files
-
+
{task.tool_calls_count || 0} - tools + tools
@@ -955,55 +921,50 @@ function AgentAuditPageContent() {
{/* Right Panel - Agent Tree + Stats */} -
- {/* Panel left glow */} -
- +
{/* Agent Tree section */} -
+
{/* Tree header */} -
- {/* Header accent */} -
- -
-
- - {agentTree && agentTree.running_agents > 0 && ( -
- )} -
- Agent Tree - {agentTree && ( - +
+
+ + + {selectedAgentId && !showAllLogs ? 'Agent Detail' : 'Agent Tree'} + + {!selectedAgentId && agentTree && ( + {agentTree.total_agents} )}
-
+
{selectedAgentId && !showAllLogs && ( )} - {agentTree && agentTree.running_agents > 0 && ( + {!selectedAgentId && agentTree && agentTree.running_agents > 0 && (
- - - - - {agentTree.running_agents} + + {agentTree.running_agents}
)}
- {/* Tree content */} -
- {treeNodes.length > 0 ? ( + {/* Tree content or Agent Detail */} +
+ {selectedAgentId && !showAllLogs ? ( + /* Agent Detail Panel - 覆盖整个内容区域 */ + selectAgent(null)} + /> + ) : treeNodes.length > 0 ? (
{treeNodes.map(node => ( {isRunning ? (
-
- -
- -
-
- INITIALIZING
AGENTS...
+ + INITIALIZING
AGENTS...
) : (
- NO AGENTS YET + NO AGENTS YET
)}
@@ -1037,18 +993,8 @@ function AgentAuditPageContent() {
- {/* Bottom section - Details + Stats */} -
- {/* Agent detail panel */} - {selectedAgentId && !showAllLogs && ( - selectAgent(null)} - /> - )} - - {/* Stats panel */} + {/* Bottom section - Stats */} +