fix(scheduler): treat /api/email/unread-state as passive UI poll (#6009)

Background scheduled agent runs were aborted as "Stopped by user" when
the web UI was merely open, because the idle /api/email/unread-state
poll was counted as foreground activity while its sibling
/api/email/urgency-state was already excluded.

Fixes #5981

Co-authored-by: michaelxer <michaelxer@users.noreply.github.com>
This commit is contained in:
Michael
2026-08-14 10:22:27 +01:00
committed by GitHub
co-authored by michaelxer
parent c4369305f0
commit a6bc86e331
2 changed files with 21 additions and 0 deletions
+2
View File
@@ -65,6 +65,8 @@ _PASSIVE_EXACT_PATHS = {
"/api/tasks/notifications", "/api/tasks/notifications",
"/api/research/active", "/api/research/active",
"/api/email/urgency-state", "/api/email/urgency-state",
# UI idle poll sibling of urgency-state; must not pre-empt background tasks.
"/api/email/unread-state",
} }
_PASSIVE_PREFIXES = ( _PASSIVE_PREFIXES = (
@@ -0,0 +1,19 @@
"""Regression for idle UI polls that must not count as foreground activity."""
from src.interactive_gate import should_track_interactive_request
def test_email_unread_state_is_passive_like_urgency_state():
assert should_track_interactive_request("/api/email/urgency-state") is False
assert should_track_interactive_request("/api/email/unread-state") is False
def test_real_interactive_paths_still_tracked():
assert should_track_interactive_request("/api/chat_stream") is True
assert should_track_interactive_request("/api/email/messages") is True
assert should_track_interactive_request("/api/tasks", method="POST") is True
def test_options_never_tracked():
assert should_track_interactive_request("/api/email/unread-state", method="OPTIONS") is False
assert should_track_interactive_request("/api/chat_stream", method="OPTIONS") is False