Skip to content

fix(channels): refresh channel test dialog status - #5517

Merged
t0ng7u merged 6 commits into
QuantumNous:mainfrom
yyhhyyyyyy:fix/channel-test-dialog-status-refresh
Jun 15, 2026
Merged

fix(channels): refresh channel test dialog status#5517
t0ng7u merged 6 commits into
QuantumNous:mainfrom
yyhhyyyyyy:fix/channel-test-dialog-status-refresh

Conversation

@yyhhyyyyyy

@yyhhyyyyyy yyhhyyyyyy commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

  • 修复渠道测试弹窗中点击“测试”后状态不刷新、loading 不显示的问题。
  • 同时补齐弹窗测试完成后的渠道列表刷新逻辑,并兼容后端返回的顶层 time 字段,让主列表的响应时间和最后测试时间能及时回填。弹窗内部状态重置也从 useEffect 同步 setState 改为 remount/事件驱动,消除 React hooks lint 报错。

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

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

修改后:
image

Summary by CodeRabbit

Release Notes

  • New Features

    • Added response time tracking for channel tests (including normalized timing support).
  • Improvements

    • Improved data table row rendering performance by accounting for column renderer changes to ensure updates display reliably.
    • Enhanced the channel test dialog with better caching behavior, streamlined refresh after batch runs, and improved streaming enable/disable handling.
    • Refined test pagination and filter handling for more consistent results.
    • Updated table header styling for the split header view.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04be8d28-408d-4a4f-808d-5e036deb1792

📥 Commits

Reviewing files that changed from the base of the PR and between 2448877 and 426c966.

📒 Files selected for processing (1)
  • web/default/src/components/data-table/core/data-table-row.tsx

Walkthrough

Two independent areas are modified: the generic DataTableRow component gains a cellRenderColumns prop added to the React.memo equality check so column definition changes trigger re-renders, and the channel test dialog is refactored to support streaming-disabled endpoint types, a ChannelTestCachePatch system for React Query cache updates, response time normalization from multiple fields, and deferred single-refresh after batch testing.

Changes

DataTable cellRenderColumns Memo Prop

Layer / File(s) Summary
DataTableRow prop and memo equality extension
web/default/src/components/data-table/core/data-table-row.tsx
Adds optional cellRenderColumns typed from TanStack Table['options']['columns'] to DataTableRowProps, destructures it in DataTableRowInner, and includes it in the React.memo comparator alongside existing row identity and selection checks.
DataTableView wiring and header selector update
web/default/src/components/data-table/core/data-table-view.tsx
Passes props.table.options.columns as cellRenderColumns to DataTableRow in renderDefaultRow, and updates the split-header Tailwind selector from &\_[data-slot=table-header] to the **:data-[slot=table-header]/bg-(--table-header-bg) variant.

Channel Test: Cache Patching, Streaming Control, and Response Time

Layer / File(s) Summary
ChannelTestResponse type and response time normalization
web/default/src/features/channels/types.ts, web/default/src/features/channels/lib/channel-actions.ts
Adds optional time?: number to ChannelTestResponse. Introduces getChannelTestResponseTime helper that reads from either response.data.response_time or response.time (rounded to ms), and threads the result into onTestComplete for both success and failure paths.
ChannelTestCachePatch helpers and dialog initialization
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Defines the internal ChannelTestCachePatch type and helpers that convert test outcomes to patches and select the latest patch from multiple model results. Refactors ChannelTestDialog to read currentRow from useChannels internally and initializes ChannelTestDialogContent with useQueryClient and channelId.
Dialog stream control and search/endpoint handlers
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Computes streamDisabled and effectiveStreamTest based on endpoint type. Adds handleEndpointTypeChange to auto-disable streaming for incompatible types and handleSearchTermChange that resets pagination. Removes the old pagination-reset useEffect.
Single and batch test execution with cache updates
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Implements updateChannelTestCache (setQueryData with response_time/test_time) and refreshChannelLists (invalidates channel list queries). Extends testSingleModel with a defer-refresh flag; batch tests defer per-model refreshes and call refreshChannelLists once using the latest resultPatch. Records completedAt on each model result.
UI wiring and loader styling
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Wires handleDialogOpenChange to onOpenChange for centralized state reset, connects handleEndpointTypeChange to the endpoint <Select>, uses effectiveStreamTest in the stream <Switch>, connects handleSearchTermChange to the filter <Input>, and updates spinner class names in the testing cell and bulk toolbar.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ChannelTestDialogContent
  participant testSingleModel
  participant handleTestChannel
  participant updateChannelTestCache
  participant refreshChannelLists
  participant QueryClient

  User->>ChannelTestDialogContent: Start batch test
  loop For each model (deferRefresh=true)
    ChannelTestDialogContent->>testSingleModel: testSingleModel(model, {deferRefresh: true})
    testSingleModel->>handleTestChannel: call with success/error callbacks
    handleTestChannel-->>testSingleModel: onTestComplete(result, responseTime, completedAt)
    testSingleModel->>updateChannelTestCache: patch local cache entry
    updateChannelTestCache->>QueryClient: setQueryData(channelId, response_time, test_time)
  end
  ChannelTestDialogContent->>refreshChannelLists: call with latestPatch (from getLatestPatch)
  refreshChannelLists->>QueryClient: invalidateQueries(channelsQueryKeys)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • QuantumNous/new-api#5460: Both PRs modify the data-table row rendering/memoization by changing web/default/src/components/data-table/core/data-table-row.tsx (React.memo comparator/props) and data-table-view.tsx to pass updated inputs into DataTableRow.

  • QuantumNous/new-api#5524: Both PRs modify web/default/src/components/data-table/core/data-table-row.tsx's React.memo comparator/memoization contract for DataTableRow (main PR adds cellRenderColumns to the comparator; retrieved PR fixes selection by comparing a captured isSelected prop).

  • QuantumNous/new-api#5405: Both PRs modify the shared web/default/src/components/data-table rendering pipeline—main PR extends DataTableRow/DataTableView with a cellRenderColumns prop affecting React.memo comparisons, while retrieved PR refactors/introduces the core DataTableRow/DataTableView infrastructure used for table rendering.

Suggested reviewers

  • seefs001
  • Calcium-Ion

Poem

🐇 Hop hop, the memo now tracks columns too,
No stale renders slip through — the table stays true!
The channel test patches the cache with a flair,
Batch tests refresh once, with precision and care.
Stream disabled? No worries, the endpoint knows best,
This rabbit has tidied the whole testing nest! ✨

🚥 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 directly addresses the main objective of fixing the channel test dialog status refresh, which is the primary issue described in the PR objectives.
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.

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

284-288: 💤 Low value

Props are destructured in the function signature.

Per coding guidelines, component props should be accessed via props.xxx directly rather than destructured. While this is an internal component, consistency with the codebase pattern would improve clarity.

-function ChannelTestDialogContent({
-  open,
-  onOpenChange,
-  currentRow,
-}: ChannelTestDialogContentProps) {
+function ChannelTestDialogContent(
+  props: ChannelTestDialogContentProps
+) {
   const { t } = useTranslation()
   const queryClient = useQueryClient()
-  const currentChannelId = currentRow.id
+  const currentChannelId = props.currentRow.id

Then use props.open, props.onOpenChange, and props.currentRow throughout.

🤖 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 284 - 288, The ChannelTestDialogContent function is destructuring
props in the function signature, but the codebase pattern prefers accessing
props directly. Change the function parameter from destructured props (open,
onOpenChange, currentRow) to accept a single props parameter of type
ChannelTestDialogContentProps, and then update all references throughout the
component to use props.open, props.onOpenChange, and props.currentRow instead of
the destructured variable names.

Source: Coding guidelines

web/default/src/features/channels/lib/channel-actions.ts (1)

55-72: 💤 Low value

Consider aligning the validation logic for both response time sources.

The first path accepts responseTime >= 0 (any finite number), while the fallback path requires response.time > 0. If a response time of exactly 0 is valid from data.response_time, it should arguably also be valid from time (after conversion). This asymmetry could cause the fallback to silently discard a legitimate zero-millisecond result.

If zero is never a valid response time in practice, consider adding && responseTime > 0 to the first condition for consistency; otherwise, relax the second condition to >= 0.

🤖 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/lib/channel-actions.ts` around lines 55 -
72, The validation logic in the getChannelTestResponseTime function is
inconsistent between the two response time sources: the first condition (for
response.data?.response_time) accepts any finite number including 0, while the
second condition (for response.time) explicitly requires response.time > 0. This
asymmetry could cause a valid zero-millisecond response time to be silently
rejected in the fallback path. Determine whether zero is a valid response time
in your domain and align both conditions accordingly: either add && responseTime
> 0 to the first condition if zero should never be valid, or change the second
condition from response.time > 0 to response.time >= 0 if zero is legitimate.
🤖 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
`@web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx`:
- Around line 284-288: The ChannelTestDialogContent function is destructuring
props in the function signature, but the codebase pattern prefers accessing
props directly. Change the function parameter from destructured props (open,
onOpenChange, currentRow) to accept a single props parameter of type
ChannelTestDialogContentProps, and then update all references throughout the
component to use props.open, props.onOpenChange, and props.currentRow instead of
the destructured variable names.

In `@web/default/src/features/channels/lib/channel-actions.ts`:
- Around line 55-72: The validation logic in the getChannelTestResponseTime
function is inconsistent between the two response time sources: the first
condition (for response.data?.response_time) accepts any finite number including
0, while the second condition (for response.time) explicitly requires
response.time > 0. This asymmetry could cause a valid zero-millisecond response
time to be silently rejected in the fallback path. Determine whether zero is a
valid response time in your domain and align both conditions accordingly: either
add && responseTime > 0 to the first condition if zero should never be valid, or
change the second condition from response.time > 0 to response.time >= 0 if zero
is legitimate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ae471fe7-2b21-4940-9c44-489670812639

📥 Commits

Reviewing files that changed from the base of the PR and between 9bc1a53 and 2448877.

📒 Files selected for processing (5)
  • web/default/src/components/data-table/core/data-table-row.tsx
  • web/default/src/components/data-table/core/data-table-view.tsx
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/channels/lib/channel-actions.ts
  • web/default/src/features/channels/types.ts

@t0ng7u
t0ng7u merged commit b36888b into QuantumNous:main Jun 15, 2026
1 check was pending
YeMao11 pushed a commit to YeMao11/new-api that referenced this pull request Jun 16, 2026
Upstream changes (50+ commits, v1.0.0-rc.11):
- data-table perf: row selection memo, column pinning, badge display
- Fixes: channel test dialog (QuantumNous#5517), CC Switch model selector (QuantumNous#5515),
  API key form options (QuantumNous#5512), cell overflow (QuantumNous#5510), kimi k2.6 temp (QuantumNous#5390),
  Anthropic-compatible GLM chunked encoding (QuantumNous#5307), streaming image relay (QuantumNous#4608)
- Feat: audit auth method tracking (QuantumNous#5462), channel affinity clear toggle (QuantumNous#5306),
  relay idle timeout config (QuantumNous#5309), 6-decimal pricing precision (QuantumNous#5332)
- Classic frontend: Rsbuild support, Semi React 19 adapter
- Shared dialog wrapper, JSON code editor, debounce channel search

Conflict resolved: web/bun.lock (accepted upstream, will regenerate)

Co-Authored-By: Claude <noreply@anthropic.com>
YeMao11 pushed a commit to YeMao11/new-api that referenced this pull request Jun 16, 2026
Merge upstream v1.0.0-rc.11 (50+ commits):
- data-table perf: row selection memo, column pinning, badge display
- Fixes: channel test dialog (QuantumNous#5517), CC Switch (QuantumNous#5515), API key (QuantumNous#5512),
  kimi k2.6 temp (QuantumNous#5390), GLM chunked encoding (QuantumNous#5307), streaming image (QuantumNous#4608)
- Feat: audit auth tracking (QuantumNous#5462), channel affinity toggle (QuantumNous#5306),
  relay idle timeout (QuantumNous#5309), 6-decimal pricing (QuantumNous#5332)
- Shared dialog wrapper, JSON code editor, classic Rsbuild support

SEO optimization:
- robots.txt: 10 AI crawler blocks + 22 path disallows + crawl-delay
- sitemap.xml: 7 public URLs with 6-language hreflang annotations
- index.html: hreflang tags, og:locale:alternate, og:image, canonical,
  5 structured data types (Organization, SoftwareApplication, FAQPage,
  WebSite, SearchAction), expanded keywords (gateway, agent router,
  aggregation, orchestration)
- i18n/config.ts: sync <html lang> with active language for SEO

Co-Authored-By: Claude <noreply@anthropic.com>
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
Merge pull request QuantumNous#5517 from yyhhyyyyyy/fix/channel-test-dialog-status-refresh
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
Merge pull request QuantumNous#5517 from yyhhyyyyyy/fix/channel-test-dialog-status-refresh
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