mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
Make TUI footer action hints capability-aware
Alvin Unreal2a47b074cc82
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.goindex fd1799c..b1143e0 100644--- a/internal/tui/tui_test.go+++ b/internal/tui/tui_test.go@@ -1597,13 +1597,22 @@ func TestSkillsFindTriggersRescan(t *testing.T) {}func TestContextualFooterAndHelpModal(t *testing.T) {+ oldLookPath := actions.LookPath+ actions.LookPath = func(file string) (string, error) {+ if file == "skills" {+ return "/usr/bin/skills", nil+ }+ return "", errors.New("not found")+ }+ t.Cleanup(func() { actions.LookPath = oldLookPath })+m := appModel{width: 100,height: 30,selected: 1,result: model.ScanResult{Skills: []*model.Skill{- {Name: "Build", Scope: model.ScopeProject},+ {Name: "Build", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}, ObservedPaths: []model.ObservedPath{{Path: "/tmp/build", Scope: model.ScopeProject, Status: model.StatusCanonical}}},},},}@@ -1614,6 +1623,9 @@ func TestContextualFooterAndHelpModal(t *testing.T) {if !strings.Contains(outDefault, "enter open · e enable/disable · c actions") {t.Fatalf("expected default footer in View, got:\n%s", outDefault)}+ if !strings.Contains(outDefault, "u update") || !strings.Contains(outDefault, "x remove") {+ t.Fatalf("expected tracked skill footer to include update/remove, got:\n%s", outDefault)+ }// 1b. Source row selected footerm.selected = 0@@ -1665,6 +1677,139 @@ func TestContextualFooterAndHelpModal(t *testing.T) {}}+func TestFooterHidesUnavailableSkillHotkeys(t *testing.T) {+ oldLookPath := actions.LookPath+ actions.LookPath = func(file string) (string, error) {+ if file == "skills" {+ return "/usr/bin/skills", nil+ }+ return "", errors.New("not found")+ }+ t.Cleanup(func() { actions.LookPath = oldLookPath })++ m := appModel{+ width: 100,+ height: 30,+ selected: 1,+ result: model.ScanResult{Skills: []*model.Skill{{+ Name: "Loose Skill",+ Scope: model.ScopeGlobal,+ CanonicalPath: "/tmp/loose-skill",+ }}},+ }+ m.syncViewport()++ footer := m.footerText(100)+ if strings.Contains(footer, "u update") {+ t.Fatalf("untracked skill footer should hide unavailable update hotkey, got %q", footer)+ }+ if !strings.Contains(footer, "enter open") || !strings.Contains(footer, "c actions") || !strings.Contains(footer, "? help") {+ t.Fatalf("expected neutral actions to remain visible, got %q", footer)+ }++ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'u'}})+ next := updated.(appModel)+ if cmd != nil || next.confirming || next.running {+ t.Fatalf("unavailable update hotkey should stay idle, confirming=%v running=%v cmd=%v", next.confirming, next.running, cmd)+ }+}++func TestSourceScanHintIgnoresBulkSelection(t *testing.T) {+ m := appModel{+ width: 120,+ height: 32,+ selected: 0,+ result: model.ScanResult{Skills: []*model.Skill{+ {Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},+ {Name: "Two", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},+ }},+ }+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true}+ m.syncViewport()++ footer := m.footerText(120)+ if !strings.Contains(footer, "d scan") {+ t.Fatalf("source header should show scan even with bulk selection active, got %q", footer)+ }+}++func TestDetailModalHelpHidesUnavailableOpen(t *testing.T) {+ t.Setenv("EDITOR", "")+ m := appModel{+ width: 120,+ height: 32,+ selected: 1,+ detailModal: true,+ result: model.ScanResult{Skills: []*model.Skill{{+ Name: "Loose Skill",+ Scope: model.ScopeProject,+ }}},+ }++ help := m.detailModalHelpLine()+ if strings.Contains(help, "o open") || strings.Contains(help, "o open in editor") {+ t.Fatalf("detail modal should hide unavailable open hint, got %q", help)+ }+ if !strings.Contains(help, "c command picker") || !strings.Contains(help, "↑/↓ scroll") {+ t.Fatalf("detail modal should keep neutral hints, got %q", help)+ }+}++func TestDetailModalOpenHintIgnoresBulkSelection(t *testing.T) {+ t.Setenv("EDITOR", "vim")+ m := appModel{+ width: 120,+ height: 32,+ selected: 2,+ detailModal: true,+ result: model.ScanResult{Skills: []*model.Skill{+ {Name: "Selected Elsewhere", Scope: model.ScopeProject, SkillPath: "/tmp/selected/SKILL.md"},+ {Name: "Current Detail", Scope: model.ScopeProject, SkillPath: "/tmp/current/SKILL.md"},+ }},+ }+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true}+ m.syncViewport()++ help := m.detailModalHelpLine()+ if !strings.Contains(help, "o open in editor") {+ t.Fatalf("detail modal should show current-row open hint even with bulk selection, got %q", help)+ }+}++func TestSourceModalHelpIsCapabilityAware(t *testing.T) {+ oldLookPath := actions.LookPath+ actions.LookPath = func(file string) (string, error) {+ if file == "skills" {+ return "/usr/bin/skills", nil+ }+ return "", errors.New("not found")+ }+ t.Cleanup(func() { actions.LookPath = oldLookPath })+ t.Setenv("EDITOR", "")++ m := appModel{+ width: 120,+ height: 32,+ selected: 0,+ detailModal: true,+ modalSource: "owner/repo",+ result: model.ScanResult{Skills: []*model.Skill{{+ Name: "Installed",+ Scope: model.ScopeProject,+ LocalLock: &model.LocalLockEntry{Source: "owner/repo"},+ }}},+ }+ m.syncViewport()++ help := m.detailModalHelpLine()+ if strings.Contains(help, "enter open") || strings.Contains(help, "o open") {+ t.Fatalf("source modal should hide unavailable installed-skill open hints, got %q", help)+ }+ if !strings.Contains(help, "d scan") || !strings.Contains(help, "c more") {+ t.Fatalf("source modal should keep available scan and actions hints, got %q", help)+ }+}+func TestSelectedSkillActionsDoNotIncludeAppActions(t *testing.T) {m := appModel{selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Scope: model.ScopeProject}}}}previews := m.currentActions()diff --git a/internal/tui/view.go b/internal/tui/view.goindex d5ea2df..b90f8f5 100644--- a/internal/tui/view.go+++ b/internal/tui/view.go@@ -8,6 +8,7 @@ import ("charm.land/glamour/v2""charm.land/glamour/v2/ansi""charm.land/glamour/v2/styles"+ "github.com/alvinunreal/lazyskills/internal/actions""github.com/alvinunreal/lazyskills/internal/compat""github.com/alvinunreal/lazyskills/internal/display""github.com/alvinunreal/lazyskills/internal/model"@@ -1254,27 +1255,66 @@ func (m appModel) footerText(width int) string {} else if m.searching {text = "type search · enter apply · esc cancel · backspace edit"} else if m.detailModal {- text = "↑/↓ scroll · o edit · c commands · esc/q close"+ modalActions := m.currentActions()+ parts := []string{"↑/↓ scroll"}+ if hasAvailableAction(modalActions, "open_skill") {+ parts = append(parts, "o edit")+ }+ parts = append(parts, "c commands", "esc/q close")+ text = strings.Join(parts, " · ")} else if m.commands {text = "↑/↓ choose · enter run · e enable/disable · esc close"} else if m.helpOpen {text = "esc/q/? close help"} else if m.focus == focusMetadata {- text = "↑/↓ scroll metadata · enter open · c commands · e enable/disable · ? help"+ footerActions := m.currentActions()+ parts := []string{"↑/↓ scroll metadata", "enter open", "c commands"}+ if hasAvailableToggleAction(footerActions) {+ parts = append(parts, "e enable/disable")+ }+ parts = append(parts, "? help")+ text = strings.Join(parts, " · ")} else if m.focus == focusPreview {- text = "↑/↓ scroll preview · enter open · c commands · e enable/disable · ? help"+ footerActions := m.currentActions()+ parts := []string{"↑/↓ scroll preview", "enter open", "c commands"}+ if hasAvailableToggleAction(footerActions) {+ parts = append(parts, "e enable/disable")+ }+ parts = append(parts, "? help")+ text = strings.Join(parts, " · ")} else {// focusSkillsrows := m.visibleRows()if len(rows) > 0 && m.selected >= 0 && m.selected < len(rows) {row := rows[m.selected]+ footerActions := m.currentActions()if row.isHeader {- text = "enter browse · e enable/disable source · d scan · c actions · ? help"+ parts := []string{"enter browse"}+ if hasAvailableToggleAction(footerActions) {+ parts = append(parts, "e enable/disable source")+ }+ if discoverable, _ := m.isSourceDiscoverable(row.groupName); discoverable {+ parts = append(parts, "d scan")+ }+ parts = append(parts, "c actions", "? help")+ text = strings.Join(parts, " · ")} else {- text = "enter open · e enable/disable · c actions · u update · x remove · ? help"+ parts := []string{"enter open"}+ if hasAvailableToggleAction(footerActions) {+ parts = append(parts, "e enable/disable")+ }+ parts = append(parts, "c actions")+ if hasAvailableAction(footerActions, preferredUpdateActionID(m.selectedCount())) {+ parts = append(parts, "u update")+ }+ if hasAvailableAction(footerActions, preferredRemoveActionID(m.selectedCount())) {+ parts = append(parts, "x remove")+ }+ parts = append(parts, "? help")+ text = strings.Join(parts, " · ")}} else {- text = "enter open · e enable/disable · c actions · u update · x remove · ? help"+ text = "enter open · c actions · ? help"}}isNormalState := !m.running && !m.confirming && !m.searching && !m.detailModal && !m.commands && !m.helpOpen@@ -1291,6 +1331,22 @@ func (m appModel) footerText(width int) string {return dimStyle.Render(truncate(text, width))}+func hasAvailableAction(previews []actions.CommandPreview, id string) bool {+ if id == "" {+ return false+ }+ for _, action := range previews {+ if action.ID == id && action.Available {+ return true+ }+ }+ return false+}++func hasAvailableToggleAction(previews []actions.CommandPreview) bool {+ return hasAvailableAction(previews, "enable_skill") || hasAvailableAction(previews, "disable_skill")+}+func (m appModel) helpModalOverlay(layout appLayout) string {modalWidth := 74if layout.Width < modalWidth+4 {@@ -1388,10 +1444,36 @@ func (m appModel) detailModalTitle() string {}func (m appModel) detailModalHelpLine() string {+ modalActions := m.currentActions()if m.modalSource != "" {- return "esc/q close · ↑/↓ select · enter install/open · c more · d scan"+ parts := []string{"esc/q close", "↑/↓ select"}+ if child, ok := m.currentModalSelectedChild(); ok {+ if child.isAvailable && hasAvailableAction(modalActions, "install_skill") {+ parts = append(parts, "enter install")+ } else if !child.isAvailable && hasAvailableAction(modalActions, "open_skill") {+ parts = append(parts, "enter open", "o open")+ }+ }+ parts = append(parts, "c more")+ if discoverable, _ := m.isSourceDiscoverable(m.modalSource); discoverable {+ parts = append(parts, "d scan")+ }+ return strings.Join(parts, " · ")+ }+ parts := []string{"esc/q close"}+ if hasAvailableAction(m.currentDetailSkillActions(), "open_skill") {+ parts = append(parts, "o open in editor")+ }+ parts = append(parts, "c command picker", "↑/↓ scroll")+ return strings.Join(parts, " · ")+}++func (m appModel) currentDetailSkillActions() []actions.CommandPreview {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) || rows[m.selected].isHeader {+ return nil}- return "esc/q close · o open in editor · c command picker · ↑/↓ scroll"+ return actions.ForSkill(rows[m.selected].skill)}func (m *appModel) ensureSourceModalSelectionVisible() {