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:
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}
|
||||
title={title()}
|
||||
current={local.model.current()}
|
||||
focusCurrent={false}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue