Add comprehensive performance monitoring and testing infrastructure
Some checks failed
Lint and Build / build (20) (pull_request) Failing after 36s
Lint and Build / build (22) (pull_request) Failing after 50s

- Implement performance dashboard with real-time metrics tracking
- Add React hooks for smart polling, debouncing, and active source lookup
- Create Jest testing framework with comprehensive test suites for components, API endpoints, and utilities
- Enhance UI components with optimized rendering and memoization
- Improve polling efficiency with visibility detection and adaptive intervals

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Decobus 2025-07-19 06:20:19 -04:00
parent a66979fb34
commit c259f0d943
15 changed files with 6320 additions and 94 deletions

View file

@ -1,6 +1,7 @@
'use client';
import { useState, useEffect } from 'react';
import { useState } from 'react';
import { useSmartPolling, PerformanceMonitor } from '@/lib/performance';
type OBSStatus = {
host: string;
@ -22,25 +23,26 @@ export default function Footer() {
const [obsStatus, setObsStatus] = useState<OBSStatus | null>(null);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
const fetchOBSStatus = async () => {
try {
const response = await fetch('/api/obsStatus');
const data = await response.json();
setObsStatus(data);
} catch (error) {
console.error('Failed to fetch OBS status:', error);
} finally {
setIsLoading(false);
}
};
// Smart polling with performance monitoring and visibility detection
const fetchOBSStatus = async () => {
const endTimer = PerformanceMonitor.startTimer('obsStatus_fetch');
try {
const response = await fetch('/api/obsStatus');
const data = await response.json();
setObsStatus(data);
} catch (error) {
console.error('Failed to fetch OBS status:', error);
// Set error state instead of leaving null
setObsStatus(prev => prev ? { ...prev, error: 'Connection failed' } : null);
} finally {
setIsLoading(false);
endTimer();
}
};
fetchOBSStatus();
// Refresh status every 30 seconds
const interval = setInterval(fetchOBSStatus, 30000);
return () => clearInterval(interval);
}, []);
// Use smart polling that respects page visibility and adapts interval based on connection status
const pollingInterval = obsStatus?.connected ? 15000 : 30000; // Poll faster when connected
useSmartPolling(fetchOBSStatus, pollingInterval, [obsStatus?.connected]);
if (isLoading) {
return (