fix(gateway): honor background_process_notifications=off for watch reinjection - #9341
fix(gateway): honor background_process_notifications=off for watch reinjection#9341Lidang-Jiang wants to merge 1 commit into
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression fix. The notification-off behavior is still missing on current main: gateway/run.py:11753-11758 drains watch events and reinjects every formatted event without checking the mode.
Problems
- The submitted helper passes
original_eventto_inject_watch_notification(PR diffgateway/run.py:7179). Current main changed that method to consume the queued event dictionary (gateway/run.py:15309) so routing comes from the process origin. The existing regression attests/gateway/test_background_process_notifications.py:450-481verifies that foreground-event routing must not be used.
Suggested changes
- Port the
offgate into the current drain atgateway/run.py:11753, while retaining_drain_gateway_watch_events()for all modes and passingevtto_inject_watch_notificationfor non-offmodes. - Update the test fixture to use the current queued-event routing contract and cover both queue draining under
offand retained injection underall.
Automated hermes-sweeper review.
| if notify_mode == "off": | ||
| continue | ||
| synth_text = _format_gateway_process_notification(evt) | ||
| if synth_text: |
There was a problem hiding this comment.
Current main's _inject_watch_notification now expects the queued event dictionary so it can route to the process origin (gateway/run.py:15309); preserve evt here rather than passing the foreground event. The current regression at tests/gateway/test_background_process_notifications.py:450 protects against cross-thread foreground routing.
There was a problem hiding this comment.
Addressed in a220f04. I rebuilt the branch on current main, retained _drain_gateway_watch_events() for every notification mode, skipped synthetic reinjection only when the mode is off, and now pass the queued evt to _inject_watch_notification() so routing continues to use the originating process context. The updated tests cover queue draining under off, retained injection under all, origin routing, and async-delegation retention.
a678bd6 to
8e41a6a
Compare
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
8e41a6a to
a220f04
Compare
|
Thanks @Lidang-Jiang — your fix landed in PR #85923 (rebase-merged, your commit and authorship preserved via cherry-pick). The off-mode gate now covers the post-turn watch drain exactly as you wrote it, rebased onto the current drain site. Closing this original; #9290 is fixed by your work. |
What does this PR do?
Makes
display.background_process_notifications: offdisable watch-pattern synthetic reinjection while still draining queued watch events. Non-offmodes continue to inject notifications using the queued event's originating thread/user context, andasync_delegationevents remain available to their dedicated watcher.Related Issue
Fixes #9290
Type of Change
Changes Made
offevtto_inject_watch_notification()in other modes so delivery preserves the originating process contextasync_delegationevents for the dedicated async-delegation watcheroff,all, origin routing, queue draining, and delegation retentionHow to Test
python -m pytest -q \ tests/gateway/test_background_process_notifications.py \ tests/tools/test_watch_patterns.py \ tests/scripts/test_release_acp_registry.py ruff check . python scripts/check-windows-footguns.py --allChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Before/After
Before
On the pre-fix implementation, the complete queue-drain harness output was:
Even with notifications set to
off, queued watch events were synthetically reinjected.After
With this commit, the same complete harness output is:
Complete focused regression-suite output:
Additional Verification
scripts/run_tests.sh -j 16: 40,267 tests passed. Fifteen unrelated failures and three process-exit timeouts remained; the recurring functional failures were reproduced on the unmodifiedupstream/mainbaseline, and the one branch-only file-state failure passed on an isolated rerun.ruff check .: passed (apart from the repository's pre-existing invalid-noqawarnings).git diff --check: passed.python scripts/check-windows-footguns.py --all: passed across 757 Python files.