fix: suppress stale process watch notifications - #32242
Conversation
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the focused regression coverage. The stale-watch-event premise is still present on current main, but this patch needs updating for current delivery semantics.
Problems
tools/process_registry.py:890must preserve main's completion-specific_drain_should_skip()path attools/process_registry.py:1184; it carries the_poll_observedCLI dedup contract documented attools/process_registry.py:1138-1149and covered bytests/tools/test_notify_on_complete.py:381-405.- The TUI poller bypasses
drain_notifications()and only suppresses consumedcompletionevents attui_gateway/server.py:8745and:8810. Gateway watch delivery also takes all watch events atgateway/run.py:2569-2570before injecting them atgateway/run.py:11873-11879. Those paths need the same consumed-session guard. - The new kill test assigns
_is_host_pid_aliveattests/tools/test_process_registry.py:1040, but current main uses_host_pid_is_ours()attools/process_registry.py:1485, so it does not control the current detached-host branch.
Suggested changes
- Keep
_drain_should_skip()for completions, add a separate watch-event consumed guard, update the TUI/gateway consumers, and test each path. - Rework the kill test around a mocked local
session.processand_terminate_host_pid.
This is an automated hermes-sweeper review.
| break | ||
| _evt_sid = evt.get("session_id", "") | ||
| if evt.get("type") == "completion" and self.is_completion_consumed(_evt_sid): | ||
| if _evt_sid and self.is_completion_consumed(_evt_sid): |
There was a problem hiding this comment.
Current main uses _drain_should_skip() for completion events so _poll_observed still suppresses the CLI's duplicate post-poll completion. Preserve that completion branch and add a separate consumed-session check for watch events instead of replacing it with is_completion_consumed() for every event.
| s.pid_scope = "host" | ||
| s.pid = 12345 | ||
| registry._running[s.id] = s | ||
| registry._is_host_pid_alive = MagicMock(return_value=True) |
There was a problem hiding this comment.
This does not control current main's detached-host kill path: kill_process() calls _host_pid_is_ours() before _terminate_host_pid. Use a mocked local session.process plus _terminate_host_pid, or mock the current identity-check seam, so the test reliably exercises the killed path.
|
Independent confirmation from a current CLI maintenance run: stale completions from superseded watchers arrived after later authoritative results. This queue-consumption fix complements #41903, which removes process completion notices from synthetic user input. Suggested integration regression: consume or kill an older watched session, complete a newer session, drain notifications, and assert the old session emits neither a user-input message nor terminal output while the current completion is displayed once. |
Summary
Test Plan