Skip to content

Fix/feishu report sync hardening - #6489

Closed
linbiqiu wants to merge 111 commits into
QuantumNous:mainfrom
linbiqiu:fix/feishu-report-sync-hardening
Closed

linbiqiu wants to merge 111 commits into
QuantumNous:mainfrom
linbiqiu:fix/feishu-report-sync-hardening

Conversation

@linbiqiu

@linbiqiu linbiqiu commented Jul 27, 2026 •

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • New Features
    • Added Feishu OAuth, batch user initialization, identity binding, token management, organization synchronization, notifications, and usage-report integration.
    • Added organization accounts, agent-owner management, subscription group synchronization, and personal funding-group settings.
    • Added automatic grouping tools with job-title mappings, protected groups, previews, suggestions, and confirmation workflows.
    • Added model quota rules and usage controls for groups, plans, and individual accounts.
    • Added user/model usage statistics, subscription reports, CSV exports, and refreshed administration pages.
  • Bug Fixes
    • Improved permanent subscription handling, quota notifications, group access, and username filtering.
  • Documentation
    • Added API, setup, migration, testing, and deployment guides.

linbiqiu and others added 30 commits April 30, 2026 20:01
… CSV export)

Backend:
- model/usedata.go: add DTOs, GetUserModelStatsByUser, GetUserModelStatsBase, GetUserModelMatrix
- controller/usedata.go: add handlers for by-user, by-model, matrix, CSV export
- router/api-router.go: register /api/data/by-user, /by-model, /matrix, /export routes

Frontend:
- pages/UserModelStats: new stats page with 3 tabs (user view, model view, matrix)
- components/user-model-stats: filters, bars, table, matrix table
- hooks/user-model-stats: useUserModelStats state management hook
- App.jsx: register /console/user-model-stats route
- SiderBar.jsx: add sidebar entry for admins

Docs:
- plans/2026-04-09-user-model-stats.md
- specs/2026-04-30-user-model-stats-implementation-plan.md
- 添加飞书OAuth绑定卡片到个人设置页面(AccountManagement)
- 新增MySubscriptions组件,个人可查看生效的订阅套餐详情
- 修复feishu.enabled checkbox即时保存逻辑确认
- 修复feishu配置字段Semi Design Form绑定问题(点号→下划线映射)
- 修复GetAllActiveUserSubscriptions/HasActiveUserSubscription查询遗漏end_time=0永久订阅
- 修复MySubscriptions前端渲染SubscriptionSummary嵌套结构
- 新增RepairBindGroupSubscriptions启动时自动补齐缺失的bind_group订阅记录
- 新增SyncUserBindGroupSubscriptions用户分组变更时同步订阅
- 新增SyncPlanBindGroupChange套餐bind_group变更时同步用户订阅
- 修复飞书Token交换endpoint从v1升级到v2
- 修复飞书Auth URL域名(accounts.feishu.cn)
- 新增 deploy/Dockerfile.local 本地构建镜像(仅COPY二进制)
- 重写 production-deploy/build.sh 适配fork路径和ACR推送
- 更新 .env.example 镜像地址指向阿里云ACR
- 新增批量初始化用户(POST /feishu/users/batch)
- 新增批量修改用户信息(PUT /feishu/users/batch)
- 新增为用户创建令牌(POST /feishu/tokens)
- 新增批量创建令牌(POST /feishu/tokens/batch)
- 新增查询用户令牌(GET /feishu/tokens,返回完整key不脱敏)
- 分组变更自动同步订阅套餐(SyncUserBindGroupSubscriptions)
- 管理员OAuth绑定支持union_id/open_id优先级
- 接口文档保存至docs/feishu-admin-api.md
- ProviderUserID统一使用open_id, 通过legacy_id(union_id)做存量迁移
- 修复legacy迁移路径调用UpdateGitHubId错误, 改用UpdateFeishuId
- 移除所有将feishu_id迁回union_id的逻辑(导致下次登录查不到)
- 飞书OAuth登录成功后自动同步display_name
- 新增model.User.UpdateFeishuId方法
- 用户视角:按用户汇总(用户/请求次数/总Token/额度消耗)
- 模型视角:按模型汇总(模型/请求次数/额度消耗)
- 用户模型消耗:用户+模型明细(用户/模型/请求次数/额度消耗)
- 移除交叉矩阵相关代码
- 后端新增 /api/data/by-detail 接口
- 导出CSV适配三个视角
- FeishuUserUpdateItem新增user_id和username可选字段
- 查找顺序: feishu_open_id -> user_id -> username
- 当提供open_id且与用户当前feishu_id不同时自动绑定
- add inactive-users export endpoint and classic tab export button

- add user_group filter/columns for 3 stats views

- aggregate stats by user_id to avoid rename split

- switch export download to authenticated blob request

- bump VERSION to 1.1.4
Update subscription usage UI with group/plan dropdown filters and remove cumulative-used display. Align monthly usage to settled records, return usable key for existing Feishu users, and fix inactive-user timestamp/export safety.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Merge latest upstream/main into fork with conflict resolution, dependency sync, and verification fixes so full Go tests and both web builds pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Apply tested relay fixes and dependency lock updates after upstream merge so full test/build verification remains green.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
linbiqiu added 26 commits July 2, 2026 22:30
daily/weekly/monthly 各自只保留最后一次同步的数据,不再累积历史周期标签
daily/weekly/monthly 各自只保留最后一次同步的数据,不再累积历史周期标签
原实现只用手机号/工号/邮箱组合查询一次,导致部分能查到的人员查不到;
现改为飞书ID、工号、手机号、邮箱、姓名逐项独立 fallback 查询,
姓名匹配多人时返回明确错误提示改用唯一标识。
设计文档:按飞书岗位自动分组。核心是新增岗位→分组映射规则表 +
创建/同步时的自动决策逻辑,复用现有 SyncUserBindGroupSubscriptions
实现订阅自动同步。包含一键初始化和受保护分组白名单。
新增「岗位 → 分组」自动映射功能:
- 新建用户(OAuth/批量/管理员创建)时根据飞书 job_title 自动分配分组
- 定时同步飞书用户信息时自动重算分组(支持调岗场景)
- 分组变更自动同步 bind_group 订阅套餐(复用 SyncUserBindGroupSubscriptions)
- 受保护分组白名单机制,白名单内用户不被规则覆盖
- 一键初始化:基于现有用户众数生成映射规则,排除空岗位和白名单用户
- 后端:model/group_mapping.go + service/auto_group.go + controller/auto_group.go
- 前端:/auto-group-rules 管理页面(规则 CRUD + 初始化 + 匹配测试)
- 27 个单元/行为测试覆盖核心决策与订阅联动
- 修复 UpdateUserGroup 双重引号 bug、usage_report Sprintf 缺参数

版本: v1.2.1
# Conflicts:
#	model/user.go
#	web/default/src/i18n/locales/en.json
#	web/default/src/i18n/locales/fr.json
#	web/default/src/i18n/locales/ja.json
#	web/default/src/i18n/locales/ru.json
#	web/default/src/i18n/locales/vi.json
#	web/default/src/i18n/locales/zh.json
Add the auto group rules page to the admin sidebar and sidebar module visibility map so administrators can access it from the UI.
Initialize column filter state for the auto group rules table so the shared toolbar can safely read active filter counts.
Move matcher test into an action dialog, keep protected groups as a compact settings card, and complete locale strings for the auto-group UI.
Include Feishu job title in the users CSV export so automatic group rule analysis can distinguish same-name positions by organization context.
Document the upgraded auto-group matching model with organization-aware fallback rules and default high-confidence mappings.
Clarify that auto-group rules should use stable organization features and path fragments instead of requiring administrators to maintain full department paths.
Replace the complex multi-condition rule engine spec with an identity classifier, confirmation queue, and learned rule workflow to reduce admin maintenance.
Clarify that itbp and executive groups are manually maintained and excluded from automatic group assignment.
Replace direct rule management with an identity-classifier workflow that replays users, queues uncertain cases for confirmation, and only auto-applies high-confidence group suggestions.
Use Feishu contact user group membership as the primary auto-group signal and map it to token packages from the approved Base table, keeping protected groups untouched and job-title rules as fallback.
Replace identity/job-title fallback assignment with admin-managed Feishu contact group to token group mappings, keeping protected groups as the auto-assignment guardrail.
…ation

- Add billing group funding policy: personal funding groups exclude
  company auto-assigned subscriptions (source=bind_group)
- Add subscription-driven group access: users automatically gain
  usable groups from active subscription plan bind_groups
- Add Feishu employee_no field to user model and sync
- Add Feishu employee_no column to user CSV export
- Add frontend config UI for billing group funding policy
- Add design doc and setup guide
- TDD: 18 tests covering model, service, and billing layers
- Update auto-group controller and workspace logic
- Enhance feishu group mappings UI with expanded configuration
- Add profile and user drawer UI improvements
- Update i18n translation reports
- model/subscription.go: use upstream lockForUpdate + keep excludeBindGroup logic
- service/pre_consume_quota.go: accept upstream deletion (dead file)
- data-table-row-actions.tsx: adopt upstream Tooltip UI + keep Manual Sync button
- AGENTS.md: merge both bun rules and billing safety invariants
- i18n locales: merge both sides' new keys
Skip invalid Feishu user records without blocking report sync, propagate real sync failures, and validate Feishu identities before persisting administrator-provided IDs.
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a73b86bc-dfc2-4d29-993b-fa8a920cdfd6

📥 Commits

Reviewing files that changed from the base of the PR and between 60a1acb and 4112fbd.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (242)
  • .gitignore
  • AGENTS.md
  • CLAUDE.md
  • Dockerfile
  • VERSION
  • common/constants.go
  • controller/agent_owner.go
  • controller/auto_group.go
  • controller/feishu_admin.go
  • controller/feishu_admin_api.go
  • controller/feishu_admin_api_permission_test.go
  • controller/feishu_identity_validation_test.go
  • controller/feishu_stats.go
  • controller/feishu_stats_test.go
  • controller/misc.go
  • controller/model_quota.go
  • controller/oauth.go
  • controller/option.go
  • controller/subscription.go
  • controller/subscription_report.go
  • controller/usedata.go
  • controller/user.go
  • deploy/Dockerfile.local
  • docs/feishu-admin-api.md
  • docs/feishu-get-user-tokens.md
  • docs/feishu-init-webhook-change-log.md
  • docs/feishu-usage-report-base-setup.md
  • docs/guides/billing-group-funding-setup-guide.md
  • docs/migration-audit-report.md
  • docs/superpowers/plans/2026-07-06-auto-group-by-jobtitle-plan.md
  • docs/superpowers/specs/2026-04-30-feishu-oauth-subscription-migration-design.md
  • docs/superpowers/specs/2026-04-30-feishu-oauth-subscription-migration-dev-plan.md
  • docs/superpowers/specs/2026-04-30-user-model-stats-implementation-plan.md
  • docs/superpowers/specs/2026-05-06-feishu-org-plan-detailed-proposal.md
  • docs/superpowers/specs/2026-05-06-feishu-uat-test-cases.md
  • docs/superpowers/specs/2026-06-11-feishu-user-org-sync-design.md
  • docs/superpowers/specs/2026-06-26-model-quota-limit-design.md
  • docs/superpowers/specs/2026-06-26-organization-account-design.md
  • docs/superpowers/specs/2026-07-06-auto-group-by-jobtitle-design.md
  • docs/superpowers/specs/2026-07-07-auto-group-multi-condition-rules-design.md
  • docs/superpowers/specs/2026-07-10-billing-group-funding-policy-design.md
  • docs/user-model-stats-api.md
  • dto/user_settings.go
  • go.mod
  • i18n/keys.go
  • i18n/locales/en.yaml
  • i18n/locales/zh-CN.yaml
  • i18n/locales/zh-TW.yaml
  • main.go
  • middleware/auth.go
  • middleware/distributor.go
  • middleware/model_quota_helpers.go
  • middleware/model_quota_limit.go
  • middleware/model_quota_limit_test.go
  • middleware/rate-limit.go
  • model/auto_group_suggestion.go
  • model/feishu_group_package_mapping.go
  • model/group_mapping.go
  • model/group_mapping_test.go
  • model/log.go
  • model/log_filter_test.go
  • model/main.go
  • model/model_quota.go
  • model/model_quota_cache.go
  • model/model_quota_test.go
  • model/option.go
  • model/subscription.go
  • model/subscription_bindgroup_test.go
  • model/usage_report_snapshot.go
  • model/usedata.go
  • model/usedata_stats_test.go
  • model/user.go
  • model/utils.go
  • oauth/feishu.go
  • production-deploy/.build.env.example
  • production-deploy/.env.example
  • production-deploy/LOCAL-BUILD-ACR-PROD-DEPLOY.md
  • production-deploy/README.md
  • production-deploy/build.sh
  • production-deploy/config.example.yaml
  • production-deploy/deploy.sh
  • production-deploy/docker-compose.yml
  • production-deploy/init-db.sh
  • production-deploy/init-server.sh
  • production-deploy/production-deploy.service
  • relay/channel/claude/relay-claude.go
  • relay/channel/minimax/adaptor_test.go
  • relay/channel/minimax/image.go
  • relay/helper/stream_scanner.go
  • router/api-router.go
  • router/relay-router.go
  • service/auto_group.go
  • service/auto_group_test.go
  • service/auto_group_workspace.go
  • service/billing.go
  • service/billing_group_funding_test.go
  • service/billing_session.go
  • service/feishu_fetch.go
  • service/feishu_stats_push.go
  • service/feishu_stats_push_test.go
  • service/feishu_user_info_sync.go
  • service/funding_source.go
  • service/group.go
  • service/group_subscription_test.go
  • service/model_quota.go
  • service/model_quota_hook.go
  • service/model_quota_test.go
  • service/notify-limit.go
  • service/notify_limit_test.go
  • service/quota.go
  • service/usage_report_admin_push.go
  • service/usage_report_base_sync.go
  • service/usage_report_period.go
  • service/usage_report_snapshot.go
  • service/user_notify.go
  • setting/operation_setting/billing_group_setting.go
  • setting/operation_setting/billing_group_setting_test.go
  • setting/system_setting/feishu.go
  • web/classic/src/App.jsx
  • web/classic/src/components/auth/LoginForm.jsx
  • web/classic/src/components/common/ErrorBoundary.jsx
  • web/classic/src/components/common/logo/FeishuIcon.jsx
  • web/classic/src/components/layout/SiderBar.jsx
  • web/classic/src/components/layout/headerbar/UserArea.jsx
  • web/classic/src/components/settings/PersonalSetting.jsx
  • web/classic/src/components/settings/SystemSetting.jsx
  • web/classic/src/components/settings/personal/cards/AccountManagement.jsx
  • web/classic/src/components/settings/personal/cards/MySubscriptions.jsx
  • web/classic/src/components/settings/personal/cards/NotificationSettings.jsx
  • web/classic/src/components/settings/personal/components/UserInfoHeader.jsx
  • web/classic/src/components/table/subscriptions/SubscriptionUsageView.jsx
  • web/classic/src/components/table/subscriptions/SubscriptionsColumnDefs.jsx
  • web/classic/src/components/table/subscriptions/SubscriptionsTable.jsx
  • web/classic/src/components/table/subscriptions/index.jsx
  • web/classic/src/components/table/subscriptions/modals/AddEditSubscriptionModal.jsx
  • web/classic/src/components/table/users/UsersActions.jsx
  • web/classic/src/components/table/users/UsersColumnDefs.jsx
  • web/classic/src/components/table/users/UsersTable.jsx
  • web/classic/src/components/table/users/index.jsx
  • web/classic/src/components/table/users/modals/FeishuBatchInitModal.jsx
  • web/classic/src/components/table/users/modals/FeishuTokenManagerModal.jsx
  • web/classic/src/components/user-model-stats/UserModelStatsFilters.jsx
  • web/classic/src/components/user-model-stats/UserModelStatsPage.jsx
  • web/classic/src/components/user-model-stats/UserModelStatsTable.jsx
  • web/classic/src/helpers/api.js
  • web/classic/src/hooks/common/useSidebar.js
  • web/classic/src/hooks/user-model-stats/useUserModelStats.js
  • web/classic/src/pages/Setting/Operation/SettingsSidebarModulesAdmin.jsx
  • web/classic/src/pages/UserModelStats/index.jsx
  • web/default/src/assets/brand-icons/icon-feishu.tsx
  • web/default/src/assets/brand-icons/index.ts
  • web/default/src/features/auth/components/oauth-providers.tsx
  • web/default/src/features/auth/hooks/use-oauth-login.ts
  • web/default/src/features/auth/lib/oauth.ts
  • web/default/src/features/auth/sign-in/components/user-auth-form.tsx
  • web/default/src/features/auth/types.ts
  • web/default/src/features/auto-group/api.ts
  • web/default/src/features/auto-group/components/feishu-group-mappings.tsx
  • web/default/src/features/auto-group/components/identity-rules.tsx
  • web/default/src/features/auto-group/components/initialize-dialog.tsx
  • web/default/src/features/auto-group/components/protected-groups-config.tsx
  • web/default/src/features/auto-group/components/resolve-test.tsx
  • web/default/src/features/auto-group/components/rule-delete-dialog.tsx
  • web/default/src/features/auto-group/components/rule-mutate-dialog.tsx
  • web/default/src/features/auto-group/components/rules-columns.tsx
  • web/default/src/features/auto-group/components/rules-dialogs.tsx
  • web/default/src/features/auto-group/components/rules-primary-buttons.tsx
  • web/default/src/features/auto-group/components/rules-provider.tsx
  • web/default/src/features/auto-group/components/rules-table.tsx
  • web/default/src/features/auto-group/components/suggestions-table.tsx
  • web/default/src/features/auto-group/components/workspace-dashboard.tsx
  • web/default/src/features/auto-group/constants.ts
  • web/default/src/features/auto-group/hooks/use-groups.ts
  • web/default/src/features/auto-group/index.tsx
  • web/default/src/features/auto-group/lib/index.ts
  • web/default/src/features/auto-group/types.ts
  • web/default/src/features/model-quota/api.ts
  • web/default/src/features/model-quota/model-quota-rules-page.tsx
  • web/default/src/features/model-quota/types.ts
  • web/default/src/features/model-quota/user-model-quota-dialog.tsx
  • web/default/src/features/playground/constants.ts
  • web/default/src/features/playground/lib/streaming/payload-builder.ts
  • web/default/src/features/profile/components/profile-header.tsx
  • web/default/src/features/profile/components/tabs/notification-tab.tsx
  • web/default/src/features/profile/constants.ts
  • web/default/src/features/profile/types.ts
  • web/default/src/features/subscriptions/api.ts
  • web/default/src/features/subscriptions/components/data-table-row-actions.tsx
  • web/default/src/features/subscriptions/components/group-plan-mapping.tsx
  • web/default/src/features/subscriptions/components/subscription-usage-dashboard.tsx
  • web/default/src/features/subscriptions/components/subscriptions-columns.tsx
  • web/default/src/features/subscriptions/components/subscriptions-mutate-drawer.tsx
  • web/default/src/features/subscriptions/index.tsx
  • web/default/src/features/subscriptions/lib/plan-form.ts
  • web/default/src/features/subscriptions/types.ts
  • web/default/src/features/system-settings/auth/index.tsx
  • web/default/src/features/system-settings/auth/oauth-section.tsx
  • web/default/src/features/system-settings/auth/section-registry.tsx
  • web/default/src/features/system-settings/billing/billing-group-funding-section.tsx
  • web/default/src/features/system-settings/billing/section-registry.tsx
  • web/default/src/features/system-settings/types.ts
  • web/default/src/features/user-model-stats/api.ts
  • web/default/src/features/user-model-stats/components/user-model-stats-filters.tsx
  • web/default/src/features/user-model-stats/components/user-model-stats-table.tsx
  • web/default/src/features/user-model-stats/constants.ts
  • web/default/src/features/user-model-stats/index.tsx
  • web/default/src/features/user-model-stats/types.ts
  • web/default/src/features/users/api.ts
  • web/default/src/features/users/components/agent-owner-dialog.tsx
  • web/default/src/features/users/components/data-table-row-actions.tsx
  • web/default/src/features/users/components/feishu-batch-init-dialog.tsx
  • web/default/src/features/users/components/feishu-token-manager-dialog.tsx
  • web/default/src/features/users/components/users-columns.tsx
  • web/default/src/features/users/components/users-mutate-drawer.tsx
  • web/default/src/features/users/components/users-primary-buttons.tsx
  • web/default/src/features/users/components/users-table.tsx
  • web/default/src/features/users/constants.ts
  • web/default/src/features/users/index.tsx
  • web/default/src/features/users/lib/user-form.ts
  • web/default/src/features/users/types.ts
  • web/default/src/hooks/use-sidebar-config.ts
  • web/default/src/hooks/use-sidebar-data.ts
  • web/default/src/i18n/locales/_reports/_sync-report.json
  • web/default/src/i18n/locales/_reports/fr.untranslated.json
  • web/default/src/i18n/locales/_reports/ja.untranslated.json
  • web/default/src/i18n/locales/_reports/ru.untranslated.json
  • web/default/src/i18n/locales/_reports/vi.untranslated.json
  • web/default/src/i18n/locales/_reports/zh.untranslated.json
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh-TW.json
  • web/default/src/i18n/locales/zh.json
  • web/default/src/lib/oauth.ts
  • web/default/src/routeTree.gen.ts
  • web/default/src/routes/_authenticated/auto-group-rules/index.tsx
  • web/default/src/routes/_authenticated/model-quota-rules/index.tsx
  • web/default/src/routes/_authenticated/org-model-stats/index.tsx
  • web/default/src/routes/_authenticated/organization-users/index.tsx
  • web/default/src/routes/_authenticated/user-model-stats/index.tsx

Walkthrough

This PR delivers an extensive multi-feature release: Feishu OAuth/admin integration (login, batch user init, token management, org sync, webhook), job-title/identity-based auto-grouping, per-model quota limiting, subscription bind-groups and funding isolation, usage report snapshots with Bitable push, organization accounts, and matching UI in both classic and default web frontends, plus documentation and production deployment tooling.

Changes

Backend: Feishu, Auto-Group, Model Quota & Subscriptions

Layer / File(s) Summary
Project config & guidelines
.gitignore, AGENTS.md, CLAUDE.md, Dockerfile, VERSION, common/constants.go, go.mod
Adds account-type constants, Feishu SDK dependency, updated agent rules, and build/version bumps.
Feishu OAuth provider & login gating
oauth/feishu.go, controller/oauth.go, controller/option.go, controller/user.go, controller/misc.go
New Feishu OAuth provider with token exchange/user info, Feishu-aware login/registration/migration, Feishu-only login gating and status exposure.
User model & organization accounts
model/user.go, controller/user.go
Extends User with Feishu identity/org fields, account-type filtering, ConvertToOrganization, manual group lock.
Agent owner binding
controller/agent_owner.go
Bind/unbind/get organization "agent owner" attribution via Feishu identity resolution.
Feishu admin bindings, batch init/update, tokens
controller/feishu_admin.go, controller/feishu_admin_api*.go, tests
Import/query bindings, batch user init/update/webhook, plaintext token CRUD with permission gating.
Auto-group model
model/group_mapping.go, model/auto_group_suggestion.go, model/feishu_group_package_mapping.go, tests
New rule/suggestion/confirmation/learned-rule tables and Feishu group-mapping model.
Auto-group service & controller
service/auto_group*.go, controller/auto_group.go, router/api-router.go
Classification engine, replay/dashboard/apply workflow, rule CRUD, initialization preview/apply.
Feishu stats & usage reports
service/feishu_stats_push.go, service/usage_report_*.go, service/feishu_user_info_sync.go, controller/feishu_stats*.go
Snapshot generation, Bitable sync/push, admin group push, Feishu user org info sync.
Model quota limiting
middleware/model_quota_*.go, service/model_quota*.go, model/model_quota*.go, controller/model_quota.go, router/relay-router.go
Group/plan/user quota rules with Redis-backed usage counters enforced via new relay middleware.
Subscription bind-groups & funding
model/subscription.go, service/funding_source.go, service/billing_session.go, service/group.go, setting/operation_setting/billing_group_setting.go, controller/subscription*.go
Bind-group virtual subscriptions, personal funding-group isolation, usable-groups-with-subscriptions.
Usage data & notifications
model/usedata.go, controller/usedata.go, model/log.go, service/notify-limit.go, service/quota.go, service/user_notify.go, i18n/*
User-model stats aggregation endpoints, username log filtering, quota-percentage notifications, Feishu app notification channel.

Frontend: Classic Web Application

Layer / File(s) Summary
App routing & login
web/classic/src/App.jsx, LoginForm.jsx, ErrorBoundary.jsx, FeishuIcon.jsx
Dynamic OAuth callback route, Feishu login option, error boundary.
Layout & API infra
SiderBar.jsx, UserArea.jsx, helpers/api.js, hooks/*
Sidebar/header updates, shared API client, sidebar/stats hooks.
Personal & system settings
PersonalSetting.jsx, SystemSetting.jsx, personal/cards/*
Feishu OAuth settings, subscriptions card, notification settings, admin sidebar module config.
Subscriptions table
table/subscriptions/*
Plan table, usage view, add/edit modal with bind-group.
Users table & Feishu modals
table/users/*, user-model-stats/*
Users table with Feishu batch-init/token modals and stats page.

Frontend: Default (TanStack) Web Application

Layer / File(s) Summary
Auth & OAuth
features/auth/*, lib/oauth.ts, assets/brand-icons/*
Feishu icon, OAuth provider buttons/hooks, sign-in form.
Auto-group workspace
features/auto-group/*
Rules table/dialogs, Feishu mappings, dashboard, suggestions, identity rules.
Model quota UI
features/model-quota/*
Group/plan/user quota rules page and usage dialog.
Subscriptions UI
features/subscriptions/*
Row actions, group-plan mapping, usage dashboard, mutate drawer.
Users UI
features/users/*
Agent owner dialog, Feishu batch-init/token dialogs, columns, mutate drawer.
Profile, stats, settings, playground
features/profile/*, features/user-model-stats/*, features/system-settings/*, features/playground/*
Profile header/notification tab, stats page, auth/billing settings sections, playground payload builder.
Sidebar hooks, routing, i18n
hooks/use-sidebar-*.ts, routeTree.gen.ts, routes/_authenticated/*, i18n/locales/*
New admin-guarded routes and locale updates.

Documentation and Production Deployment

Layer / File(s) Summary
Design specs & API docs
docs/**
Feishu admin API, model-quota-limit design, organization-account design, migration audit, usage-report setup docs.
Deployment infra
production-deploy/*, deploy/Dockerfile.local
Build/deploy scripts, docker-compose, init scripts, systemd unit.

Estimated code review effort: 5 (Critical) | ~180 minutes

Possibly related PRs

  • QuantumNous/new-api#1904: Modifies the same classic PersonalSetting.jsx/AccountManagement.jsx Telegram binding UI touched by this PR.
  • QuantumNous/new-api#6044: Touches the same playground parameter-enabled payload-building mechanism updated here.

Poem

A rabbit hops through Feishu's gate,
Groups auto-sort, quotas calibrate,
Bind-groups bloom where subscriptions grow,
Docs and scripts deploy just so,
Two frontends dance in perfect sync —
🐇 thump-thump, ship it, don't overthink!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch fix/feishu-report-sync-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch, ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@linbiqiu linbiqiu closed this Jul 27, 2026
@linbiqiu
linbiqiu deleted the fix/feishu-report-sync-hardening branch July 27, 2026 08:19
@coderabbitai coderabbitai Bot mentioned this pull request Jul 30, 2026
11 tasks
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