fix(tui): open model selector at top (#36679)

Co-authored-by: Dax Raad <d@ironbay.co>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot] 2026-07-13 10:20:15 -04:00 committed by GitHub
commit 50a1add183
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -154,6 +154,7 @@ export function DialogModel(props: { providerID?: string }) {
skipFilter={true}
title={title()}
current={local.model.current()}
focusCurrent={false}
/>
)
}

View file

@ -51,6 +51,7 @@ export interface DialogSelectProps<T> {
}[]
bindings?: readonly Binding<Renderable, KeyEvent>[]
current?: T
focusCurrent?: boolean
}
export interface DialogSelectOption<T = any> {
@ -104,6 +105,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
on(
() => props.current,
(current) => {
if (props.focusCurrent === false) return
if (current) {
const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current))
if (currentIndex >= 0) {
@ -229,7 +231,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
return
}
if (!selection) {
if (props.current !== undefined) {
if (props.focusCurrent !== false && props.current !== undefined) {
const index = flat().findIndex((option) => isDeepEqual(option.value, props.current))
if (index >= 0) {
setStore("selected", index)
@ -279,7 +281,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
setTimeout(() => {
if (filter.length > 0) {
moveTo(0, true, false)
} else if (current) {
} else if (current && props.focusCurrent !== false) {
const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current))
if (currentIndex >= 0) {
moveTo(currentIndex, true)