diff --git a/packages/tui/internal/completions/files.go b/packages/tui/internal/completions/files.go index 861762db8..22a8b91e3 100644 --- a/packages/tui/internal/completions/files.go +++ b/packages/tui/internal/completions/files.go @@ -54,7 +54,9 @@ func (cg *filesContextGroup) getGitFiles() []dialog.CompletionItemI { Value: file.Path, ProviderID: cg.GetId(), Raw: file, - }) + }, + dialog.WithBackgroundColor(t.BackgroundPanel()), + ) items = append(items, item) } } @@ -100,7 +102,9 @@ func (cg *filesContextGroup) GetChildEntries( Value: file, ProviderID: cg.GetId(), Raw: file, - }) + }, + dialog.WithBackgroundColor(theme.CurrentTheme().BackgroundPanel()), + ) items = append(items, item) } } diff --git a/packages/tui/internal/components/dialog/complete.go b/packages/tui/internal/components/dialog/complete.go index 0e8019a23..58ec2fef1 100644 --- a/packages/tui/internal/components/dialog/complete.go +++ b/packages/tui/internal/components/dialog/complete.go @@ -9,6 +9,7 @@ import ( "github.com/charmbracelet/bubbles/v2/textarea" tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/lipgloss/v2" + "github.com/charmbracelet/lipgloss/v2/compat" "github.com/lithammer/fuzzysearch/fuzzy" "github.com/muesli/reflow/truncate" "github.com/sst/opencode/internal/components/list" @@ -18,10 +19,11 @@ import ( ) type CompletionItem struct { - Title string - Value string - ProviderID string - Raw any + Title string + Value string + ProviderID string + Raw any + backgroundColor *compat.AdaptiveColor } type CompletionItemI interface { @@ -38,8 +40,13 @@ func (ci *CompletionItem) Render(selected bool, width int) string { truncatedStr := truncate.String(string(ci.DisplayValue()), uint(width-4)) + backgroundColor := t.BackgroundElement() + if ci.backgroundColor != nil { + backgroundColor = *ci.backgroundColor + } + itemStyle := baseStyle. - Background(t.BackgroundElement()). + Background(backgroundColor). Padding(0, 1) if selected { @@ -66,7 +73,18 @@ func (ci *CompletionItem) GetRaw() any { return ci.Raw } -func NewCompletionItem(completionItem CompletionItem) CompletionItemI { +type CompletionItemOption func(*CompletionItem) + +func WithBackgroundColor(color compat.AdaptiveColor) CompletionItemOption { + return func(ci *CompletionItem) { + ci.backgroundColor = &color + } +} + +func NewCompletionItem(completionItem CompletionItem, opts ...CompletionItemOption) CompletionItemI { + for _, opt := range opts { + opt(&completionItem) + } return &completionItem } diff --git a/packages/tui/internal/components/dialog/find.go b/packages/tui/internal/components/dialog/find.go index a7f43842b..1f716c892 100644 --- a/packages/tui/internal/components/dialog/find.go +++ b/packages/tui/internal/components/dialog/find.go @@ -133,7 +133,7 @@ func (f *findDialogComponent) View() string { listView := f.list.View() return styles.NewStyle(). Height(12). - Background(t.BackgroundElement()). + Background(t.BackgroundPanel()). Width(f.width - 4). Render(inputView + "\n" + listView) }