From a7bcec220a5c6cbe4ffda60a9fe3b02c3cba0901 Mon Sep 17 00:00:00 2001 From: Adeniji Adekunle James Date: Wed, 10 Dec 2025 01:07:03 +0000 Subject: [PATCH] Fix: Custom Model Not Updating (#1817) (#1840) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes (#1817) --- ## Summary by cubic Fixes the bug where editing a custom model didn’t update the currently selected model. The selection now stays in sync after renaming or editing. - **Bug Fixes** - Use useSettings to detect if the edited model is the active one (match provider and apiName). - Update settings.selectedModel with the new apiName; on failure show an error and keep the dialog open; otherwise show success, call onSuccess, then close. Written for commit 88045165a3989277e703a8f31712fcf1dfeaa32a. Summary will update automatically on new commits. --- src/components/EditCustomModelDialog.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/EditCustomModelDialog.tsx b/src/components/EditCustomModelDialog.tsx index a30ab0b..2db06ae 100644 --- a/src/components/EditCustomModelDialog.tsx +++ b/src/components/EditCustomModelDialog.tsx @@ -11,6 +11,7 @@ import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { IpcClient } from "@/ipc/ipc_client"; +import { useSettings } from "@/hooks/useSettings"; import { useMutation } from "@tanstack/react-query"; import { showError, showSuccess } from "@/lib/toast"; @@ -44,6 +45,7 @@ export function EditCustomModelDialog({ const [description, setDescription] = useState(""); const [maxOutputTokens, setMaxOutputTokens] = useState(""); const [contextWindow, setContextWindow] = useState(""); + const { settings, updateSettings } = useSettings(); const ipcClient = IpcClient.getInstance(); @@ -89,7 +91,22 @@ export function EditCustomModelDialog({ // Then create the new model await ipcClient.createCustomLanguageModel(newParams); }, - onSuccess: () => { + onSuccess: async () => { + if ( + settings?.selectedModel?.name === model?.apiName && + settings?.selectedModel?.provider === providerId + ) { + const newModel = { + ...settings.selectedModel, + name: apiName, + }; + try { + await updateSettings({ selectedModel: newModel }); + } catch { + showError("Failed to update settings"); + return; // stop closing dialog + } + } showSuccess("Custom model updated successfully!"); onSuccess(); onClose();