fix: 修复管理后台多处交互失效与布局问题#4703
Conversation
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (6)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRefactors channel copy persistence, adds quota↔dollar conversions and credited-amount UI, standardizes form/dialog interaction patterns, tightens layout/truncation, and adds related i18n strings across multiple locales. ChangesMulti-faceted System Updates: Subscriptions, Forms, and Backend Improvements
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 2
🧹 Nitpick comments (4)
web/default/src/components/layout/components/chat-presets-item.tsx (1)
64-66: 💤 Low value
whitespace-nowrapis redundant alongsidetruncateTailwind's
truncateutility already compiles tooverflow: hidden; text-overflow: ellipsis; white-space: nowrap, so the explicitwhitespace-nowrapclass on all four<span>wrappers is a no-op.♻️ Proposed cleanup (same pattern applies to all four spans)
-<span className='min-w-0 flex-1 truncate whitespace-nowrap'> +<span className='min-w-0 flex-1 truncate'>Also applies to: 82-84, 113-115, 128-130
🤖 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/layout/components/chat-presets-item.tsx` around lines 64 - 66, In the ChatPresetsItem component remove redundant Tailwind classes: delete the explicit "whitespace-nowrap" on the span wrappers (the one wrapping {preset.name} and the other three spans referenced in the review) because "truncate" already sets white-space: nowrap; update the JSX in chat-presets-item.tsx to keep "min-w-0 flex-1 truncate" (and similarly remove "whitespace-nowrap" from the spans at the other locations mentioned) so the UI behavior is unchanged but the class list is cleaned up.web/default/src/i18n/locales/vi.json (1)
1005-1005: 🏗️ Heavy liftUse a hierarchical i18n key instead of a raw UI string key
Line 1005 introduces a literal key (
"Credited Amount"). Please switch to a semantic hierarchical key (for example,subscriptions.plan.creditedAmount) and keep it aligned across locale files/usages.As per coding guidelines, "Use hierarchical and semantically clear translation key names such as
dashboard.overview.titleand maintain naming consistency".🤖 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/vi.json` at line 1005, Replace the literal translation key "Credited Amount" with a hierarchical semantic key (for example subscriptions.plan.creditedAmount) in this vi.json entry and update all corresponding locale files and UI usages to reference that new key instead of the raw UI string; ensure the new key is added to other locale JSONs with the same structure and that components or code using "Credited Amount" (search for the string or exact key) are changed to use subscriptions.plan.creditedAmount so translations stay consistent.web/default/src/i18n/locales/ru.json (1)
1005-1005: 🏗️ Heavy liftUse a hierarchical i18n key for this new entry
Line 1005 adds a flat text key (
"Credited Amount"), which breaks the required hierarchical key convention for this directory. Please rename it to a semantic key (for example,subscriptions.plan.creditedAmount) and update call sites/locales consistently.As per coding guidelines:
web/default/src/i18n/**/*.{ts,tsx,json}: Use hierarchical and semantically clear translation key names such as dashboard.overview.title and maintain naming consistency.🤖 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 1005, The JSON added a flat translation key "Credited Amount" which violates the hierarchical i18n key convention; rename the key to a semantic hierarchical key (for example subscriptions.plan.creditedAmount), replace the "Credited Amount" entry in this locale with subscriptions.plan.creditedAmount: "Зачисляемая сумма", and update all call sites that reference "Credited Amount" to use the new key (e.g., t('subscriptions.plan.creditedAmount')); also propagate the same hierarchical key and value to other locale files to keep locales consistent.web/default/src/features/channels/lib/channel-actions.ts (1)
238-248: 💤 Low valueConsider extracting the duplicate error string into
ERROR_MESSAGES.
'Failed to copy channel'appears literally on both lines 243 and 246, while every other handler in this file delegates to a constant (e.g.,ERROR_MESSAGES.DELETE_FAILED,ERROR_MESSAGES.UPDATE_FAILED). Adding aCOPY_FAILEDkey keeps the error strings manageable in one place and consistent with i18n key tracking.♻️ Proposed refactor
In
../constants(or whereverERROR_MESSAGESis defined):export const ERROR_MESSAGES = { + COPY_FAILED: 'Failed to copy channel', DELETE_FAILED: '...', // ... }Then in
handleCopyChannel:- } else { - toast.error(response.message || i18next.t('Failed to copy channel')) - } + } else { + toast.error(response.message || i18next.t(ERROR_MESSAGES.COPY_FAILED)) + } } catch (_error) { - toast.error(i18next.t('Failed to copy channel')) + toast.error(i18next.t(ERROR_MESSAGES.COPY_FAILED)) }🤖 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 238 - 248, The duplicated literal i18n key 'Failed to copy channel' in handleCopyChannel should be moved into the shared ERROR_MESSAGES constant (add ERROR_MESSAGES.COPY_FAILED) and then replace both literal usages in handleCopyChannel with toast.error(i18next.t(ERROR_MESSAGES.COPY_FAILED)) (and use ERROR_MESSAGES.COPY_FAILED for the fallback in the catch). Update imports if necessary so handleCopyChannel references ERROR_MESSAGES; keep SUCCESS_MESSAGES.COPIED and queryClient logic unchanged.
🤖 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/subscriptions/components/subscriptions-mutate-drawer.tsx`:
- Around line 199-206: The per-keystroke numeric coercion using parseFloat(... )
|| 0 in the Input onChange is dropping intermediate decimal states (e.g.
"1.")—replace field.onChange(parseFloat(e.target.value) || 0) with
field.onChange(e.target.value) (pass the raw string) so the input can represent
intermediate values; perform parsing/validation to a Number only on blur or form
submit (or in the form controller's value-to-model transform) so components like
Input and the form field’s onBlur/submit handler convert the string to a float
once instead of coercing every keystroke; apply the same change to the other
occurrence that uses parseFloat in this component.
In `@web/default/src/i18n/locales/zh.json`:
- Line 1005: Replace the flat English key "Credited Amount" in the zh.json
locale with a semantic hierarchical key like "subscriptions.plan.creditedAmount"
(keeping the value "到账金额"), then update all call sites that currently reference
the literal key "Credited Amount" to use the new key
"subscriptions.plan.creditedAmount" (search for usages in code that call i18n.t
or similar helpers), and mirror the same key change across other locale files so
all locales remain consistent.
---
Nitpick comments:
In `@web/default/src/components/layout/components/chat-presets-item.tsx`:
- Around line 64-66: In the ChatPresetsItem component remove redundant Tailwind
classes: delete the explicit "whitespace-nowrap" on the span wrappers (the one
wrapping {preset.name} and the other three spans referenced in the review)
because "truncate" already sets white-space: nowrap; update the JSX in
chat-presets-item.tsx to keep "min-w-0 flex-1 truncate" (and similarly remove
"whitespace-nowrap" from the spans at the other locations mentioned) so the UI
behavior is unchanged but the class list is cleaned up.
In `@web/default/src/features/channels/lib/channel-actions.ts`:
- Around line 238-248: The duplicated literal i18n key 'Failed to copy channel'
in handleCopyChannel should be moved into the shared ERROR_MESSAGES constant
(add ERROR_MESSAGES.COPY_FAILED) and then replace both literal usages in
handleCopyChannel with toast.error(i18next.t(ERROR_MESSAGES.COPY_FAILED)) (and
use ERROR_MESSAGES.COPY_FAILED for the fallback in the catch). Update imports if
necessary so handleCopyChannel references ERROR_MESSAGES; keep
SUCCESS_MESSAGES.COPIED and queryClient logic unchanged.
In `@web/default/src/i18n/locales/ru.json`:
- Line 1005: The JSON added a flat translation key "Credited Amount" which
violates the hierarchical i18n key convention; rename the key to a semantic
hierarchical key (for example subscriptions.plan.creditedAmount), replace the
"Credited Amount" entry in this locale with subscriptions.plan.creditedAmount:
"Зачисляемая сумма", and update all call sites that reference "Credited Amount"
to use the new key (e.g., t('subscriptions.plan.creditedAmount')); also
propagate the same hierarchical key and value to other locale files to keep
locales consistent.
In `@web/default/src/i18n/locales/vi.json`:
- Line 1005: Replace the literal translation key "Credited Amount" with a
hierarchical semantic key (for example subscriptions.plan.creditedAmount) in
this vi.json entry and update all corresponding locale files and UI usages to
reference that new key instead of the raw UI string; ensure the new key is added
to other locale JSONs with the same structure and that components or code using
"Credited Amount" (search for the string or exact key) are changed to use
subscriptions.plan.creditedAmount so translations stay consistent.
🪄 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: a6de7143-d109-4a5f-ab36-d69e82d11ca3
📒 Files selected for processing (18)
controller/channel.goweb/default/src/components/layout/components/chat-presets-item.tsxweb/default/src/features/channels/components/data-table-row-actions.tsxweb/default/src/features/channels/lib/channel-actions.tsweb/default/src/features/keys/components/api-keys-mutate-drawer.tsxweb/default/src/features/subscriptions/components/dialogs/user-subscriptions-dialog.tsxweb/default/src/features/subscriptions/components/subscriptions-columns.tsxweb/default/src/features/subscriptions/components/subscriptions-mutate-drawer.tsxweb/default/src/features/subscriptions/lib/plan-form.tsweb/default/src/features/system-settings/models/model-ratio-form.tsxweb/default/src/features/system-settings/models/ratio-settings-card.tsxweb/default/src/features/users/components/data-table-row-actions.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
| <Input | ||
| {...field} | ||
| type='number' | ||
| step='0.01' | ||
| min={0} | ||
| onChange={(e) => | ||
| field.onChange(parseFloat(e.target.value) || 0) | ||
| } |
There was a problem hiding this comment.
Decimal entry is broken by per-keystroke numeric coercion.
At Line 205 and Line 239, converting input text with parseFloat(... ) || 0 on every change drops intermediate states (like 1.), making decimal typing unreliable for money fields.
💡 Suggested fix
<Input
{...field}
type='number'
step='0.01'
min={0}
- onChange={(e) =>
- field.onChange(parseFloat(e.target.value) || 0)
- }
/> <Input
{...field}
type='number'
step={tokensOnly ? 1 : 0.01}
min={0}
placeholder={
tokensOnly
? t('Enter quota in tokens')
: t('Enter quota in {{currency}}', {
currency: currencyLabel,
})
}
- onChange={(e) =>
- field.onChange(parseFloat(e.target.value) || 0)
- }
/>Also applies to: 226-240
🤖 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/subscriptions/components/subscriptions-mutate-drawer.tsx`
around lines 199 - 206, The per-keystroke numeric coercion using parseFloat(...
) || 0 in the Input onChange is dropping intermediate decimal states (e.g.
"1.")—replace field.onChange(parseFloat(e.target.value) || 0) with
field.onChange(e.target.value) (pass the raw string) so the input can represent
intermediate values; perform parsing/validation to a Number only on blur or form
submit (or in the form controller's value-to-model transform) so components like
Input and the form field’s onBlur/submit handler convert the string to a float
once instead of coercing every keystroke; apply the same change to the other
occurrence that uses parseFloat in this component.
| "Create, revoke, and audit API tokens.": "创建、撤销和审计 API 令牌。", | ||
| "Created": "创建时间", | ||
| "Created At": "创建时间", | ||
| "Credited Amount": "到账金额", |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Use a semantic i18n key instead of an English sentence key.
Please switch this new key to a hierarchical identifier (for example, subscriptions.plan.creditedAmount) and update its call sites accordingly to keep keys stable across locales.
As per coding guidelines, web/default/src/i18n/**/*.{ts,tsx,json} should use hierarchical and semantically clear translation key names and keep naming consistency.
🤖 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/zh.json` at line 1005, Replace the flat English
key "Credited Amount" in the zh.json locale with a semantic hierarchical key
like "subscriptions.plan.creditedAmount" (keeping the value "到账金额"), then update
all call sites that currently reference the literal key "Credited Amount" to use
the new key "subscriptions.plan.creditedAmount" (search for usages in code that
call i18n.t or similar helpers), and mirror the same key change across other
locale files so all locales remain consistent.
Important
📝 变更描述 / Description
本 PR 修复了默认前端管理后台中多处点击无响应、保存无效和布局显示异常的问题。
主要变更包括:
onClick,原实现使用了不匹配的
onSelect。这些修改主要集中在管理后台交互入口、表单提交绑定和表单布局样式上,不改变核心业务模型。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
QuantumNous/new-api/pulls),确认不是重复提交。
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为bug。
📸 运行证明 / Proof of Work
已在本地对相关前端修改运行检查: