fix(simplex): unwrap resp envelope for inbound, address DMs by name, stop idle reconnect churn - #37045
Merged
Conversation
Do not treat lack of application-level SimpleX events as a stale WebSocket. The websockets client already uses protocol ping/pong for connection liveness, so quiet but healthy connections should not be closed by the health monitor.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
1 |
invalid-argument-type |
1 |
First entries
plugins/platforms/simplex/adapter.py:311: [unresolved-attribute] unresolved-attribute: Attribute `get` is not defined on `None` in union `Unknown | None | dict[Unknown, Unknown]`
plugins/platforms/simplex/adapter.py:308: [invalid-argument-type] invalid-argument-type: Argument to bound method `SimplexAdapter._handle_new_chat_item` is incorrect: Expected `dict[Unknown, Unknown]`, found `Unknown | None | dict[Unknown, Unknown]`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
unresolved-import |
1 |
First entries
tests/gateway/test_simplex_plugin.py:312: [unresolved-import] unresolved-import: Cannot resolve imported module `websockets.client`
Unchanged: 4966 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
15 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.
Summary
SimpleX bidirectional messaging now works: inbound messages reach the agent and replies get delivered.
Salvages @maxcz79's PR #27120 onto current main. Three adapter bugs, confirmed live by a community user (Grieschbrei) whose daemon-event shape log nailed the exact path.
Root cause (inbound): the daemon sends
{"resp": {"type": "newChatItems", "chatItems": [...]}}but the adapter readevent["chatItems"](top-level, always empty), so every inbound item was silently dropped before becoming a gateway message.Changes
plugins/platforms/simplex/adapter.py:_handle_event: unwrap therespenvelope before dispatch, readresp["chatItems"]. Top-level shape still handled for back-compat.@Name) instead of@[id]/@[Name]— the SimpleX CLI treats brackets literally, so@[4]never delivered.chat_id= display name (reply target),user_id/sender_id= numericcontactId(stable auth key)._health_monitor: stop force-reconnecting a quiet-but-healthy WebSocket. The websockets client already sends protocol pings; treating an absence of chat events as "stale" caused needless reconnect churn (the "WS idle for 120s, forcing reconnect" loop the reporter saw).scripts/release.py: AUTHOR_MAP entry for the contributor email (CI gate).Validation
resp.chatItemsshape@[4]— not delivered@DisplayName— delivereduser_id)contactId(unchanged path)tests/gateway/test_simplex_plugin.py28/28 pass.user_id="4"(numeric, auth-safe),chat_id="Grieschbrei"(reply routing), outbound@Grieschbrei hello back, top-level back-compat shape still works.Closes the inbound/outbound/idle-reconnect issues from PR #27120 and #26433. #26433 (@ruangraung) independently found the same nesting + bracket bugs first, credited below.
Contributor authorship preserved via rebase-merge.
Infographic