test(tui_gateway): accept include_ancestors kwarg in test_session_resume mock#16683
Closed
briandevans wants to merge 1 commit into
Closed
Conversation
…ume mock The session.resume handler in tui_gateway/server.py:1807 was updated in d4dde6b ("fix(tui): restore resumed transcript lineage") to call db.get_messages_as_conversation(target, include_ancestors=True) for the display history, but the inline _DB stub in test_session_resume_returns_ hydrated_messages still defined the method with a single positional arg. That signature mismatch makes the call raise TypeError, which the handler catches and returns as a JSON-RPC error, breaking the test on origin/main: assert 'error' not in {'error': {'code': 5000, 'message': "resume failed: ...get_messages_as_conversation() got an unexpected keyword argument 'include_ancestors'"}, ...} The sibling stub in tests/test_tui_gateway_server.py already accepts include_ancestors=False; align this one with the same default. No production change — just unblocks the existing test of the expected hydrated-message shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a failing TUI gateway protocol test by updating an inline DB stub to match the production get_messages_as_conversation(..., include_ancestors=...) call signature used by session.resume.
Changes:
- Update the
_DB.get_messages_as_conversationtest stub to acceptinclude_ancestors=False, aligning with current server behavior and an existing sibling stub.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Apr 28, 2026
Contributor
Author
|
Closing — already fixed on main. The same 1-line stub update ( default) landed via fc7f55f (#17661) on 2026-04-29. The test now passes on |
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
_DBstub intest_session_resume_returns_hydrated_messagesonly declaredget_messages_as_conversation(self, _sid), so whentui_gateway/server.pystarted calling it withinclude_ancestors=True(ind4dde6b5f), the call raisedTypeError, the handler returned a JSON-RPC error, and the test failed on cleanorigin/main.False, matching the sibling stub intests/test_tui_gateway_server.py.The bug
tui_gateway/server.py:1807(added in d4dde6b5f — "fix(tui): restore resumed transcript lineage") calls:But the test stub was still:
The handler wraps the body in
try: ... except Exception as e: return _err(rid, 5000, f\"resume failed: {e}\"), which absorbed theTypeErrorand returned a JSON-RPC error envelope:So the test fails on
origin/main(ef41d3bd4) for everyone.The fix
Add
include_ancestors=Falseto the stub. The two production calls (db.get_messages_as_conversation(target)for the agent-inithistory, anddb.get_messages_as_conversation(target, include_ancestors=True)for the display payload) both return the same canned list under the stub, which is exactly what the existing assertions expect —message_count == 3and the three filtered hydrated messages. No production change.The sibling stub in tests/test_tui_gateway_server.py:101 already uses the
include_ancestors=Falsedefault — this just brings the protocol-level test stub in line.Test plan
origin/main(ef41d3bd4):tests/tui_gateway/test_protocol.pyruns 40 passed (full file, including the previously failing test).TypeError-driven JSON-RPC error; popped the stash → green again.Related
include_ancestors=Truecall without updating this stub.tests/test_tui_gateway_server.py:101already had the matching signature, so this just aligns the second mock.