mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
Support selectable source group rows and expand/collapse actions
alvinrealef798d756a2b
diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 298aa60..d446f46 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -64,6 +64,7 @@ type appModel struct {detailModal boolhelpOpen boolfocus focusState+ collapsedGroups map[string]bool}type paneLayout struct {@@ -141,6 +142,7 @@ func newModel(cwd string) appModel {viewport: viewport.New(0, 0),metadataViewport: viewport.New(0, 0),previewViewport: viewport.New(0, 0),+ collapsedGroups: make(map[string]bool),}}@@ -366,19 +368,37 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.action = 0m.actionResult = nilcase "enter":- items := m.filteredSkills()- if len(items) > 0 && m.selected < len(items) {- m.detailModal = true- m.detailsFocused = true- m.viewport.GotoTop()- m.syncViewport()+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) {+ row := rows[m.selected]+ if row.isHeader {+ if m.isCollapsed(row.groupName) {+ m.expandGroup(row.groupName)+ } else {+ m.collapseGroup(row.groupName)+ }+ } else {+ m.detailModal = true+ m.detailsFocused = true+ m.viewport.GotoTop()+ m.syncViewport()+ }}case "o":- return m.startCurrentSkillActionByID("open_skill")+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {+ return m.startCurrentSkillActionByID("open_skill")+ }case "u":- return m.startActionByID(preferredUpdateActionID(m.selectedCount()))+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {+ return m.startActionByID(preferredUpdateActionID(m.selectedCount()))+ }case "x":- return m.startActionByID(preferredRemoveActionID(m.selectedCount()))+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {+ return m.startActionByID(preferredRemoveActionID(m.selectedCount()))+ }case "/":m.searching = truecase "r":@@ -440,13 +460,21 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.jumpSourceGroup(-1)case "]":m.jumpSourceGroup(1)- case "l":+ case "l", "+":if m.focus == focusSkills {- m.jumpSourceGroup(1)+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) {+ row := rows[m.selected]+ m.expandGroup(row.groupName)+ }}- case "h":+ case "h", "-":if m.focus == focusSkills {- m.jumpSourceGroup(-1)+ rows := m.visibleRows()+ if len(rows) > 0 && m.selected < len(rows) {+ row := rows[m.selected]+ m.collapseGroup(row.groupName)+ }}case "right":if m.focus == focusSkills {@@ -470,10 +498,13 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.previewViewport.LineDown(1)m.clampViewportOffset()} else {- m.selected++- m.actionResult = nil- m.metadataViewport.GotoTop()- m.previewViewport.GotoTop()+ rows := m.visibleRows()+ if m.selected < len(rows)-1 {+ m.selected+++ m.actionResult = nil+ m.metadataViewport.GotoTop()+ m.previewViewport.GotoTop()+ }}case "up", "k":if m.focus == focusMetadata {@@ -483,10 +514,12 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.previewViewport.LineUp(1)m.clampViewportOffset()} else {- m.selected--- m.actionResult = nil- m.metadataViewport.GotoTop()- m.previewViewport.GotoTop()+ if m.selected > 0 {+ m.selected--+ m.actionResult = nil+ m.metadataViewport.GotoTop()+ m.previewViewport.GotoTop()+ }}case "pgdown", "ctrl+d":var cmd tea.Cmd@@ -543,11 +576,15 @@ func (m appModel) currentActions() []actions.CommandPreview {if len(selected) > 0 {return actions.ForSkills(selected)}- items := m.filteredSkills()- if len(items) == 0 || m.selected >= len(items) {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {+ return actions.AppLevelActions()+ }+ row := rows[m.selected]+ if row.isHeader {return actions.AppLevelActions()}- return append(actions.ForSkill(items[m.selected]), actions.AppLevelActions()...)+ return actions.ForSkill(row.skill)}func (m appModel) startAction() (tea.Model, tea.Cmd) {@@ -585,11 +622,15 @@ func (m appModel) startActionByID(id string) (tea.Model, tea.Cmd) {}func (m appModel) startCurrentSkillActionByID(id string) (tea.Model, tea.Cmd) {- items := m.filteredSkills()- if len(items) == 0 || m.selected >= len(items) {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {return m, nil}- for _, action := range actions.ForSkill(items[m.selected]) {+ row := rows[m.selected]+ if row.isHeader {+ return m, nil+ }+ for _, action := range actions.ForSkill(row.skill) {if action.ID == id {if !action.Available {return m, nil@@ -759,29 +800,119 @@ func (m *appModel) syncViewport() {m.clampViewportOffset()}-func (m *appModel) clampSelection() {+type skillsRow struct {+ isHeader bool+ groupName string+ skill *model.Skill+ skillIndex int+}++func (m appModel) visibleRows() []skillsRow {items := m.filteredSkills()- if len(items) == 0 {+ var rows []skillsRow+ previousGroup := ""+ for i, skill := range items {+ group := listGroupLabel(skill)+ if group != previousGroup {+ rows = append(rows, skillsRow{+ isHeader: true,+ groupName: group,+ skillIndex: -1,+ })+ previousGroup = group+ }+ if m.isCollapsed(group) {+ continue+ }+ rows = append(rows, skillsRow{+ isHeader: false,+ groupName: group,+ skill: skill,+ skillIndex: i,+ })+ }+ return rows+}++func (m appModel) getGroupCounts(group string) (visible int, total int) {+ items := m.filteredSkills()+ for _, skill := range items {+ if listGroupLabel(skill) == group {+ total+++ if !m.isCollapsed(group) {+ visible+++ }+ }+ }+ return+}++func (m *appModel) collapseGroup(group string) {+ if m.collapsedGroups == nil {+ m.collapsedGroups = make(map[string]bool)+ }+ m.collapsedGroups[group] = true++ rows := m.visibleRows()+ for idx, r := range rows {+ if r.isHeader && r.groupName == group {+ m.selected = idx+ break+ }+ }+ m.clampSelection()+}++func (m *appModel) expandGroup(group string) {+ if m.collapsedGroups == nil {+ m.collapsedGroups = make(map[string]bool)+ }+ delete(m.collapsedGroups, group)++ rows := m.visibleRows()+ for idx, r := range rows {+ if r.isHeader && r.groupName == group {+ m.selected = idx+ break+ }+ }+ m.clampSelection()+}++func (m *appModel) clampSelection() {+ rows := m.visibleRows()+ if len(rows) == 0 {m.selected = 0return}if m.selected < 0 {m.selected = 0}- if m.selected >= len(items) {- m.selected = len(items) - 1+ if m.selected >= len(rows) {+ m.selected = len(rows) - 1+ }+}++func (m appModel) isCollapsed(group string) bool {+ if m.collapsedGroups == nil {+ return false}+ return m.collapsedGroups[group]}func (m *appModel) toggleSelectedSkill() {- items := m.filteredSkills()- if len(items) == 0 || m.selected >= len(items) {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {+ return+ }+ row := rows[m.selected]+ if row.isHeader {return}if m.selectedKeys == nil {m.selectedKeys = map[string]bool{}}- key := skillKey(items[m.selected])+ key := skillKey(row.skill)if m.selectedKeys[key] {delete(m.selectedKeys, key)} else {@@ -793,20 +924,22 @@ func (m *appModel) toggleSelectedSkill() {}func (m *appModel) selectCurrentSourceGroup() {- items := m.filteredSkills()- if len(items) == 0 || m.selected >= len(items) {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {return}- currentGroup := sourceGroupKey(items[m.selected])- if currentGroup == "" {+ row := rows[m.selected]+ group := row.groupName+ if group == "" {return}if m.selectedKeys == nil {m.selectedKeys = map[string]bool{}}changed := false+ items := m.filteredSkills()for _, skill := range items {- if sourceGroupKey(skill) == currentGroup {+ if listGroupLabel(skill) == group {m.selectedKeys[skillKey(skill)] = truechanged = true}@@ -817,44 +950,43 @@ func (m *appModel) selectCurrentSourceGroup() {}func (m *appModel) jumpSourceGroup(direction int) {- items := m.filteredSkills()- if len(items) == 0 || direction == 0 {+ rows := m.visibleRows()+ if len(rows) == 0 {return}m.clampSelection()- starts := sourceGroupStartIndexes(items)- if len(starts) <= 1 {++ var headerIndices []int+ for idx, r := range rows {+ if r.isHeader {+ headerIndices = append(headerIndices, idx)+ }+ }+ if len(headerIndices) <= 1 {+ if len(headerIndices) == 1 {+ m.selected = headerIndices[0]+ }return}- currentGroup := 0- for i, start := range starts {- if start <= m.selected {- currentGroup = i++ currentHeaderIdx := 0+ for i, idx := range headerIndices {+ if idx <= m.selected {+ currentHeaderIdx = i}}+if direction > 0 {- currentGroup = (currentGroup + 1) % len(starts)+ currentHeaderIdx = (currentHeaderIdx + 1) % len(headerIndices)} else {- currentGroup = (currentGroup + len(starts) - 1) % len(starts)+ currentHeaderIdx = (currentHeaderIdx + len(headerIndices) - 1) % len(headerIndices)}- m.selected = starts[currentGroup]++ m.selected = headerIndices[currentHeaderIdx]m.actionResult = nilm.viewport.GotoTop()}-func sourceGroupStartIndexes(items []*model.Skill) []int {- starts := []int{}- previousGroup := ""- for i, skill := range items {- group := listGroupLabel(skill)- if i == 0 || group != previousGroup {- starts = append(starts, i)- previousGroup = group- }- }- return starts-}-func (m appModel) isSelected(skill *model.Skill) bool {return len(m.selectedKeys) > 0 && m.selectedKeys[skillKey(skill)]}@@ -884,18 +1016,28 @@ func skillKey(skill *model.Skill) string {}func (m appModel) currentSelectedKey() string {- items := m.filteredSkills()- if len(items) == 0 || m.selected < 0 || m.selected >= len(items) {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {return ""}- return skillKey(items[m.selected])+ row := rows[m.selected]+ if row.isHeader {+ return "group:" + row.groupName+ }+ return "skill:" + skillKey(row.skill)}func (m *appModel) restoreSelection(selectedKey string, fallback int) {- items := m.filteredSkills()+ rows := m.visibleRows()if selectedKey != "" {- for i, skill := range items {- if skillKey(skill) == selectedKey {+ for i, r := range rows {+ key := ""+ if r.isHeader {+ key = "group:" + r.groupName+ } else {+ key = "skill:" + skillKey(r.skill)+ }+ if key == selectedKey {m.selected = ireturn}@@ -1062,7 +1204,7 @@ func (m appModel) View() string {listWidth, rightWidth, topHeight, bottomHeight := viewModel.getThreePaneLayout()- listLayout := newPaneLayout(listWidth, viewModel.height - 1)+ listLayout := newPaneLayout(listWidth, viewModel.height-1)metadataLayout := newPaneLayout(rightWidth, topHeight)previewLayout := newPaneLayout(rightWidth, bottomHeight)@@ -1272,62 +1414,69 @@ func (m appModel) listPane(height, width int) string {}visible := max(1, height-len(lines))- rows := []listRow{}- previousGroup := ""- selectedRow := 0- for i := 0; i < len(items); i++ {- skill := items[i]- view := display.Skill(skill)- if group := listGroupLabel(skill); group != previousGroup {- rows = append(rows, listRow{line: dimStyle.Render(truncate("─ "+group, width)), skillIndex: -1})- previousGroup = group- }- mark := " "- if m.isSelected(skill) {- mark = "● "- }- coreLabel := fmt.Sprintf("%s%s [%s]", mark, view.Name, scopeBadge(view.Scope))- if m.agent != "" {- coreLabel += " " + agentVisibilityBadge(items[i], m.agent)- }- issueErrors, issueWarnings := healthIssueCounts(view.HealthIssues)- badgeLen := 0- if issueErrors > 0 {- badgeLen = len(fmt.Sprintf(" !%d", issueErrors))- } else if issueWarnings > 0 {- badgeLen = len(fmt.Sprintf(" ⚠ %d", issueWarnings))- }- truncatedCore := truncate(coreLabel, width-badgeLen)+ vRows := m.visibleRows()+ var renderedRows []string+ selectedRow := m.selected++ for idx, row := range vRows {var line string- if i == m.selected {- badge := ""+ if row.isHeader {+ affordance := "- "+ if m.isCollapsed(row.groupName) {+ affordance = "+ "+ }+ headerText := affordance + row.groupName+ if idx == selectedRow {+ line = selectedStyle.Render(truncate(headerText, width))+ } else {+ line = dimStyle.Render(truncate(headerText, width))+ }+ } else {+ view := display.Skill(row.skill)+ mark := " "+ if m.isSelected(row.skill) {+ mark = "● "+ }+ coreLabel := fmt.Sprintf("%s%s [%s]", mark, view.Name, scopeBadge(view.Scope))+ if m.agent != "" {+ coreLabel += " " + agentVisibilityBadge(row.skill, m.agent)+ }+ issueErrors, issueWarnings := healthIssueCounts(view.HealthIssues)+ badgeLen := 0if issueErrors > 0 {- badge = fmt.Sprintf(" !%d", issueErrors)+ badgeLen = len(fmt.Sprintf(" !%d", issueErrors))} else if issueWarnings > 0 {- badge = fmt.Sprintf(" ⚠ %d", issueWarnings)+ badgeLen = len(fmt.Sprintf(" ⚠ %d", issueWarnings))+ }+ truncatedCore := truncate(coreLabel, width-badgeLen)+ if idx == selectedRow {+ badge := ""+ if issueErrors > 0 {+ badge = fmt.Sprintf(" !%d", issueErrors)+ } else if issueWarnings > 0 {+ badge = fmt.Sprintf(" ⚠ %d", issueWarnings)+ }+ line = selectedStyle.Render(truncatedCore + badge)+ } else if issueErrors > 0 {+ badge := errorStyle.Render(fmt.Sprintf(" !%d", issueErrors))+ line = errorStyle.Render(truncatedCore) + badge+ } else if issueWarnings > 0 {+ badge := warningStyle.Render(fmt.Sprintf(" ⚠ %d", issueWarnings))+ line = truncatedCore + badge+ } else {+ line = truncatedCore}- line = selectedStyle.Render(truncatedCore + badge)- } else if issueErrors > 0 {- badge := errorStyle.Render(fmt.Sprintf(" !%d", issueErrors))- line = errorStyle.Render(truncatedCore) + badge- } else if issueWarnings > 0 {- badge := warningStyle.Render(fmt.Sprintf(" ⚠ %d", issueWarnings))- line = truncatedCore + badge- } else {- line = truncatedCore- }- if i == m.selected {- selectedRow = len(rows)}- rows = append(rows, listRow{line: line, skillIndex: i})+ renderedRows = append(renderedRows, line)}+start := 0if selectedRow >= visible {start = selectedRow - visible + 1}- end := min(len(rows), start+visible)- for _, row := range rows[start:end] {- lines = append(lines, row.line)+ end := min(len(renderedRows), start+visible)+ for _, line := range renderedRows[start:end] {+ lines = append(lines, line)}return strings.Join(lines, "\n")}@@ -1395,17 +1544,21 @@ func (m appModel) detailText(width int) string {}func (m appModel) detailTitle() string {- items := m.filteredSkills()- if len(items) == 0 {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {return "2 Details"}- view := display.Skill(items[m.selected])+ row := rows[m.selected]+ if row.isHeader {+ return "2 Details: " + row.groupName+ }+ view := display.Skill(row.skill)return "2 Details: " + view.Name}func (m appModel) metadataLines(width int) []string {- items := m.filteredSkills()- if len(items) == 0 {+ rows := m.visibleRows()+ if len(rows) == 0 {var lines []stringif len(m.result.HealthIssues) > 0 {@@ -1457,12 +1610,40 @@ func (m appModel) metadataLines(width int) []string {return lines}- view := display.Skill(items[m.selected])++ if m.selected < 0 || m.selected >= len(rows) {+ return []string{dimStyle.Render("Select a skill to inspect it.")}+ }++ row := rows[m.selected]+ if row.isHeader {+ visible, total := m.getGroupCounts(row.groupName)+ stateStr := "expanded"+ if m.isCollapsed(row.groupName) {+ stateStr = "collapsed"+ }+ lines := []string{+ formatMetaLine("Source:", row.groupName, width),+ formatMetaLine("State:", stateStr, width),+ formatMetaLine("Skills:", fmt.Sprintf("%d visible / %d total", visible, total), width),+ "",+ dimStyle.Render("Source-level actions coming later."),+ }+ if len(m.result.HealthIssues) > 0 {+ lines = append(lines, "", errorStyle.Render("Scan health"))+ for _, issue := range m.result.HealthIssues {+ lines = append(lines, truncate(fmt.Sprintf("- %s: %s", compat.SanitizeMetadata(issue.Type), compat.SanitizeMetadata(issue.Message)), width))+ }+ }+ return lines+ }++ view := display.Skill(row.skill)lines := []string{formatMetaLine("Scope:", string(view.Scope), width),formatMetaLine("Lock:", display.LockSummary(view), width),}- if sourceLines := sourceDetailLines(items[m.selected], width); len(sourceLines) > 0 {+ if sourceLines := sourceDetailLines(row.skill, width); len(sourceLines) > 0 {lines = append(lines, sourceLines...)}if view.CanonicalPath != "" {@@ -1536,8 +1717,8 @@ func (m appModel) metadataLines(width int) []string {}func (m appModel) previewLines(width int) []string {- items := m.filteredSkills()- if len(items) == 0 {+ rows := m.visibleRows()+ if len(rows) == 0 {if m.result.Preflight != nil && !m.result.Preflight.CanRunSkills {return []string{errorStyle.Render("Preview Unavailable"),@@ -1549,7 +1730,18 @@ func (m appModel) previewLines(width int) []string {}}- view := display.Skill(items[m.selected])+ if m.selected < 0 || m.selected >= len(rows) {+ return []string{dimStyle.Render("No skill selected for preview.")}+ }++ row := rows[m.selected]+ if row.isHeader {+ return []string{+ dimStyle.Render("Preview not applicable for source groups."),+ }+ }++ view := display.Skill(row.skill)if view.Preview == "" {return []string{dimStyle.Render("No preview available for this skill.")}}@@ -1563,11 +1755,15 @@ func (m appModel) previewLines(width int) []string {}func (m appModel) detailLines(width int) []string {- items := m.filteredSkills()- if len(items) == 0 {+ rows := m.visibleRows()+ if len(rows) == 0 || m.selected < 0 || m.selected >= len(rows) {+ return m.metadataLines(width)+ }+ row := rows[m.selected]+ if row.isHeader {return m.metadataLines(width)}- view := display.Skill(items[m.selected])+ view := display.Skill(row.skill)lines := []string{titleStyle.Render(view.Name),"",@@ -1848,8 +2044,9 @@ func (m appModel) helpModalOverlay(layout appLayout) string {" ↑/↓, j/k Move selection (Skills focus) or scroll (Metadata/Preview)"," 1 / 2 / 3 Focus Skills (1), Metadata (2), or Preview (3) pane"," tab / shift-tab Cycle focus forward / backward through panes",- " →/l / ←/h Cycle focus forward / backward through panes",- " [ / ] Jump to previous / next source group",+ " ← / → Move focus backward / forward outside Skills; jump groups in Skills",+ " h / l Collapse / expand current source group in Skills",+ " [ / ] Jump to previous / next source group in Skills","",sectionHeaderStyle.Render("Filters:")," P / G Filter Project-only / Global-only scope",diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.goindex daed0ab..da21d50 100644--- a/internal/tui/tui_test.go+++ b/internal/tui/tui_test.go@@ -214,7 +214,7 @@ func TestTopLevelScanHealthIsRenderedSanitized(t *testing.T) {}func TestCommandPreviewModeRendersWithoutExecuting(t *testing.T) {- m := appModel{width: 120, height: 40, commands: true, result: model.ScanResult{Skills: []*model.Skill{{+ m := appModel{width: 120, height: 40, selected: 1, commands: true, result: model.ScanResult{Skills: []*model.Skill{{Name: "Deploy Skill",Scope: model.ScopeProject,LocalLock: &model.LocalLockEntry{Source: "owner/repo"},@@ -229,7 +229,7 @@ func TestCommandPreviewModeRendersWithoutExecuting(t *testing.T) {}func TestActiveAgentVisibilityReasonIsRendered(t *testing.T) {- m := appModel{width: 120, height: 32, agent: "claude-code", result: model.ScanResult{Skills: []*model.Skill{{+ m := appModel{width: 120, height: 32, selected: 1, agent: "claude-code", result: model.ScanResult{Skills: []*model.Skill{{Name: "Build",Description: "desc",Scope: model.ScopeProject,@@ -285,9 +285,7 @@ func TestListRendersIssueRowsWithSeverityBadges(t *testing.T) {}func TestDetailRendersWarningOnlyIssuesAsWarnings(t *testing.T) {- m := appModel{result: model.ScanResult{Skills: []*model.Skill{- {Name: "Custom", Scope: model.ScopeGlobal, HealthIssues: []model.HealthIssue{{Type: "ghost_agent_skill", Severity: "warning", Message: "agent-specific skill"}}},- }}}+ m := appModel{selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Custom", Scope: model.ScopeGlobal, HealthIssues: []model.HealthIssue{{Type: "ghost_agent_skill", Severity: "warning", Message: "agent-specific skill"}}}}}}out := m.detailText(80)if !strings.Contains(out, "Warnings") || strings.Contains(out, "Health Issues") {t.Fatalf("expected warning-only detail section, got %q", out)@@ -445,8 +443,10 @@ func TestActionExecUsesProjectCwdAndPreventsDuplicateWhileRunning(t *testing.T)func TestSpaceMarksSkillsAndEscClearsSelection(t *testing.T) {m := bulkActionTestModel(t.TempDir())+ fmt.Printf("BEFORE: selected=%d visibleRows=%+v\n", m.selected, m.visibleRows())updated, _ := m.Update(tea.KeyMsg{Type: tea.KeySpace})m = updated.(appModel)+ fmt.Printf("AFTER: selected=%d visibleRows=%+v\n", m.selected, m.visibleRows())if m.selectedCount() != 1 || !strings.Contains(m.View(), "● One") {t.Fatalf("expected one marked skill, count=%d view=%q", m.selectedCount(), m.View())}@@ -652,7 +652,7 @@ func TestSourceMarkOnlySelectsFilteredSkills(t *testing.T) {}func TestSourceAndFolderDetailsRender(t *testing.T) {- m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{{+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md", Ref: "main"},}}}}out := m.View()@@ -664,7 +664,7 @@ func TestSourceAndFolderDetailsRender(t *testing.T) {}func TestSkillListShowsSourceGroups(t *testing.T) {- m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},{Name: "Two", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},{Name: "Other", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/data/SKILL.md"}},@@ -673,18 +673,18 @@ func TestSkillListShowsSourceGroups(t *testing.T) {if !strings.Contains(out, "owner/repo") {t.Fatalf("expected source group header, got %q", out)}- if strings.Count(out, "─ owner/repo") != 1 || strings.Contains(out, "owner/repo / skills/web") || strings.Contains(out, "owner/repo / skills/data") {- t.Fatalf("expected one repo-level group header, got %q", out)+ if strings.Count(out, "owner/repo") != 3 || strings.Contains(out, "owner/repo / skills/web") || strings.Contains(out, "owner/repo / skills/data") {+ t.Fatalf("expected repo-level group header (one in list, two in details), got %q", out)}}func TestSkillListSeparatesNoSourceMetadata(t *testing.T) {- m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Tracked", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},{Name: "Manual", Scope: model.ScopeProject},}}}out := m.View()- if !strings.Contains(out, "─ owner/repo") || !strings.Contains(out, "─ Custom / untracked") {+ if !strings.Contains(out, "owner/repo") || !strings.Contains(out, "Custom / untracked") {t.Fatalf("expected explicit source and no-source groups, got %q", out)}}@@ -699,7 +699,7 @@ func TestBracketJumpSourceGroupsWithoutChangingScope(t *testing.T) {updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{']'}})next := updated.(appModel)- if next.filter != scopeAll || next.selected != 2 {+ if next.filter != scopeAll || next.selected != 3 {t.Fatalf("expected ] to jump to next source group without changing scope, filter=%d selected=%d", next.filter, next.selected)}@@ -813,7 +813,7 @@ func TestFocusControls(t *testing.T) {}func TestEnterSkillModal(t *testing.T) {- m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "One", Scope: model.ScopeProject},}}}@@ -847,7 +847,7 @@ func TestGroupedListKeepsSelectedRowVisible(t *testing.T) {for i := 0; i < 12; i++ {skills = append(skills, &model.Skill{Name: fmt.Sprintf("Skill %02d", i), Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: fmt.Sprintf("owner/repo-%02d", i)}})}- m := appModel{width: 120, height: 10, selected: 11, result: model.ScanResult{Skills: skills}}+ m := appModel{width: 120, height: 10, selected: 23, result: model.ScanResult{Skills: skills}}out := m.View()if !strings.Contains(out, "Skill 11 [P]") {t.Fatalf("expected selected row visible with many group headers, got %q", out)@@ -902,7 +902,7 @@ func TestRemoveRequiresExactTypedIdentity(t *testing.T) {}func actionTestModel(cwd string) appModel {- return appModel{cwd: cwd, width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{{+ return appModel{cwd: cwd, width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Deploy Skill",Description: "desc",Scope: model.ScopeProject,@@ -912,7 +912,7 @@ func actionTestModel(cwd string) appModel {}func bulkActionTestModel(cwd string) appModel {- return appModel{cwd: cwd, width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{+ return appModel{cwd: cwd, width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "One", Description: "desc", Scope: model.ScopeProject, CanonicalPath: "/tmp/one", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},{Name: "Two", Description: "desc", Scope: model.ScopeProject, CanonicalPath: "/tmp/two", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},}}}@@ -985,7 +985,7 @@ func TestDetailPaneClipsLongPreview(t *testing.T) {func TestDetailScrollKeysMoveViewport(t *testing.T) {preview := strings.Repeat("line\n", 80)- m := appModel{width: 100, height: 20, result: model.ScanResult{Skills: []*model.Skill{{Name: "Long", Description: "desc", Scope: model.ScopeProject, Preview: preview}}}}+ m := appModel{width: 100, height: 20, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Long", Description: "desc", Scope: model.ScopeProject, Preview: preview}}}}m.syncViewport()updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyPgDown})next := updated.(appModel)@@ -1014,7 +1014,7 @@ func TestThreePaneLayoutFocusAndScroll(t *testing.T) {// In Skills focus, h/l or left/right jump source groups instead of changing focus.updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRight})m = updated.(appModel)- if m.focus != focusSkills || m.selected != 1 {+ if m.focus != focusSkills || m.selected != 2 {t.Fatalf("expected right in skills focus to jump source group, got focus %v selection %d", m.focus, m.selected)}updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyLeft})@@ -1092,6 +1092,7 @@ func TestThreePaneLayoutFocusAndScroll(t *testing.T) {}// Enter opens modal+ m.selected = 1updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter})m = updated.(appModel)if !m.detailModal {@@ -1214,7 +1215,7 @@ func TestVisibilityReasonTranslation(t *testing.T) {}func TestStaticUpdateAwarenessDisclaimers(t *testing.T) {- m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{{+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", ComputedHash: "abcdef123456"},}}}}out := m.View()@@ -1336,3 +1337,130 @@ func TestContextualFooterAndHelpModal(t *testing.T) {t.Fatal("expected q to close help modal")}}++func TestSelectedSkillActionsDoNotIncludeAppActions(t *testing.T) {+ m := appModel{selected: 1, result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Scope: model.ScopeProject}}}}+ previews := m.currentActions()+ for _, preview := range previews {+ if preview.ID == "skills_init" || preview.ID == "skills_find" || preview.ID == "skills_update" {+ t.Fatalf("selected-skill actions should not include app-level action %q", preview.ID)+ }+ }+}++func TestCollapseExpandSourceGroups(t *testing.T) {+ m := appModel{+ width: 120,+ height: 32,+ focus: focusSkills,+ collapsedGroups: make(map[string]bool),+ result: model.ScanResult{+ Skills: []*model.Skill{+ {Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/one"}},+ {Name: "Two", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/one"}},+ {Name: "Three", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/two"}},+ },+ },+ }+ m.syncViewport()++ // Initially, both are expanded+ out1 := m.View()+ if !strings.Contains(out1, "- owner/one") || !strings.Contains(out1, "One") || !strings.Contains(out1, "Two") {+ t.Fatalf("expected expanded groups (with ASCII minus) and skills, got:\n%s", out1)+ }++ // Selection starts at 0 (header row of owner/one)+ if m.selected != 0 {+ t.Fatalf("expected selection to start at header row 0, got %d", m.selected)+ }++ // Press h to collapse "owner/one"+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'h'}})+ m = updated.(appModel)+ if !m.isCollapsed("owner/one") {+ t.Fatal("expected owner/one to be collapsed")+ }++ // Selection should remain on index 0 (collapsed header)+ if m.selected != 0 {+ t.Fatalf("expected selection to remain on collapsed header row 0, got %d", m.selected)+ }++ // View should show + and hide "One" and "Two"+ out2 := m.View()+ if !strings.Contains(out2, "+ owner/one") || strings.Contains(out2, " One [P]") || strings.Contains(out2, " Two [P]") {+ t.Fatalf("expected collapsed group A (with ASCII plus) to hide child skills, got:\n%s", out2)+ }++ // Press l to expand "owner/one" again+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'l'}})+ m = updated.(appModel)+ if m.isCollapsed("owner/one") {+ t.Fatal("expected owner/one to be expanded")+ }++ out3 := m.View()+ if !strings.Contains(out3, "- owner/one") || !strings.Contains(out3, "One") {+ t.Fatalf("expected expanded group A to show child skills, got:\n%s", out3)+ }++ // Test j/k navigation skips collapsed rows+ // Collapse "owner/one" again+ m.collapsedGroups["owner/one"] = true+ m.clampSelection() // selection should clamp to 0 (header) or 1 (owner/two) or 2 (Three)++ // Since owner/one is collapsed, visible rows are:+ // index 0: + owner/one+ // index 1: - owner/two+ // index 2: Three+ m.selected = 2 // on Three++ // Pressing up/k from Three (index 2) should go to owner/two (index 1)+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'k'}})+ m = updated.(appModel)+ if m.selected != 1 {+ t.Fatalf("expected selection to go to index 1 (owner/two), got %d", m.selected)+ }++ // Test h/l outside focusSkills do not collapse groups and do not change focus+ m.focus = focusMetadata+ m.collapsedGroups = make(map[string]bool)+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'h'}})+ m = updated.(appModel)+ if len(m.collapsedGroups) > 0 {+ t.Fatalf("h outside focusSkills should not collapse groups")+ }+ if m.focus != focusMetadata {+ t.Fatalf("h outside focusSkills should not change focus")+ }++ // Test group header row action details and commands+ m.focus = focusSkills+ m.selected = 0 // select header row owner/one+ m.collapsedGroups["owner/one"] = true+ outHeader := m.View()+ if !strings.Contains(outHeader, "State: collapsed") || !strings.Contains(outHeader, "Source-level actions coming later.") {+ t.Fatalf("expected header placeholder in Metadata pane, got:\n%s", outHeader)+ }++ // Verify that header row selection has no skill-scoped actions+ previewsHeader := m.currentActions()+ for _, p := range previewsHeader {+ if p.ID == "reinstall_update" || p.ID == "remove" {+ t.Fatalf("header row actions should not include skill-scoped action %q", p.ID)+ }+ }++ // Test enter on header row toggles expand/collapse+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter})+ m = updated.(appModel)+ if m.isCollapsed("owner/one") {+ t.Fatal("expected enter on collapsed header to expand it")+ }+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter})+ m = updated.(appModel)+ if !m.isCollapsed("owner/one") {+ t.Fatal("expected enter on expanded header to collapse it")+ }+}