This commit is contained in:
Timothy Jaeryang Baek
2026-03-06 15:29:38 -06:00
parent 016928722c
commit af4500e504
@@ -37,6 +37,20 @@
let unsubscribeSettings;
const cleanupStalePinnedModels = async (modelIds) => {
const validModels = modelIds.filter((id) => {
const model = $models.find((m) => m.id === id);
// Remove if model not found (deleted) or if hidden
return model && !(model?.info?.meta?.hidden ?? false);
});
if (validModels.length !== modelIds.length) {
pinnedModels = validModels;
settings.set({ ...$settings, pinnedModels: validModels });
await updateUserSettings(localStorage.token, { ui: $settings });
}
};
onMount(async () => {
pinnedModels = $settings?.pinnedModels ?? [];
@@ -48,6 +62,11 @@
await updateUserSettings(localStorage.token, { ui: $settings });
}
// Auto-unpin hidden or deleted models
if (pinnedModels.length > 0) {
await cleanupStalePinnedModels(pinnedModels);
}
unsubscribeSettings = settings.subscribe((value) => {
pinnedModels = value?.pinnedModels ?? [];
});