瀏覽代碼

- Fixed bug where chamber_light state was not included in WebSocket broadcasts, so the frontend never received updates when the printer's light state actually changed (only the optimistic update would show, which could be overwritten or stay stale)

maziggy 9 月之前
父節點
當前提交
9ae25f4c6e
共有 3 個文件被更改,包括 6 次插入 和 3 次删除
  1. 2 1
      backend/app/main.py
  2. 2 0
      backend/app/services/printer_manager.py
  3. 2 2
      frontend/public/sw.js

+ 2 - 1
backend/app/main.py

@@ -241,7 +241,8 @@ async def on_printer_status_change(printer_id: int, state: PrinterState):
         f"{state.connected}:{state.state}:{state.progress}:{state.layer_num}:"
         f"{nozzle_temp}:{bed_temp}:{nozzle_2_temp}:{chamber_temp}:"
         f"{state.stg_cur}:{bed_target}:{nozzle_target}:"
-        f"{state.cooling_fan_speed}:{state.big_fan1_speed}:{state.big_fan2_speed}"
+        f"{state.cooling_fan_speed}:{state.big_fan1_speed}:{state.big_fan2_speed}:"
+        f"{state.chamber_light}"
     )
     if _last_status_broadcast.get(printer_id) == status_key:
         return  # No change, skip broadcast

+ 2 - 0
backend/app/services/printer_manager.py

@@ -504,6 +504,8 @@ def printer_state_to_dict(state: PrinterState, printer_id: int | None = None) ->
         "big_fan1_speed": state.big_fan1_speed,
         "big_fan2_speed": state.big_fan2_speed,
         "heatbreak_fan_speed": state.heatbreak_fan_speed,
+        # Chamber light state
+        "chamber_light": state.chamber_light,
     }
     # Add cover URL if there's an active print and printer_id is provided
     # Include PAUSE/PAUSED states so skip objects modal can show cover

+ 2 - 2
frontend/public/sw.js

@@ -1,6 +1,6 @@
 // Bambuddy Service Worker
-const CACHE_NAME = 'bambuddy-v22';
-const STATIC_CACHE = 'bambuddy-static-v22';
+const CACHE_NAME = 'bambuddy-v23';
+const STATIC_CACHE = 'bambuddy-static-v23';
 
 // Static assets to cache on install
 const STATIC_ASSETS = [