feat: 渠道模型测试增加超时设置与响应时间筛选功能 - #5844
Conversation
- 新增测试超时时间设置(默认 10 秒),超时自动 abort 请求并标记失败 - 新增响应时间筛选下拉(≤0.5s/1s/2s/5s/10s/自定义),测试列表可按延迟过滤 - 将"全选成功模型"改为"选择符合条件的模型",与响应时间筛选联动 - 测试请求支持 AbortController 信号透传,批量测试停止时同步取消当前请求 - 同时适配 default 和 classic 两个前端主题
- 将7个新增key从JSON根级别移入translation命名空间内 - 原提交将key放在了translation兄弟节点导致t()无法匹配 - 为fr/ja/ru/vi四个语种补充完整翻译 - 移除多余的逗号空行使格式与项目风格一致
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds 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. ChangesChannel test timeout and filtering
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
web/classic/src/components/table/channels/modals/ModelTestModal.jsx (1)
152-180: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDuplicate response-time filtering logic between
filteredModelsandfittingModels.The threshold-resolution and filter block (
maxMscomputation + 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, whilefittingModelsapplies 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
📒 Files selected for processing (18)
web/classic/src/components/table/channels/modals/ModelTestModal.jsxweb/classic/src/hooks/channels/useChannelsData.jsxweb/classic/src/i18n/locales/en.jsonweb/classic/src/i18n/locales/fr.jsonweb/classic/src/i18n/locales/ja.jsonweb/classic/src/i18n/locales/ru.jsonweb/classic/src/i18n/locales/vi.jsonweb/classic/src/i18n/locales/zh-CN.jsonweb/classic/src/i18n/locales/zh-TW.jsonweb/default/src/features/channels/api.tsweb/default/src/features/channels/components/dialogs/channel-test-dialog.tsxweb/default/src/features/channels/lib/channel-actions.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
| 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' }, | ||
| ] |
There was a problem hiding this comment.
📐 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
… 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直接复用
4eee790 to
1f80a33
Compare
- filteredModels中保留无测试结果和正在测试的模型,仅过滤已失败和超时模型 - fittingModels统一使用success过滤,移除responseTimeFilter条件分支 - 与新版前端channel-test-dialog行为保持一致
There was a problem hiding this comment.
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 winReset the table page when the response-time filter changes.
Search input resets
modelTablePageto 1 (Line 386), but changingresponseTimeFilterdoes not. When the new filter shrinksfilteredModelsbelow 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 winKeep the batch-test count aligned with the queued models. The button uses
filteredModels.length, butbatchTestModelsonly filters bymodelSearchKeywordinuseChannelsData.jsxand ignoresresponseTimeFilter. 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 inbatchTestModels.🤖 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
📒 Files selected for processing (1)
web/classic/src/components/table/channels/modals/ModelTestModal.jsx
- 7 个经典版 i18n locale 文件采用 HEAD 版本(已包含上游所有 key) - channel-test-dialog 移除 BatchProgressSummary 内联进度(上游改用 toast) - 保留超时设置和响应时间筛选功能,与上游重构后的代码兼容
- Select onChange 切换响应时间筛选时重置 modelTablePage 为 1,避免表格显示空白页 - batchTestModels 在关键词过滤后增加与 filteredModels 一致的响应时间筛选逻辑, 确保批量测试按钮显示的数量与实际测试的模型一致
📝 变更描述 / Description
功能概述
渠道模型测试弹窗增加测试超时控制与响应时间筛选功能,同时适配 default 和 classic 两套前端。
具体变更
测试超时控制
响应时间筛选
i18n
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
📸 运行证明 / Proof of Work
纯前端功能
经典前端
新版前端
Summary by CodeRabbit