Skip to content

修复:模型定价中无法删除模型、同步渠道弹窗中无法选中渠道、控制台日志中的翻译错误 - #5493

Closed
zhangzhichaolove wants to merge 3 commits into
QuantumNous:mainfrom
zhangzhichaolove:main
Closed

修复:模型定价中无法删除模型、同步渠道弹窗中无法选中渠道、控制台日志中的翻译错误#5493
zhangzhichaolove wants to merge 3 commits into
QuantumNous:mainfrom
zhangzhichaolove:main

Conversation

@zhangzhichaolove

@zhangzhichaolove zhangzhichaolove commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

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

📝 变更描述 / Description

主要修复了3个问题,这些问题是我使用最新代码本地部署时发现,他人可基于最新代码进行复现,具体变更见下面变更类型。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 模型定价列表,单击删除某个模型,无任何反应问题。
  • 🐛 Bug 修复 (Bug fix) - 选择同步渠道弹窗中,复选框点击没有反应问题。
  • 🐛 Bug 修复 (Bug fix) - 控制台很多类似翻译找不到key的日志i18next::translator: missingKey zh-CN translation 主页 主页

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

1.控制台翻译相关错误如下图,已修复。

1

2.模型定价列表,单击删除某个模型,无任何反应,已修复,并增加弹窗二次确认。

2

3.选择同步渠道弹窗中,复选框点击没有反应,已修复。

3

Summary by CodeRabbit

Release Notes

  • New Features

    • Added confirmation dialog when deleting model pricing to prevent accidental deletions.
    • "Save model prices" button now always visible in model settings form.
  • Improvements

    • Enhanced safety when managing model pricing configurations.
    • Updated navigation and footer text rendering.
    • Added comprehensive internationalization support for pricing deletion flows across multiple languages.

Copilot AI review requested due to automatic review settings June 14, 2026 12:15
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds a DeleteButton component with a ConfirmDialog for confirmed deletion of model pricing rows, fixes visual editor draft-over-saved row priority and deleted-draft filtering, makes the Save button always visible in ModelRatioForm, removes t() wrapping from layout link titles in PublicHeader and footer, and drops the React.memo wrapper from DataTableRow.

Changes

Model Ratio Delete Confirmation and Editor Fixes

Layer / File(s) Summary
Delete pricing i18n strings
web/default/src/i18n/locales/en.json, fr.json, ja.json, ru.json, vi.json, zh.json
Adds delete-pricing confirmation prompt (with {{name}} placeholder) and "Delete model pricing" label to all six locale files.
DeleteButton component and table actions column
web/default/src/features/system-settings/models/model-ratio-table-columns.tsx
Introduces DeleteButton with useState-controlled ConfirmDialog; calls onDelete(modelName) only after confirmation. Replaces inline trash button in the actions cell with DeleteButton, fixes edit button to stop propagation, and updates t() type to accept optional interpolation options.
Visual editor draft priority and deleted-row filtering
web/default/src/features/system-settings/models/model-ratio-visual-editor.tsx
Changes displayed row to prefer draft over saved (draft ?? saved), and filters out isDraftDeleted rows before sorting.
Save button always visible
web/default/src/features/system-settings/models/model-ratio-form.tsx
Removes editMode === 'json' condition so the Save model prices button is always rendered, tied to handleSave and isSaving.

Layout Link Title Translation Bypass

Layer / File(s) Summary
Remove t() from footer and public-header link titles
web/default/src/components/layout/components/footer.tsx, public-header.tsx
Footer renders column.title directly. PublicHeader removes t() from authPromptTarget.title and from all desktop and mobile nav link text render paths.

DataTableRow React.memo Removal

Layer / File(s) Summary
Remove React.memo from DataTableRow
web/default/src/components/data-table/core/data-table-row.tsx
DataTableRow becomes a direct alias of DataTableRowInner, removing the custom props comparator and memo-based render skipping.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • QuantumNous/new-api#5275: Modifies the same model-ratio-form.tsx and model-ratio-visual-editor.tsx files, refactoring the visual editor draft commit flow that this PR also touches with draft priority and save-button changes.

Suggested reviewers

  • Calcium-Ion
  • seefs001

Poem

🐇 A rabbit once feared the delete key's might,
Now a dialog asks: "Are you sure this is right?"
The draft takes the lead, the deleted rows flee,
Save buttons stand always, for all modes to see.
No memo confusion — just render it plain!
✨ Confirmation granted, good pricing remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

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.
Title check ⚠️ Warning The PR title is in Chinese and does not clearly communicate the changes to English-speaking developers unfamiliar with the codebase language. Use an English title that clearly summarizes the three main fixes: e.g., 'Fix: model pricing deletion, sync channel selection, and console translation errors'.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds UI support for deleting “model pricing” with localized strings and adjusts model pricing editor/table behaviors.

Changes:

  • Added new i18n strings for “Delete model pricing” and its confirmation prompt across multiple locales.
  • Updated model pricing table UI to show a delete confirmation dialog and prevent row click propagation from action buttons.
  • Adjusted model pricing editor row derivation/filtering and removed memoization from DataTableRow.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
web/default/src/i18n/locales/zh.json Adds Chinese strings for deleting model pricing.
web/default/src/i18n/locales/vi.json Adds Vietnamese strings for deleting model pricing.
web/default/src/i18n/locales/ru.json Adds Russian strings for deleting model pricing.
web/default/src/i18n/locales/ja.json Adds Japanese strings for deleting model pricing.
web/default/src/i18n/locales/fr.json Adds French strings for deleting model pricing.
web/default/src/i18n/locales/en.json Adds English keys/strings for deleting model pricing.
web/default/src/features/system-settings/models/model-ratio-visual-editor.tsx Prefers draft values and filters out draft-deleted rows.
web/default/src/features/system-settings/models/model-ratio-table-columns.tsx Adds confirmation dialog for delete and stops propagation on action buttons.
web/default/src/features/system-settings/models/model-ratio-form.tsx Always shows the save button (previously only in JSON mode).
web/default/src/components/layout/components/public-header.tsx Stops translating header link titles (uses raw link.title).
web/default/src/components/layout/components/footer.tsx Stops translating footer column titles (uses raw column.title).
web/default/src/components/data-table/core/data-table-row.tsx Removes React.memo optimization from DataTableRow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

setAuthPromptSecondsLeft(AUTH_PROMPT_SECONDS)
setAuthPromptTarget({
title: t(link.title),
title: link.title,
)}
>
{t(link.title)}
{link.title}
)}
>
{t(link.title)}
{link.title}
style={transitionStyle}
>
{t(link.title)}
{link.title}
style={transitionStyle}
>
{t(link.title)}
{link.title}
<div key={index}>
<p className='text-muted-foreground/50 mb-3 text-xs font-medium tracking-wider uppercase'>
{t(column.title)}
{column.title}
prev.row.getIsSelected() === next.row.getIsSelected()
)
}) as typeof DataTableRowInner
export const DataTableRow = DataTableRowInner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

经过多次排查,这里的缓存会导致同步渠道中的复选框无法被选中,底层数据已经选中但是UI不会得到更新,尝试通过添加更新的逻辑条件,会导致更新选中状态时页面闪烁。

Comment on lines +84 to +87
handleConfirm={() => {
onDelete(modelName)
setConfirmOpen(false)
}}
@zhangzhichaolove

Copy link
Copy Markdown
Contributor Author

翻译问题通过排查,是因为这些key被多次翻译导致,如上面CodeRabbit评论的几处问题,需要移除重复的翻译。

@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: 2

🧹 Nitpick comments (1)
web/default/src/components/data-table/core/data-table-row.tsx (1)

54-54: ⚡ Quick win

Consider using React.memo with default shallow comparison instead of removing memoization entirely.

Removing React.memo fixes the checkbox bug (the custom comparator was likely preventing re-renders when selection changed), but it also removes performance optimization. Every row will now re-render on any parent update, which could impact tables with many rows.

A better approach: keep React.memo but rely on default shallow prop comparison, which correctly detects when the row object reference changes:

-export const DataTableRow = DataTableRowInner
+export const DataTableRow = React.memo(DataTableRowInner) as typeof DataTableRowInner

This preserves render skipping when props are unchanged while fixing the selection-state bug. As per coding guidelines, React.memo should be used judiciously for components like table rows that render repeatedly.

🤖 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/components/data-table/core/data-table-row.tsx` at line 54,
The current export of DataTableRow removes memoization entirely, which
eliminates performance optimization for rows that render repeatedly. Instead of
removing React.memo completely, wrap the DataTableRowInner component with
React.memo at the export statement, but without any custom comparator function.
This will use default shallow prop comparison, which correctly allows re-renders
when the row object reference changes (fixing the selection bug) while still
skipping renders when props are unchanged. Change the export statement from
exporting the bare component to exporting React.memo(DataTableRowInner).

Source: Coding guidelines

🤖 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/model-ratio-table-columns.tsx`:
- Around line 64-73: The Button component at lines 64-73 containing only the
Trash2 icon lacks an accessible name for screen reader users. Add a localized
aria-label attribute to this delete button to provide an accessible description.
The same issue also applies to the edit/action button at lines 194-203, which
similarly needs an aria-label attribute added. Both icon-only buttons should
include aria-label with appropriate localized text describing their actions to
comply with accessibility guidelines.

In `@web/default/src/i18n/locales/ru.json`:
- Line 1164: The Russian translation for the "Delete model pricing" key uses
inconsistent terminology. The related keys "Add model pricing" and "Edit model
pricing" already use the term «тариф» (tariff/plan), but this new key uses «цена
модели» (model price). Replace «цена модели» with «тариф» in the translation
value for "Delete model pricing" to maintain consistent terminology across all
pricing-related strings in the Russian locale file.

---

Nitpick comments:
In `@web/default/src/components/data-table/core/data-table-row.tsx`:
- Line 54: The current export of DataTableRow removes memoization entirely,
which eliminates performance optimization for rows that render repeatedly.
Instead of removing React.memo completely, wrap the DataTableRowInner component
with React.memo at the export statement, but without any custom comparator
function. This will use default shallow prop comparison, which correctly allows
re-renders when the row object reference changes (fixing the selection bug)
while still skipping renders when props are unchanged. Change the export
statement from exporting the bare component to exporting
React.memo(DataTableRowInner).
🪄 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: ac16cb03-7ebe-4b1b-866d-79c4b95d1c31

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac0f58 and 8a3eb5b.

📒 Files selected for processing (12)
  • web/default/src/components/data-table/core/data-table-row.tsx
  • web/default/src/components/layout/components/footer.tsx
  • web/default/src/components/layout/components/public-header.tsx
  • web/default/src/features/system-settings/models/model-ratio-form.tsx
  • web/default/src/features/system-settings/models/model-ratio-table-columns.tsx
  • web/default/src/features/system-settings/models/model-ratio-visual-editor.tsx
  • 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 on lines +64 to +73
<Button
variant='ghost'
size='sm'
onClick={(e) => {
e.stopPropagation()
setConfirmOpen(true)
}}
>
<Trash2 />
</Button>

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add accessible names to icon-only action buttons.

At Line 64 and Line 194, the icon-only delete/edit buttons have no accessible name. Add aria-label (localized) so assistive tech users can discover and operate these controls.

Proposed fix
       <Button
         variant='ghost'
         size='sm'
+        aria-label={t('Delete model pricing')}
         onClick={(e) => {
           e.stopPropagation()
           setConfirmOpen(true)
         }}
       >
         <Trash2 />
       </Button>
@@
           <Button
             variant='ghost'
             size='sm'
+            aria-label={t('Edit model pricing')}
             onClick={(e) => {
               e.stopPropagation()
               onEdit(row.original)
             }}
           >
             <Pencil />
           </Button>

As per coding guidelines: “Ensure keyboard operability and logical focus order; use ARIA attributes when necessary (aria-label, aria-expanded, aria-hidden)…”.

Also applies to: 194-203

🤖 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/model-ratio-table-columns.tsx`
around lines 64 - 73, The Button component at lines 64-73 containing only the
Trash2 icon lacks an accessible name for screen reader users. Add a localized
aria-label attribute to this delete button to provide an accessible description.
The same issue also applies to the edit/action button at lines 194-203, which
similarly needs an aria-label attribute added. Both icon-only buttons should
include aria-label with appropriate localized text describing their actions to
comply with accessibility guidelines.

Source: Coding guidelines

"Delete logs": "Удалить логи",
"Delete mapping": "Удалить сопоставление",
"Delete Model": "Удалить модель",
"Delete model pricing": "Удалить цену модели",

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use the same Russian pricing term here.

Add model pricing and Edit model pricing already use «тариф», but this new key says «цена модели». Keeping the wording consistent will make the pricing UI read more naturally.

💡 Suggested wording
-    "Delete model pricing": "Удалить цену модели",
+    "Delete model pricing": "Удалить тариф модели",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"Delete model pricing": "Удалить цену модели",
"Delete model pricing": "Удалить тариф модели",
🤖 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/i18n/locales/ru.json` at line 1164, The Russian translation
for the "Delete model pricing" key uses inconsistent terminology. The related
keys "Add model pricing" and "Edit model pricing" already use the term «тариф»
(tariff/plan), but this new key uses «цена модели» (model price). Replace «цена
модели» with «тариф» in the translation value for "Delete model pricing" to
maintain consistent terminology across all pricing-related strings in the
Russian locale file.

@zhangzhichaolove zhangzhichaolove changed the title 修复:模型定价中无法删除模型、同步渠道弹窗中选中渠道、控制台日志中的翻译错误 修复:模型定价中无法删除模型、同步渠道弹窗中无法选中渠道、控制台日志中的翻译错误 Jun 14, 2026
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