perf(model-pricing): optimize upstream price sync tables - #6092
Conversation
- batch select and unselect operations into single state updates to reduce lag with large model lists. - align current price and upstream preset rows by rendering the same ordered field set. - switch the table to a fixed header, internal body scrolling, and fixed pagination layout with compact upstream header counts. - hide synthesized preset internal IDs and count only effective selectable resolutions.
- keep input focus and invalid rings inside the shared Input component to avoid clipping in constrained containers. - make the sync channel selector table use a fixed header, internal body scrolling, and fixed pagination inside the dialog. - align status cells with their header and translate channel status labels through existing i18n keys.
- remove built-in horizontal padding from status badges so table columns align with headers. - drop legacy negative-margin compensation from badge cells and affected table renderers. - clean touched table components to satisfy lint rules around type imports, keys, and JSX flow.
WalkthroughThe changes standardize badge spacing, improve table and dialog layouts, centralize upstream ratio resolution updates, add bulk synchronization state, and adjust several table-rendering details such as stable React keys and localized labels. ChangesBadge rendering and table alignment
System-settings layouts
Upstream ratio synchronization
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant UpstreamRatioSyncTable
participant UpstreamRatioSync
participant ResolutionHelpers
Operator->>UpstreamRatioSyncTable: select or unselect upstream values
UpstreamRatioSyncTable->>UpstreamRatioSync: submit selections or removal plan
UpstreamRatioSync->>ResolutionHelpers: apply resolution changes
ResolutionHelpers-->>UpstreamRatioSync: return updated resolutions
UpstreamRatioSync-->>UpstreamRatioSyncTable: update table state
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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: 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/system-settings/models/channel-selector-dialog.tsx`:
- Around line 238-242: Localize the endpoint labels in the Select built from
ENDPOINT_OPTIONS by replacing raw display strings with the appropriate i18n
translation keys and resolving them through the existing localization mechanism.
Add matching entries for pricing, ratio_config, OpenRouter, and custom to every
required locale.
🪄 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: 0059537e-7b63-45b8-abf6-8765cd19a847
📒 Files selected for processing (27)
web/default/src/components/data-table/core/badge-cell.tsxweb/default/src/components/data-table/core/badge-list-cell.tsxweb/default/src/components/data-table/layout/card-row-content.tsxweb/default/src/components/provider-badge.tsxweb/default/src/components/status-badge.tsxweb/default/src/components/ui/input.tsxweb/default/src/features/channels/components/channel-card.tsxweb/default/src/features/channels/components/channels-columns.tsxweb/default/src/features/keys/components/api-keys-cells.tsxweb/default/src/features/keys/components/api-keys-columns.tsxweb/default/src/features/models/components/deployments-columns.tsxweb/default/src/features/models/components/models-columns.tsxweb/default/src/features/pricing/components/pricing-columns.tsxweb/default/src/features/redemption-codes/components/redemptions-columns.tsxweb/default/src/features/subscriptions/components/subscriptions-columns.tsxweb/default/src/features/system-settings/components/settings-page.tsxweb/default/src/features/system-settings/models/channel-selector-dialog.tsxweb/default/src/features/system-settings/models/constants.tsweb/default/src/features/system-settings/models/model-ratio-table-columns.tsxweb/default/src/features/system-settings/models/ratio-settings-card.tsxweb/default/src/features/system-settings/models/upstream-ratio-sync-columns.tsxweb/default/src/features/system-settings/models/upstream-ratio-sync-helpers.tsweb/default/src/features/system-settings/models/upstream-ratio-sync-table.tsxweb/default/src/features/system-settings/models/upstream-ratio-sync.tsxweb/default/src/features/usage-logs/components/columns/drawing-logs-columns.tsxweb/default/src/features/usage-logs/components/columns/task-logs-columns.tsxweb/default/src/features/users/components/users-columns.tsx
💤 Files with no reviewable changes (4)
- web/default/src/features/pricing/components/pricing-columns.tsx
- web/default/src/features/usage-logs/components/columns/drawing-logs-columns.tsx
- web/default/src/features/usage-logs/components/columns/task-logs-columns.tsx
- web/default/src/features/system-settings/models/model-ratio-table-columns.tsx
| <Select | ||
| items={[ | ||
| ...ENDPOINT_OPTIONS.map((option) => ({ | ||
| value: option.value, | ||
| label: option.label, | ||
| })), | ||
| ]} | ||
| items={ENDPOINT_OPTIONS.map((option) => ({ | ||
| value: option.value, | ||
| label: option.label, | ||
| }))} |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -nP -C3 'ENDPOINT_OPTIONS' web/default/src/features/system-settings/models/Repository: QuantumNous/new-api
Length of output: 4088
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,120p' web/default/src/features/system-settings/models/constants.ts
printf '\n--- upstream-ratio-sync-table.tsx ---\n'
rg -n -C3 't\\(|ENDPOINT_OPTIONS|SelectItem|Select' web/default/src/features/system-settings -g 'upstream-ratio-sync-table.tsx' -g 'channel-selector-dialog.tsx'Repository: QuantumNous/new-api
Length of output: 3776
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,220p' web/default/src/features/system-settings/models/upstream-ratio-sync-table.tsx
printf '\n--- translation usage in feature ---\n'
rg -n -C2 "useTranslation\\(|t\\(" web/default/src/features/system-settings/models -g '*.tsx' -g '*.ts'Repository: QuantumNous/new-api
Length of output: 50376
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- endpoint labels in translations ---'
rg -n '"(pricing|ratio_config|OpenRouter|custom)"' web/default/src -g '*.json' -g '*.ts' -g '*.tsx' || true
printf '\n%s\n' '--- endpoint option usages ---'
rg -n -C2 'ENDPOINT_OPTIONS|option\.label|t\(option\.label\)' web/default/src/features/system-settings/models -g '*.ts' -g '*.tsx'Repository: QuantumNous/new-api
Length of output: 6391
Localize the endpoint labels. ENDPOINT_OPTIONS uses raw display strings (pricing, ratio_config, OpenRouter, custom), so this select renders English-only. Switch these to i18n keys here and add the matching locale entries.
🤖 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/system-settings/models/channel-selector-dialog.tsx`
around lines 238 - 242, Localize the endpoint labels in the Select built from
ENDPOINT_OPTIONS by replacing raw display strings with the appropriate i18n
translation keys and resolving them through the existing localization mechanism.
Add matching entries for pricing, ratio_config, OpenRouter, and custom to every
required locale.
Sources: Coding guidelines, Path instructions
…#6092) Merge pull request QuantumNous#6092 from QuantumNous/perf/model-pricing-sync-table
…#6092) Merge pull request QuantumNous#6092 from QuantumNous/perf/model-pricing-sync-table
…#6092) Merge pull request QuantumNous#6092 from QuantumNous/perf/model-pricing-sync-table
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
概述
改动说明
效果
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
before

after

Summary by CodeRabbit