Skip to content

fix: complete channel model batch testing - #5532

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
yyhhyyyyyy:fix/channel-model-batch-testing
Jun 17, 2026
Merged

fix: complete channel model batch testing#5532
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
yyhhyyyyyy:fix/channel-model-batch-testing

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
完善 default 前端渠道模型批量测试只覆盖当前页,新增按当前筛选结果全量测试的入口,并支持实时进度更新。

🚀 变更类型 / 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

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

iShot_2026-06-16_14.34.36.mp4

Summary by CodeRabbit

  • New Features

    • Added ability to stop batch model testing while in progress.
    • Added batch test progress display with real-time status updates and completion summary.
    • Enhanced model testing with improved concurrency handling and performance.
  • Internationalization

    • Added and updated translations for batch testing workflows across all supported languages (English, French, Japanese, Russian, Vietnamese, Chinese).

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The channel test dialog gains stop-testing support and live batch progress display. The batch handler is replaced with a concurrency-limited, delay-paced implementation using Promise.allSettled, incremental batchProgress state, and a ref-tracked stop flag. A BatchProgressSummary component renders a progress bar with counts. All six locales receive matching new translation keys.

Changes

Batch Test Stop and Progress Feature

Layer / File(s) Summary
BatchProgress type, constants, and sleep helper
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Adds the BatchProgress type (total/completed/success/failed), BATCH_TEST_CONCURRENCY, BATCH_TEST_DELAY_MS constants, and a sleep(ms) promise helper. Adds useRef and Progress to imports.
Stop-request ref/state and resetState update
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Introduces batchStopRequestedRef, isBatchStopRequested state, and batchProgress state; extends resetState to clear all three alongside existing fields.
handleStopBatchTest and reworked handleBatchTest
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Replaces previous batch handler: handleStopBatchTest sets the stop ref/state; handleBatchTest trims/deduplicates models, runs chunks via Promise.allSettled at fixed concurrency, updates batchProgress per chunk, breaks early on stop, computes resultPatch from the latest cache patch, and emits differentiated toast messages for stopped vs completed/failed. Finalization resets stop flags, progress, selection, and refreshes channel lists.
Toolbar UI, table row identity, and BatchProgressSummary
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Reworks the models toolbar to show a "Stop testing" button (disabled when stop is pending), filter-aware "Test … matching/all models" labels, and conditional BatchProgressSummary. Adds getRowId: (row) => row.model; updates header checkbox to select all rows. BatchProgressSummary renders a Progress bar with completed/success/failed counts, adapting copy for the stopping state.
i18n keys across all locales
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
Adds translation keys for completion progress ({{completed}}/{{total}} completed), success/failure summary, batch testing status messages, stop-testing states, and "Test {{count}} matching/selected/all models" labels across all six locale files. Several existing entries are repositioned without value changes.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Toolbar as Models Toolbar
  participant handleBatchTest
  participant Chunk as Promise.allSettled (chunk)
  participant BatchProgressSummary
  participant ChannelList

  User->>Toolbar: click "Test N models"
  Toolbar->>handleBatchTest: invoke with filteredModels
  handleBatchTest->>handleBatchTest: trim/dedupe, init batchProgress
  loop Each concurrency chunk
    handleBatchTest->>Chunk: run N model tests in parallel
    Chunk-->>handleBatchTest: settled results
    handleBatchTest->>BatchProgressSummary: update completed/success/failed
    handleBatchTest->>handleBatchTest: check stop ref → break if set
    handleBatchTest->>handleBatchTest: sleep(BATCH_TEST_DELAY_MS)
  end
  alt User clicks "Stop testing"
    User->>Toolbar: click Stop testing
    Toolbar->>handleBatchTest: set batchStopRequestedRef + isBatchStopRequested
  end
  handleBatchTest->>ChannelList: refresh with resultPatch
  handleBatchTest->>BatchProgressSummary: clear progress state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • QuantumNous/new-api#1819: Overhauls batch channel testing in the underlying useChannelsData hook with the same cancellation-via-ref, concurrency, and incremental progress patterns introduced here in the dialog UI.
  • QuantumNous/new-api#5517: Modifies channel-test-dialog.tsx to refresh channel list status after test completion, directly related to the cache-patch-based refresh logic added in this PR.
  • QuantumNous/new-api#4876: Modifies channel-test-dialog.tsx to update single-model test error messaging, sharing the same dialog component being refactored here.

Suggested reviewers

  • creamlike1024
  • seefs001

Poem

🐇 Hop hop, the tests now run in packs,
With concurrency limits keeping track!
A "Stop" button gleams in the toolbar bright,
Progress bars fill from left to right. 🟩🟩🟩
The rabbit cheers — no test left behind,
Batch testing smarter, one chunk at a time! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. 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 'fix: complete channel model batch testing' accurately summarizes the main change: enabling full batch testing of all models with completion/progress tracking, moving beyond single-page limitations.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 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

🧹 Nitpick comments (1)
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx (1)

974-980: 💤 Low value

Consider using props.xxx pattern instead of destructuring props.

Per coding guidelines, component props should not be destructured. However, the existing components in this file (TestStatusCell, FailureStatusContent, etc.) all use destructuring, so this is consistent with the current codebase pattern. Consider aligning with the guideline in a future refactor.

🤖 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/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`
around lines 974 - 980, The BatchProgressSummary component currently uses
destructured props in its function signature, but the coding guidelines
recommend using the props.xxx pattern instead. Refactor the BatchProgressSummary
function to accept a single props parameter of the same type as currently
destructured, then replace all references to the destructured variables
(progress and isStopping) with props.progress and props.isStopping throughout
the function body to align with the established coding guidelines.

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.

Inline comments:
In `@web/default/src/i18n/locales/fr.json`:
- Line 1248: The French translation of the legal disclaimer contains multiple
misspellings and missing diacritical marks that reduce readability and legal
clarity. Correct the following words in the translation string by adding the
appropriate accents: replace "prerequis" with "prérequis", "necessite" with
"nécessite", "prealable" with "préalable", "reserves" with "réservés", and
"destines" with "destinés". These corrections ensure proper French spelling and
maintain the professional legal tone of the disclaimer for francophone users.

---

Nitpick comments:
In
`@web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`:
- Around line 974-980: The BatchProgressSummary component currently uses
destructured props in its function signature, but the coding guidelines
recommend using the props.xxx pattern instead. Refactor the BatchProgressSummary
function to accept a single props parameter of the same type as currently
destructured, then replace all references to the destructured variables
(progress and isStopping) with props.progress and props.isStopping throughout
the function body to align with the established coding guidelines.
🪄 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

Run ID: 22a2f428-39d2-4602-b618-cce1c456dd84

📥 Commits

Reviewing files that changed from the base of the PR and between eb86311 and 378fd81.

📒 Files selected for processing (7)
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • 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

"Disabled Reason": "Raison de la désactivation",
"Disabled Time": "Heure de désactivation",
"Disabling...": "Désactivation en cours...",
"Disclaimer: Personal use only. Do not distribute or share any credentials. This channel has prerequisites and requires prior setup; use it only if you understand the flow and risks, and comply with OpenAI's terms and policies. Credentials and configuration are for Codex CLI integration only, and are not intended for any other client, platform, or channel.": "Avertissement : usage personnel uniquement. Ne distribuez ni ne partagez aucun identifiant. Ce canal a des prerequis et necessite une configuration prealable ; utilisez-le uniquement si vous comprenez la procedure et les risques, et respectez les conditions et politiques d'OpenAI. Les identifiants et la configuration sont reserves a l'integration Codex CLI et ne sont pas destines a d'autres clients, plateformes ou canaux.",

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 | ⚡ Quick win

Improve legal disclaimer French spelling/diacritics for clarity

Line 1248 contains multiple misspellings in a legal warning string; this can weaken readability and legal precision for francophone users.

Suggested text correction
-    "Disclaimer: Personal use only. Do not distribute or share any credentials. This channel has prerequisites and requires prior setup; use it only if you understand the flow and risks, and comply with OpenAI's terms and policies. Credentials and configuration are for Codex CLI integration only, and are not intended for any other client, platform, or channel.": "Avertissement : usage personnel uniquement. Ne distribuez ni ne partagez aucun identifiant. Ce canal a des prerequis et necessite une configuration prealable ; utilisez-le uniquement si vous comprenez la procedure et les risques, et respectez les conditions et politiques d'OpenAI. Les identifiants et la configuration sont reserves a l'integration Codex CLI et ne sont pas destines a d'autres clients, plateformes ou canaux.",
+    "Disclaimer: Personal use only. Do not distribute or share any credentials. This channel has prerequisites and requires prior setup; use it only if you understand the flow and risks, and comply with OpenAI's terms and policies. Credentials and configuration are for Codex CLI integration only, and are not intended for any other client, platform, or channel.": "Avertissement : usage personnel uniquement. Ne distribuez ni ne partagez aucun identifiant. Ce canal a des prérequis et nécessite une configuration préalable ; utilisez-le uniquement si vous comprenez la procédure et les risques, et respectez les conditions et politiques d'OpenAI. Les identifiants et la configuration sont réservés à l'intégration Codex CLI et ne sont pas destinés à d'autres clients, plateformes ou canaux.",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Disclaimer: Personal use only. Do not distribute or share any credentials. This channel has prerequisites and requires prior setup; use it only if you understand the flow and risks, and comply with OpenAI's terms and policies. Credentials and configuration are for Codex CLI integration only, and are not intended for any other client, platform, or channel.": "Avertissement : usage personnel uniquement. Ne distribuez ni ne partagez aucun identifiant. Ce canal a des prerequis et necessite une configuration prealable ; utilisez-le uniquement si vous comprenez la procedure et les risques, et respectez les conditions et politiques d'OpenAI. Les identifiants et la configuration sont reserves a l'integration Codex CLI et ne sont pas destines a d'autres clients, plateformes ou canaux.",
"Disclaimer: Personal use only. Do not distribute or share any credentials. This channel has prerequisites and requires prior setup; use it only if you understand the flow and risks, and comply with OpenAI's terms and policies. Credentials and configuration are for Codex CLI integration only, and are not intended for any other client, platform, or channel.": "Avertissement : usage personnel uniquement. Ne distribuez ni ne partagez aucun identifiant. Ce canal a des prérequis et nécessite une configuration préalable ; utilisez-le uniquement si vous comprenez la procédure et les risques, et respectez les conditions et politiques d'OpenAI. Les identifiants et la configuration sont réservés à l'intégration Codex CLI et ne sont pas destinés à d'autres clients, plateformes ou canaux.",
🤖 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/default/src/i18n/locales/fr.json` at line 1248, The French translation of
the legal disclaimer contains multiple misspellings and missing diacritical
marks that reduce readability and legal clarity. Correct the following words in
the translation string by adding the appropriate accents: replace "prerequis"
with "prérequis", "necessite" with "nécessite", "prealable" with "préalable",
"reserves" with "réservés", and "destines" with "destinés". These corrections
ensure proper French spelling and maintain the professional legal tone of the
disclaimer for francophone users.

@Calcium-Ion
Calcium-Ion merged commit a2f3ac0 into QuantumNous:main Jun 17, 2026
2 checks passed
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 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.

2 participants