Skip to content

feat(models): auto disable/enable models by channel availability - #6456

Open
LaplaceOrange wants to merge 11 commits into
QuantumNous:mainfrom
LaplaceOrange:feat/auto-model-channel-availability
Open

feat(models): auto disable/enable models by channel availability#6456
LaplaceOrange wants to merge 11 commits into
QuantumNous:mainfrom
LaplaceOrange:feat/auto-model-channel-availability

Conversation

@LaplaceOrange

@LaplaceOrange LaplaceOrange commented Jul 24, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

当模型元数据已配置,但没有可用渠道(或渠道被禁用)时,前台仍可能展示“可用”模型,导致调用失败。

本 PR 增加“按渠道可用性自动启停模型元数据状态”能力:

  1. 配置开关
    • AutomaticDisableModelEnabled:无可用渠道时自动禁用模型
    • AutomaticEnableModelEnabled:仅恢复被规则自动禁用、且渠道已恢复的模型
  2. 标记字段 models.auto_disabled_by_rule
    • 区分人工禁用 / 规则自动禁用,避免自动恢复误开人工禁用项
  3. 触发点
    • 渠道创建/更新/删除/状态变更/标签操作/自动启停
    • 模型创建/更新(名称或匹配规则变化)/删除/上游同步
    • 开关从关到开时全量校准
  4. 管理端
    • 模型页顶部双开关
    • 批量操作:禁用无渠道模型 / 启用有渠道模型
    • 状态 Badge 与筛选:Enabled / Disabled / Auto-enabled / Auto-disabled

本地验证:go test ./service -run ModelChannelAvailability 通过;页面手动验证开关、筛选与批量菜单可见。

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

UI 截图(/models/metadata)

  1. 模型页 + 自动开关 + 状态 Badge

    • Auto-disable 开关开启
    • claude-3 显示 Auto-disabled(无可用渠道)
    • gpt-4 显示 Enabled(渠道 test-channel 可用)
    01-models-page
  2. 批量操作菜单

    • Disable Models with No Channels
    • Enable Models with Available Channels
02-batch-actions-menu
  1. 状态筛选新增 Auto-enabled / Auto-disabled
03-status-filter
  1. 筛选 Auto-disabled 结果
    • 仅剩 claude-3,Total=1
04-filtered-auto-disabled

API 抽查(root 登录后)

  • POST /api/models/batch_disable_no_channels → success
  • POST /api/models/batch_enable_with_channels → success,曾恢复 1 个有渠道模型
  • option 中可见:
    • AutomaticDisableModelEnabled=true
    • AutomaticEnableModelEnabled=true

备注

  1. 关闭自动开关不会回滚已自动禁用的模型,仅停止后续自动化。
  2. 手动“启用有渠道模型”当前也会启用人工禁用但已有渠道的模型;如需仅恢复 auto-disabled,可再收窄逻辑。
  3. 自动恢复后 auto_disabled_by_rule 仍为 true,Badge 显示 Auto-enabled,便于识别规则托管状态。

Summary by CodeRabbit

  • New Features
    • Added automatic model availability calibration driven by enabled channel/ability matching, including auto re-enable when availability returns.
    • Added system toggles for automatic enable/disable and “Auto-enabled/Auto-disabled” status badges, filtering, and UI switches.
    • Added admin batch actions (with one-click UI) to disable models with no available channels and re-enable models after recovery.
  • Bug Fixes
    • Improved calibration consistency across channel/model/option lifecycle events and corrected status update behavior to preserve disabled states.
  • Tests
    • Added comprehensive automated tests covering matching rules, marker behavior, batch actions, and lifecycle integrations.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds automatic model enable/disable reconciliation based on available channels, lifecycle triggers, manual batch endpoints, model status filtering, and frontend controls, actions, badges, and translations.

Changes

Model channel availability automation

Layer / File(s) Summary
Availability contracts and status representations
common/constants.go, model/..., web/src/features/models/types.ts, web/src/features/system-settings/...
Adds automation flags, the auto_disabled_by_rule field, expanded status filtering, option pairing, and frontend status/settings representations.
Availability reconciliation and validation
service/model_channel_availability.go, service/model_channel_availability_test.go, service/task_billing_test.go
Implements channel matching, automatic/manual reconciliation, marker handling, pricing refreshes, and scenario coverage.
Lifecycle synchronization and admin endpoints
controller/..., router/api-router.go, service/channel.go
Triggers reconciliation after channel, model, upstream, and option changes, and exposes authenticated batch operations.
Model management UI and API
web/src/features/models/..., web/src/i18n/locales/*, .gitignore
Adds batch actions, availability switches, status badges and filters, table integration, defaults, translations, and local artifact exclusions.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant ModelsUI
  participant ModelsAPI
  participant AvailabilityService
  Admin->>ModelsUI: change automation switch or choose batch action
  ModelsUI->>ModelsAPI: update option or POST batch endpoint
  ModelsAPI->>AvailabilityService: reconcile model channel availability
  AvailabilityService-->>ModelsAPI: return disabled/enabled counts
  ModelsAPI-->>ModelsUI: return result
  ModelsUI-->>Admin: show result and refresh model list
Loading

Poem

A rabbit flips switches bright,
Models follow channels’ light.
When paths fade, statuses hop,
When they return, enables pop.
Badges bloom and tests align—
A tidy burrow, state in line!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: automatic model disable/enable behavior driven by channel availability.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (2)
service/model_channel_availability.go (1)

27-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

forceFull doc comment overstates its effect.

The comment says forceFull=true always evaluates all models; otherwise only when disable switch is on, but the model scan at lines 58-80 always covers every row regardless of forceFull; the flag only affects whether a zero-change result gets logged (119-124), and _ = forceFull at 126 is a no-op once the flag is already used. Worth tightening the comment (or the design) so future readers don't assume partial-scope scans exist.

Also applies to: 113-126

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@service/model_channel_availability.go` around lines 27 - 47, Update the
documentation for syncModelChannelAvailability and
SyncModelChannelAvailabilityFull so forceFull is described accurately: model
evaluation already scans all rows, while the flag only controls zero-change
result logging. Remove the misleading “partial-skip” wording and eliminate the
redundant _ = forceFull statement if it is no longer needed after documenting
the actual behavior.
web/src/features/models/lib/model-actions.ts (1)

278-349: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract shared logic between the two batch-availability handlers.

handleBatchDisableModelsNoChannels and handleBatchEnableModelsWithChannels duplicate the same try/success-check/toast/invalidate/catch flow, differing only by the API call, the result field name, and the i18n messages.

♻️ Proposed shared helper
+async function runBatchAvailabilityAction(
+  apiCall: () => Promise<{ success: boolean; message?: string; data?: { disabled: number; enabled: number } }>,
+  countField: 'disabled' | 'enabled',
+  messages: { success: (count: number) => string; empty: string; failure: string },
+  queryClient?: QueryClient,
+  onSuccess?: (count: number) => void
+): Promise<void> {
+  try {
+    const response = await apiCall()
+    if (response.success) {
+      const count = response.data?.[countField] ?? 0
+      if (count > 0) {
+        toast.success(messages.success(count))
+      } else {
+        toast.info(messages.empty)
+      }
+      queryClient?.invalidateQueries({ queryKey: modelsQueryKeys.lists() })
+      onSuccess?.(count)
+    } else {
+      toast.error(response.message || messages.failure)
+    }
+  } catch (error: unknown) {
+    toast.error((error as Error)?.message || messages.failure)
+  }
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/models/lib/model-actions.ts` around lines 278 - 349, Extract
the duplicated try/success-check/toast/invalidate/catch flow from
handleBatchDisableModelsNoChannels and handleBatchEnableModelsWithChannels into
a shared private helper. Parameterize the helper with the batch API call, result
count, success/empty/error messages, and operation-specific toast text, then
have both handlers delegate to it while preserving their existing callbacks and
query invalidation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@controller/channel.go`:
- Around line 1097-1100: Update the sync guard in UpdateChannel to compare only
channel.Models against originChannel.Models, removing the ineffective
channel.Status comparison while preserving the existing
SyncModelChannelAvailability("channel.update") call.

In `@controller/model_sync.go`:
- Around line 437-441: Update chooseStatus to preserve a legitimate fallback
status of 0 instead of returning hardcoded status 1 when both inputs are zero,
while preserving existing call-site behavior including chooseStatus(up.Status,
1). In the status overwrite flow around local.AutoDisabledByRule, clear the
marker only when the selected status genuinely differs from the existing local
status; otherwise preserve the disabled state and marker.

In `@service/model_channel_availability.go`:
- Around line 189-200: Update the manual batch enable UPDATE for enableAutoIDs
in manualSyncModelChannelAvailability to include auto_disabled_by_rule = true in
its WHERE clause, mirroring the sync enable path’s defensive condition. Preserve
the existing update behavior while preventing it from re-enabling a marker
cleared concurrently by ClearModelAutoDisabledByRule.

In `@web/src/features/models/components/models-primary-buttons.tsx`:
- Around line 74-81: Gate the system-wide batch actions behind confirmation by
updating the relevant DropdownMenuItem onClick handlers to call setConfirmAction
instead of invoking handleBatchDisableNoChannels or
handleBatchEnableWithChannels directly. Add a Dialog matching the existing
DataTableBulkActions confirmation pattern, and invoke the selected handler only
after explicit confirmation.

In `@web/src/i18n/locales/ru.json`:
- Around line 509-510: Translate the values for the Russian locale keys
"Auto-disable models with no available channels" and "Auto-enable models
disabled by this setting when a channel recovers" into Russian, while preserving
the keys and JSON structure.

In `@web/src/i18n/locales/vi.json`:
- Around line 509-510: Translate the Vietnamese locale values for “Auto-disable
models with no available channels” and “Auto-enable models disabled by this
setting when a channel recovers” in the locale entries, replacing the English
text with natural Vietnamese while preserving the keys unchanged.

In `@web/src/i18n/locales/zh-TW.json`:
- Around line 509-510: Translate the values for “Auto-disable models with no
available channels” and “Auto-enable models disabled by this setting when a
channel recovers” in the zh-TW locale to natural Traditional Chinese, while
preserving both existing keys and JSON validity.

In `@web/src/i18n/locales/zh.json`:
- Line 511: Update the Chinese translations for the batch model enable/disable
strings, including the related entries around the second referenced location, to
preserve the distinction between recovered channels and unavailable channels.
Replace wording that only indicates configured channels with wording equivalent
to “models with recovered channels” and “models with no available channels,”
while keeping the existing automation meaning.

---

Nitpick comments:
In `@service/model_channel_availability.go`:
- Around line 27-47: Update the documentation for syncModelChannelAvailability
and SyncModelChannelAvailabilityFull so forceFull is described accurately: model
evaluation already scans all rows, while the flag only controls zero-change
result logging. Remove the misleading “partial-skip” wording and eliminate the
redundant _ = forceFull statement if it is no longer needed after documenting
the actual behavior.

In `@web/src/features/models/lib/model-actions.ts`:
- Around line 278-349: Extract the duplicated
try/success-check/toast/invalidate/catch flow from
handleBatchDisableModelsNoChannels and handleBatchEnableModelsWithChannels into
a shared private helper. Parameterize the helper with the batch API call, result
count, success/empty/error messages, and operation-specific toast text, then
have both handlers delegate to it while preserving their existing callbacks and
query invalidation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a5c2210-e9bb-491b-9a72-9a1835bc3825

📥 Commits

Reviewing files that changed from the base of the PR and between 84a79b6 and aa007b0.

📒 Files selected for processing (31)
  • .gitignore
  • common/constants.go
  • controller/channel.go
  • controller/model_meta.go
  • controller/model_sync.go
  • controller/option.go
  • model/model_meta.go
  • model/option.go
  • router/api-router.go
  • service/channel.go
  • service/model_channel_availability.go
  • service/model_channel_availability_test.go
  • service/task_billing_test.go
  • web/src/features/models/api.ts
  • web/src/features/models/components/drawers/model-mutate-drawer.tsx
  • web/src/features/models/components/models-availability-switches.tsx
  • web/src/features/models/components/models-columns.tsx
  • web/src/features/models/components/models-primary-buttons.tsx
  • web/src/features/models/components/models-table.tsx
  • web/src/features/models/constants.ts
  • web/src/features/models/lib/model-actions.ts
  • web/src/features/models/types.ts
  • web/src/features/system-settings/models/index.tsx
  • web/src/features/system-settings/types.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json

Comment thread controller/channel.go Outdated
Comment thread controller/model_sync.go Outdated
Comment thread service/model_channel_availability.go Outdated
Comment thread web/src/features/models/components/models-primary-buttons.tsx Outdated
Comment thread web/src/i18n/locales/ru.json Outdated
Comment thread web/src/i18n/locales/vi.json Outdated
Comment thread web/src/i18n/locales/zh-TW.json Outdated
Comment thread web/src/i18n/locales/zh.json Outdated
@LaplaceOrange

Copy link
Copy Markdown
Author

@bigsongeth 求审批

@bigsongeth

Copy link
Copy Markdown
Contributor

抱歉,我不是本项目的维护者,只是提过一个 PR 的外部贡献者,没有仓库权限,审批不了 🙏

能 review / merge 的是维护者 Calcium-Ion 和 seefs001,建议找他们。

另外顺手提一句:这个 PR 目前跟 main 已经冲突了(mergeable: CONFLICTING),CodeRabbit 那轮也还留着 8 条 actionable comments。先 rebase 并把这些处理掉,应该更容易推进。

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@model/option.go`:
- Around line 210-213: Refactor the paired-flag handling around updateOptionMap
and the load/bulk reconciliation paths to canonicalize enabled values
consistently, including "1", and reconcile AutomaticEnableModelEnabled with
AutomaticDisableModelEnabled independent of processing order. Normalize both
flags before persistence, clear and persist the child when the parent is
disabled, and persist the resulting pair atomically after bulk updates and
loadOptionsFromDatabase so in-memory and database state remain synchronized.

In `@web/src/i18n/locales/fr.json`:
- Line 5229: Update the French translation for the “No disabled models with
available channels found” key to preserve the source meaning: disabled models
with available channels. Remove the auto-disabled and recovered-channel wording
that duplicates the nearby translation, while leaving the neighboring locale
entries unchanged.

In `@web/src/i18n/locales/ru.json`:
- Line 5229: Update the Russian translation value for the “No disabled models
with available channels found” key to describe generic disabled models with
available channels, removing references to automatic disabling and recovered
channels while preserving the key’s intended meaning.

In `@web/src/i18n/locales/vi.json`:
- Line 5229: Update the Vietnamese translation value for “No disabled models
with available channels found” to preserve the key’s broader meaning, referring
to all disabled models with available channels without adding the narrower
“automatically disabled” condition.

In `@web/src/i18n/locales/zh-TW.json`:
- Line 5229: Update the translation value for “No disabled models with available
channels found” in the zh-TW locale to directly express that no disabled models
with available channels were found, removing the narrower references to
rule-based disabling and recovered channels.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d5f525f-c908-4729-be24-f56bd18c5aa9

📥 Commits

Reviewing files that changed from the base of the PR and between abba861 and 91336b1.

📒 Files selected for processing (16)
  • controller/model_meta.go
  • controller/model_sync.go
  • model/option.go
  • service/model_channel_availability.go
  • service/model_channel_availability_test.go
  • service/task_billing_test.go
  • web/src/features/models/components/models-availability-switches.tsx
  • web/src/features/models/components/models-primary-buttons.tsx
  • web/src/features/models/lib/model-actions.ts
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-TW.json
  • web/src/i18n/locales/zh.json
🚧 Files skipped from review as they are similar to previous changes (10)
  • service/task_billing_test.go
  • web/src/i18n/locales/en.json
  • service/model_channel_availability.go
  • web/src/features/models/components/models-primary-buttons.tsx
  • web/src/features/models/components/models-availability-switches.tsx
  • controller/model_sync.go
  • web/src/features/models/lib/model-actions.ts
  • web/src/i18n/locales/zh.json
  • service/model_channel_availability_test.go
  • controller/model_meta.go

Comment thread model/option.go Outdated
Comment thread web/src/i18n/locales/fr.json Outdated
Comment thread web/src/i18n/locales/ru.json Outdated
Comment thread web/src/i18n/locales/vi.json Outdated
Comment thread web/src/i18n/locales/zh-TW.json Outdated
@LaplaceOrange
LaplaceOrange force-pushed the feat/auto-model-channel-availability branch from 91336b1 to 7f8f1b0 Compare July 27, 2026 16:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
model/model_meta.go (1)

261-279: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove or use the unused parseModelStatusFilter wrapper.

golangci-lint reports this function as unused, while callers now use parseModelStatusFilterSpec. Delete the stale compatibility wrapper or migrate a real status-only caller to it.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@model/model_meta.go` around lines 261 - 279, Remove the unused
parseModelStatusFilter wrapper from model metadata parsing, since callers now
use parseModelStatusFilterSpec directly. Do not migrate callers unless an actual
status-only caller exists; retain parseModelStatusFilterSpec and its current
behavior unchanged.

Source: Linters/SAST tools

controller/model_meta.go (1)

152-188: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Flatten the unnecessary else for early-return style.

The if statusOnly { ...; return } branch already returns, so the following else just adds nesting for the rest of the function. As per coding guidelines, **/*.{go,ts,tsx}: "prefer early returns, clear branches, and well-named local variables over deep nesting or layered control flow."

♻️ Proposed restructure
-	} else {
-		// 名称冲突检查
-		if dup, err := model.IsModelNameDuplicated(m.Id, m.ModelName); err != nil {
-			common.ApiError(c, err)
-			return
-		} else if dup {
-			common.ApiErrorMsg(c, "模型名称已存在")
-			return
-		}
+	}
+	// 名称冲突检查
+	if dup, err := model.IsModelNameDuplicated(m.Id, m.ModelName); err != nil {
+		common.ApiError(c, err)
+		return
+	} else if dup {
+		common.ApiErrorMsg(c, "模型名称已存在")
+		return
+	}
 
-		// Preserve previous status to detect explicit status changes.
-		var prev model.Model
-		_ = model.DB.Select("id", "status", "model_name", "name_rule").Where("id = ?", m.Id).First(&prev).Error
+	// Preserve previous status to detect explicit status changes.
+	var prev model.Model
+	_ = model.DB.Select("id", "status", "model_name", "name_rule").Where("id = ?", m.Id).First(&prev).Error
 
-		if err := m.Update(); err != nil {
-			common.ApiError(c, err)
-			return
-		}
+	if err := m.Update(); err != nil {
+		common.ApiError(c, err)
+		return
+	}
 	...
-		common.ApiSuccess(c, &m)
-		return
-	}
+	common.ApiSuccess(c, &m)
+	return
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@controller/model_meta.go` around lines 152 - 188, Remove the unnecessary else
wrapping the metadata update path after the statusOnly branch, since that branch
already returns. Dedent the duplicate-name validation, previous-model lookup,
update, synchronization, pricing refresh, and success response logic while
preserving their existing behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@controller/model_meta.go`:
- Around line 152-188: Remove the unnecessary else wrapping the metadata update
path after the statusOnly branch, since that branch already returns. Dedent the
duplicate-name validation, previous-model lookup, update, synchronization,
pricing refresh, and success response logic while preserving their existing
behavior.

In `@model/model_meta.go`:
- Around line 261-279: Remove the unused parseModelStatusFilter wrapper from
model metadata parsing, since callers now use parseModelStatusFilterSpec
directly. Do not migrate callers unless an actual status-only caller exists;
retain parseModelStatusFilterSpec and its current behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 92f9bd1a-0e07-41ab-9790-f477b7357f50

📥 Commits

Reviewing files that changed from the base of the PR and between 91336b1 and 7f8f1b0.

📒 Files selected for processing (8)
  • .gitignore
  • common/constants.go
  • controller/channel.go
  • controller/model_meta.go
  • controller/model_sync.go
  • controller/option.go
  • model/model_meta.go
  • model/option.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • .gitignore
  • common/constants.go
  • controller/option.go
  • controller/model_sync.go
  • controller/channel.go

@LaplaceOrange

Copy link
Copy Markdown
Author

@Calcium-Ion @seefs001 求审核awa

@LaplaceOrange

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@LaplaceOrange
LaplaceOrange force-pushed the feat/auto-model-channel-availability branch from f0164d4 to d6b4a1f Compare August 2, 2026 10:36
Rain-kl added a commit to Rain-kl/new-api that referenced this pull request Aug 5, 2026
…ntumNous#6456)

When model metadata has no available channels, auto-disable it; re-enable only
models previously disabled by this rule when channels recover. Adds admin
switches, status badges/filters, and batch availability actions.

Upstream: QuantumNous#6456
Reconcile model metadata status against enabled channels and abilities.
Add AutomaticDisableModelEnabled / AutomaticEnableModelEnabled options,
batch admin actions, status filters/badges, and coverage for channel
lifecycle hooks. Preserve manual disable decisions via auto_disabled_by_rule.
Keep feature commits code-only by excluding local output, playwright
artifacts, server logs, temp helpers, and i18n report dumps.
Guard UpdateChannel sync on models only, preserve disabled status=0 in
chooseStatus, clear auto markers only on real status change, harden
manual auto-enable WHERE, require batch-action confirmation, and improve
locale wording for recovered vs unavailable channels.
Only recover auto-disabled models in batch enable, pair enable switch
with disable (runtime + persistence), avoid duplicate pricing refresh,
re-evaluate after manual status edits, and complete locale strings.
# Conflicts:
#	service/task_billing_test.go
@LaplaceOrange
LaplaceOrange force-pushed the feat/auto-model-channel-availability branch from d6b4a1f to 8c31127 Compare August 14, 2026 09:01
@Calcium-Ion

Copy link
Copy Markdown
Member

感谢贡献,但是这个功能改的太大了,要不先电邮和我沟通一下想法 i@caion.me

Make channel and model mutations transactional and cache-coherent. Reject stale upstream results, coordinate batched model status changes, and cover retry, locking, cache invalidation, and UI behavior with regression tests.
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