From af4500e5040c8343d339cd88dd1d2fb6138c7a72 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 6 Mar 2026 15:29:38 -0600 Subject: [PATCH] refac --- .../layout/Sidebar/PinnedModelList.svelte | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/components/layout/Sidebar/PinnedModelList.svelte b/src/lib/components/layout/Sidebar/PinnedModelList.svelte index da35a3df3..235dda903 100644 --- a/src/lib/components/layout/Sidebar/PinnedModelList.svelte +++ b/src/lib/components/layout/Sidebar/PinnedModelList.svelte @@ -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 ?? []; });