not marking seen when push to pending

This commit is contained in:
Yanxin Lu
2026-02-26 20:59:55 -08:00
parent b14a93866e
commit 1e3faa0b20

View File

@@ -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")