fix: implement proper multi-timeframe batch analysis
- Create /api/batch-analysis endpoint that collects ALL screenshots first - Then sends all screenshots to AI for comprehensive analysis - Fixes issue where individual timeframes were analyzed immediately - Multi-timeframe analysis now provides cross-timeframe consensus - Update AIAnalysisPanel to use batch analysis for multiple timeframes - Maintains backward compatibility with single timeframe analysis
This commit is contained in:
@@ -8,9 +8,10 @@ class AggressiveCleanup {
|
||||
private static instance: AggressiveCleanup
|
||||
private cleanupInterval: NodeJS.Timeout | null = null
|
||||
private isRunning = false
|
||||
private isInitialized = false
|
||||
|
||||
private constructor() {
|
||||
this.startPeriodicCleanup()
|
||||
// Don't auto-start - let startup.ts control it
|
||||
}
|
||||
|
||||
static getInstance(): AggressiveCleanup {
|
||||
@@ -20,7 +21,21 @@ class AggressiveCleanup {
|
||||
return AggressiveCleanup.instance
|
||||
}
|
||||
|
||||
private startPeriodicCleanup() {
|
||||
startPeriodicCleanup() {
|
||||
if (this.isInitialized) {
|
||||
console.log('🔄 Aggressive cleanup already initialized')
|
||||
return
|
||||
}
|
||||
|
||||
this.isInitialized = true
|
||||
console.log('🚀 Starting aggressive cleanup system')
|
||||
|
||||
// In development, disable aggressive cleanup to avoid interfering with analysis
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log('🔒 Aggressive cleanup disabled in development mode')
|
||||
return
|
||||
}
|
||||
|
||||
// Clean up every 5 minutes
|
||||
this.cleanupInterval = setInterval(async () => {
|
||||
try {
|
||||
@@ -34,6 +49,8 @@ class AggressiveCleanup {
|
||||
setTimeout(() => {
|
||||
this.cleanupOrphanedProcesses().catch(console.error)
|
||||
}, 30000)
|
||||
|
||||
console.log('✅ Aggressive cleanup system started (5 min intervals)')
|
||||
}
|
||||
|
||||
async cleanupOrphanedProcesses(): Promise<void> {
|
||||
@@ -43,6 +60,23 @@ class AggressiveCleanup {
|
||||
console.log('🧹 Running aggressive cleanup for orphaned processes...')
|
||||
|
||||
try {
|
||||
// Check for active analysis sessions
|
||||
try {
|
||||
const { progressTracker } = await import('./progress-tracker')
|
||||
const activeSessions = progressTracker.getActiveSessions()
|
||||
|
||||
if (activeSessions.length > 0) {
|
||||
console.log(`⚠️ Skipping cleanup - ${activeSessions.length} active analysis sessions: ${activeSessions.join(', ')}`)
|
||||
return
|
||||
}
|
||||
|
||||
console.log('✅ No active analysis sessions, proceeding with cleanup')
|
||||
} catch (importError) {
|
||||
console.error('❌ Error importing progress tracker:', importError)
|
||||
console.log('⚠️ Skipping cleanup due to import error')
|
||||
return
|
||||
}
|
||||
|
||||
// Find and kill orphaned chromium processes
|
||||
const chromiumProcesses = await this.findChromiumProcesses()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user