Skip to content

Commit f1e7e7c

Browse files
committed
feat(tui): even better model selector
1 parent 80b77ca commit f1e7e7c

8 files changed

Lines changed: 675 additions & 67 deletions

File tree

‎packages/tui/internal/completions/commands.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *CommandCompletionProvider) getCommandCompletionItem(
4343
Title: title,
4444
Value: value,
4545
ProviderID: c.GetId(),
46-
})
46+
}, dialog.WithBackgroundColor(t.BackgroundElement()))
4747
}
4848

4949
func (c *CommandCompletionProvider) GetChildEntries(
@@ -91,7 +91,7 @@ func (c *CommandCompletionProvider) GetChildEntries(
9191
}
9292

9393
// Find fuzzy matches
94-
matches := fuzzy.RankFind(query, commandNames)
94+
matches := fuzzy.RankFindFold(query, commandNames)
9595

9696
// Sort by score (best matches first)
9797
sort.Sort(matches)

‎packages/tui/internal/completions/files.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (cg *filesContextGroup) GetEmptyMessage() string {
3030
func (cg *filesContextGroup) getGitFiles() []dialog.CompletionItemI {
3131
t := theme.CurrentTheme()
3232
items := make([]dialog.CompletionItemI, 0)
33-
base := styles.NewStyle().Background(t.BackgroundPanel())
33+
base := styles.NewStyle().Background(t.BackgroundElement())
3434
green := base.Foreground(t.Success()).Render
3535
red := base.Foreground(t.Error()).Render
3636

@@ -55,7 +55,7 @@ func (cg *filesContextGroup) getGitFiles() []dialog.CompletionItemI {
5555
ProviderID: cg.GetId(),
5656
Raw: file,
5757
},
58-
dialog.WithBackgroundColor(t.BackgroundPanel()),
58+
dialog.WithBackgroundColor(t.BackgroundElement()),
5959
)
6060
items = append(items, item)
6161
}
@@ -103,7 +103,7 @@ func (cg *filesContextGroup) GetChildEntries(
103103
ProviderID: cg.GetId(),
104104
Raw: file,
105105
},
106-
dialog.WithBackgroundColor(theme.CurrentTheme().BackgroundPanel()),
106+
dialog.WithBackgroundColor(theme.CurrentTheme().BackgroundElement()),
107107
)
108108
items = append(items, item)
109109
}

‎packages/tui/internal/components/dialog/complete.go‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ type CompletionItemI interface {
3434
GetRaw() any
3535
}
3636

37-
func (ci *CompletionItem) Render(selected bool, width int) string {
37+
func (ci *CompletionItem) Render(selected bool, width int, isFirstInViewport bool) string {
3838
t := theme.CurrentTheme()
3939
baseStyle := styles.NewStyle().Foreground(t.Text())
4040

4141
truncatedStr := truncate.String(string(ci.DisplayValue()), uint(width-4))
4242

43-
backgroundColor := t.BackgroundElement()
43+
backgroundColor := t.BackgroundPanel()
4444
if ci.backgroundColor != nil {
4545
backgroundColor = *ci.backgroundColor
4646
}
@@ -73,6 +73,10 @@ func (ci *CompletionItem) GetRaw() any {
7373
return ci.Raw
7474
}
7575

76+
func (ci *CompletionItem) Selectable() bool {
77+
return true
78+
}
79+
7680
type CompletionItemOption func(*CompletionItem)
7781

7882
func WithBackgroundColor(color compat.AdaptiveColor) CompletionItemOption {
@@ -81,7 +85,10 @@ func WithBackgroundColor(color compat.AdaptiveColor) CompletionItemOption {
8185
}
8286
}
8387

84-
func NewCompletionItem(completionItem CompletionItem, opts ...CompletionItemOption) CompletionItemI {
88+
func NewCompletionItem(
89+
completionItem CompletionItem,
90+
opts ...CompletionItemOption,
91+
) CompletionItemI {
8592
for _, opt := range opts {
8693
opt(&completionItem)
8794
}

0 commit comments

Comments
 (0)