From 9ae25f4c6e36113a7484a3b66c44457a1ffa46e1 Mon Sep 17 00:00:00 2001 From: maziggy Date: Mon, 12 Jan 2026 09:52:49 +0100 Subject: [PATCH] - 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) --- backend/app/main.py | 3 ++- backend/app/services/printer_manager.py | 2 ++ frontend/public/sw.js | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index 733e9d8ef..f866c6c99 100644 --- a/backend/app/main.py +++ b/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 diff --git a/backend/app/services/printer_manager.py b/backend/app/services/printer_manager.py index 488d0abc9..018738bb9 100644 --- a/backend/app/services/printer_manager.py +++ b/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 diff --git a/frontend/public/sw.js b/frontend/public/sw.js index 8566e9730..674403521 100644 --- a/frontend/public/sw.js +++ b/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 = [