test(tui): cover WSTransport write paths, peer label, and handle_ws lifecycle (#36617) - #39393
Open
rodboev wants to merge 4 commits into
Open
test(tui): cover WSTransport write paths, peer label, and handle_ws lifecycle (#36617)#39393rodboev wants to merge 4 commits into
rodboev wants to merge 4 commits into
Conversation
2 tasks
rodboev
force-pushed
the
pr/test-slash-worker
branch
from
June 28, 2026 17:56
5567bbf to
a72d89e
Compare
rodboev
force-pushed
the
pr/test-slash-worker
branch
from
July 7, 2026 04:30
a72d89e to
d29b3c4
Compare
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for adding focused WebSocket coverage. This needs a current-main refresh before it can be salvaged.
Problems
tests/tui_gateway/test_ws.py:116patches onlytui_gateway.ws.server, while currenthandle_wsdirectly imports and invokesstart_background_mcp_discoveryattui_gateway/ws.py:312-317. These tests would mutate the shared MCP-startup guard (hermes_cli/mcp_startup.py:31-50) and can start real background discovery.- Current
WSTransportnow coalesces streaming frames and sends via_safe_send_many(tui_gateway/ws.py:97-104,125-159,193-207). The proposed tests cover the earlier simple write paths but not batching, ordering, batch-send failure, or flush cancellation.
Suggested changes
- Add a shared patch for
hermes_cli.mcp_startup.start_background_mcp_discovery, modeled ontests/test_tui_gateway_ws.py:10-42. - Extend coverage for the current coalescing and teardown contracts; existing lifecycle coverage is in
tests/test_tui_gateway_ws.py:90-164.
Automated hermes-sweeper review.
rodboev
force-pushed
the
pr/test-slash-worker
branch
from
July 14, 2026 02:48
d29b3c4 to
b410224
Compare
19 tasks
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.
Fixes #36617
Summary
Current
mainalready covers MCP startup, disconnect teardown, and stalled-loop recovery fortui_gateway/ws.py, so the older branch description was no longer accurate. The remaining gap was the coalesced transport path: buffered streaming frames,_safe_send_many, batch-send failure, and close-time timer cancellation. The branch also patched onlyserver, even thoughhandle_wsdirectly imports and callsstart_background_mcp_discovery.This refresh rebuilds the PR on current
main, consolidates the surviving coverage intotests/test_tui_gateway_ws.py, applies one shared MCP-startup patch across everyhandle_wscase, and adds assertions that distinguish the buffered_safe_send_manypath from the old direct-send transport.Changes
tests/test_tui_gateway_ws.py(+248/-41): add shared MCP-startup patching, prove buffered_safe_send_manybatching, cover batch-send failure and timer cancellation, and keep the current-mainhandle_wslifecycle cases in one module.tests/tui_gateway/test_ws.py(-225): remove the duplicate older module after its surviving cases were consolidated into the current-main test file.Validation
_safe_send_manybatch before the control frame_safe_send_manyfailure mid-batchclose()with an armed token flush timerhandle_wsstartup side effect in test casesserverwas patched in the added caseshandle_wscase runs under the sharedstart_background_mcp_discoverypatchTest plan
pytest tests/test_tui_gateway_ws.py -v— 18 passedruff check tests/test_tui_gateway_ws.py— passed