fix(scheduler): treat /api/email/unread-state as passive UI poll - #6009
Draft
michaelxer wants to merge 1 commit into
Draft
fix(scheduler): treat /api/email/unread-state as passive UI poll#6009michaelxer wants to merge 1 commit into
michaelxer wants to merge 1 commit into
Conversation
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 odysseus-dev#5981
michaelxer
force-pushed
the
michaelxer/fix-email-unread-state-passive-5981-20260812
branch
from
August 12, 2026 17:48
8218ad9 to
8be5784
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With the web UI open, scheduled/background agent runs were being aborted within about a minute and logged as
Stopped by user, even though no real user interaction happened. The idle pollGET /api/email/unread-statewas treated as foreground activity by_InteractiveActivityMiddleware, which callsstop_background_tasks_for_foreground(). Its siblingGET /api/email/urgency-statewas already on the passive exact-path list; unread-state was missing.This PR adds
/api/email/unread-stateto_PASSIVE_EXACT_PATHSinsrc/interactive_gate.pyso the UI timer poll no longer pre-empts background work, and adds focused regression tests for the passive/interactive path classification.Target branch
dev, notmain.Linked Issue
Fixes #5981
Type of Change
What changed
src/interactive_gate.py: add/api/email/unread-statenext to/api/email/urgency-statein_PASSIVE_EXACT_PATHS.tests/test_interactive_gate_passive_paths.py: assert unread-state and urgency-state are passive; real interactive paths still track; OPTIONS still untracked.No change to the foreground-gate design itself — only the passive allowlist for idle email polls.
How to Test
python -m pytest tests/test_interactive_gate_passive_paths.py -q # 3 passed python -m py_compile src/interactive_gate.py tests/test_interactive_gate_passive_paths.pyManual (with web UI open):
/api/email/unread-state.Stopped by userfromforeground request GET /api/email/unread-state.Checklist
dev.should_track_interactive_request()and a live scheduled run.Visual / UI changes
None — backend gate classification only.
Limitations / notes
Stopped by user) is intentionally out of scope here so the PR stays one-line + tests.