From 1e3faa0b2096e07b9fd5f02f5c2ebb035ee1992a Mon Sep 17 00:00:00 2001 From: Yanxin Lu Date: Thu, 26 Feb 2026 20:59:55 -0800 Subject: [PATCH] not marking seen when push to pending --- scripts/email_processor/main.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/scripts/email_processor/main.py b/scripts/email_processor/main.py index 2d9aa23..8a547bd 100644 --- a/scripts/email_processor/main.py +++ b/scripts/email_processor/main.py @@ -329,9 +329,21 @@ def cmd_scan(config, recent=None, dry_run=False): auto_acted = 0 queued = 0 + skipped = 0 + + # Load pending queue once to skip already-queued emails + pending = load_pending() + pending_eids = {v.get("envelope_id") for v in pending.values() if v.get("status") == "pending"} for envelope in envelopes: eid = envelope.get("id", "?") + + # Skip emails already in the pending queue + if str(eid) in pending_eids: + print(f"[{eid}] (already pending, skipped)") + skipped += 1 + continue + print(f"[{eid}] ", end="", flush=True) # Read message body without marking as seen @@ -382,12 +394,6 @@ def cmd_scan(config, recent=None, dry_run=False): else: # Not enough confidence or history — queue for manual review add_to_pending(email_data, summary, reason, action, confidence) - # Mark as read to prevent re-processing on next scan - if not dry_run: - try: - _himalaya("flag", "add", str(eid), "seen") - except subprocess.CalledProcessError: - pass log_result(log_file, email_data, f"QUEUED:{action}@{confidence}%", reason, duration) print(f" -> Queued (confidence {confidence}% < {confidence_threshold}%)") queued += 1 @@ -397,6 +403,8 @@ def cmd_scan(config, recent=None, dry_run=False): print(f"Processed: {len(envelopes)} emails") print(f" Auto-acted: {auto_acted}") print(f" Queued for review: {queued}") + if skipped: + print(f" Skipped (already pending): {skipped}") print(f"\nRun 'python main.py review list' to see pending emails")