Browse Source

1. Runtime tracking - Removed the 60s upper bound so restarts don't break hour counting
2. Chamber stream check - Added _active_chamber_streams check for A1/P1 printers (proactive)
3. Browser freeze - Removed immediate printerStatus invalidation on print_complete

maziggy 4 months ago
parent
commit
fe1d10b705
4 changed files with 9 additions and 7 deletions
  1. 6 2
      backend/app/main.py
  2. 2 4
      frontend/src/hooks/useWebSocket.ts
  3. 0 0
      static/assets/index-3dBx4a1x.js
  4. 1 1
      static/index.html

+ 6 - 2
backend/app/main.py

@@ -1168,7 +1168,7 @@ async def on_print_complete(printer_id: int, data: dict):
         try:
             logger.info(f"[PHOTO-BG] Starting finish photo capture for archive {archive_id}")
 
-            from backend.app.api.routes.camera import _active_streams, get_buffered_frame
+            from backend.app.api.routes.camera import _active_chamber_streams, _active_streams, get_buffered_frame
 
             async with async_session() as db:
                 from backend.app.api.routes.settings import get_setting
@@ -1196,10 +1196,14 @@ async def on_print_complete(printer_id: int, data: dict):
                             photo_filename = None
 
                             # Check if camera stream is active - use buffered frame to avoid freeze
+                            # Check both RTSP streams (_active_streams) and chamber image streams (_active_chamber_streams)
                             active_for_printer = [k for k in _active_streams if k.startswith(f"{printer_id}-")]
+                            active_chamber_for_printer = [
+                                k for k in _active_chamber_streams if k.startswith(f"{printer_id}-")
+                            ]
                             buffered_frame = get_buffered_frame(printer_id)
 
-                            if active_for_printer and buffered_frame:
+                            if (active_for_printer or active_chamber_for_printer) and buffered_frame:
                                 # Use frame from active stream
                                 logger.info("[PHOTO-BG] Using buffered frame from active stream")
                                 photos_dir = archive_dir / "photos"

+ 2 - 4
frontend/src/hooks/useWebSocket.ts

@@ -196,10 +196,8 @@ export function useWebSocket() {
         break;
 
       case 'print_complete':
-        // Refetch printer status when print completes to clear printable_objects_count
-        if (message.printer_id !== undefined) {
-          queryClient.invalidateQueries({ queryKey: ['printerStatus', message.printer_id] });
-        }
+        // Don't invalidate printerStatus here - it causes re-render cascade and browser freeze
+        // The printer_status websocket messages will naturally update the status
         debouncedInvalidate('archives');
         debouncedInvalidate('archiveStats');
         break;

File diff suppressed because it is too large
+ 0 - 0
static/assets/index-3dBx4a1x.js


+ 1 - 1
static/index.html

@@ -23,7 +23,7 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-CCnKMi2S.js"></script>
+    <script type="module" crossorigin src="/assets/index-3dBx4a1x.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-CrUIX1oi.css">
   </head>
   <body>

Some files were not shown because too many files changed in this diff