fix(desktop): report the model actually tested when Test Connection falls back - #4223
fix(desktop): report the model actually tested when Test Connection falls back#4223liuxiaocs7 wants to merge 1 commit into
Conversation
…alls back An OpenCode Free connection probes the enabled models then the provider fallbacks and returns the first that answers, so a selected model that is rate-limited or returns an empty completion made "测试连接" silently report success for a fallback model (e.g. nemotron-3-ultra-free) the user never enabled — reading as if the selection never took. Detect this in runTest by comparing result.modelTested against the enabled model ids: when the answering model isn't one the user selected, show a warning toast naming the unresponsive selection and the model used to verify, instead of a plain success. The resilient fallback probe is left intact. Fixes apache#4222 Generated-by: Claude Code (Opus 4.8)
jackwener
left a comment
There was a problem hiding this comment.
I found no blocking issues on 694fbf224d9406a4c4170aca7bedcedd4320744a.
The runtime already returns the exact model that answered after probing every enabled OpenCode Free model before provider fallbacks. This renderer-only change preserves that behavior and correctly distinguishes the three relevant outcomes: a selected model answered, every selected model failed and an unselected fallback answered, or no model is selected and a fallback is used only to verify the connection. The warning names both the selected models and the answering fallback without changing persisted state, IPC, or send authority.
I verified the Desktop preload/main/renderer/Storybook typecheck, the seven OpenCode Free runtime fallback tests, Biome, diff-check, ASF headers, the clean current-main merge result, and the successful exact-head hosted test check.
Automated review notice: This comment was posted by an automated review agent operated by WAWQAQ. It is not an independent human review and does not replace one.
Summary
For an OpenCode Free connection, "测试连接 (Test Connection)" probes the enabled models then the provider fallbacks and returns the first model that answers (
testConnectionStrict,packages/runtime/src/test-connection.ts:166-195). When the selected model (e.g.mimo-v2.5-free) is rate-limited, temporarily down, or returns an empty completion, the loop falls through to a fallback model (nemotron-3-ultra-free, the provider default) and the success toast reports that model — reading as if the user's model selection never took, and hiding that their chosen model is currently unavailable.The probe-until-one-answers behavior is intentional and worth keeping (free models rotate and rate-limit). The fix is scoped to the renderer:
runTestnow comparesresult.modelTestedagainst the enabled model ids. When the answering model isn't one the user selected, it shows awarningtoast that names the unresponsive selection and the model used to verify, instead of a plain green success. When the selected model does answer, behavior is unchanged.No runtime / IPC / persisted types were touched — the renderer already has both facts (the enabled set and
modelTested), so the detection lives entirely inuse-connection-detail.tsplus two new copy strings (zh + en).Fixes #4222
Verification
npm run typecheckinapps/desktop(preload + main + renderer + storybook) — passes.Review focus
testedId !== undefined && enabledModelIds.length > 0 && !enabledModelIds.includes(testedId). For non-opencode-freeproviders the backend returns the first enabled candidate, somodelTestedis always in the enabled set and the warning never fires. Thelength > 0guard avoids a spurious warning for a zero-model connection that verifies its credential against a fallback.AI use
Select exactly one:
Tool(s) and scope: Claude Code (Opus 4.8) diagnosed the root cause and authored the fix and copy. The affected commit carries a
Generated-by: Claude Code (Opus 4.8)trailer.Checklist
Does this PR entail a change in behavior?