Skip to content

fix(tui): 删除模型 profile 未找到文件时给出提示 - #359

Open
openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:mainfrom
openjiuwenai:sync/pr-254
Open

openjiuwen-sync-bot[bot] wants to merge 1 commit into
openJiuwen-ai:mainfrom
openjiuwenai:sync/pr-254

Conversation

@openjiuwen-sync-bot

@openjiuwen-sync-bot openjiuwen-sync-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Paired: GitHub #359 ↔ GitCode !254

问题

模型配置界面的 _do_delete() 直接丢弃 delete_profile() 的返回值。当列表中残留的 profile 在磁盘上已没有对应 YAML(例如被外部删除)时,删除操作看起来与正常成功完全一样,用户无法得知磁盘上其实没有任何文件被删除。

修复

  • 接收 delete_profile() 的返回值,为 False 时弹出 warning 提示,说明磁盘上未找到文件、仅移除了列表中的残留条目。
  • 仍按原有语义移除注册表中的残留条目并继续指针重协调流程,不改变正常的删除与重载行为。
  • 在 tests/app/tui/screens/test_model_config.py 新增两个用例:文件缺失时产生 warning 且残留条目被移除;正常删除成功时不得产生 warning。

验证

  • ruff check / ruff format --check 通过
  • pytest tests/app/tui/screens/test_model_config.py 50 passed

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


zxy12_zxy seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 8f409c0f6852e065e1432914bf2644536a73bc96

变更摘要

本次变更修复了 TUI 模型配置界面在删除模型 profile 时的反馈缺失问题:_do_delete() 原先直接丢弃 delete_profile() 的返回值,导致磁盘上 YAML 文件已被外部删除、仅列表中残留条目的场景与正常删除表现一致。现在改为接收返回值,在文件不存在时向用户弹出 warning 提示,同时保持原有移除残留条目与后续指针重协调流程不变,并补充了对应测试用例。

主要改动

  • 删除结果反馈: _do_delete() 改为接收 delete_profile() 的布尔返回值 deleted,不再忽略删除是否真正作用于磁盘文件。
  • 缺失文件的用户提示: 当 deleted 为 False 时,通过 self.notify() 以 severity="warning" 提示磁盘上未找到模型 profile 文件、仅移除了列表中的残留条目,标题沿用 _MODEL_SETTINGS_TITLE 的 _render_toast 渲染结果。
  • 删除语义保持不变: 无论文件是否存在,仍照旧调用 self._registry.remove(profile_id) 并从 _listed_profiles() 重新获取列表、继续原有的默认 profile 与指针重协调流程。
  • 测试覆盖: 在 tests/app/tui/screens/test_model_config.py 新增 test_model_config_delete_warns_when_the_file_is_already_gone,断言缺失文件时产生 warning 提示、_cancel_result() 返回 "deleted",且残留条目被移除、其它 profile 保留。

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 8f409c0f6852e065e1432914bf2644536a73bc96

代码审查

✅ 未发现问题

@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 8f409c0f6852e065e1432914bf2644536a73bc96

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

The models screen discarded delete_profile()'s return value, so deleting a stale entry whose YAML was already gone looked like an ordinary success. Capture the result and show a warning toast when the file was not on disk, while still removing the stale entry and reconciling the pointers as before.

Signed-off-by: zxy12_zxy <419500457@qq.com>
@openjiuwen-collaboration-bot

Copy link
Copy Markdown
Contributor

head_sha: 66df19d08ce5bdce517711f4c043066e8399a30d

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
禁用词扫描 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A
issue关联检查 N/A N/A
pr size检查 N/A N/A

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant