feat: 新版本前端设置页"模型定价"添加"未定价模型"选项,补充便捷的未定价模型管理功能 - #5564
Conversation
…ut responsiveness
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds an "Unpriced Models" tab to the model pricing settings. Introduces ChangesUnpriced Models Pricing Workflow
Sequence DiagramsequenceDiagram
actor User
participant UnpricedModelsEditor
participant useUpdateModelRatios
participant OptionAPI as /api/option/
participant EnabledModelsAPI as /api/channel/models_enabled
participant QueryCache
User->>UnpricedModelsEditor: opens Unpriced Models tab
UnpricedModelsEditor->>EnabledModelsAPI: GET models_enabled
EnabledModelsAPI-->>UnpricedModelsEditor: enabled model list
UnpricedModelsEditor->>UnpricedModelsEditor: filter unpriced, apply search
User->>UnpricedModelsEditor: selects model, sets price, clicks Save
UnpricedModelsEditor->>useUpdateModelRatios: mutate(ModelRatioData)
useUpdateModelRatios->>OptionAPI: GET /api/option/
OptionAPI-->>useUpdateModelRatios: current options map
useUpdateModelRatios->>useUpdateModelRatios: apply billingMode rules
loop each changed option key
useUpdateModelRatios->>OptionAPI: PUT /api/option/
end
useUpdateModelRatios->>QueryCache: invalidate system-options, enabled-models
UnpricedModelsEditor->>User: success toast
Estimated code review effort🎯 4 (Complex) | ⏱️ ~65 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
Actionable comments posted: 5
🧹 Nitpick comments (2)
web/default/src/features/system-settings/models/unpriced-model-card.tsx (1)
31-35: ⚡ Quick winUse
props.xxxaccess instead of destructuring component props.Please align this component with the TSX guideline by taking a single
propsobject and referencing fields directly.Suggested refactor
-export function UnpricedModelCard({ - modelName, - active = false, - onEdit, -}: UnpricedModelCardProps) { +export function UnpricedModelCard(props: UnpricedModelCardProps) { + const active = props.active ?? false const { t } = useTranslation() return ( @@ - onClick={onEdit} + onClick={props.onEdit} @@ - onEdit() + props.onEdit() @@ - <h4 className='truncate text-sm font-medium'>{modelName}</h4> + <h4 className='truncate text-sm font-medium'>{props.modelName}</h4> @@ - onEdit() + props.onEdit()As per coding guidelines, “Do not destructure component props; use
props.xxxdirectly instead for clarity.”🤖 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/unpriced-model-card.tsx` around lines 31 - 35, The UnpricedModelCard component is destructuring props directly in the function parameters, but the coding guideline requires using a single props object instead. Change the function signature to accept a single props parameter of type UnpricedModelCardProps, then update all references throughout the component body to access properties via props.modelName, props.active, and props.onEdit instead of using the destructured variable names directly.Source: Coding guidelines
web/default/src/features/system-settings/models/unpriced-models-editor.tsx (1)
73-75: ⚡ Quick winAvoid destructuring component props in this TSX component.
Please switch to a single
propsparameter and accessprops.modelRatiosdirectly to match repository conventions.As per coding guidelines, “Do not destructure component props; use
props.xxxdirectly instead for clarity.”🤖 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/unpriced-models-editor.tsx` around lines 73 - 75, The UnpricedModelsEditor component function is destructuring the modelRatios prop directly in the function parameters, but the repository convention requires avoiding prop destructuring. Change the function signature to accept a single props parameter of type UnpricedModelsEditorProps instead of destructuring, then update all references to modelRatios within the function body to use props.modelRatios to access the property directly.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 `@Dockerfile`:
- Around line 10-13: The find command in the RUN instruction hardcodes the path
`dist/static/js`, which causes the entire build to fail if the output directory
structure changes even when bun run build succeeds. Make the find command
non-fatal by appending `|| true` at the end of the find command (after the
`-print`), or alternatively make the search path more flexible by starting the
search from a higher directory level like `dist` with appropriate glob patterns
to accommodate potential layout variations.
In `@web/default/src/features/system-settings/models/unpriced-models-editor.tsx`:
- Around line 257-263: Add an associated label element for the search Input
field that currently only has placeholder text. Create a label element with an
htmlFor attribute that references a unique id on the Input component (you can
generate an id like "search-models" or similar). The label can be visually
hidden using appropriate CSS classes (like a visually-hidden or sr-only utility
class) so it remains accessible to screen readers while not appearing in the UI.
This ensures the Input component with the handleSearchChange handler and
searchQuery value binding has a stable, accessible field name for assistive
technologies.
In `@web/default/src/features/system-settings/models/use-update-model-ratios.ts`:
- Around line 206-213: The update loop iterates through multiple options with
individual API calls to the put endpoint, and if one request fails mid-loop,
previously persisted updates remain while later ones do not, creating an
inconsistent state. Replace the individual loop of api.put calls with either a
single batch endpoint that atomically updates all options at once, or implement
rollback semantics that reverts any successfully written keys if a subsequent
update fails during the loop iteration.
- Line 47: Import the translation function from i18next at the top of the
use-update-model-ratios.ts file by adding `import { t } from 'i18next'`. Then,
locate the hardcoded error message strings ('Failed to fetch current options'
and the similar string at line 211) and wrap them with the t() function to
enable i18n translation support. The error messages should be passed as
arguments to t() so they can be properly localized instead of remaining as raw
English literals.
In `@web/default/src/i18n/locales/en.json`:
- Around line 4298-4309: The en.json translation file contains a duplicate key
entry for "Search model name..." which causes one definition to shadow the other
at parse time, creating ambiguity. Locate and remove one of the two duplicate
"Search model name..." entries in the file, keeping only a single instance of
this key with its corresponding translation value to maintain a clean and
unambiguous translation file.
---
Nitpick comments:
In `@web/default/src/features/system-settings/models/unpriced-model-card.tsx`:
- Around line 31-35: The UnpricedModelCard component is destructuring props
directly in the function parameters, but the coding guideline requires using a
single props object instead. Change the function signature to accept a single
props parameter of type UnpricedModelCardProps, then update all references
throughout the component body to access properties via props.modelName,
props.active, and props.onEdit instead of using the destructured variable names
directly.
In `@web/default/src/features/system-settings/models/unpriced-models-editor.tsx`:
- Around line 73-75: The UnpricedModelsEditor component function is
destructuring the modelRatios prop directly in the function parameters, but the
repository convention requires avoiding prop destructuring. Change the function
signature to accept a single props parameter of type UnpricedModelsEditorProps
instead of destructuring, then update all references to modelRatios within the
function body to use props.modelRatios to access the property directly.
🪄 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: ce11896f-5b93-4351-9f9d-6ba7b084cb4c
📒 Files selected for processing (10)
Dockerfileweb/default/src/features/system-settings/billing/section-registry.tsxweb/default/src/features/system-settings/models/model-ratio-form.tsxweb/default/src/features/system-settings/models/model-ratio-visual-editor.tsxweb/default/src/features/system-settings/models/ratio-settings-card.tsxweb/default/src/features/system-settings/models/unpriced-model-card.tsxweb/default/src/features/system-settings/models/unpriced-models-editor.tsxweb/default/src/features/system-settings/models/use-update-model-ratios.tsweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/zh.json
| // Send all updates | ||
| for (const update of updates) { | ||
| const res = await api.put('/api/option/', update) | ||
| const response = res.data | ||
| if (!response.success) { | ||
| throw new Error(response.message || 'Failed to update option') | ||
| } | ||
| } |
There was a problem hiding this comment.
Prevent partial config writes across pricing keys.
Line 207 updates each option independently; if one request fails mid-loop, persisted pricing state becomes internally inconsistent (some keys updated, some stale). This path should be atomic (single batch endpoint/transaction) or include rollback semantics for already-written keys.
🤖 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/use-update-model-ratios.ts`
around lines 206 - 213, The update loop iterates through multiple options with
individual API calls to the put endpoint, and if one request fails mid-loop,
previously persisted updates remain while later ones do not, creating an
inconsistent state. Replace the individual loop of api.put calls with either a
single batch endpoint that atomically updates all options at once, or implement
rollback semantics that reverts any successfully written keys if a subsequent
update fails during the loop iteration.
New front model price fix clean
…se props directly
…ng options in multiple languages
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/unpriced-model-card.tsx`:
- Line 31: The function `UnpricedModelCard` is missing an explicit return type
annotation. Add a return type annotation to the function signature after the
parameters list (following the closing parenthesis). Since this is a React
component in a TSX file, use JSX.Element or React.ReactElement as the return
type to comply with the coding guidelines for web/default files that require
explicit type annotations for both parameters and return values.
🪄 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: 08313bee-e4f5-40f2-b10f-544f95361163
📒 Files selected for processing (10)
privacy-filterweb/default/src/features/system-settings/models/unpriced-model-card.tsxweb/default/src/features/system-settings/models/unpriced-models-editor.tsxweb/default/src/features/system-settings/models/use-update-model-ratios.tsweb/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
✅ Files skipped from review due to trivial changes (4)
- privacy-filter
- web/default/src/i18n/locales/ru.json
- web/default/src/i18n/locales/vi.json
- web/default/src/i18n/locales/ja.json
🚧 Files skipped from review as they are similar to previous changes (3)
- web/default/src/features/system-settings/models/unpriced-models-editor.tsx
- web/default/src/features/system-settings/models/use-update-model-ratios.ts
- web/default/src/i18n/locales/zh.json
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
web/default/src/i18n/locales/en.json (1)
4345-4345:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the duplicate
Search model name...key.This is the same duplicate entry flagged earlier; the later copy still shadows the first one at parse time.
🛠️ Suggested cleanup
- "Search model name...": "Search model name...",🤖 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/en.json` at line 4345, Remove the duplicate entry for the key "Search model name..." from the en.json locale file. Search for all occurrences of this key in the file and delete the later duplicate entry, keeping only the first occurrence to prevent key shadowing at parse time.Source: Linters/SAST tools
🤖 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/i18n/locales/zh.json`:
- Line 3578: The translation key "Search model name..." is declared twice in the
zh.json file with one entry shadowing the other, causing Biome linting warnings.
Find both occurrences of the "Search model name..." key in the file and remove
one of the duplicate entries, keeping only a single copy of this translation to
resolve the duplication issue.
---
Duplicate comments:
In `@web/default/src/i18n/locales/en.json`:
- Line 4345: Remove the duplicate entry for the key "Search model name..." from
the en.json locale file. Search for all occurrences of this key in the file and
delete the later duplicate entry, keeping only the first occurrence to prevent
key shadowing at parse time.
🪄 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: cd007c00-4991-41d6-9d0c-4c3f4ba57fe5
📒 Files selected for processing (6)
web/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
✅ Files skipped from review due to trivial changes (3)
- web/default/src/i18n/locales/vi.json
- web/default/src/i18n/locales/fr.json
- web/default/src/i18n/locales/ja.json
🚧 Files skipped from review as they are similar to previous changes (1)
- web/default/src/i18n/locales/ru.json
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
♻️ Duplicate comments (1)
web/default/src/i18n/locales/en.json (1)
4345-4345:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the duplicate
Search model name...key.This is the same duplicate entry flagged earlier; the later copy still shadows the first one at parse time.
🛠️ Suggested cleanup
- "Search model name...": "Search model name...",🤖 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/en.json` at line 4345, Remove the duplicate entry for the key "Search model name..." from the en.json locale file. Search for all occurrences of this key in the file and delete the later duplicate entry, keeping only the first occurrence to prevent key shadowing at parse time.Source: Linters/SAST tools
🤖 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/i18n/locales/zh.json`:
- Line 3578: The translation key "Search model name..." is declared twice in the
zh.json file with one entry shadowing the other, causing Biome linting warnings.
Find both occurrences of the "Search model name..." key in the file and remove
one of the duplicate entries, keeping only a single copy of this translation to
resolve the duplication issue.
---
Duplicate comments:
In `@web/default/src/i18n/locales/en.json`:
- Line 4345: Remove the duplicate entry for the key "Search model name..." from
the en.json locale file. Search for all occurrences of this key in the file and
delete the later duplicate entry, keeping only the first occurrence to prevent
key shadowing at parse time.
🪄 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: cd007c00-4991-41d6-9d0c-4c3f4ba57fe5
📒 Files selected for processing (6)
web/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
✅ Files skipped from review due to trivial changes (3)
- web/default/src/i18n/locales/vi.json
- web/default/src/i18n/locales/fr.json
- web/default/src/i18n/locales/ja.json
🚧 Files skipped from review as they are similar to previous changes (1)
- web/default/src/i18n/locales/ru.json
🛑 Comments failed to post (1)
web/default/src/i18n/locales/zh.json (1)
3578-3578:
⚠️ Potential issue | 🟠 Major | ⚡ Quick winRemove the duplicate translation key.
Search model name...is already declared elsewhere in this JSON, so one entry will silently shadow the other and Biome will keep flagging the file. Keep only one copy.🧰 Tools
🪛 Biome (2.5.0)
[error] 3578-3578: The key Search model name... was already declared.
(lint/suspicious/noDuplicateObjectKeys)
🤖 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 3578, The translation key "Search model name..." is declared twice in the zh.json file with one entry shadowing the other, causing Biome linting warnings. Find both occurrences of the "Search model name..." key in the file and remove one of the duplicate entries, keeping only a single copy of this translation to resolve the duplication issue.Source: Linters/SAST tools
funkpopo
left a comment
There was a problem hiding this comment.
Solve i18n conflict.
…Chinese for unpriced models page.
268fdc8 to
c78c23e
Compare
- Deleted Privacy Filter service and its settings from operation settings. - Removed Privacy Filter middleware from video router. - Updated error codes to remove references to privacy filter failures. - Removed Privacy Filter UI components and translations from the frontend. - Cleaned up related settings in the operations settings structure.
Important
📝 变更描述 / Description
新版前端界面"模型定价"页,仅有"模型价格""工具价格""上游价格同步"选项,导致管理员新增渠道和模型后,管理未定价模型的操作较繁琐。添加"未定价模型"选项,方便捕获未定价模型列表,并提供快捷配置入口。
🚀 变更类型 / Type of change
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit