Skip to content

fix(model-pricing): 修复模型定价列表项无法删除 (#5623) - #5628

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:fix/model-pricing-row-delete
Jun 20, 2026
Merged

fix(model-pricing): 修复模型定价列表项无法删除 (#5623)#5628
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
feitianbubu:fix/model-pricing-row-delete

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jun 20, 2026

Copy link
Copy Markdown
Member

📝 变更描述 / Description

新版 UI「系统设置 → 模型定价」可视化编辑器中,点击列表项的删除按钮后该行不会消失,表现为「无法删除」。

根因:删除时 handleDelete 已把模型从草稿(draft)map 中移除,但列表数据 modelssaved ∪ draft 的并集,且行内容优先取 displayed = saved ?? draft。删除后 draft 没了、saved 仍在,行依旧用 saved 数据渲染;代码已算出 isDraftDeleted 标记,但渲染处从未使用它,所以列表毫无变化。

修复:

  • models 中过滤掉已暂存删除(isDraftDeleted)的行,删除后该行立即从列表消失,计数 / 空状态同步更新,并随保存持久化。
  • 若删除的正是右侧编辑器当前打开的行,则同时关闭编辑器,避免从残留面板再次保存把该模型写回、抵消删除。

⚠️ 备注:删除后需要再点击任意一个模型,保存按钮才会出现(保存按钮依赖编辑器/表单的交互态)。这是本次未一并处理的既有交互问题,删除本身在保存后会正确生效。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 已整理撰写此描述。
  • 非重复提交: 已搜索现有 Issues 与 PRs,确认不重复。
  • Bug fix 说明: 已关联对应 Issue 新版 UI 中的模型定价列表项无法删除 #5623
  • 变更理解: 已理解更改原理及影响。
  • 范围聚焦: 本 PR 仅修复该列表删除问题。
  • 本地验证: 已分析并核对 saved/draft 数据流与保存链路,确认删除经保存可正确持久化。
  • 安全合规: 无敏感凭据,符合代码规范。

📸 运行证明 / Proof of Work

代码逻辑核对:删除将模型从草稿 map 移除并触发 onChange 更新表单字段;过滤 isDraftDeleted 后该行从列表移除;保存时整段 JSON 草稿被持久化,删除生效。

修复后:
image

Summary by CodeRabbit

  • Bug Fixes
    • Draft-deleted models no longer appear in the model list display.
    • The model editor now properly closes and clears all related panels when you delete the model currently being edited.

删除时已从草稿中移除模型,但列表为 saved∪draft 并集且优先取 saved,
导致行不消失(isDraftDeleted 计算后未被使用),表现为无法删除。改为过滤
掉已暂存删除的行;并在删除当前正在编辑的行时关闭编辑器,避免从残留面板
保存又把模型写回。
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5524870d-9504-41a4-b0cb-4d764888ec1d

📥 Commits

Reviewing files that changed from the base of the PR and between 0c6c1b3 and ef32cf4.

📒 Files selected for processing (1)
  • web/default/src/features/system-settings/models/model-ratio-visual-editor.tsx

Walkthrough

In ModelRatioVisualEditor, the models computed list now filters out entries where isDraftDeleted is true. The handleDelete callback is extended to clear editData and close the editor panel and mobile sheet when the deleted model matches the one currently being edited. editData is added to the useCallback dependency array accordingly.

Changes

Model Deletion Fix

Layer / File(s) Summary
Draft-delete filter and editor-close on deletion
web/default/src/features/system-settings/models/model-ratio-visual-editor.tsx
Adds .filter((row) => !row.isDraftDeleted) to the models pipeline so deleted rows are removed from the table. Extends handleDelete to reset editData and close the editor and mobile sheet when the deleted model name matches the currently edited model. Adds editData to the useCallback dependency array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

🐇 A model once stuck in the list would not flee,
Draft-deleted but rendered for all eyes to see.
Now filters say "gone!" and the panel snaps shut,
No ghost rows remain, no editor half-cut.
Hop hop, the delete key works perfectly free! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: resolving the issue where model pricing list items could not be deleted in the visual editor.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #5623: enabling deletion of model pricing list items by filtering out draft-deleted entries and closing the editor panel when the edited row is deleted.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the deletion functionality in ModelRatioVisualEditor; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@Calcium-Ion
Calcium-Ion merged commit d58029c into QuantumNous:main Jun 20, 2026
2 checks passed
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
删除时已从草稿中移除模型,但列表为 saved∪draft 并集且优先取 saved,
导致行不消失(isDraftDeleted 计算后未被使用),表现为无法删除。改为过滤
掉已暂存删除的行;并在删除当前正在编辑的行时关闭编辑器,避免从残留面板
保存又把模型写回。
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
删除时已从草稿中移除模型,但列表为 saved∪draft 并集且优先取 saved,
导致行不消失(isDraftDeleted 计算后未被使用),表现为无法删除。改为过滤
掉已暂存删除的行;并在删除当前正在编辑的行时关闭编辑器,避免从残留面板
保存又把模型写回。
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
删除时已从草稿中移除模型,但列表为 saved∪draft 并集且优先取 saved,
导致行不消失(isDraftDeleted 计算后未被使用),表现为无法删除。改为过滤
掉已暂存删除的行;并在删除当前正在编辑的行时关闭编辑器,避免从残留面板
保存又把模型写回。
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.

新版 UI 中的模型定价列表项无法删除

2 participants