mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
Merge branch 'fix/stale-model-cleanup'
This commit is contained in:
commit
0836e324a3
1 file changed
+14
-5
@@ -81,16 +81,25 @@ export const useModelStore = create<ModelStore>()(
|
||||
|
||||
const state = get()
|
||||
|
||||
if (!providers || !state.model) {
|
||||
if (!providers) {
|
||||
get().syncFromConfig(configModel)
|
||||
return
|
||||
}
|
||||
|
||||
const modelExists = providers.some(
|
||||
(p) => p.id === state.model!.providerID && p.models && state.model!.modelID in p.models
|
||||
)
|
||||
const modelExists = (model: ModelSelection) =>
|
||||
providers.some(
|
||||
(p) => p.id === model.providerID && p.models && model.modelID in p.models
|
||||
)
|
||||
|
||||
if (!modelExists) {
|
||||
const currentModelExists = state.model ? modelExists(state.model) : false
|
||||
|
||||
const cleanedRecentModels = state.recentModels.filter(modelExists)
|
||||
|
||||
if (cleanedRecentModels.length !== state.recentModels.length) {
|
||||
set({ recentModels: cleanedRecentModels })
|
||||
}
|
||||
|
||||
if (!currentModelExists) {
|
||||
get().syncFromConfig(configModel, true)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user