Files
Ofer Shaal da900c2689 fix: resolve real-time visualization connection and timestamp issues (#96)
* fix: update WebSocket connection port and improve MindMap data filtering

- Changed WebSocket connection port from 3001 to 8080 for compatibility.
- Enhanced MindMap component to handle undefined currentGraphData, ensuring nodes and edges are filtered correctly.

This update improves the stability of the WebSocket connection and ensures the MindMap component functions correctly with varying data inputs.

* feat: enhance LifecycleTimeline and WebSocket handling

- Updated LifecycleTimeline component to include additional event types and improve icon and color handling.
- Modified WebSocketContext to handle both direct and nested message formats for initial state, ensuring compatibility with frontend expectations.
- Introduced a new script for emitting agent events to the EventStore, facilitating better visualization and tracking of agent lifecycle events.
- Adjusted API base URL for consistency and improved CORS settings for local development.

This update enhances the overall functionality and robustness of the event handling and visualization components.

* fix: update edge source ID in DataTransformer

- Changed the source ID for edges in the DataTransformer class to directly use the agent ID without a prefix. This aligns the edge representation with the agent node ID format, improving consistency in data visualization.

This update enhances the accuracy of the data transformation process.

* feat: add visualization dashboard and event emission scripts

- Introduced a new visualization dashboard for real-time agent activity tracking.
- Added scripts for emitting agent events (spawn, start, complete, error) to the EventStore.
- Implemented hooks for automatic event emission during task execution.
- Enhanced the settings configuration to include commands for visualization event emission.

This update significantly improves the monitoring and debugging capabilities of agent activities.

* feat: improve timestamp handling in DrillDownPanel and LifecycleTimeline

- Added a utility function `toTimestampMs` to safely convert timestamps from both ISO strings and numeric formats to milliseconds.
- Updated sorting and formatting of event timestamps in both the DrillDownPanel and LifecycleTimeline components to utilize the new timestamp conversion function.
- Enhanced the display of event logs and metadata to ensure consistent timestamp representation across the application.

This update improves the accuracy and reliability of timestamp handling in event visualizations.

---------

Co-authored-by: Dragan Spiridonov <spiridonovdragan@gmail.com>
2025-12-02 08:53:15 +01:00
..

Agentic QE Fleet Visualization - Frontend

React-based interactive visualization dashboard for Phase 3 of the Agentic QE Fleet.

🎯 Features

V7: Interactive Mind Map (MindMap.tsx)

  • Cytoscape.js graph rendering with 1000+ node support
  • Expand/collapse subtrees with double-click
  • Zoom/pan with mouse and touch gestures
  • Search and highlight nodes in real-time
  • Filter by agent type, status, and time range
  • Tooltips showing node details on hover
  • Multiple layout algorithms (hierarchical cose-bilkent, force-directed)

V8: Quality Metrics Panel (RadarChart.tsx)

  • Recharts radar chart visualization
  • 6 quality dimensions: coverage, performance, security, maintainability, reliability, efficiency
  • Real-time updates via WebSocket
  • Historical comparison mode
  • Color-coded progress bars
  • Overall quality score

V9: Lifecycle Timeline (LifecycleTimeline.tsx)

  • Horizontal timeline showing agent lifecycle events
  • Events: spawn, execute, complete, error, retry
  • Click to view event details
  • Zoom to time ranges (all time, last hour, last 5 minutes)
  • Visual event icons and color coding

V10: Drill-Down Detail Panel (DrillDownPanel.tsx)

  • Sliding panel with full event/reasoning details
  • Three view modes: Overview, JSON, Logs
  • JSON view with syntax highlighting (react-json-view)
  • Trace links to OpenTelemetry spans
  • Export functionality (JSON, CSV)

🚀 Quick Start

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

🏗️ Architecture

State Management

  • React Context: Global WebSocket connection and selected node state
  • Custom Hooks: Data fetching and real-time subscriptions
  • Local State: UI interactions (filters, view modes, collapsed nodes)

Components Structure

frontend/src/
├── components/
│   ├── MindMap/
│   │   └── MindMap.tsx          # Interactive graph visualization
│   ├── MetricsPanel/
│   │   └── RadarChart.tsx       # Quality metrics radar chart
│   ├── Timeline/
│   │   └── LifecycleTimeline.tsx # Event timeline
│   └── DetailPanel/
│       └── DrillDownPanel.tsx    # Event detail view
├── contexts/
│   └── WebSocketContext.tsx     # WebSocket state management
├── types/
│   └── index.ts                 # TypeScript type definitions
├── hooks/                       # Custom React hooks
├── utils/                       # Utility functions
├── App.tsx                      # Main application layout
└── main.tsx                     # Application entry point

WebSocket Integration

  • Connects to backend at ws://localhost:3001/ws
  • Auto-reconnection on disconnect (3s delay)
  • Real-time message types:
    • graph-update: Node/edge updates
    • metrics-update: Quality metrics
    • lifecycle-event: Agent events
    • initial-state: Full state on connect

📊 Performance

Benchmarks

  • 100 nodes: ~16ms render time
  • 1000 nodes: ~150ms render time
  • Virtual rendering: Handles 10,000+ nodes with pagination
  • WebSocket latency: <50ms average

Optimizations

  • React.memo for component memoization
  • useMemo for expensive computations
  • Lazy loading for large datasets
  • Debounced search and filters
  • Virtual scrolling for event lists

🎨 UI/UX

Layout

┌─────────────────────────────────────────────────┐
│ Header: Agentic QE Fleet Visualization          │
├───────────────────────┬─────────────────────────┤
│                       │ Metrics Panel (35%)     │
│                       ├─────────────────────────┤
│  Mind Map (70%)       │ Timeline (30%)          │
│                       ├─────────────────────────┤
│                       │ Detail Panel (35%)      │
├───────────────────────┴─────────────────────────┤
│ Footer: Connection Status                        │
└─────────────────────────────────────────────────┘

Color Scheme

  • Primary: Blue (#3b82f6) - Coordinator agents
  • Success: Green (#10b981) - Completed status, researcher agents
  • Warning: Yellow (#f59e0b) - Running status, coder agents
  • Error: Red (#ef4444) - Error status, tester agents
  • Info: Purple (#8b5cf6) - Reviewer agents
  • Accent: Cyan (#06b6d4) - Analyzer agents

🔌 Backend Integration

Expected WebSocket Messages

Graph Update:

{
  "type": "graph-update",
  "data": {
    "nodes": [...],
    "edges": [...]
  }
}

Metrics Update:

{
  "type": "metrics-update",
  "data": {
    "timestamp": 1234567890,
    "coverage": 0.85,
    "performance": 0.92,
    "security": 0.78,
    "maintainability": 0.88,
    "reliability": 0.91,
    "efficiency": 0.87
  }
}

Lifecycle Event:

{
  "type": "lifecycle-event",
  "data": {
    "id": "event-123",
    "agentId": "agent-456",
    "agentName": "Test Generator",
    "type": "complete",
    "timestamp": 1234567890,
    "duration": 1500,
    "status": "success",
    "details": {...}
  }
}

🧪 Testing

# Run tests (when available)
npm test

# Type checking
npm run typecheck

# Linting
npm run lint

📝 Memory Storage

All frontend code is stored in memory under:

aqe/phase3/visualization/frontend/
├── components/
├── contexts/
├── types/
└── hooks/

🔧 Configuration

Environment Variables

Create .env.local:

VITE_WS_URL=ws://localhost:3001/ws
VITE_API_URL=http://localhost:3001/api

Vite Proxy

Configured in vite.config.ts to proxy API and WebSocket requests to backend.

📦 Dependencies

Core:

  • react ^18.3.1
  • react-dom ^18.3.1
  • typescript ^5.7.2

Visualization:

  • cytoscape ^3.30.2
  • cytoscape-cose-bilkent ^4.1.0
  • recharts ^2.15.0
  • react-json-view ^1.21.3

Utilities:

  • date-fns ^4.1.0
  • lucide-react ^0.468.0

WebSocket:

  • ws ^8.18.0

Styling:

  • tailwindcss ^3.4.15

🚢 Deployment

# Build production bundle
npm run build

# Preview production build
npm run preview

# Output: dist/ directory ready for deployment

📄 License

Part of Agentic QE Fleet project - See main README for license details.