Skip to content

perf(web): refine channel test dialog interactions - #5886

Merged
t0ng7u merged 2 commits into
mainfrom
perf/channel-test-dialog-layout
Jul 3, 2026
Merged

perf(web): refine channel test dialog interactions#5886
t0ng7u merged 2 commits into
mainfrom
perf/channel-test-dialog-layout

Conversation

@QuentinHsu

@QuentinHsu QuentinHsu commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。
  • 本次代码由 AI 辅助生成,并已人工整理与复核。

📝 变更描述 / Description

优化渠道测试弹窗的模型测试结果展示与操作布局。模型测试状态和测试结果拆分为独立列,失败摘要、详情入口和响应耗时不再挤在状态列中;批量测试进度改为 toast 更新,避免测试开始和结束时改变弹窗高度;标题、顶部操作区和行内测试按钮也做了压缩整理,让整体布局更稳定。

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

  • bunx oxfmt --check src/features/channels/components/dialogs/channel-test-dialog.tsx

  • bunx oxlint -c .oxlintrc.json src/features/channels/components/dialogs/channel-test-dialog.tsx

  • git diff --check

  • before
    CleanShot 2026-07-03 at 23 45 38

  • after
    CleanShot 2026-07-03 at 23 46 22

Summary by CodeRabbit

  • UI Improvements

    • Refined the channel batch test dialog layout, including updated table sizing, toolbar arrangement, and simpler header/footer content.
    • Reworked the per-channel test action into a compact icon button with clearer loading and testing states.
  • Bug Fixes

    • Improved batch test progress handling so loading indicators dismiss correctly when testing finishes or stops.
    • Better handles channel model lists by removing duplicates and trimming entries.
    • Updated status and result displays for clearer success, idle, and failure presentation.

- split model test status from result details so failures and latency no longer crowd one column.
- move batch progress into toast updates to keep the dialog height stable during tests.
- consolidate the channel title and model actions to reduce vertical churn.
- replace per-model test text buttons with icon-only actions matching the channel list.
- let the action column shrink to its icon content to reduce table width.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Refactors the channel batch-test dialog UI and behavior: import formatting, error normalization using replaceAll, a persistent toast.loading for batch progress replacing the progress bar, adjusted column sizing, restructured status/result cell rendering, redesigned per-row action button, and reorganized header/footer/toolbar layout.

Changes

Channel test dialog refactor

Layer / File(s) Summary
Import cleanup and error normalization
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Reformats icon/type imports, removes unused Progress import, and switches inline error normalization from replace to replaceAll.
Batch progress toast lifecycle
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Adds batchProgressToastIdRef and dismissBatchProgressToast, effects to show/update a persistent toast.loading during batch progress and dismiss it on completion/stop, updated unique-model dedup via Set, and expanded hook dependencies.
Table column sizing and cell rendering
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Updates column width classes and colgroup widths, wires status/result columns to TestStatusCell/TestResultCell, refactors status/result rendering for idle/testing/success/error states (often returning -), and restyles FailureStatusContent.
Dialog header/footer and toolbar redesign
web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
Replaces per-row test button with a tooltip-wrapped icon button, simplifies header/footer markup, reorganizes the Channel models toolbar buttons, and adjusts the model filter wrapper layout.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • QuantumNous/new-api#1819: Batch-test dialog toast/progress behavior coordinates with hook-level batch testing flow changes (batchTestModels, concurrency/cancellation).
  • QuantumNous/new-api#5517: Both PRs modify testing status cell/loading indicators and batch test flow within the same dialog component.
  • QuantumNous/new-api#5532: Both PRs modify batch testing dedup/model list handling and progress/completion behavior in the same component.

Suggested reviewers: creamlike1024, xyfacai, seefs001

Poem

A rabbit clicks "test" with a gleeful hop,
Toasts now linger till the batch will stop.
Icons spin where badges used to be,
Columns trimmed as neat as can be.
Thump thump — ship it, then back to my carrot patch! 🥕🐇

🚥 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 The title is concise and accurately reflects the main channel test dialog interaction and layout refinements.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/channel-test-dialog-layout

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

🤖 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/components/dialogs/channel-test-dialog.tsx`:
- Around line 367-399: The batch progress toast in channel-test-dialog should
stay visible for the full batch run instead of inheriting the default
auto-dismiss timeout. Update the toast.loading call inside the batch progress
useEffect so it explicitly uses an infinite duration, while keeping the existing
dismissBatchProgressToast cleanup and toast id reuse logic intact. Use the
batchProgressToastIdRef, dismissBatchProgressToast, and toast.loading references
to locate the change.
🪄 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: c1f2aeb3-da17-41f8-9fea-249d48c7c1a5

📥 Commits

Reviewing files that changed from the base of the PR and between 917a2cf and c5600f9.

📒 Files selected for processing (1)
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx

Comment on lines +367 to +399
const dismissBatchProgressToast = useCallback(() => {
if (batchProgressToastIdRef.current === null) return

toast.dismiss(batchProgressToastIdRef.current)
batchProgressToastIdRef.current = null
}, [])

useEffect(() => {
if (!batchProgress) {
dismissBatchProgressToast()
return
}

const title = isBatchStopRequested
? t('Stopping batch test...')
: t('Batch testing models...')
const completedText = t('{{completed}}/{{total}} completed', {
completed: batchProgress.completed,
total: batchProgress.total,
})
const resultText = t('{{success}} succeeded, {{failed}} failed', {
success: batchProgress.success,
failed: batchProgress.failed,
})

batchProgressToastIdRef.current = toast.loading(title, {
id: batchProgressToastIdRef.current ?? undefined,
description: `${completedText} · ${resultText}`,
})
}, [batchProgress, dismissBatchProgressToast, isBatchStopRequested, t])

useEffect(() => dismissBatchProgressToast, [dismissBatchProgressToast])

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

sonner toast.loading default duration Infinity vs Toaster duration prop

💡 Result:

In Sonner, the duration prop on the <Toaster /> component sets the default global duration for all toasts, while setting duration: Infinity on an individual toast() call (including toast.loading) is the recommended way to keep a specific toast visible indefinitely until it is manually dismissed or updated [1][2][3]. Key distinctions and technical details: 1. Global vs. Local Duration: The <Toaster /> duration prop (default 4000ms) establishes the automatic dismissal time for all toasts that do not have an explicit duration set [4][5][3]. Individual toast calls override this global setting [3]. 2. Using Infinity: Setting duration: Infinity on a toast (e.g., toast.loading('Loading...', { duration: Infinity })) effectively disables the automatic close timer [6][1][2]. Internally, Sonner includes logic to check for this value to avoid calling setTimeout with Infinity, which would otherwise cause the toast to close immediately [6][7]. 3. Common Patterns: For loading states, it is common practice to set duration: Infinity so the toast remains on screen until the associated asynchronous operation completes. Once finished, you can update the toast by referencing its ID (returned by toast.loading) and calling toast.success or toast.error with a standard duration to allow the final message to dismiss automatically [1][8]. Note: If you encounter issues where duration: Infinity causes a toast not to render, ensure you are using a compatible version of the library, as earlier versions had reported bugs regarding infinite timers [7][9].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Toaster config ==\n'
ast-grep outline web/default/src/routes/__root.tsx --view expanded || true
printf '\n-- relevant lines --\n'
sed -n '1,140p' web/default/src/routes/__root.tsx | cat -n

printf '\n== batch progress toast callsite ==\n'
sed -n '340,430p' web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx | cat -n

printf '\n== sonner dependency version ==\n'
if [ -f package.json ]; then
  rg -n '"sonner"|sonner@' package.json bun.lock* pnpm-lock.yaml package-lock.json yarn.lock -S || true
fi

Repository: QuantumNous/new-api

Length of output: 9199


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Sonner wrapper ==\n'
fd -a 'sonner.tsx' web/default/src/components web/default/src -t f || true
fd -a 'sonner.ts' web/default/src/components web/default/src -t f || true
for f in $(fd -a 'sonner.*' web/default/src -t f); do
  echo "--- $f ---"
  sed -n '1,200p' "$f" | cat -n
done

printf '\n== batch test cadence / delay constants ==\n'
rg -n 'BATCH_TEST_DELAY_MS|batchProgress|setBatchProgress|toast\.loading|toast\.dismiss|isBatchStopRequested' web/default/src/features/channels -S

printf '\n== surrounding batch test logic ==\n'
sed -n '220,420p' web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx | cat -n

Repository: QuantumNous/new-api

Length of output: 14943


🌐 Web query:

Sonner toast.loading default duration loading toasts inherit Toaster duration or Infinity

💡 Result:

In Sonner, a toast.loading call does not automatically default to Infinity [1][2]. It inherits the default duration set on the <Toaster /> component (which is 4000ms by default) [3][4][1]. If you want a toast.loading toast to stay visible indefinitely until you manually update or dismiss it, you must explicitly set the duration to Infinity [1][2]: javascript toast.loading("Loading...", { duration: Infinity }); This behavior is by design [1]. Because toast.loading follows the standard toast lifecycle, it will automatically close after the set duration unless duration: Infinity is provided or the toast is updated (e.g., replaced by a toast.success or toast.error using the same ID) [1][2].

Citations:


Keep the batch progress toast visible until the batch finishes web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx:392
toast.loading inherits the global duration={5000} here, so this progress toast can disappear mid-run between updates. Pass duration: Infinity to keep it on screen until it’s dismissed or replaced.

🤖 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 367 - 399, The batch progress toast in channel-test-dialog should
stay visible for the full batch run instead of inheriting the default
auto-dismiss timeout. Update the toast.loading call inside the batch progress
useEffect so it explicitly uses an infinite duration, while keeping the existing
dismissBatchProgressToast cleanup and toast id reuse logic intact. Use the
batchProgressToastIdRef, dismissBatchProgressToast, and toast.loading references
to locate the change.

@t0ng7u t0ng7u self-assigned this Jul 3, 2026
@t0ng7u
t0ng7u merged commit b6e8ff9 into main Jul 3, 2026
2 checks passed
Jacobinwwey pushed a commit to Jacobinwwey/new-api that referenced this pull request Jul 11, 2026
Merge pull request QuantumNous#5886 from QuantumNous/perf/channel-test-dialog-layout
@Calcium-Ion
Calcium-Ion deleted the perf/channel-test-dialog-layout branch July 21, 2026 06:46
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
Merge pull request QuantumNous#5886 from QuantumNous/perf/channel-test-dialog-layout
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
Merge pull request QuantumNous#5886 from QuantumNous/perf/channel-test-dialog-layout
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