Просмотр исходного кода

Fix cache splash screen and add debugging for cache checks

Frontend:
- Remove cacheProgress?.is_running from useEffect dependency to prevent
  unnecessary WebSocket reconnection loops

Backend:
- Add detailed logging to is_cache_generation_needed_async() to show
  exactly why cache generation is triggered (missing metadata/images)
- Log when cache is up to date

Nginx:
- Add more legacy endpoints to proxy configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 3 недель назад
Родитель
Сommit
6af86a9c5b
3 измененных файлов с 17 добавлено и 4 удалено
  1. 1 1
      frontend/src/components/layout/Layout.tsx
  2. 15 2
      modules/core/cache_manager.py
  3. 1 1
      nginx.conf

+ 1 - 1
frontend/src/components/layout/Layout.tsx

@@ -491,7 +491,7 @@ export function Layout() {
         cacheWsRef.current = null
       }
     }
-  }, [isBackendConnected, cacheProgress?.is_running])
+  }, [isBackendConnected]) // Only reconnect based on backend connection, not cache state
 
   // Calculate cache progress percentage
   const cachePercentage = cacheProgress?.total_files

+ 15 - 2
modules/core/cache_manager.py

@@ -776,6 +776,12 @@ async def is_cache_generation_needed_async():
         
         if pattern_set != metadata_keys:
             # Metadata is missing some patterns
+            missing_metadata = pattern_set - metadata_keys
+            extra_metadata = metadata_keys - pattern_set
+            if missing_metadata:
+                logger.info(f"Cache needed: {len(missing_metadata)} patterns missing from metadata cache")
+            if extra_metadata:
+                logger.info(f"Cache needed: {len(extra_metadata)} patterns in metadata but not on disk")
             return True
         
         # Step 3: Check image cache
@@ -793,10 +799,17 @@ async def is_cache_generation_needed_async():
         
         if pattern_set != cached_images:
             # Some patterns missing image cache
+            missing_images = pattern_set - cached_images
+            extra_images = cached_images - pattern_set
+            if missing_images:
+                logger.info(f"Cache needed: {len(missing_images)} patterns missing image cache")
+            if extra_images:
+                logger.info(f"Cache needed: {len(extra_images)} cached images without patterns")
             return True
-        
+
+        logger.info(f"Cache is up to date ({len(pattern_set)} patterns)")
         return False
-        
+
     except Exception as e:
         logger.warning(f"Error checking cache status: {e}")
         return False  # Don't block startup on errors

+ 1 - 1
nginx.conf

@@ -42,7 +42,7 @@ server {
     }
 
     # All backend API endpoints (legacy non-/api/ routes)
-    location ~ ^/(list_theta_rho_files|preview_thr_batch|get_theta_rho_coordinates|upload_theta_rho|pause_execution|resume_execution|stop_execution|skip_pattern|set_speed|restart|shutdown|run_pattern|run_playlist|connect_device|disconnect_device|home_device|clear_sand|move_to_position|get_playlists|save_playlist|delete_playlist|rename_playlist|get_status|list_serial_ports|serial_status|cache-progress|rebuild_cache) {
+    location ~ ^/(list_theta_rho_files|preview_thr_batch|get_theta_rho_coordinates|upload_theta_rho|pause_execution|resume_execution|stop_execution|skip_pattern|set_speed|get_speed|restart|shutdown|run_pattern|run_playlist|connect_device|disconnect_device|home_device|clear_sand|move_to_position|get_playlists|save_playlist|delete_playlist|rename_playlist|get_status|list_serial_ports|serial_status|cache-progress|rebuild_cache|get_led_config|set_led_config|get_wled_ip|set_wled_ip|led|send_home|send_coordinate|move_to_center|move_to_perimeter|run_theta_rho|connect|disconnect|list_theta_rho_files_with_metadata|list_all_playlists|get_playlist|create_playlist|modify_playlist|add_to_playlist|preview_thr|preview) {
         proxy_pass http://backend:8080;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;