Skip to content

Refactor text-first chat app adapters to reduce duplicated scaffolding#25

Merged
lsdefine merged 2 commits intolsdefine:mainfrom
ViviqwerAsd:codex/chat-app-adapters-trim
Mar 13, 2026
Merged

Refactor text-first chat app adapters to reduce duplicated scaffolding#25
lsdefine merged 2 commits intolsdefine:mainfrom
ViviqwerAsd:codex/chat-app-adapters-trim

Conversation

@ViviqwerAsd
Copy link
Copy Markdown
Contributor

@ViviqwerAsd ViviqwerAsd commented Mar 13, 2026

Summary

  • extract shared command, restore, reply-cleaning, and agent-run helpers into chatapp_common.py
  • slim down the QQ, WeCom, and DingTalk adapters to thin platform-specific wrappers
  • trim duplicated helper logic from fsapp.py as well, while keeping Feishu behavior unchanged

Why

The previous chat-app integration PR landed the features, but the adapter implementations still repeated a lot of scaffolding: text cleaning, restore handling, command handling, and agent task loops. This follow-up keeps the feature set while making the maintenance footprint smaller and the adapter files easier to review.

Impact

  • qqapp.py goes from 307 lines to 121 lines
  • wecomapp.py goes from 274 lines to 108 lines
  • dingtalkapp.py goes from 317 lines to 140 lines
  • fsapp.py goes from 538 lines to 465 lines
  • current PR diff vs main: 330 insertions and 746 deletions
  • no config keys changed
  • no media behavior changed

Testing

  • python -m py_compile chatapp_common.py qqapp.py wecomapp.py dingtalkapp.py fsapp.py launch.pyw agentmain.py agent_loop.py llmcore.py

@lsdefine lsdefine merged commit 081aa12 into lsdefine:main Mar 13, 2026
shaun0927 added a commit to shaun0927/GenericAgent that referenced this pull request Apr 17, 2026
Closes lsdefine#95.

wechatapp.py was the only adapter under frontends/ without an
allowed_users gate, while every other adapter (tg, fs, qq, dingtalk,
wecom) reads <platform>_allowed_users from mykey.py and rejects
unknown senders.

Mirror the QQ adapter's pattern (introduced in PR lsdefine#25):

  - Read 'wechat_allowed_users' via mykeys, normalize via the same
    'set comprehension that keeps non-empty stripped strings' idiom.
  - Use the existing chatapp_common.public_access() helper so the
    semantics ('empty or ["*"] means public') match the rest of the
    ecosystem; this preserves backward compatibility for existing
    setups that have no wechat_allowed_users key.
  - Drop unauthorized senders with the same '[<Adapter>] unauthorized
    user: <id>' log message convention used by qq/dingtalk.

Add the optional knob to mykey_template.py next to the other
allowed_users entries so users can copy the comment block.
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.

2 participants