From 25226095e487a673fb41de97d4f5228001988e64 Mon Sep 17 00:00:00 2001 From: "jampick@microsoft.com" Date: Sun, 5 Apr 2026 08:11:51 -0700 Subject: [PATCH] =?UTF-8?q?feat:=20add=20'next'=20quiet=20wake=20mode=20?= =?UTF-8?q?=E2=80=94=20print=20oldest=20queued=20item=20only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a third option for quiet_wake_mode: "next" prints only the oldest item in the queue when quiet hours end, leaving remaining items for subsequent poll cycles. Default remains "latest" (no breaking change). Fixes #71 Co-Authored-By: Claude Opus 4.6 (1M context) --- pi/webapp/server.py | 4 ++-- pi/webapp/templates/index.html | 1 + printpulse/app.py | 5 +++-- printpulse/watch.py | 9 ++++++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pi/webapp/server.py b/pi/webapp/server.py index 891d9a9..29e0ff6 100644 --- a/pi/webapp/server.py +++ b/pi/webapp/server.py @@ -552,8 +552,8 @@ def validate_save_input(form) -> tuple[dict | None, list[str]]: errors.append(f"{label} is not a valid time.") quiet_wake_mode = form.get("quiet_wake_mode", "latest") - if quiet_wake_mode not in ("latest", "all"): - errors.append("Quiet wake mode must be 'latest' or 'all'.") + if quiet_wake_mode not in ("latest", "all", "next"): + errors.append("Quiet wake mode must be 'latest', 'all', or 'next'.") quiet_wake_mode = "latest" # --- Auto-update --- diff --git a/pi/webapp/templates/index.html b/pi/webapp/templates/index.html index 01c9951..e5fcdde 100644 --- a/pi/webapp/templates/index.html +++ b/pi/webapp/templates/index.html @@ -311,6 +311,7 @@

[ PRINTPULSE ]

diff --git a/printpulse/app.py b/printpulse/app.py index bc022d9..56f6875 100644 --- a/printpulse/app.py +++ b/printpulse/app.py @@ -142,10 +142,11 @@ def _build_parser() -> argparse.ArgumentParser: ) parser.add_argument( "--quiet-wake-mode", - choices=["latest", "all"], + choices=["latest", "all", "next"], default="latest", help="What to print when quiet hours end: 'latest' prints only the most " - "recent item per source (default), 'all' prints every queued item.", + "recent item per source (default), 'all' prints every queued item, " + "'next' prints only the oldest queued item.", ) # ── Letter mode ── parser.add_argument( diff --git a/printpulse/watch.py b/printpulse/watch.py index 0b7b3ac..dc60ace 100644 --- a/printpulse/watch.py +++ b/printpulse/watch.py @@ -299,14 +299,21 @@ def run_watch_loop(feed_urls: list[str], interval: int, max_prints: int, quiet_queue = _load_quiet_queue() if quiet_queue and not (use_quiet and _is_in_quiet_hours(quiet_start, quiet_end)): live.stop() - _save_quiet_queue([]) # Clear before printing so a crash doesn't re-print if quiet_wake_mode == "latest": + _save_quiet_queue([]) # Clear entire queue total_queued = len(quiet_queue) quiet_queue = _filter_quiet_queue_latest(quiet_queue) skipped = total_queued - len(quiet_queue) msg = (f"Quiet hours ended — printing {len(quiet_queue)} latest item(s)" f" ({skipped} older item(s) discarded).") + elif quiet_wake_mode == "next": + # Print only the oldest item, keep the rest queued + quiet_queue, remaining = quiet_queue[:1], quiet_queue[1:] + _save_quiet_queue(remaining) + msg = (f"Quiet hours ended — printing next item" + f" ({len(remaining)} still queued).") else: + _save_quiet_queue([]) # Clear entire queue msg = f"Quiet hours ended — printing {len(quiet_queue)} saved item(s)." ui.retro_panel("QUIET QUEUE", msg, theme) for i, q_item in enumerate(quiet_queue, 1):