fix(cli): restore saved custom model IDs when re-entering the auth wizard - #5651
fix(cli): restore saved custom model IDs when re-entering the auth wizard#5651pomelo-nwu wants to merge 1 commit into
Conversation
…zard When re-entering the provider auth wizard for a ModelStudio provider that already had saved model IDs, the Model IDs step reset to the provider's built-in defaults instead of the user's saved models. Submitting then overwrote the previously saved custom model IDs with the defaults, losing the user's configuration. Share the existing model-lookup logic from core between the desktop/ACP path and the CLI wizard, and have the wizard pre-fill the Model IDs step with the saved models when present, falling back to the built-in defaults otherwise. Closes #5636 Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
E2E / Test ReportAutomated tests (vitest, all green):
Real-CLI verification (tmux): launched the built CLI against an isolated settings file pre-seeded with a custom Token Plan model and walked
The API key step already restored the saved key before this change; only the model IDs were not being restored. See the Before/After blocks in the PR description. 中文E2E / 测试报告自动化测试(vitest,全部通过):
真实 CLI 验证(tmux): 针对一个预置了自定义 Token Plan model 的隔离 settings 启动构建后的 CLI,走
API Key 步骤在本次改动前就已经会恢复保存的 key,只有 model ID 没有被恢复。详见 PR 描述中的 Before/After。 |
|
Thanks for the PR, @pomelo-nwu! Template looks good ✓ On direction: this is a straightforward data-loss bug fix — re-entering the auth wizard silently overwrites saved custom model IDs with built-in defaults. Linked issue #5636 is tagged P1, and the desktop app already handles this correctly, so bringing the CLI to parity is clearly the right move. No direction concerns. On approach: the scope is tight and proportional. 243 additions / 39 deletions across 8 files for a bug that spans CLI auth + shared provider config feels right. The key move — extracting One small thing I want to verify in code review: the Moving on to code review. 🔍 中文说明感谢贡献,@pomelo-nwu! 模板完整 ✓ 方向:这是一个明确的数据丢失 bug 修复——重新进入 auth 向导时,已保存的自定义 model ID 会被内置默认值静默覆盖。关联 issue #5636 标记为 P1,且桌面端已正确处理此场景,CLI 对齐是正确方向。无方向顾虑。 方案:范围紧凑合理。8 个文件 243 增 39 删,对于跨 CLI auth 和共享 provider config 的 bug 来说比例恰当。将 需要在代码审查中确认的一点: 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewThe implementation is clean and minimal. The core move — extracting Signature change is sound: the old version took One thing I verified: No correctness bugs, no security concerns, no unnecessary abstractions. The test coverage is thorough — 5 unit tests for Real-Scenario TestingBefore (installed qwen v0.18.5 — bug reproduces)Walked Bug confirmed: input is empty ( After (this PR — via test suite)The Instead, verified via the test suite which includes a component test that exercises the exact same wizard flow: The component test in SummaryCode review: clean, minimal, well-tested. No concerns. 中文说明代码审查实现简洁且最小化。将 签名变更合理:旧版本接受 验证了 无正确性 bug、无安全隐患、无不必要的抽象。测试覆盖充分——5 个单元测试覆盖正常路径、空输入、缺失数据、不可解析归属和多协议扫描。 真实场景测试修复前(已安装的 qwen v0.18.5 — bug 复现)在 tmux 中使用预填 Bug 确认:输入框为空( 修复后(本 PR — 通过测试套件)此 CI 环境中 改为通过测试套件验证,其中包含一个走完全相同向导流程的组件测试:
总结代码审查:简洁、最小化、测试充分。无顾虑。 — Qwen Code · qwen3.7-max |
|
Stepping back: this is exactly what a good bug fix PR should look like. The problem is real and well-documented — users lose custom model IDs silently when re-entering the auth wizard. The fix is proportional: extract a shared lookup function, thread it through the two call sites that need it, and fall back to the existing defaults when nothing's saved. No abstractions for abstraction's sake, no speculative features, no "while I'm here" refactors. My independent proposal before reading the diff was essentially the same approach — look up existing models from settings before falling back to defaults. The PR exceeds it by placing the shared function in The tmux capture of the installed build shows the bug viscerally — an empty input field and all defaults checked, with the user's saved custom model nowhere in sight. The component test validates the fix end-to-end through the real React tree. The dev build being blocked by an unrelated If I had to maintain this in six months, I'd thank the author. Clean diff, clear motivation, thorough tests. Approving. ✅ 中文说明退一步看:这是一个好的 bug 修复 PR 应有的样子。 问题是真实且记录充分的——用户重新进入 auth 向导时会静默丢失自定义 model ID。修复比例恰当:提取共享查找函数,在需要的两个调用点接入,无保存内容时回退到既有默认值。没有为抽象而抽象,没有投机性功能,没有"顺手"重构。 我在读 diff 之前的独立方案基本相同——在回退到默认值之前查找 settings 中已有的 model。PR 做得更好,将共享函数放在 tmux 截图直观展示了 bug——空输入框、所有默认项选中,用户保存的自定义 model 完全不见。组件测试通过真实 React 树端到端验证了修复。dev 构建因无关的 如果六个月后需要维护这段代码,我会感谢作者。干净的 diff、清晰的动机、充分的测试。 批准 ✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
What this PR does
Re-entering the provider auth wizard for an Alibaba ModelStudio provider now pre-fills the Model IDs step with the model IDs already saved in settings — including any custom ones the user added — instead of resetting to the provider's built-in defaults. The API key step already restored the saved key; the model IDs now restore the same way, and the shared lookup logic is reused from the desktop/ACP path so both surfaces behave identically.
Why it's needed
Previously the Model IDs step always started from the provider's built-in default list and ignored what the user had already saved. So when a user who had added custom model IDs re-opened the wizard for the same provider, their custom entries were gone from the step, and completing the wizard overwrote the saved custom models with the defaults — silent data loss. The desktop app already restored saved model IDs when re-opening the provider form; this brings the CLI wizard to parity.
Reviewer Test Plan
How to verify
/auth, set up an Alibaba ModelStudio provider (Standard API Key / Coding Plan / Token Plan) and add a custom model ID, then finish the wizard so it is saved to settings./authand walk to the same provider's Model IDs step (Step 2/2).Verified locally by launching the real CLI in tmux against a settings file that already contained a custom Token Plan model, walking
/auth → Alibaba ModelStudio → Token Plan → Model IDs, and confirming the saved custom model appears in the input. Unit and component tests were added and pass alongside the existing suites.Evidence (Before & After)
Before — the Model IDs input is empty and the built-in defaults are all checked (
◉), so submitting overwrites the saved custom model:After — the input is pre-filled with the saved custom model and the defaults are unchecked (
○):Tested on
Environment (optional)
Real dev CLI launched in tmux with an isolated HOME and a fake API key. Core/CLI unit and component tests run via vitest.
Risk & Scope
Linked Issues
Closes #5636
中文说明
这个 PR 做了什么
重新进入 Alibaba ModelStudio provider 的 auth 向导时,Model IDs 步骤现在会用 settings 中已保存的 model ID(包括用户添加的自定义项)预填,而不是重置为 provider 的内置默认值。API Key 步骤本就会恢复已保存的 key,现在 model ID 也以同样的方式恢复,并且复用了桌面端 / ACP 路径里共享的查找逻辑,让两端行为一致。
为什么需要
此前 Model IDs 步骤总是从 provider 的内置默认列表开始,忽略用户已经保存的内容。于是当用户重新打开同一个 provider 的向导时,之前添加的自定义条目就不见了,走完向导会用默认值覆盖已保存的自定义 model —— 造成静默的数据丢失。桌面应用在重新打开 provider 表单时已经会恢复已保存的 model ID,本 PR 让 CLI 向导与之对齐。
评审测试计划
如何验证
/auth配置一个 Alibaba ModelStudio provider(Standard API Key / Coding Plan / Token Plan),添加一个自定义 model ID,走完向导保存到 settings。/auth,走到同一个 provider 的 Model IDs 步骤(Step 2/2)。本地验证方式:在 tmux 中针对一个已包含自定义 Token Plan model 的 settings 启动真实 CLI,走
/auth → Alibaba ModelStudio → Token Plan → Model IDs,确认输入框出现已保存的自定义 model。新增了单元与组件测试,并与既有测试套件一同通过。证据(Before & After)
修复前 —— Model IDs 输入框为空,内置默认项全部选中(
◉),提交会覆盖已保存的自定义 model:修复后 —— 输入框预填已保存的自定义 model,默认项未选中(
○):测试平台
仅在 macOS 本地验证;Windows、Linux 未本地测试(由 CI 覆盖)。
风险与范围
关联 Issue
Closes #5636