All files / web/src/components/agents agents-view.tsx

75.72% Statements 78/103
66.66% Branches 12/18
100% Functions 2/2
75.72% Lines 78/103

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125    1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 22x 22x     22x 22x                         22x   22x 22x 22x 13x 13x 13x 13x   22x 1x 1x 1x 1x   22x 2x 2x 2x 2x   22x 1x 1x 1x 1x   22x 1x 1x 1x 1x   22x 1x 1x 1x 1x   22x 1x 1x 1x 1x   22x 1x 1x 1x 1x   22x 1x 1x 1x 1x   22x           22x           22x           22x   22x 22x   22x 22x 22x 22x   22x  
'use client';
 
import { AgentView } from '@web/components/agents/agent-view';
import { useNavigationPerformance } from '@web/hooks/use-navigation-performance';
import { useNavigation } from '@web/providers/navigation';
import type { ReactElement } from 'react';
import { useEffect } from 'react';
import { AgentErrorBoundary } from './agent-error-boundary';
import { AgentsListView } from './agents-list-view';
import { EditAgentView } from './edit-agent-view';
import { EditSkillView, SkillDashboardView } from './skills';
import { ArmDetailView } from './skills/arms/arm-detail-view';
import { ClusterArmsView } from './skills/clusters/cluster-arms-view';
import { EvaluationEditView } from './skills/evaluations/evaluation-edit-view';
import { EvaluationsListView } from './skills/evaluations/evaluations-list-view';
import { SkillEventsView } from './skills/events/skill-events-view';
import { LogDetailsView, LogsView } from './skills/logs';
 
export function AgentsView(): ReactElement {
  const { navigationState } = useNavigation();
  const { currentMetric, getPerformanceReport } = useNavigationPerformance();
 
  // Log performance metrics in development
  useEffect(() => {
    if (process.env.NODE_ENV === 'development' && currentMetric) {
      const report = getPerformanceReport();
      if (report && report.averageLoadTime > 500) {
        console.info('Navigation Performance:', {
          currentRoute: report.currentRoute,
          loadTime: currentMetric.loadTime
            ? `${currentMetric.loadTime.toFixed(2)}ms`
            : 'N/A',
          averageLoadTime: `${report.averageLoadTime.toFixed(2)}ms`,
          slowestRoute: report.slowestRoute,
        });
      }
    }
  }, [currentMetric, getPerformanceReport]);
 
  const renderContent = () => {
    switch (navigationState.currentView) {
      case 'agents-list':
        return (
          <AgentErrorBoundary sectionName="Agents List">
            <AgentsListView />
          </AgentErrorBoundary>
        );
      case 'edit-agent':
        return (
          <AgentErrorBoundary sectionName="Edit Agent">
            <EditAgentView />
          </AgentErrorBoundary>
        );
      case 'agent-view':
        return (
          <AgentErrorBoundary sectionName="Skills List">
            <AgentView />
          </AgentErrorBoundary>
        );
      case 'skill-dashboard':
        return (
          <AgentErrorBoundary sectionName="Skill Dashboard">
            <SkillDashboardView />
          </AgentErrorBoundary>
        );
      case 'edit-skill':
        return (
          <AgentErrorBoundary sectionName="Edit Skill">
            <EditSkillView />
          </AgentErrorBoundary>
        );
      case 'logs':
        return (
          <AgentErrorBoundary sectionName="Logs">
            <LogsView />
          </AgentErrorBoundary>
        );
      case 'log-detail':
        return (
          <AgentErrorBoundary sectionName="Log Detail">
            <LogDetailsView />
          </AgentErrorBoundary>
        );
      case 'cluster-arms':
        return (
          <AgentErrorBoundary sectionName="Partition Arms">
            <ClusterArmsView />
          </AgentErrorBoundary>
        );
      case 'arm-detail':
        return (
          <AgentErrorBoundary sectionName="Arm Detail">
            <ArmDetailView />
          </AgentErrorBoundary>
        );
      case 'skill-events':
        return (
          <AgentErrorBoundary sectionName="Events">
            <SkillEventsView />
          </AgentErrorBoundary>
        );
      case 'evaluations':
        return (
          <AgentErrorBoundary sectionName="Evaluations">
            <EvaluationsListView />
          </AgentErrorBoundary>
        );
      case 'edit-evaluation':
        return (
          <AgentErrorBoundary sectionName="Edit Evaluation">
            <EvaluationEditView />
          </AgentErrorBoundary>
        );
      default:
        return <div>Unknown view</div>;
    }
  };
 
  return (
    <div className="flex flex-col h-full">
      <div className="flex-1 overflow-auto">{renderContent()}</div>
    </div>
  );
}