Skip to content

改进渠道管理功能(优先级提示、定时测试优化、参数修复) - #2048

Closed
QLHazyCoder wants to merge 4488 commits into
QuantumNous:mainfrom
QLHazyCoder:feature/channel-improvements
Closed

改进渠道管理功能(优先级提示、定时测试优化、参数修复)#2048
QLHazyCoder wants to merge 4488 commits into
QuantumNous:mainfrom
QLHazyCoder:feature/channel-improvements

Conversation

@QLHazyCoder

@QLHazyCoder QLHazyCoder commented Oct 15, 2025

Copy link
Copy Markdown

本 PR 包含三个针对渠道管理的改进:

  1. feat: 为渠道优先级和权重添加提示图标

    • 提升用户体验,让优先级和权重配置更直观
  2. refactor: 优化定时测试逻辑

    • 跳过已关闭自动禁用的渠道
    • 减少不必要的测试开销
  3. fix: 修复 ShouldDisableChannel 参数错误

    • 将错误的 ChannelId 参数改为正确的 ChannelType
    • 修复潜在的逻辑错误

Summary by CodeRabbit

  • New Features

    • Added help tooltips with icons to the priority and weight fields in the Edit Channel modal for clearer guidance.
  • Refactor

    • Updated auto-disable behavior to determine eligibility based on channel type, improving consistency in when channels are automatically disabled.
  • Tests

    • Adjusted tests to skip channels without auto-ban and align with the updated disable conditions.

Calcium-Ion and others added 30 commits September 29, 2025 14:02
# Conflicts:
#	web/src/i18n/locales/zh.json
 feat(i18n): Add French language support.
解锁deepseek补全倍率;允许deepseek渠道获取模型
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
fix: Redirect address after successful tg binding
fix: sync third-party binding state in personal settings
…ENS/CUSTOM)

Replace the legacy boolean “DisplayInCurrencyEnabled” with an injected, type-safe
configuration `general_setting.quota_display_type`, and wire it through the
backend and frontend.

Backend
- Add `QuotaDisplayType` to `operation_setting.GeneralSetting` with injected
  registration via `config.GlobalConfig.Register("general_setting", ...)`.
  Helpers: `IsCurrencyDisplay()`, `IsCNYDisplay()`, `GetQuotaDisplayType()`.
- Expose `quota_display_type` in `/api/status` and keep legacy
  `display_in_currency` for backward compatibility.
- Logger: update `LogQuota` and `FormatQuota` to support USD/CNY/TOKENS. When
  CNY is selected, convert using `operation_setting.USDExchangeRate`.
- Controllers:
  - `billing`: compute subscription/usage amounts based on the selected type
    (USD: divide by `QuotaPerUnit`; CNY: USD→CNY; TOKENS: keep raw tokens).
  - `topup` / `topup_stripe`: treat inputs as “amount” for USD/CNY and as
    token-count for TOKENS; adjust min topup and pay money accordingly.
  - `misc`: include `quota_display_type` in status payload.
- Compatibility: in `model/option.UpdateOption`, map updates to
  `DisplayInCurrencyEnabled` → `general_setting.quota_display_type`
  (true→USD, false→TOKENS). Keep exporting the legacy key in `OptionMap`.

Frontend
- Settings: replace the “display in currency” switch with a Select
  (`general_setting.quota_display_type`) offering USD / CNY / Tokens.
  Provide fallback mapping from legacy `DisplayInCurrencyEnabled`.
- Persist `quota_display_type` to localStorage (keep `display_in_currency`
  for legacy components).
- Rendering helpers: base all quota/price rendering on `quota_display_type`;
  use `usd_exchange_rate` for CNY symbol/values.
- Pricing page: default view currency follows site display type (USD/CNY),
  while TOKENS mode still allows per-view currency toggling when needed.

Notes
- No database migrations required.
- Legacy clients remain functional via compatibility fields.
feat: support claude-sonnet-4-5-20250929
fix: Optimize sidebar refresh to avoid redundant loading states
Calcium-Ion and others added 25 commits October 12, 2025 15:40
refactor: Openai video model 移动到 dto
feat: jimeng use openai sdk input_reference i2v
将 `ClaudeMediaMessage.Thinking` 的类型从 `string` 修改为 `*string`,以解决 `omitempty` 导致 `"thinking": ""` 字段在 JSON 序列化时被忽略的问题。

同时更新了 `service/convert.go` 和 `relay/channel/claude/relay-claude.go` 中的相关逻辑,以兼容新的指针类型,确保生成的 Claude 事件流符合官方规范。
1. 将对SiliconFlow渠道的RelayModeImagesGenerations请求,转发至v1/images/generations端点。
2. SiliconFlow图像生成接口额外参数适配。
1. 解析ImageRequest的Extra时,处理err
2. DoResponse方法添加RelayModeImagesGenerations(fallthrough)
fix(convert): 修复 OpenAI 转 Claude 流时 thinking 块的格式问题
feat: 添加SiliconFlow图像生成接口自动转换支持
@coderabbitai

coderabbitai Bot commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updates tests to skip non-auto-ban channels, adjusts relay logic to determine disable-eligibility by channelType instead of channelId, and enhances the EditChannelModal UI with tooltips and an icon explaining priority and weight.

Changes

Cohort / File(s) Summary
Controller tests
controller/channel-test.go
Early-return in test loop for channels with GetAutoBan() == false; downstream disable condition simplified to rely on the prior filter; error handling call sites updated accordingly.
Relay disable flow
controller/relay.go, service/...
Disable eligibility now uses channelType: service signature changed from ShouldDisableChannel(channelId, err) to ShouldDisableChannel(channelType, err); async DisableChannel trigger unchanged.
Web UI: EditChannelModal tooltips
web/src/components/table/channels/modals/EditChannelModal.jsx
Added Tooltip and IconHelpCircle imports; labels for priority and weight now wrapped with a tooltip explaining semantics; no data or validation changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Controller as Controller (relay.go)
  participant Service as Service (ShouldDisableChannel)
  participant Worker as gopool worker
  participant Store as ChannelStore

  Client->>Controller: Relay request
  Controller->>Service: ShouldDisableChannel(channelType, err)
  alt eligible to disable
    Controller->>Worker: async DisableChannel(channelId)
    Worker->>Store: DisableChannel(channelId)
    Store-->>Worker: result
    Worker-->>Controller: (async completes)
  else not eligible
    Controller-->>Client: proceed without disable
  end
  note over Controller,Service: Eligibility now keyed by channelType (was channelId)

  %% Styling notes (color is supplemental; labels carry meaning)
  rect rgba(230, 240, 255, 0.6)
  note over Controller: Changed interaction
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • seefs001

Poem

I thump my paw: types lead the way,
From IDs to kinds, we hop and sway.
Tooltips bloom where labels stood,
Tests now skip what never would.
Burrow secure, channels in line—
Auto-ban guards, all by design. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the three targeted improvements—priority hints, scheduled test optimization, and parameter correction—directly matching the PR objectives without introducing unrelated details or vague phrasing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa35d8d and 4273892.

📒 Files selected for processing (3)
  • controller/channel-test.go (2 hunks)
  • controller/relay.go (1 hunks)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
controller/relay.go (1)
service/channel.go (1)
  • ShouldDisableChannel (47-99)
🔇 Additional comments (4)
controller/channel-test.go (2)

562-565: Good optimization: early exit for non-auto-ban channels.

The added guard correctly skips channels with auto-ban disabled before processing, reducing unnecessary test overhead. This aligns with the PR objective and improves efficiency.


589-591: Correctly removed redundant check after early filtering.

The channel.GetAutoBan() check is no longer needed here because channels with auto-ban disabled are now filtered at the start of the loop (lines 562-565). The updated comment clearly documents this change.

controller/relay.go (1)

287-287: Critical fix: corrected parameter from channelId to channelType.

This is an important bug fix. The ShouldDisableChannel function expects channelType (a channel type constant like ChannelTypeGemini) as shown in the service/channel.go snippet, not channelId (a unique identifier). Passing channelId would have broken type-specific disable logic, such as the switch statement at line 60-64 in service/channel.go that checks for specific channel types.

Based on code from service/channel.go showing the correct function signature and type-specific switch logic.

web/src/components/table/channels/modals/EditChannelModal.jsx (1)

51-51: Verify IconHelpCircle export
Ensure IconHelpCircle is actually exported by @douyinfe/semi-icons (e.g., inspect node_modules/@douyinfe/semi-icons/index.* or run npm explore @douyinfe/semi-icons -- grep -R "IconHelpCircle" -n .). If the name differs, update to the correct export (e.g., IconInfoCircle or IconQuestionCircle).

Comment on lines +2394 to +2401
label={
<span>
{t('渠道优先级')}
<Tooltip content='优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)'>
<IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} />
</Tooltip>
</span>
}

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.

⚠️ Potential issue | 🟡 Minor

Add i18n support for tooltip content.

The tooltip content is hardcoded in Chinese without using the t() translation function, which is inconsistent with the rest of the file and breaks internationalization support.

Apply this diff to add i18n support:

                          label={
                            <span>
                              {t('渠道优先级')}
-                              <Tooltip content='优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)'>
+                              <Tooltip content={t('优先级决定渠道选择顺序。数值越高越优先,重试时依次降低优先级(retry=0选最高组)')}>
                                <IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} />
                              </Tooltip>
                            </span>
                          }
                          label={
                            <span>
                              {t('渠道权重')}
-                              <Tooltip content='权重决定同优先级内的流量分配。数值越高流量越多,weight=0也会分配流量(实际权重+10)'>
+                              <Tooltip content={t('权重决定同优先级内的流量分配。数值越高流量越多,weight=0也会分配流量(实际权重+10)')}>
                                <IconHelpCircle className='text-gray-400 cursor-help' style={{ marginLeft: 4 }} />
                              </Tooltip>
                            </span>
                          }

Also applies to: 2413-2420

🤖 Prompt for AI Agents
In web/src/components/table/channels/modals/EditChannelModal.jsx around lines
2394-2401 and 2413-2420, the Tooltip content is hardcoded in Chinese; replace
the literal Chinese strings with calls to the translation function t() (e.g.
t('渠道优先级说明') or an appropriate i18n key) so the tooltip text is
internationalized, ensuring the Tooltip's content prop receives the translated
string and updating/adding the corresponding translation entries for the key(s)
used.

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.