fix(state): deserialize display_metadata in get_messages and get_messages_around - #70829
DavidMetcalfe wants to merge 1 commit into
Conversation
eac668a to
7fa7c4e
Compare
7fa7c4e to
ff9d278
Compare
|
The fix covers both public retrieval paths, but the diff currently has no regression test exercising either one. Existing |
ff9d278 to
34c5897
Compare
…ages_around Commit a4bc1ca added display_metadata as a new messages column and properly deserialized it in _rows_to_conversation(), but missed adding json.loads() to get_messages() and get_messages_around(). Both use SELECT * which now returns the raw JSON string. When the Desktop frontend renders a message with display_kind='async_delegation_complete', chat-messages.ts:321 does 'task_count' in message.display_metadata. Since display_metadata was a JSON string (not a parsed dict), the 'in' operator threw TypeError ('Cannot use in operator to search for task_count in {...}'), causing a 'Resume failed' popup when resuming sessions containing delegation completion events.
34c5897 to
a7364f9
Compare
|
@isak-ialogics Thanks for the review! Added regression tests for both Test suite: 416 passed ( |
|
Thanks for the focused report and regression tests. Automated hermes-sweeper review found that current
The requested behavioral guarantee is therefore already implemented on main. |
What
get_messages()andget_messages_around()inhermes_state.pyuseSELECT *but don't deserialize thedisplay_metadatacolumn (added in #69771) from JSON. The frontend receives a raw JSON string, and the'task_count' in message.display_metadataexpression inchat-messages.tsthrowsTypeErrorbecause JavaScript'sinoperator requires an object, not a primitive.How to reproduce
async_delegation_completedisplay event (any session that useddelegate_task)GET /api/sessions/{id}/messagesCannot use 'in' operator to search for 'task_count' in {"delegation_id":...}Fix
Add
json.loads()fordisplay_metadatain bothget_messages()andget_messages_around(), matching the existing pattern fortool_callsand the pattern already in_rows_to_conversation().Testing
tests/test_hermes_state.py: 413 passedtests/hermes_cli/test_web_server.py -k session: 49 passedCloses #70835