Fix model selection resetting issue

The useEffect was re-running every time model changed, causing
Claude model selection to reset back to Ollama models. Fixed by:
- Removing model from useEffect dependency array
- Only run model fetch on component mount
- Check if saved model exists before loading it
- Don't reset model if it's not in Ollama list (allows Claude)
This commit is contained in:
Dave
2025-12-27 19:50:47 +00:00
parent e3f4f92c54
commit 2976c854d0

View File

@@ -102,9 +102,9 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
const savedModel = await invoke<string | null>(
"get_model_preference",
);
if (savedModel && models.includes(savedModel)) {
if (savedModel) {
setModel(savedModel);
} else if (!models.includes(model)) {
} else if (models.length > 0) {
setModel(models[0]);
}
} catch (e) {
@@ -114,7 +114,7 @@ export function Chat({ projectPath, onCloseProject }: ChatProps) {
})
.catch((err) => console.error(err));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [model]);
}, []);
useEffect(() => {
const unlistenUpdatePromise = listen<Message[]>("chat:update", (event) => {