Skip to content

Stabilize WeCom channel state and session isolation#184

Open
Atlas-SZ wants to merge 1 commit intodataelement:mainfrom
Atlas-SZ:fix/wecom-channel-state-182
Open

Stabilize WeCom channel state and session isolation#184
Atlas-SZ wants to merge 1 commit intodataelement:mainfrom
Atlas-SZ:fix/wecom-channel-state-182

Conversation

@Atlas-SZ
Copy link
Copy Markdown
Contributor

@Atlas-SZ Atlas-SZ commented Mar 24, 2026

WeCom channel configuration was executing correctly server-side, but the UI could misreport connection health and silently fail after disconnect because it tried to parse a 204 response as JSON. The stream path also treated official WeCom AI Bot payloads as if they used legacy field names, which let group messages fall into p2p sessions. This change makes runtime connection state authoritative, separates group and p2p session keys correctly, and adds explicit UI feedback for save and disconnect actions.

Constraint: WeCom AI Bot traffic arrives through the official SDK fields from_userid, chattype, and chatid
Constraint: Local macOS system proxy settings must not break the WeCom websocket client
Rejected: Adding python-socks as a local dependency | unnecessary once the SDK path is forced to proxy=None
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Do not treat websocket mode as connected in the UI without consulting the backend is_connected flag
Tested: backend/.venv/bin/python -m ruff check backend/app/api/wecom.py backend/app/services/wecom_stream.py backend/tests/test_wecom_channel_api.py backend/tests/test_wecom_stream.py
Tested: backend/.venv/bin/python -m pytest backend/tests/test_wecom_stream.py backend/tests/test_wecom_channel_api.py
Tested: cd frontend && npm run build
Tested: Real WeCom websocket connect and disconnect with local runtime config
Not-tested: End-to-end live single-chat and group-chat message exchange against the running bot
Related: #182

Summary

Checklist

  • Tested locally
  • No unrelated changes included

@wisdomqin wisdomqin requested a review from yaojin3616 March 26, 2026 14:04
Rebuild the WeCom runtime fix on top of the current mainline so the
channel-state and session-isolation changes can merge independently.
This keeps the scope to runtime connection status, disconnect handling,
official SDK payload parsing, group-vs-p2p session keys, and the
minimal UI feedback needed for save and disconnect actions.

Constraint: WeCom AI Bot traffic uses official SDK fields like from_userid, chattype, and chatid
Constraint: The fix must stand alone on upstream/main without pulling in org-sync or password-reset work
Rejected: Reuse the old PR branch history directly | earlier iterations mixed in unrelated changes and made scope review harder
Rejected: Add a proxy dependency for the websocket path | forcing proxy=None is sufficient for the local SDK path
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep channel runtime behavior and ChannelConfig feedback changes together; splitting them will reintroduce silent disconnect failures
Tested: cd backend && .venv/bin/python -m pytest tests/test_wecom_stream.py tests/test_wecom_channel_api.py
Tested: cd backend && .venv/bin/python -m ruff check app/api/wecom.py app/services/wecom_stream.py tests/test_wecom_channel_api.py tests/test_wecom_stream.py
Tested: cd frontend && npm run build
Not-tested: End-to-end live single-chat and group-chat exchanges against a running WeCom bot
@Atlas-SZ Atlas-SZ force-pushed the fix/wecom-channel-state-182 branch from 7172f8e to ef076f1 Compare March 27, 2026 02:19
@Atlas-SZ
Copy link
Copy Markdown
Contributor Author

This PR has been rebuilt cleanly on top of upstream/main.

It now contains only the WeCom runtime/session fix:

  • runtime websocket status reporting
  • safe disconnect handling for 204 responses
  • official WeCom SDK payload parsing
  • correct group vs p2p session isolation
  • minimal ChannelConfig feedback/status updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant