Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
tui: add left arrow back navigation in model selector (#14940)
Eva H7d7c90d7028d
diff --git a/cmd/tui/selector.go b/cmd/tui/selector.goindex 28ffda562..74f905bf3 100644--- a/cmd/tui/selector.go+++ b/cmd/tui/selector.go@@ -242,6 +242,10 @@ func (m selectorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.cancelled = truereturn m, tea.Quit+ case tea.KeyLeft:+ m.cancelled = true+ return m, tea.Quit+case tea.KeyEnter:filtered := m.filteredItems()if len(filtered) > 0 && m.cursor < len(filtered) {@@ -354,7 +358,7 @@ func (m selectorModel) renderContent() string {}s.WriteString("\n")- help := "↑/↓ navigate • enter select • esc cancel"+ help := "↑/↓ navigate • enter select • ← back"if m.helpText != "" {help = m.helpText}@@ -608,6 +612,10 @@ func (m multiSelectorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.cancelled = truereturn m, tea.Quit+ case tea.KeyLeft:+ m.cancelled = true+ return m, tea.Quit+case tea.KeyTab:m.multi = !m.multi@@ -810,7 +818,7 @@ func (m multiSelectorModel) View() string {s.WriteString("\n")if !m.multi {- s.WriteString(selectorHelpStyle.Render("↑/↓ navigate • enter select • tab add multiple • esc cancel"))+ s.WriteString(selectorHelpStyle.Render("↑/↓ navigate • enter select • tab add multiple • ← back"))} else {count := m.selectedCount()if count == 0 {@@ -819,7 +827,7 @@ func (m multiSelectorModel) View() string {s.WriteString(selectorDescStyle.Render(fmt.Sprintf(" %d selected - press enter to continue", count)))}s.WriteString("\n\n")- s.WriteString(selectorHelpStyle.Render("↑/↓ navigate • space toggle • tab select single • enter confirm • esc cancel"))+ s.WriteString(selectorHelpStyle.Render("↑/↓ navigate • space toggle • tab select single • enter confirm • ← back"))}result := s.String()diff --git a/cmd/tui/selector_test.go b/cmd/tui/selector_test.goindex 53700bba7..1887c3af5 100644--- a/cmd/tui/selector_test.go+++ b/cmd/tui/selector_test.go@@ -782,6 +782,9 @@ func TestMulti_MultiModeHelpText(t *testing.T) {if !strings.Contains(content, "tab select single") {t.Error("multi mode should show 'tab select single' in help")}+ if !strings.Contains(content, "← back") {+ t.Error("multi mode should show '← back' in help")+ }}// --- preChecked initialization order ---@@ -868,6 +871,46 @@ func TestMulti_UncheckingTopDefaultFallsBackToNearestCheckedBelow(t *testing.T)}}+// --- Left arrow back navigation ---++func TestSelectorLeftArrowCancelsWhenNoFilter(t *testing.T) {+ m := selectorModelWithCurrent("Pick:", items("a", "b", "c"), "")+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyLeft})+ got := updated.(selectorModel)+ if !got.cancelled {+ t.Error("left arrow with empty filter should cancel (go back)")+ }+}++func TestSelectorLeftArrowCancelsWhenFiltering(t *testing.T) {+ m := selectorModelWithCurrent("Pick:", items("a", "b", "c"), "")+ m.filter = "a"+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyLeft})+ got := updated.(selectorModel)+ if !got.cancelled {+ t.Error("left arrow with active filter should still cancel (go back)")+ }+}++func TestMultiSelectorLeftArrowCancelsWhenNoFilter(t *testing.T) {+ m := newMultiSelectorModel("Pick:", items("a", "b", "c"), nil)+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyLeft})+ got := updated.(multiSelectorModel)+ if !got.cancelled {+ t.Error("left arrow with empty filter should cancel (go back)")+ }+}++func TestMultiSelectorLeftArrowCancelsWhenFiltering(t *testing.T) {+ m := newMultiSelectorModel("Pick:", items("a", "b", "c"), nil)+ m.filter = "a"+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyLeft})+ got := updated.(multiSelectorModel)+ if !got.cancelled {+ t.Error("left arrow with active filter should still cancel (go back)")+ }+}+// Key message helpers for testingtype keyType = int