Skip to content

feat: implement multi-channel Feishu Bot settings UI and WebSocket hot reload#303

Open
skloxo wants to merge 11 commits into
HKUDS:mainfrom
skloxo:contrib/feat-feishu-multi-channel
Open

feat: implement multi-channel Feishu Bot settings UI and WebSocket hot reload#303
skloxo wants to merge 11 commits into
HKUDS:mainfrom
skloxo:contrib/feat-feishu-multi-channel

Conversation

@skloxo

@skloxo skloxo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary (概述)

This PR introduces multi-channel Feishu (Lark) Bot settings UI and implements WebSocket connection isolation with hot-reloading. It also resolves critical event loop conflicts in the Lark SDK when running multiple connections concurrently or reloading.
此 PR 实现了多通道飞书(Lark)机器人的可视化配置与热重载,并通过对 Lark SDK WebSocket 模块的动态属性代理,解决了多连接或热重载时因共享主线程 Uvicorn 事件循环引发的 RuntimeError 和死锁冲突。

Key Changes (主要修改)

  1. Multi-channel Configurations & Visualized UI

    • Implemented a unified backend configuration storage (feishu_channels.json) and CRUD API endpoints (/settings/platforms/feishu/channels).
    • Redesigned the Settings UI with Feishu channels CRUD capability, cards layout, and an easy toggle.
    • 实现了多通道的持久化存储以及 CRUD API 端点;在前端 Settings 页重构了可视化管理卡片和开关。
  2. Event Loop Isolation via Thread-local LoopProxy (Critical Fix)

    • Patched lark_oapi.ws.client.loop using a thread-local proxy class. When Lark SDK accesses the loop, it dynamically routes to the dedicated event loop running in its isolated background Thread.
    • This resolves Uvicorn/uvloop conflicts (RuntimeError: Event loop is already running) when launching or restarting multiple WS connections.
    • 通过对 Lark SDK 全局 WebSocket 模块的 loop 变量注入 LoopProxy 动态代理,将每个飞书机器人的长连接隔离在专属的后台线程与事件循环中,彻底解决了多通道热重载与并发时引发的 RuntimeError。
  3. User-friendly OpenID Reflection Command & UX

    • Allows users to retrieve their Feishu OpenID by sending /myid to the Bot even when they are not whitelisted yet.
    • Dynamically folds/unfolds the "Allowed Users" whitelist inputs based on the public debug mode checkbox, alongside safety warnings.
    • 在未配置白名单时,允许用户通过向 Bot 发送 /myid 反射获取自己的 OpenID,解决初始化配置的死锁;优化了白名单输入框的自动折叠与安全提示横幅。

Verification (验证情况)

  • Backend platform tests (agent/tests/test_platform_base.py) run successfully and coverage passes.
  • Verified in local container that multiple Feishu bots concurrently process commands (/myid, /goal, etc.) stably with instant UI toggling and live reload.
  • 后端平台测试与前端 UI 单元测试均已通过;在容器开发环境中验证通过,多个 Bot 可稳定独立响应飞书指令。

@warren618

Copy link
Copy Markdown
Collaborator

Thanks for the PR — we’ve seen it and will review as soon as we can.

Since this touches settings UI and hot reload behavior, we’ll check the backend/frontend contract, i18n coverage, and whether the first PR keeps the messaging/settings scope clean.

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