Procházet zdrojové kódy

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>
opencode-agent[bot] před 1 měsícem
rodič
revize
50a1add183

+ 1 - 0
packages/tui/src/component/dialog-model.tsx

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

+ 4 - 2
packages/tui/src/ui/dialog-select.tsx

@@ -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)