mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 01:57:41 +02:00
fix: persist plate-clear gate so Auto Off power cycles can't bypass the queue confirmation (#961)
With Auto Off enabled and another job queued, the smart plug cut power when a
print finished and immediately re-powered the printer because the scheduler
saw pending items. The printer booted fresh into IDLE and the next job
auto-dispatched, bypassing the "Clear Plate & Start Next" confirmation.
Root cause: the plate-clear gate lived only in PrinterManager._plate_cleared
(in-memory set) and _is_printer_idle treated IDLE as unconditionally idle. On
power cycle the in-memory flag was lost and the IDLE-on-boot state skipped
the gate entirely.
Fix:
- Replace the in-memory flag with an awaiting_plate_clear column on the
printers table, rehydrated into the PrinterManager at startup.
- Set the flag in on_print_complete for completed/failed prints (not user
cancellations); clear it on ack and on scheduler dispatch.
- _is_printer_idle now short-circuits to not-idle whenever require_plate_clear
is on and the flag is set, regardless of the currently reported state —
so the gate holds through power cycles, Bambuddy restarts, and the printer
booting back into IDLE.
- /printers/{id}/clear-plate no longer requires the printer to report
FINISH/FAILED; it accepts the ack whenever the flag is raised.
- Frontend widgets (PrinterQueueWidget, Layout, BulkPrinterToolbar) gate on
the flag rather than reported state.
Tests: added regression tests for IDLE+awaiting=True (the #961 case) and
full DB round-trip tests for the persistence layer.
This commit is contained in:
@@ -283,8 +283,9 @@ export interface PrinterStatus {
|
||||
firmware_version: string | null; // Firmware version from MQTT
|
||||
// Developer LAN mode: true = enabled, false = disabled, null = unknown
|
||||
developer_mode: boolean | null;
|
||||
// Queue: user has acknowledged plate is cleared for next queued print
|
||||
plate_cleared: boolean;
|
||||
// Queue: printer is awaiting user ack that the build plate was cleared after a
|
||||
// finished/failed print. Persisted across restarts (#961).
|
||||
awaiting_plate_clear: boolean;
|
||||
// AMS drying support
|
||||
supports_drying: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user