Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions internal/app/context_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ func newContextTable() table.Model {
styles := table.DefaultStyles()
styles.Header = dimStyle.Copy().Bold(true).Padding(0, 1)
styles.Cell = table.DefaultStyles().Cell.Copy()
styles.Selected = selectedStyle.Copy().
Bold(true).
Background(lipgloss.Color("236"))
styles.Selected = contextTableSelectedStyle()

t := table.New(
table.WithColumns(contextTableColumns(0)),
Expand All @@ -51,6 +49,14 @@ func newContextTable() table.Model {
return t
}

func contextTableSelectedStyle() lipgloss.Style {
base := selectedStyle
return base.
Bold(true).
Foreground(lipgloss.Color("255")).
Background(lipgloss.Color("57"))
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

func (m *Model) syncContextTable() {
m.contextTable.SetColumns(contextTableColumns(m.width))
m.contextTable.SetWidth(contextTableWidth(m.width))
Expand Down
6 changes: 4 additions & 2 deletions internal/app/screen_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ func (m Model) viewContextPicker() string {
b.WriteString(renderDetailLine("Shell env", m.displayShellEnvContext()))
b.WriteString("\n\n")

b.WriteString(m.renderFilterValue(filterContexts))
b.WriteString("\n\n")
if filter := m.renderFilterValue(filterContexts); filter != "" {
b.WriteString(filter)
b.WriteString("\n\n")
}

if len(m.ctxList) == 0 {
panel.WriteString(normalStyle.Render(" No contexts defined."))
Expand Down
30 changes: 30 additions & 0 deletions internal/app/styles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,33 @@ func TestContextPickerPanelDoesNotOverflowHelpBar(t *testing.T) {
t.Fatalf("expected help bar below panel border, got border line %d help line %d in %q", borderLine, helpLine, view)
}
}

func TestContextPickerKeepsSelectionVisibleInCompactTerminal(t *testing.T) {
m := New(testConfig(), "", "dev")
m.width = 80
m.height = 14

updated, _ := m.Update(contextsLoadedMsg{contexts: styleTestContexts()})
m = updated.(Model)
view := stripANSI(m.View())

for _, want := range []string{"Select Context", "prod", "q: quit"} {
if !strings.Contains(view, want) {
t.Fatalf("expected compact context picker to keep %q visible, got %q", want, view)
}
}
if strings.Contains(view, "...") {
t.Fatalf("expected compact context picker to fit without middle truncation, got %q", view)
}
}

func TestContextTableSelectedStyleUsesHighContrast(t *testing.T) {
base := selectedStyle
want := base.
Bold(true).
Foreground(lipgloss.Color("255")).
Background(lipgloss.Color("57"))
if !reflect.DeepEqual(contextTableSelectedStyle(), want) {
t.Fatal("expected context table selected style to use high-contrast foreground/background")
}
}
Loading