mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
fix: improve registry search modal ux
Alvin Unreal6a8a5b21e104
diff --git a/internal/actions/actions.go b/internal/actions/actions.goindex 8e30d99..a6bf662 100644--- a/internal/actions/actions.go+++ b/internal/actions/actions.go@@ -149,6 +149,56 @@ func bulkBatch(skills []*model.Skill, resolve SkillsResolver, actionID string) (return batch, true, ""}+type AvailableSkillInstall struct {+ Source string+ DisplayName string+ Slug string+}++func ForAvailableSkills(skills []AvailableSkillInstall, global bool) CommandPreview {+ return ForAvailableSkillsWithOptionsAndResolver(skills, global, ResolveSkillsCommand)+}++func ForAvailableSkillsWithOptionsAndResolver(skills []AvailableSkillInstall, global bool, resolve SkillsResolver) CommandPreview {+ if len(skills) == 0 {+ title := "Install selected skills"+ if global {+ title = "Install selected skills globally"+ }+ return unavailablePreview(title, "no skills selected")+ }++ var batch []ExecSpec+ for _, sk := range skills {+ previews := ForAvailableSkillWithOptionsAndResolver(sk.Source, InstallOptions{+ DisplayName: sk.DisplayName,+ Slug: sk.Slug,+ Global: global,+ }, resolve)+ if len(previews) == 0 || !previews[0].Available {+ reason := "unsupported command"+ if len(previews) > 0 {+ reason = previews[0].Reason+ }+ title := "Install selected skills"+ if global {+ title = "Install selected skills globally"+ }+ return unavailablePreview(title, fmt.Sprintf("%s: %s", compat.SanitizeMetadata(sk.DisplayName), reason))+ }+ batch = append(batch, previews[0].Exec)+ }++ title := "Install selected skills"+ confirmValue := fmt.Sprintf("install %d skills", len(skills))+ if global {+ title = "Install selected skills globally"+ confirmValue = fmt.Sprintf("install %d skills globally", len(skills))+ }++ return newBatchPreview("bulk_install_skills", title, batch, "Install the selected skills.", confirmValue, false)+}+func ForAvailableSkill(source, name string) []CommandPreview {return ForAvailableSkillWithResolver(source, name, false, ResolveSkillsCommand)}diff --git a/internal/actions/actions_test.go b/internal/actions/actions_test.goindex ca923f7..272f348 100644--- a/internal/actions/actions_test.go+++ b/internal/actions/actions_test.go@@ -547,3 +547,39 @@ func TestForAvailableSkillWithOptions(t *testing.T) {})}}++func TestForAvailableSkills(t *testing.T) {+ ResetActionCaches()+ originalLookPath := LookPath+ defer func() {+ LookPath = originalLookPath+ ResetActionCaches()+ }()+ LookPath = func(name string) (string, error) {+ return "/usr/bin/" + name, nil+ }+ ResetActionCaches()++ skills := []AvailableSkillInstall{+ {Source: "owner/one", DisplayName: "One", Slug: "one"},+ {Source: "owner/two", DisplayName: "Two", Slug: "two"},+ }++ // Project install+ preview := ForAvailableSkills(skills, false)+ if !preview.Available || preview.ID != "bulk_install_skills" {+ t.Fatalf("expected project bulk install preview available, got %+v", preview)+ }+ if len(preview.Exec.Batch) != 2 {+ t.Fatalf("expected batch size 2, got %d", len(preview.Exec.Batch))+ }++ // Global install+ globalPreview := ForAvailableSkills(skills, true)+ if !globalPreview.Available || globalPreview.ID != "bulk_install_skills" {+ t.Fatalf("expected global bulk install preview available, got %+v", globalPreview)+ }+ if len(globalPreview.Exec.Batch) != 2 {+ t.Fatalf("expected global batch size 2, got %d", len(globalPreview.Exec.Batch))+ }+}diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 0eacaa6..0b24080 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -117,6 +117,8 @@ type appModel struct {registryError errorregistryGeneration intregistryFocusList bool+ registrySelectedKeys map[string]registry.Skill+ confirmReturnRegistry bool}type paneLayout struct {diff --git a/internal/tui/update.go b/internal/tui/update.goindex 76de0b6..f34b2b2 100644--- a/internal/tui/update.go+++ b/internal/tui/update.go@@ -199,6 +199,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registryResults = nilm.registryError = nilm.registryLoading = false+ m.registrySelectedKeys = nilm.syncViewport()return m, nilcase "q":@@ -208,6 +209,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registryResults = nilm.registryError = nilm.registryLoading = false+ m.registrySelectedKeys = nilm.syncViewport()return m, nil}@@ -236,6 +238,24 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.syncViewport()}return m, nil+ case " ":+ if m.registryFocusList && len(m.registryResults) > 0 {+ s := m.registryResults[m.registrySelected]+ status, _ := m.checkRegistrySkillStatus(s)+ if status != StatusInstalled && !s.Invalid {+ if m.registrySelectedKeys == nil {+ m.registrySelectedKeys = make(map[string]registry.Skill)+ }+ key := s.Source + "\x00" + s.Slug+ if _, exists := m.registrySelectedKeys[key]; exists {+ delete(m.registrySelectedKeys, key)+ } else {+ m.registrySelectedKeys[key] = s+ }+ m.syncViewport()+ }+ return m, nil+ }case "enter":if !m.registryFocusList {if len(m.registryQuery) >= 2 && (m.registryError != nil || len(m.registryResults) == 0) {@@ -251,7 +271,28 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {return m, nil}// List is focused: start project install confirmation- if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {+ selectedCount := len(m.registrySelectedKeys)+ if selectedCount > 0 {+ var list []actions.AvailableSkillInstall+ for _, s := range m.registrySelectedKeys {+ list = append(list, actions.AvailableSkillInstall{+ Source: s.Source,+ DisplayName: s.DisplayName,+ Slug: s.Slug,+ })+ }+ preview := actions.ForAvailableSkills(list, false)+ if preview.Available {+ m.registryModal = false+ m.pendingAction = &preview+ m.confirming = true+ m.confirmInput = ""+ m.confirmError = ""+ m.confirmReturnRegistry = true+ m.syncViewport()+ return m, nil+ }+ } else if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {s := m.registryResults[m.registrySelected]status, checkMsg := m.checkRegistrySkillStatus(s)if status == StatusInstalled || s.Invalid {@@ -274,6 +315,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.confirming = truem.confirmInput = ""m.confirmError = ""+ m.confirmReturnRegistry = truem.syncViewport()return m, nil}@@ -282,7 +324,28 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {case "g":if m.registryFocusList {// list focused: start global install confirmation- if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {+ selectedCount := len(m.registrySelectedKeys)+ if selectedCount > 0 {+ var list []actions.AvailableSkillInstall+ for _, s := range m.registrySelectedKeys {+ list = append(list, actions.AvailableSkillInstall{+ Source: s.Source,+ DisplayName: s.DisplayName,+ Slug: s.Slug,+ })+ }+ preview := actions.ForAvailableSkills(list, true)+ if preview.Available {+ m.registryModal = false+ m.pendingAction = &preview+ m.confirming = true+ m.confirmInput = ""+ m.confirmError = ""+ m.confirmReturnRegistry = true+ m.syncViewport()+ return m, nil+ }+ } else if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {s := m.registryResults[m.registrySelected]status, checkMsg := m.checkRegistrySkillStatus(s)if status == StatusInstalled || s.Invalid {@@ -304,6 +367,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.confirming = truem.confirmInput = ""m.confirmError = ""+ m.confirmReturnRegistry = truem.syncViewport()return m, nil}@@ -328,12 +392,14 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registrySelected = 0m.registryGeneration++if len(m.registryQuery) >= 2 {+ m.registryLoading = truem.syncViewport()return m, scheduleRegistrySearch(m.registryQuery, m.registryGeneration)} else {m.registryResults = nilm.registryError = nilm.registryLoading = false+ m.registrySelectedKeys = nilm.syncViewport()return m, nil}@@ -503,7 +569,10 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.confirmInput = ""m.confirmError = ""m.pendingAction = nil- if m.confirmReturnDetailModal {+ if m.confirmReturnRegistry {+ m.registryModal = true+ m.confirmReturnRegistry = false+ } else if m.confirmReturnDetailModal {m.detailModal = truem.modalSource = m.confirmReturnModalSourcem.modalSelected = m.confirmReturnModalSelected@@ -1515,6 +1584,7 @@ func (m appModel) openRegistryModal() appModel {m.registryError = nilm.registryLoading = falsem.registryFocusList = false+ m.registrySelectedKeys = nilm.registryGeneration++return m}diff --git a/internal/tui/update_test.go b/internal/tui/update_test.goindex 36a4048..a1ff36a 100644--- a/internal/tui/update_test.go+++ b/internal/tui/update_test.go@@ -469,3 +469,160 @@ func TestTUIRegistryInvalidResultDisablesInstall(t *testing.T) {t.Fatalf("invalid registry install should no-op in modal, confirming=%v modal=%v cmd=%v", m.confirming, m.registryModal, cmd)}}++func TestTUINoFalseNoSkillsFoundWhileSearchPending(t *testing.T) {+ m := newModel("")+ m.width = 100+ m.height = 30+ m.registryModal = true+ m.registryQuery = "a"+ m.registryResults = nil+ m.registryFocusList = false++ modelTmp, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'b'}})+ m = modelTmp.(appModel)+ if !m.registryLoading {+ t.Fatal("expected registryLoading to be true immediately on typing query >= 2 chars")+ }++ viewStr := m.View()+ if strings.Contains(viewStr, "No skills found in registry.") {+ t.Error("should not show 'No skills found' while search is loading/pending")+ }+ if !strings.Contains(viewStr, "Searching registry...") {+ t.Error("expected 'Searching registry...' to be shown while search is loading/pending")+ }+}++func TestTUICancelPreservesRegistryModalState(t *testing.T) {+ m := newModel("")+ m.width = 100+ m.height = 30+ m.registryModal = true+ m.registryQuery = "hello"+ m.registryResults = []registry.Skill{{+ DisplayName: "Hello Skill",+ Slug: "hello-slug",+ Source: "owner/hello",+ }}+ m.registrySelected = 0+ m.registryFocusList = true++ // Press Enter to install (this starts confirmation)+ modelTmp, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})+ m = modelTmp.(appModel)+ if m.registryModal {+ t.Fatal("expected registryModal to be false during confirmation")+ }+ if !m.confirming {+ t.Fatal("expected confirmation to be active")+ }++ // Press Esc to cancel+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyEsc})+ m = modelTmp.(appModel)+ if !m.registryModal {+ t.Fatal("expected return to registryModal after cancelling")+ }+ if m.registryQuery != "hello" {+ t.Errorf("expected registryQuery to be preserved, got %q", m.registryQuery)+ }+ if len(m.registryResults) != 1 || m.registryResults[0].Slug != "hello-slug" {+ t.Errorf("expected registryResults to be preserved, got %#v", m.registryResults)+ }+}++func TestTUIRegistrySpaceTogglesMultiSelect(t *testing.T) {+ m := newModel("")+ m.width = 100+ m.height = 30+ m.registryModal = true+ m.registryQuery = "hello"+ m.registryResults = []registry.Skill{+ {DisplayName: "One", Slug: "one", Source: "owner/one"},+ {DisplayName: "Two", Slug: "two", Source: "owner/two"},+ }+ m.registrySelected = 0+ m.registryFocusList = true++ // Press Space to select "One"+ modelTmp, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{' '}})+ m = modelTmp.(appModel)++ key1 := "owner/one\x00one"+ if _, ok := m.registrySelectedKeys[key1]; !ok {+ t.Fatal("expected 'One' to be selected")+ }++ // Press Down then Space to select "Two"+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyDown})+ m = modelTmp.(appModel)+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{' '}})+ m = modelTmp.(appModel)++ key2 := "owner/two\x00two"+ if _, ok := m.registrySelectedKeys[key2]; !ok {+ t.Fatal("expected 'Two' to be selected")+ }+ if len(m.registrySelectedKeys) != 2 {+ t.Errorf("expected 2 selected skills, got %d", len(m.registrySelectedKeys))+ }++ // Press Space again on "Two" to deselect it+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{' '}})+ m = modelTmp.(appModel)+ if _, ok := m.registrySelectedKeys[key2]; ok {+ t.Fatal("expected 'Two' to be deselected")+ }+ if len(m.registrySelectedKeys) != 1 {+ t.Errorf("expected 1 selected skill remaining, got %d", len(m.registrySelectedKeys))+ }+}++func TestTUIRegistryMultiInstallDispatch(t *testing.T) {+ m := newModel("")+ m.width = 100+ m.height = 30+ m.registryModal = true+ m.registryQuery = "hello"+ m.registryResults = []registry.Skill{+ {DisplayName: "One", Slug: "one", Source: "owner/one"},+ {DisplayName: "Two", Slug: "two", Source: "owner/two"},+ }+ m.registrySelected = 0+ m.registryFocusList = true++ // Select both of them+ modelTmp, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{' '}})+ m = modelTmp.(appModel)+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyDown})+ m = modelTmp.(appModel)+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{' '}})+ m = modelTmp.(appModel)++ // Press Enter to install+ modelTmp, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter})+ m = modelTmp.(appModel)++ if m.registryModal {+ t.Fatal("expected registryModal to be closed")+ }+ if !m.confirming {+ t.Fatal("expected confirming to be active")+ }+ if m.pendingAction == nil {+ t.Fatal("expected pendingAction to be set")+ }+ if m.pendingAction.ID != "bulk_install_skills" {+ t.Errorf("expected bulk_install_skills action, got %s", m.pendingAction.ID)+ }+ if len(m.pendingAction.Exec.Batch) != 2 {+ t.Errorf("expected a batch size of 2, got %d", len(m.pendingAction.Exec.Batch))+ }++ // Check prompt/visual contains bulk info+ viewStr := m.View()+ if !strings.Contains(viewStr, "Confirm action") && !strings.Contains(viewStr, "Install selected skills") {+ t.Errorf("unexpected confirmation view: %s", viewStr)+ }+}diff --git a/internal/tui/view.go b/internal/tui/view.goindex deb9279..eb1bac4 100644--- a/internal/tui/view.go+++ b/internal/tui/view.go@@ -1605,7 +1605,8 @@ func (m appModel) confirmationOverlay(layout appLayout) string {if input == "" {input = dimStyle.Render(placeholder)}- lines = append(lines, "", "> "+input+"_")+ cursor := lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Render("┃")+ lines = append(lines, "", "> "+input+cursor)box := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(borderColor).Padding(1, 2).Width(52).Render(strings.Join(lines, "\n"))return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)}@@ -1708,6 +1709,10 @@ func truncateReleaseNotes(notes string, width int) string {return strings.Join(out, "\n")}+func (m appModel) registrySelectedCount() int {+ return len(m.registrySelectedKeys)+}+func (m appModel) registryModalOverlay(layout appLayout) string {modalWidth, modalHeight := detailModalDimensions(layout)innerWidth := modalWidth - 4@@ -1720,26 +1725,38 @@ func (m appModel) registryModalOverlay(layout appLayout) string {// Left pane header: Query inputvar inputLine stringfocusPrompt := "Search: "- if !m.registryFocusList {- focusPrompt = "Search › "- }cursor := ""if !m.registryFocusList {- cursor = "_"+ cursor = lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Render("┃")}- if m.registryQuery == "" {- inputLine = focusPrompt + dimStyle.Render("Type to search...") + cursor++ if m.registryFocusList {+ // List is focused: input prompt is dim+ promptStyled := dimStyle.Render(focusPrompt)+ if m.registryQuery == "" {+ inputLine = promptStyled + dimStyle.Render("Type to search...")+ } else {+ inputLine = promptStyled + m.registryQuery+ }} else {- inputLine = lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Bold(true).Render(focusPrompt) + m.registryQuery + cursor+ // Search input is focused: prompt has high contrast+ promptStyled := lipgloss.NewStyle().Foreground(lipgloss.Color("205")).Bold(true).Render(focusPrompt)+ if m.registryQuery == "" {+ inputLine = promptStyled + dimStyle.Render("Type to search...") + cursor+ } else {+ inputLine = promptStyled + m.registryQuery + cursor+ }+ }++ if m.registryLoading {+ inputLine += dimStyle.Render(" (searching...)")}var leftContentLines []stringleftContentLines = append(leftContentLines, inputLine, "")// Left pane body: status or results- if m.registryLoading {- leftContentLines = append(leftContentLines, " "+runningStyle.Render("Searching registry..."))- } else if m.registryError != nil {+ if m.registryError != nil && !m.registryLoading {leftContentLines = append(leftContentLines,errorStyle.Render(" Error fetching results:"),wrapText(" "+m.registryError.Error(), leftWidth),@@ -1749,7 +1766,11 @@ func (m appModel) registryModalOverlay(layout appLayout) string {} else if len(m.registryQuery) < 2 {leftContentLines = append(leftContentLines, " Type at least 2 characters to search.")} else if len(m.registryResults) == 0 {- leftContentLines = append(leftContentLines, " No skills found in registry.")+ if m.registryLoading {+ leftContentLines = append(leftContentLines, " "+runningStyle.Render("Searching registry..."))+ } else {+ leftContentLines = append(leftContentLines, " No skills found in registry.")+ }} else {// Show resultsfor idx, s := range m.registryResults {@@ -1782,7 +1803,13 @@ func (m appModel) registryModalOverlay(layout appLayout) string {if availNameWidth < 5 {availNameWidth = 5}- namePart := truncate(s.DisplayName, availNameWidth)+ selectedMark := " "+ if m.registrySelectedKeys != nil {+ if _, isSel := m.registrySelectedKeys[s.Source+"\x00"+s.Slug]; isSel {+ selectedMark = "● "+ }+ }+ namePart := truncate(selectedMark+s.DisplayName, availNameWidth)// Pad the lineline := selector + namePart@@ -1802,9 +1829,52 @@ func (m appModel) registryModalOverlay(layout appLayout) string {leftPane := fitLines(strings.Join(leftContentLines, "\n"), innerHeight)- // Right pane: detail preview+ // Right pane: detail preview / bulk detailsvar rightContentLines []string- if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {+ selectedCount := m.registrySelectedCount()+ if selectedCount > 0 {+ rightContentLines = append(rightContentLines,+ titleStyle.Render(fmt.Sprintf("Bulk Installation (%d)", selectedCount)),+ "",+ sectionHeaderStyle.Render("Selected Skills:"),+ "",+ )+ for _, selSkill := range m.registrySelectedKeys {+ rightContentLines = append(rightContentLines,+ fmt.Sprintf(" • %s (%s)", selSkill.DisplayName, selSkill.Slug),+ )+ }++ var list []actions.AvailableSkillInstall+ for _, s := range m.registrySelectedKeys {+ list = append(list, actions.AvailableSkillInstall{+ Source: s.Source,+ DisplayName: s.DisplayName,+ Slug: s.Slug,+ })+ }+ projPreview := actions.ForAvailableSkills(list, false)+ globalPreview := actions.ForAvailableSkills(list, true)++ rightContentLines = append(rightContentLines, "")+ rightContentLines = append(rightContentLines, sectionHeaderStyle.Render("Install Commands:"), "")+ if projPreview.Available {+ rightContentLines = append(rightContentLines,+ dimStyle.Render("Project-local:"),+ " "+projPreview.Command,+ )+ } else {+ rightContentLines = append(rightContentLines, errorStyle.Render("Project-local: "+projPreview.Reason))+ }+ if globalPreview.Available {+ rightContentLines = append(rightContentLines,+ dimStyle.Render("Globally (adds -g):"),+ " "+globalPreview.Command,+ )+ } else {+ rightContentLines = append(rightContentLines, errorStyle.Render("Globally: "+globalPreview.Reason))+ }+ } else if len(m.registryResults) > 0 && m.registrySelected >= 0 && m.registrySelected < len(m.registryResults) {s := m.registryResults[m.registrySelected]status, similarMsg := m.checkRegistrySkillStatus(s)@@ -1931,10 +2001,16 @@ func (m appModel) registryModalHelpLine() string {return "type search · tab select list · esc close"}parts := []string{"↑/↓ choose"}- if m.selectedRegistryResultInstallable() {- parts = append(parts, "enter install to project", "g install globally")+ parts = append(parts, "space toggle")+ selectedCount := m.registrySelectedCount()+ if selectedCount > 0 {+ parts = append(parts, fmt.Sprintf("enter install (%d)", selectedCount), fmt.Sprintf("g install globally (%d)", selectedCount))} else {- parts = append(parts, "install unavailable")+ if m.selectedRegistryResultInstallable() {+ parts = append(parts, "enter install to project", "g install globally")+ } else {+ parts = append(parts, "install unavailable")+ }}parts = append(parts, "tab type search", "esc close")return strings.Join(parts, " · ")