not marking seen when push to pending
This commit is contained in:
@@ -329,9 +329,21 @@ def cmd_scan(config, recent=None, dry_run=False):
|
|||||||
|
|
||||||
auto_acted = 0
|
auto_acted = 0
|
||||||
queued = 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:
|
for envelope in envelopes:
|
||||||
eid = envelope.get("id", "?")
|
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)
|
print(f"[{eid}] ", end="", flush=True)
|
||||||
|
|
||||||
# Read message body without marking as seen
|
# Read message body without marking as seen
|
||||||
@@ -382,12 +394,6 @@ def cmd_scan(config, recent=None, dry_run=False):
|
|||||||
else:
|
else:
|
||||||
# Not enough confidence or history — queue for manual review
|
# Not enough confidence or history — queue for manual review
|
||||||
add_to_pending(email_data, summary, reason, action, confidence)
|
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)
|
log_result(log_file, email_data, f"QUEUED:{action}@{confidence}%", reason, duration)
|
||||||
print(f" -> Queued (confidence {confidence}% < {confidence_threshold}%)")
|
print(f" -> Queued (confidence {confidence}% < {confidence_threshold}%)")
|
||||||
queued += 1
|
queued += 1
|
||||||
@@ -397,6 +403,8 @@ def cmd_scan(config, recent=None, dry_run=False):
|
|||||||
print(f"Processed: {len(envelopes)} emails")
|
print(f"Processed: {len(envelopes)} emails")
|
||||||
print(f" Auto-acted: {auto_acted}")
|
print(f" Auto-acted: {auto_acted}")
|
||||||
print(f" Queued for review: {queued}")
|
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")
|
print(f"\nRun 'python main.py review list' to see pending emails")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user