fix: patch model selector

This commit is contained in:
cpacker
2025-11-27 02:24:56 -08:00
parent 06ec8b9d3c
commit 7ee5634021
2 changed files with 18 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
// Import useInput from vendored Ink for bracketed paste support
import { Box, Text, useInput } from "ink";
import { useMemo, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { models } from "../../agent/model";
import { colors } from "./colors";
@@ -40,6 +40,18 @@ export function ModelSelector({
return typedModels.slice(0, 5);
}, [featuredModels, showAll, typedModels]);
// Set initial selection to current model on mount
const initializedRef = useRef(false);
useEffect(() => {
if (!initializedRef.current) {
const index = visibleModels.findIndex((m) => m.handle === currentModel);
if (index >= 0) {
setSelectedIndex(index);
}
initializedRef.current = true;
}
}, [visibleModels, currentModel]);
const totalItems = showAll ? visibleModels.length : visibleModels.length + 1;
useInput((_input, key) => {