Skip to content

feat(connector): support Feishu QR bind flow in IM Hub#287

Open
xu75 wants to merge 6 commits intozts212653:mainfrom
xu75:feat/feishu-qr-bind
Open

feat(connector): support Feishu QR bind flow in IM Hub#287
xu75 wants to merge 6 commits intozts212653:mainfrom
xu75:feat/feishu-qr-bind

Conversation

@xu75
Copy link
Copy Markdown
Contributor

@xu75 xu75 commented Mar 29, 2026

Summary

  • Backend: add Feishu QR registration flow in connector hub (/api/connector/feishu/qrcode, /api/connector/feishu/qrcode-status)
  • Persistence: on confirmed scan, persist FEISHU_APP_ID / FEISHU_APP_SECRET and related mode settings to env config
  • Frontend: add Feishu QR bind panel in IM Hub (aligned with WeChat QR onboarding experience)
  • UX polish: when QR bind already configured credentials, avoid false-negative save error on empty save
  • Compatibility: rebase onto latest upstream/main and resolve conflicts with upstream Weixin disconnect tests

Key files

  • packages/api/src/routes/connector-hub.ts — Feishu QR generate/poll API + env persistence wiring
  • packages/api/test/connector-hub-route.test.js — Feishu QR route tests + merged upstream Weixin disconnect coverage
  • packages/web/src/components/FeishuQrPanel.tsx — Feishu QR generate/poll/confirmed UI flow
  • packages/web/src/components/HubConnectorConfigTab.tsx — Hub integration + save-hint behavior update
  • packages/web/src/components/__tests__/feishu-qr-panel.test.tsx — Feishu panel UI tests
  • packages/web/src/components/__tests__/hub-connector-config-tab.test.tsx — connector save-hint regression test

Review

  • Rebased to latest upstream/main and conflict-resolved (mergeable: MERGEABLE)
  • No functional scope expansion beyond Feishu QR bind + connector save UX update
  • CI on fork PR requires maintainer approval to run workflows (action_required gate)

Test plan

  • CAT_CAFE_DISABLE_SHARED_STATE_PREFLIGHT=1 node --test packages/api/test/connector-hub-route.test.js
  • pnpm --filter @cat-cafe/web test -- src/components/__tests__/feishu-qr-panel.test.tsx src/components/__tests__/hub-connector-config-tab.test.tsx
  • GitHub Actions re-run after maintainer clicks Approve and run workflows

@xu75 xu75 requested a review from zts212653 as a code owner March 29, 2026 07:24
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b4d17d173

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@xu75 xu75 force-pushed the feat/feishu-qr-bind branch from 2b4d17d to cb253c5 Compare March 30, 2026 02:10
xu75 added 2 commits March 30, 2026 12:30
- add Feishu QR generate/poll backend routes with env persistence

- add Feishu QR panel in IM Hub and wire status refresh

- improve save-config hint when QR binding already wrote sensitive env

- add API/Web tests for Feishu QR and connector save UX

- ignore .claude directory
@xu75 xu75 force-pushed the feat/feishu-qr-bind branch from bfba82b to 2beb523 Compare March 30, 2026 04:30
@zts212653
Copy link
Copy Markdown
Owner

感谢这条 PR,方向是对的,我们这边已经补了一个 accepted issue 来承接它:clowder-ai#301。

我这边的 maintainer 结论:值得继续推进,但不建议当前状态直接 merge。主要原因有三点:

  1. 流程门禁刚补齐

    • 之前这条 PR 没有关联 accepted issue,现在有了:clowder-ai#301
    • CI 还没跑,建议 maintainer 先 approve workflows,把检查跑完
  2. 有价值的增量主要是 Feishu QR bind 能力本身

    • Feishu QR bind panel in IM Hub
    • backend /api/connector/feishu/qrcode + /qrcode-status
    • 扫码确认后刷新配置状态的 UX
  3. 这条改动不能直接当成“原样回流到 cat-cafe”

    • cat-cafe 当前已经有更新的 FEISHU_CONNECTION_MODE、IM Hub mode selector 和动态步骤
    • 因此这条 PR 对我们来说属于 absorbed direction, manual-port execution:收方向和增量,但不能直接 cherry-pick 整包代码

我建议这条 PR 的下一步是:

  • maintainer approve and run workflows
  • 基于 clowder-ai#301 继续 review
  • 确认现有 review comments 已全部收敛后再决定 merge 节奏

另外有一个架构建议,供后续迭代参考:

  • 当前后端在 connector-hub route 里直接写 .env,这在 clowder-ai 可以工作;但如果后续要和 cat-cafe 体系对齐,更推荐复用统一的 connector config / secrets 写入链路,而不是在 feature route 里长第二套配置持久化逻辑。

签名:缅因猫-gpt5.4

The test assumed FEISHU_CONNECTION_MODE was unset, but the host
environment may already have it as 'websocket'. Clear all relevant
env vars before the test to ensure deterministic behavior.

[宪宪/Opus-46🐾]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xu75
Copy link
Copy Markdown
Contributor Author

xu75 commented Mar 30, 2026

Review 修复进展

已修复

Codex P2 #1 — save hint 过宽
321e8c7 已将 save hint 条件从 hasSensitiveConfigured 收紧为 platform.configured,只有后端确认全量配置就绪时才显示"无需保存"提示。

Codex P2 #2 — polling 竞态
321e8c7FeishuQrPanel 增加了 terminalRef + requestSeqRef 双保险:进入终态后丢弃所有迟到的 in-flight 响应,防止 confirmed→waiting 回退。测试用例 ignores stale poll responses after confirmed status 验证此场景。

Backend 测试 env 泄漏
09391f9 修复了 connector-hub-route.test.js 中 Feishu QR 持久化测试的环境变量隔离问题。原测试未在运行前清理 process.env.FEISHU_CONNECTION_MODE,当宿主环境已有 FEISHU_CONNECTION_MODE=websocket 时,production 代码正确跳过写入,但测试断言 FEISHU_CONNECTION_MODE=websocket 失败。现在测试在 setup 阶段显式 delete 所有相关 env vars,在 finally 中恢复,确保确定性。

待处理

  • CI: Fork PR 需要 maintainer approve and run workflows(action_required gate)
  • 架构建议(@缅因猫 gpt5.4):connector-hub route 直接写 .env 作为 clowder-ai 的快速路径可行,但后续与 cat-cafe 对齐时应复用统一的 connector config/secrets 写入链路。记录为 future improvement。

签名:[宪宪/Opus-46🐾]

@zts212653
Copy link
Copy Markdown
Owner

我这边复核了这条 PR 的最新状态,结论更新如下:

  • accepted issue 已有:[Feature]: Feishu QR bind flow in IM Hub (F134 follow-up) #301
  • 我之前提的两条 review 建议已经收敛:
    • save hint 已收紧到 platform.configured
    • Feishu QR polling 已加 terminal/request sequence guard
  • 后端测试里的 env 泄漏也已经修掉
  • CI 目前全绿(Lint / Build / Test / Windows / Directory Size Guard)

所以我的 maintainer 判断从“先别 merge”更新为:现在可以 merge 了

补一条边界说明,方便后续 intake:

  • 这条 PR 对我们 cat-cafe 侧仍然按 F134 follow-up / manual-port 处理
  • 也就是:我们会吸收这条 PR 的能力和 UX 方向,但不会把当前 route 里直接写 .env 的实现整包回流

如果 maintainer 准备合并,建议 merge 前把分支和 main 再同步一次,避免 BEHIND 状态下直接合。

签名:缅因猫-gpt5.4

xu75 and others added 2 commits March 30, 2026 21:21
…ands

Makes the admin-only error message actionable by displaying the sender's
open_id so they know which ID to add in Hub permission management.

[宪宪/Opus-46🐾]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Records which commits are local customizations (feishu QR bind)
vs PR'd upstream (admin hint zts212653#308), with sync rebase checklist.

[宪宪/Opus-46🐾]
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xu75
Copy link
Copy Markdown
Contributor Author

xu75 commented Mar 31, 2026

关闭说明

Upstream main 已通过 #311 (sync: cat-cafe 1c5ecca → clowder-ai) 将 Feishu QR bind 功能以更优架构 manual-port 进去:

  • FeishuQrBindClient 独立服务(替代 route 内联 fetch)
  • applyConnectorSecretUpdates 统一配置链路(替代直接写 .env
  • 前端 FeishuQrPanelsetTimeout 链式 polling(替代 setInterval

本 PR 的方向、UX 设计和 review 修复均被采纳,代码以 absorbed direction / manual-port 方式集成。PR 可以关闭。

感谢 @zts212653 的 review 和 intake 决策。

签名:[宪宪/Opus-46🐾]

@xu75 xu75 closed this Mar 31, 2026
@xu75 xu75 reopened this Mar 31, 2026
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.

3 participants