Skip to content

feat: 渠道模型测试增加超时设置与响应时间筛选功能 - #5844

Open
bonaluo wants to merge 9 commits into
QuantumNous:mainfrom
bonaluo:feat/channel-test-timeout-filter
Open

feat: 渠道模型测试增加超时设置与响应时间筛选功能#5844
bonaluo wants to merge 9 commits into
QuantumNous:mainfrom
bonaluo:feat/channel-test-timeout-filter

Conversation

@bonaluo

@bonaluo bonaluo commented Jul 1, 2026

Copy link
Copy Markdown

📝 变更描述 / Description

功能概述

渠道模型测试弹窗增加测试超时控制与响应时间筛选功能,同时适配 default 和 classic 两套前端。

具体变更

测试超时控制

  • 测试弹窗新增超时时间输入框,默认 10 秒,可自定义
  • 通过 AbortController + setTimeout 实现请求中止,超时后标记 test_timeout 错误码
  • resetState 同步重置超时配置和 abortController

响应时间筛选

  • 测试结果列表新增筛选下拉框,支持预设档位(≤0.5s / ≤1s / ≤2s / ≤5s / ≤10s / 自定义)
  • 筛选与搜索关键词联动,测试中或未测试的模型不受筛选影响
  • 筛选结果与"选择符合条件的模型"按钮联动

i18n

  • default 和 classic 两套前端的 en/zh/fr/ja/ru/vi 六个语种均已补充翻译

🚀 变更类型 / Type of change

  • ✨ 新功能 (New feature)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 Issues 与 PRs,确认不是重复提交。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过手动验证。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

纯前端功能

经典前端

image image image image image

新版前端

image image image image image

Summary by CodeRabbit

  • New Features
    • Added configurable channel/model test timeout (seconds) and response-time filtering, including a custom maximum, with new “fitting models” selection based on the chosen response-time criteria.
  • Bug Fixes
    • Improved in-flight test cancellation/timeout handling with clearer timeout/cancel messaging and more reliable cleanup during modal close and stop actions.
  • Documentation
    • Added localized UI strings for the new timeout/response-time controls, timeout/cancel status, “no matching models,” and quality/latency rating labels across multiple languages.

Hermes Bot added 2 commits July 1, 2026 01:23
- 新增测试超时时间设置(默认 10 秒),超时自动 abort 请求并标记失败
- 新增响应时间筛选下拉(≤0.5s/1s/2s/5s/10s/自定义),测试列表可按延迟过滤
- 将"全选成功模型"改为"选择符合条件的模型",与响应时间筛选联动
- 测试请求支持 AbortController 信号透传,批量测试停止时同步取消当前请求
- 同时适配 default 和 classic 两个前端主题
- 将7个新增key从JSON根级别移入translation命名空间内
- 原提交将key放在了translation兄弟节点导致t()无法匹配
- 为fr/ja/ru/vi四个语种补充完整翻译
- 移除多余的逗号空行使格式与项目风格一致
@coderabbitai

coderabbitai Bot commented Jul 1, 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 timeout-based cancellation and response-time filtering to classic and default channel test flows, plus matching locale strings for the new controls and result states.

Changes

Channel test timeout and filtering

Layer / File(s) Summary
Classic test flow
web/classic/src/hooks/channels/useChannelsData.jsx, web/classic/src/components/table/channels/modals/ModelTestModal.jsx
Adds timeout and response-time filter state, abort-controller request handling, timeout/cancel result updates, response-time-based filtering and selection, and new modal controls.
Classic locale strings
web/classic/src/i18n/locales/{en,fr,ja,ru,vi,zh-CN,zh-TW}.json
Adds translations for timeout, response-time filter, cancellation, no-match, and rating labels.
Default API signal propagation
web/default/src/features/channels/api.ts, web/default/src/features/channels/lib/channel-actions.ts
Passes an optional AbortSignal through the channel test API and action layer.
Default test dialog
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Adds timeout and response-time filter state, request cancellation, timeout handling, response-time-based filtering, fitting-model selection, batch-stop aborts, and new dialog controls.
Default locale strings
web/default/src/i18n/locales/{en,fr,ja,ru,vi,zh}.json
Adds translations for response-time tiers and timeout/filtering messages.

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

Possibly related issues

Possibly related PRs

  • QuantumNous/new-api#5517: Updates channel test response handling by adding or normalizing timing data used here for response-time filtering.
  • QuantumNous/new-api#5532: Touches the same default channel test dialog batch testing and stop behavior, plus shared test-state handling.
  • QuantumNous/new-api#4988: Modifies the default channel test dialog’s result-handling UI in the same component.

Suggested reviewers: creamlike1024, xyfacai

Poem

I’m a bunny with a timer bright,
Filtering models left and right.
If tests are slow, I hop away,
And keep the fitting ones in play. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要改动:为渠道模型测试增加超时设置和响应时间筛选。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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: 4

🧹 Nitpick comments (1)
web/classic/src/components/table/channels/modals/ModelTestModal.jsx (1)

152-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate response-time filtering logic between filteredModels and fittingModels.

The threshold-resolution and filter block (maxMs computation + filtering) is duplicated almost verbatim across both IIFEs, and the two already diverge subtly (this block folds the "must have succeeded" check into the time filter, while fittingModels applies it as a separate upstream .filter()). Extracting a shared helper (e.g. getResponseTimeThresholdMs(filter, customSec) and a reusable predicate) would reduce the risk of further divergence.

🤖 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/classic/src/components/table/channels/modals/ModelTestModal.jsx` around
lines 152 - 180, The response-time threshold calculation and filtering logic are
duplicated between the model list builders, and the two paths are already
drifting apart. Extract the shared `maxMs` resolution and time-based predicate
into a reusable helper used by both the `filteredModels` and `fittingModels`
IIFEs in `ModelTestModal`, so both flows apply the same rules consistently and
avoid future divergence.
🤖 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/features/channels/api.ts`:
- Around line 212-222: The new AbortSignal handling in testChannel is being lost
because api.get deduplicates in-flight GETs by URL and params only, so
overlapping channel tests can share one request created with another caller’s
signal. Update the testChannel flow (and/or the api.get dedup path in
web/default/src/lib/api.ts) so cancellable test requests are not deduped, or
include abortability in the cache key and request creation. Ensure each
testChannel call gets its own axios request when a signal is present, so
aborting one caller’s AbortController actually cancels that specific test.

In
`@web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`:
- Around line 217-225: The response-time filter labels in
RESPONSE_TIME_FILTER_OPTIONS are using t(option.label) but the threshold strings
have no matching locale keys, so add flat JSON entries for each composite label
in the locale files for fr/ja/ru/vi. Use the exact English source strings as
keys, alongside the existing All and Custom entries, so the dropdown renders
translated labels instead of falling back to English.
- Around line 1140-1152: The timeout input in channel-test-dialog.tsx is fully
controlled by testTimeoutMs / 1000, but the current onChange only updates when
the parsed value is >= 1, which makes the field impossible to clear or edit
intermediate values. Update the timeout handling in the channel-test-dialog
component to support a transient empty/string state while typing, and only
clamp/normalize the value when committing it (for example on blur) in the
timeout input logic around the Input for test-timeout and setTestTimeoutMs.
- Around line 1157-1176: The "Response time filter" form label is not associated
with its select control, unlike the nearby Endpoint Type field. Update the Label
and SelectTrigger in channel-test-dialog.tsx so the Label uses an htmlFor tied
to a stable id on the SelectTrigger, following the same association pattern used
by the existing labeled fields in this component.

---

Nitpick comments:
In `@web/classic/src/components/table/channels/modals/ModelTestModal.jsx`:
- Around line 152-180: The response-time threshold calculation and filtering
logic are duplicated between the model list builders, and the two paths are
already drifting apart. Extract the shared `maxMs` resolution and time-based
predicate into a reusable helper used by both the `filteredModels` and
`fittingModels` IIFEs in `ModelTestModal`, so both flows apply the same rules
consistently and avoid future divergence.
🪄 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: d7621c65-9219-498b-a43c-903ceff51d2e

📥 Commits

Reviewing files that changed from the base of the PR and between 52858ad and 95ea6da.

📒 Files selected for processing (18)
  • web/classic/src/components/table/channels/modals/ModelTestModal.jsx
  • web/classic/src/hooks/channels/useChannelsData.jsx
  • web/classic/src/i18n/locales/en.json
  • web/classic/src/i18n/locales/fr.json
  • web/classic/src/i18n/locales/ja.json
  • web/classic/src/i18n/locales/ru.json
  • web/classic/src/i18n/locales/vi.json
  • web/classic/src/i18n/locales/zh-CN.json
  • web/classic/src/i18n/locales/zh-TW.json
  • web/default/src/features/channels/api.ts
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/channels/lib/channel-actions.ts
  • 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

Comment thread web/default/src/features/channels/api.ts
Comment on lines +217 to +225
const RESPONSE_TIME_FILTER_OPTIONS: ResponseTimeFilterOption[] = [
{ value: 'all', label: 'All' },
{ value: String(RESPONSE_TIME_THRESHOLDS.EXCELLENT), label: '<=0.5s (Excellent)' },
{ value: String(RESPONSE_TIME_THRESHOLDS.GOOD), label: '<=1s (Good)' },
{ value: String(RESPONSE_TIME_THRESHOLDS.FAIR), label: '<=2s (Fair)' },
{ value: String(RESPONSE_TIME_THRESHOLDS.POOR), label: '<=5s (Poor)' },
{ value: '10000', label: '<=10s' },
{ value: 'custom', label: 'Custom' },
]

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add locale entries for the response-time filter option labels.

The threshold labels (<=0.5s (Excellent), <=1s (Good), <=2s (Fair), <=5s (Poor), <=10s) are rendered via t(option.label) at Line 1171 but have no matching keys in the locale files (only All and Custom exist). For fr/ja/ru/vi these will fall back to English, leaving the dropdown untranslated.

As per path instructions ("Use flat JSON locale files at web/default/src/i18n/locales/{lang}.json with English source strings as keys"), add these five composite strings to each locale file.

🤖 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 217 - 225, The response-time filter labels in
RESPONSE_TIME_FILTER_OPTIONS are using t(option.label) but the threshold strings
have no matching locale keys, so add flat JSON entries for each composite label
in the locale files for fr/ja/ru/vi. Use the exact English source strings as
keys, alongside the existing All and Custom entries, so the dropdown renders
translated labels instead of falling back to English.

Source: Path instructions

Hermes Bot and others added 4 commits July 2, 2026 02:43
… test dialog

The channel-test-dialog response time filter dropdown options (<=0.5s, <=1s,
<=2s, <=5s, <=10s) used hardcoded English labels as i18n keys but these keys
did not exist in any locale file, so the labels always displayed in English
regardless of the selected language.

Add the 5 missing keys to en.json and provide translations for zh, ja, fr, ru,
vi matching the classic frontend's Chinese labels (优秀/良好/一般/较差).

Co-Authored-By: Claude <noreply@anthropic.com>
- api.get的dedup机制按URL+params缓存Promise,忽略signal参数
- 同一渠道同一模型并发测试时共用同一个请求,一方abort会导致另一方也失败
- 参照getCodexUsage等接口做法,添加disableDuplicate: true绕过dedup
- 超时输入框改用timeoutInputValue字符串状态,支持清空和编辑中间值,失焦时自动归位到有效值
- Response time filter标签添加htmlFor与SelectTrigger的id关联,修复无障碍问题
- 提取getResponseTimeThresholdMs公共函数,消除filteredModels和fittingModels中重复的maxMs计算逻辑
- 提取getResponseTimeThresholdMs函数统一处理自定义和预设阈值转换
- fittingModels改为从filteredModels派生,不再独立重复过滤搜索关键词和成功状态
- 当响应时间筛选激活时,filteredModels已包含完整过滤,fittingModels直接复用
@bonaluo
bonaluo force-pushed the feat/channel-test-timeout-filter branch from 4eee790 to 1f80a33 Compare July 3, 2026 18:07
- filteredModels中保留无测试结果和正在测试的模型,仅过滤已失败和超时模型
- fittingModels统一使用success过滤,移除responseTimeFilter条件分支
- 与新版前端channel-test-dialog行为保持一致

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
web/classic/src/components/table/channels/modals/ModelTestModal.jsx (2)

426-432: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reset the table page when the response-time filter changes.

Search input resets modelTablePage to 1 (Line 386), but changing responseTimeFilter does not. When the new filter shrinks filteredModels below the current page's range, the table renders an empty page until the user manually navigates back.

🐛 Proposed fix
               <Select
                 value={responseTimeFilter}
-                onChange={(v) => { if (v !== null) setResponseTimeFilter(v); }}
+                onChange={(v) => {
+                  if (v !== null) {
+                    setResponseTimeFilter(v);
+                    setModelTablePage(1);
+                  }
+                }}
                 optionList={RESPONSE_TIME_FILTER_OPTIONS}
                 className='!w-44'
                 placeholder={t('全部')}
               />
🤖 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/classic/src/components/table/channels/modals/ModelTestModal.jsx` around
lines 426 - 432, The response-time filter change in ModelTestModal should also
reset the table pagination to the first page, just like the search input does.
Update the Select onChange handler for responseTimeFilter so it also sets
modelTablePage back to 1 whenever a new filter value is chosen, using the same
state pattern already used in the search logic.

320-331: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep the batch-test count aligned with the queued models. The button uses filteredModels.length, but batchTestModels only filters by modelSearchKeyword in useChannelsData.jsx and ignores responseTimeFilter. With a response-time filter active, the label can undercount what will actually be re-tested. Either derive the label from the batch-test list or apply the same filter in batchTestModels.

🤖 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/classic/src/components/table/channels/modals/ModelTestModal.jsx` around
lines 320 - 331, The batch-test button label is using filteredModels.length, but
the actual batch queue in batchTestModels does not honor the same
responseTimeFilter logic as useChannelsData.jsx. Update ModelTestModal’s label
source to reflect the real queued models, or make batchTestModels apply the same
filtering criteria so the displayed count matches what will be tested.
🤖 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.

Outside diff comments:
In `@web/classic/src/components/table/channels/modals/ModelTestModal.jsx`:
- Around line 426-432: The response-time filter change in ModelTestModal should
also reset the table pagination to the first page, just like the search input
does. Update the Select onChange handler for responseTimeFilter so it also sets
modelTablePage back to 1 whenever a new filter value is chosen, using the same
state pattern already used in the search logic.
- Around line 320-331: The batch-test button label is using
filteredModels.length, but the actual batch queue in batchTestModels does not
honor the same responseTimeFilter logic as useChannelsData.jsx. Update
ModelTestModal’s label source to reflect the real queued models, or make
batchTestModels apply the same filtering criteria so the displayed count matches
what will be tested.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 57e68691-cf79-48f4-a35f-21a2f5b99778

📥 Commits

Reviewing files that changed from the base of the PR and between 1f80a33 and 7577da3.

📒 Files selected for processing (1)
  • web/classic/src/components/table/channels/modals/ModelTestModal.jsx

Hermes Bot added 2 commits July 5, 2026 04:10
- 7 个经典版 i18n locale 文件采用 HEAD 版本(已包含上游所有 key)
- channel-test-dialog 移除 BatchProgressSummary 内联进度(上游改用 toast)
- 保留超时设置和响应时间筛选功能,与上游重构后的代码兼容
- Select onChange 切换响应时间筛选时重置 modelTablePage 为 1,避免表格显示空白页
- batchTestModels 在关键词过滤后增加与 filteredModels 一致的响应时间筛选逻辑,
  确保批量测试按钮显示的数量与实际测试的模型一致
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