修复:模型定价中无法删除模型、同步渠道弹窗中无法选中渠道、控制台日志中的翻译错误 - #5493
Conversation
WalkthroughThis PR adds a ChangesModel Ratio Delete Confirmation and Editor Fixes
Layout Link Title Translation Bypass
DataTableRow React.memo Removal
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
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 |
There was a problem hiding this comment.
经过多次排查,这里的缓存会导致同步渠道中的复选框无法被选中,底层数据已经选中但是UI不会得到更新,尝试通过添加更新的逻辑条件,会导致更新选中状态时页面闪烁。
| handleConfirm={() => { | ||
| onDelete(modelName) | ||
| setConfirmOpen(false) | ||
| }} |
|
翻译问题通过排查,是因为这些key被多次翻译导致,如上面CodeRabbit评论的几处问题,需要移除重复的翻译。 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
web/default/src/components/data-table/core/data-table-row.tsx (1)
54-54: ⚡ Quick winConsider using
React.memowith default shallow comparison instead of removing memoization entirely.Removing
React.memofixes 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.memobut rely on default shallow prop comparison, which correctly detects when therowobject reference changes:-export const DataTableRow = DataTableRowInner +export const DataTableRow = React.memo(DataTableRowInner) as typeof DataTableRowInnerThis preserves render skipping when props are unchanged while fixing the selection-state bug. As per coding guidelines,
React.memoshould 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
📒 Files selected for processing (12)
web/default/src/components/data-table/core/data-table-row.tsxweb/default/src/components/layout/components/footer.tsxweb/default/src/components/layout/components/public-header.tsxweb/default/src/features/system-settings/models/model-ratio-form.tsxweb/default/src/features/system-settings/models/model-ratio-table-columns.tsxweb/default/src/features/system-settings/models/model-ratio-visual-editor.tsxweb/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
| <Button | ||
| variant='ghost' | ||
| size='sm' | ||
| onClick={(e) => { | ||
| e.stopPropagation() | ||
| setConfirmOpen(true) | ||
| }} | ||
| > | ||
| <Trash2 /> | ||
| </Button> |
There was a problem hiding this comment.
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": "Удалить цену модели", |
There was a problem hiding this comment.
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.
| "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.
Important
📝 变更描述 / Description
主要修复了3个问题,这些问题是我使用最新代码本地部署时发现,他人可基于最新代码进行复现,具体变更见下面变更类型。
🚀 变更类型 / Type of change
i18next::translator: missingKey zh-CN translation 主页 主页🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
1.控制台翻译相关错误如下图,已修复。
2.模型定价列表,单击删除某个模型,无任何反应,已修复,并增加弹窗二次确认。
3.选择同步渠道弹窗中,复选框点击没有反应,已修复。
Summary by CodeRabbit
Release Notes
New Features
Improvements