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
co-authored by Dax Raad opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
parent 3533047421
commit 50a1add183
2 changed files with 5 additions and 2 deletions
@@ -154,6 +154,7 @@ export function DialogModel(props: { providerID?: string }) {
skipFilter={true} skipFilter={true}
title={title()} title={title()}
current={local.model.current()} current={local.model.current()}
focusCurrent={false}
/> />
) )
} }
+4 -2
View File
@@ -51,6 +51,7 @@ export interface DialogSelectProps<T> {
}[] }[]
bindings?: readonly Binding<Renderable, KeyEvent>[] bindings?: readonly Binding<Renderable, KeyEvent>[]
current?: T current?: T
focusCurrent?: boolean
} }
export interface DialogSelectOption<T = any> { export interface DialogSelectOption<T = any> {
@@ -104,6 +105,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
on( on(
() => props.current, () => props.current,
(current) => { (current) => {
if (props.focusCurrent === false) return
if (current) { if (current) {
const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current)) const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current))
if (currentIndex >= 0) { if (currentIndex >= 0) {
@@ -229,7 +231,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
return return
} }
if (!selection) { if (!selection) {
if (props.current !== undefined) { if (props.focusCurrent !== false && props.current !== undefined) {
const index = flat().findIndex((option) => isDeepEqual(option.value, props.current)) const index = flat().findIndex((option) => isDeepEqual(option.value, props.current))
if (index >= 0) { if (index >= 0) {
setStore("selected", index) setStore("selected", index)
@@ -279,7 +281,7 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
setTimeout(() => { setTimeout(() => {
if (filter.length > 0) { if (filter.length > 0) {
moveTo(0, true, false) moveTo(0, true, false)
} else if (current) { } else if (current && props.focusCurrent !== false) {
const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current)) const currentIndex = flat().findIndex((opt) => isDeepEqual(opt.value, current))
if (currentIndex >= 0) { if (currentIndex >= 0) {
moveTo(currentIndex, true) moveTo(currentIndex, true)