fix(desktop): auto-recover dangling model refs on provider removal#3249
Open
SivanCola wants to merge 3 commits into
Open
fix(desktop): auto-recover dangling model refs on provider removal#3249SivanCola wants to merge 3 commits into
SivanCola wants to merge 3 commits into
Conversation
…ers are removed When a provider is deleted or replaced in desktop settings, tabs with stale model refs (default_model, planner_model, tab.model) would fail at startup with "unknown model" errors. This adds automatic fallback to the first configured provider, fixes all open tab refs on provider deletion, and shows actionable recovery UI when no model is available. - Add ResolveModelWithFallback: resolve model ref with automatic fallback to the first configured provider - Fix RemoveProvider: detect "provider/model" refs in default_model and planner_model, auto-migrate instead of blocking - Fix buildTabController / rebuild / currentProviderEntryForTab to use fallback resolution - Sync all tab model refs when a provider is deleted, rebuild active tab - Add model health diagnostics to SettingsView (validity flags, warnings) - Add SyncActiveTabModelToDefault / SyncAllTabModelsToDefault methods - Structured startup error fields for actionable recovery UI - Startup error banner with "Switch to X" button and settings shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a provider is deleted or replaced in desktop settings, tabs with stale model refs (
default_model,planner_model,tab.model) would fail at startup withunknown model "deepseek-flash" (configured: glm-4v)errors. This adds automatic fallback to the first configured provider, fixes all open tab refs on provider deletion, and shows actionable recovery UI.Key changes
ResolveModelWithFallback— resolves a model ref with automatic fallback to the first configured provider when the ref is stale. Only picks providers with a valid API key.RemoveProviderauto-migration — detects both"name"and"name/model"refs indefault_modelandplanner_model. Auto-migrates to fallback instead of blocking. Only refuses when no other configured provider exists.DeleteProvidertab sync — traverses all open tabs and fixes model refs targeting the deleted provider. Always callsrebuild()and propagates errors.SettingsViewnow exposescurrentModel,currentModelValid,defaultModelValid,plannerModelValid,modelWarning.SyncActiveTabModelToDefault()andSyncAllTabModelsToDefault()Wails bindings with frontend buttons.startupErrCode,startupErrModel,startupErrConfigured,startupRecoveryModel). Banner shows "Switch to X" button, "Open model settings" shortcut, and expandable error details.SetModelForTabfix — now clearstab.StartupErr, setstab.Ready = true, and emitsagent:readyso the frontend refreshes Meta/Balance/Effort after model recovery.Risk mitigations verified
LoadForRootloads global credentials vialoadDotEnvForRootbeforeResolveModelWithFallbackis called —Configured()correctly detects keyed providers.config.RemoveProvider— the auto-migration semantic is desktop-only in practice.DeleteProvidercorrectly propagatesrebuild()errors (no_ = a.rebuild()).StartupErrorBannerusesuseController.setModelwhich dispatches Meta/Context/Effort refreshes after recovery.Test plan