Skip to content

mission control for agent skills

Discovery polish (2/3): one home — declutter sidebar, slim preview

Alvin Unreal4199fed0a36c
diff --git a/internal/tui/state.go b/internal/tui/state.go
index eeedd5d..ca41a25 100644
--- a/internal/tui/state.go
+++ b/internal/tui/state.go
@@ -64,12 +64,10 @@ func (m *appModel) syncViewport() {
}
type skillsRow struct {
- isHeader bool
- isAvailable bool
- groupName string
- skill *model.Skill
- discoveredSkill *DiscoveredSkill
- skillIndex int
+ isHeader bool
+ groupName string
+ skill *model.Skill
+ skillIndex int
}
func (m appModel) visibleRows() []skillsRow {
@@ -79,9 +77,6 @@ func (m appModel) visibleRows() []skillsRow {
for i, skill := range items {
group := listGroupLabel(skill)
if group != previousGroup {
- if previousGroup != "" && !m.isCollapsed(previousGroup) {
- rows = append(rows, m.getAvailableRowsForGroup(previousGroup)...)
- }
rows = append(rows, skillsRow{
isHeader: true,
groupName: group,
@@ -99,30 +94,23 @@ func (m appModel) visibleRows() []skillsRow {
skillIndex: i,
})
}
- if previousGroup != "" && !m.isCollapsed(previousGroup) {
- rows = append(rows, m.getAvailableRowsForGroup(previousGroup)...)
- }
return rows
}
-func (m appModel) getAvailableRowsForGroup(groupName string) []skillsRow {
- var rows []skillsRow
+// availableCount reports how many discovered-but-not-installed skills a source
+// group has, once it has been scanned. Zero when not yet scanned.
+func (m appModel) availableCount(groupName string) int {
disc, ok := m.discovery[groupName]
if !ok || disc.Status != DiscoveryReady {
- return nil
+ return 0
}
- for i, ds := range disc.Skills {
+ n := 0
+ for _, ds := range disc.Skills {
if !m.isSkillInstalled(ds.Name, groupName) {
- rows = append(rows, skillsRow{
- isHeader: false,
- isAvailable: true,
- groupName: groupName,
- discoveredSkill: &disc.Skills[i],
- skillIndex: -1,
- })
+ n++
}
}
- return rows
+ return n
}
func (m appModel) getGroupCounts(group string) (visible int, total int) {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 009b80f..19ebc5f 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1333,7 +1333,7 @@ func TestContextualFooterAndHelpModal(t *testing.T) {
// 1b. Source row selected footer
m.selected = 0
outHeaderFooter := m.View()
- if !strings.Contains(outHeaderFooter, "enter details · c source actions") {
+ if !strings.Contains(outHeaderFooter, "enter browse · d scan · c source actions") {
t.Fatalf("expected source group footer in View, got:\n%s", outHeaderFooter)
}
m.selected = 1
@@ -1542,17 +1542,17 @@ func TestRichSourceInventoryMetadataAndActions(t *testing.T) {
t.Errorf("hash should no longer appear in metadata, got %q", metaJoined)
}
- // 2. Assert source preview listing installed skills
+ // 2. Assert source preview shows a compact summary (full browser is the modal)
prevLines := m.previewLines(80)
prevJoined := strings.Join(prevLines, "\n")
- if !strings.Contains(prevJoined, "Installed Skills:") {
- t.Errorf("expected Installed Skills header in preview, got %q", prevJoined)
+ if !strings.Contains(prevJoined, "Installed: 2") {
+ t.Errorf("expected installed count in preview, got %q", prevJoined)
}
- if !strings.Contains(prevJoined, "• One [P]") || !strings.Contains(prevJoined, "• Two [G]") {
- t.Errorf("expected skills listed with scope badges in preview, got %q", prevJoined)
+ if !strings.Contains(prevJoined, "Available: press d to scan.") {
+ t.Errorf("expected available scan hint in preview, got %q", prevJoined)
}
- if !strings.Contains(prevJoined, "Discovery shows installed and available skills from this source.") || !strings.Contains(prevJoined, "Use d to refresh local/remote source discovery.") {
- t.Errorf("expected preview footnotes in preview, got %q", prevJoined)
+ if !strings.Contains(prevJoined, "enter to browse · d to scan") {
+ t.Errorf("expected action hint in preview, got %q", prevJoined)
}
// 3. Assert currentActions for source row
@@ -1627,16 +1627,18 @@ func TestRemoteDiscoverySuccess(t *testing.T) {
t.Fatalf("expected empty captured ref, got %s", capturedRef)
}
- rows := next.visibleRows()
var foundAvailable bool
- for _, r := range rows {
- if r.isAvailable && r.discoveredSkill != nil && r.discoveredSkill.Name == "Remote Skill" {
+ for _, ds := range next.discovery["owner/repo"].Skills {
+ if ds.Name == "Remote Skill" {
foundAvailable = true
break
}
}
if !foundAvailable {
- t.Fatalf("expected available row for 'Remote Skill', but not found in rows: %#v", rows)
+ t.Fatalf("expected 'Remote Skill' among discovered skills, got %#v", next.discovery["owner/repo"].Skills)
+ }
+ if next.availableCount("owner/repo") < 1 {
+ t.Fatalf("expected at least one available (uninstalled) skill, got %d", next.availableCount("owner/repo"))
}
}
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 7baa7c5..8510c60 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -341,10 +341,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.syncViewport()
return m, cmd
}
- } else if row.isAvailable {
- m.focus = focusPreview
- m.detailsFocused = true
- m.syncViewport()
} else {
m.detailModal = true
m.modalSource = ""
@@ -356,17 +352,17 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case "o":
rows := m.visibleRows()
- if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader && !rows[m.selected].isAvailable {
+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {
return m.startCurrentSkillActionByID("open_skill")
}
case "u":
rows := m.visibleRows()
- if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader && !rows[m.selected].isAvailable {
+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {
return m.startActionByID(preferredUpdateActionID(m.selectedCount()))
}
case "x":
rows := m.visibleRows()
- if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader && !rows[m.selected].isAvailable {
+ if len(rows) > 0 && m.selected < len(rows) && !rows[m.selected].isHeader {
return m.startActionByID(preferredRemoveActionID(m.selectedCount()))
}
case "d":
@@ -567,9 +563,6 @@ func (m appModel) currentActions() []actions.CommandPreview {
if row.isHeader {
return m.sourceActions(row.groupName)
}
- if row.isAvailable {
- return actions.ForAvailableSkill(row.groupName, row.discoveredSkill.Name)
- }
return actions.ForSkill(row.skill)
}
diff --git a/internal/tui/view.go b/internal/tui/view.go
index 7cb8ae5..beeb4a5 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -174,19 +174,14 @@ func (m appModel) listPane(height, width int) string {
affordance = "+ "
}
headerText := affordance + row.groupName
- if idx == selectedRow {
- line = selectedStyle.Render(truncate(headerText, width))
- } else {
- line = dimStyle.Render(truncate(headerText, width))
+ hint := ""
+ if n := m.availableCount(row.groupName); n > 0 {
+ hint = fmt.Sprintf(" +%d available", n)
}
- } else if row.isAvailable {
- ds := row.discoveredSkill
- coreLabel := fmt.Sprintf(" + %s [available]", ds.Name)
- truncatedCore := truncate(coreLabel, width)
if idx == selectedRow {
- line = selectedStyle.Render(truncatedCore)
+ line = selectedStyle.Render(truncate(headerText+hint, width))
} else {
- line = dimStyle.Render(truncatedCore)
+ line = dimStyle.Render(truncate(headerText, width-lipgloss.Width(hint))) + dimStyle.Render(hint)
}
} else {
view := display.Skill(row.skill)
@@ -432,20 +427,6 @@ func (m appModel) metadataLines(width int) []string {
return lines
}
- if row.isAvailable {
- ds := row.discoveredSkill
- lines := []string{
- formatMetaLine("Skill:", ds.Name, width),
- formatMetaLine("Status:", "available", width),
- formatMetaLine("Source:", ds.Source, width),
- }
- if ds.SkillPath != "" {
- lines = append(lines, formatMetaLine("Path:", ds.SkillPath, width))
- }
- lines = append(lines, "", wrapText(ds.Description, width))
- return lines
- }
-
view := display.Skill(row.skill)
lines := []string{
formatMetaLine("Scope:", string(view.Scope), width),
@@ -547,70 +528,31 @@ func (m appModel) previewLines(width int) []string {
row := rows[m.selected]
if row.isHeader {
- disc, discOk := m.discovery[row.groupName]
- lines := []string{
- sectionHeaderStyle.Render("Installed Skills:"),
- }
+ // Read-only source summary; the interactive installed/available
+ // browser lives in the source detail modal (enter).
skills := m.sourceGroupSkills(row.groupName)
- if len(skills) == 0 {
- lines = append(lines, " No installed skills under this source.")
- } else {
- for _, sk := range skills {
- scopeBadgeStr := "[P]"
- if sk.Scope == model.ScopeGlobal {
- scopeBadgeStr = "[G]"
- }
- lines = append(lines, fmt.Sprintf(" • %s %s", sk.Name, scopeBadgeStr))
- }
- }
-
- lines = append(lines, "")
+ lines := []string{fmt.Sprintf("Installed: %d", len(skills))}
+ disc, discOk := m.discovery[row.groupName]
_, _, isRemote := parseRemoteGitHubSource(row.groupName)
- statusHeader := sectionHeaderStyle.Render("Available Skills:")
- if !discOk {
- if isRemote {
- lines = append(lines, statusHeader, " Remote source discovery not run yet. Press 'd' to scan.")
+ switch {
+ case !discOk:
+ lines = append(lines, dimStyle.Render("Available: press d to scan."))
+ case disc.Status == DiscoveryLoading && isRemote:
+ lines = append(lines, dimStyle.Render("Available: cloning & scanning…"))
+ case disc.Status == DiscoveryLoading:
+ lines = append(lines, dimStyle.Render("Available: scanning…"))
+ case disc.Status == DiscoveryFailed:
+ lines = append(lines, errorStyle.Render("Couldn't scan: "+disc.Error))
+ default: // DiscoveryReady
+ if n := m.availableCount(row.groupName); n > 0 {
+ lines = append(lines, fmt.Sprintf("Available: %d", n))
} else {
- lines = append(lines, statusHeader, " Local source discovery not run yet. Press 'd' to scan.")
- }
- } else {
- switch disc.Status {
- case DiscoveryLoading:
- if isRemote {
- lines = append(lines, statusHeader, " Cloning and scanning remote repository...")
- } else {
- lines = append(lines, statusHeader, " Scanning local checkout...")
- }
- case DiscoveryFailed:
- lines = append(lines, statusHeader, fmt.Sprintf(" Discovery failed: %s", disc.Error))
- case DiscoveryReady:
- var avails []DiscoveredSkill
- for _, ds := range disc.Skills {
- if !m.isSkillInstalled(ds.Name, row.groupName) {
- avails = append(avails, ds)
- }
- }
- if len(avails) == 0 {
- if isRemote {
- lines = append(lines, statusHeader, " All discovered skills from this remote repository are installed.")
- } else {
- lines = append(lines, statusHeader, " All discovered skills from this local source are installed.")
- }
- } else {
- lines = append(lines, statusHeader)
- for _, av := range avails {
- lines = append(lines, fmt.Sprintf(" + %s", av.Name))
- }
- }
+ lines = append(lines, dimStyle.Render("Available: all installed."))
}
}
- lines = append(lines,
- "",
- dimStyle.Render("Discovery shows installed and available skills from this source."),
- dimStyle.Render("Use d to refresh local/remote source discovery."),
- )
+ lines = append(lines, "", dimStyle.Render("enter to browse · d to scan"))
var wrapped []string
for _, line := range lines {
wrapped = append(wrapped, wrapText(line, width))
@@ -618,23 +560,6 @@ func (m appModel) previewLines(width int) []string {
return wrapped
}
- if row.isAvailable {
- ds := row.discoveredSkill
- if ds.Preview != "" {
- var lines []string
- previewLines := strings.Split(ds.Preview, "\n")
- for _, line := range previewLines {
- lines = append(lines, wrapText(line, width))
- }
- return lines
- }
- return []string{
- dimStyle.Render("No preview content found for this available skill."),
- "",
- dimStyle.Render("Press 'c' to open actions and install it."),
- }
- }
-
view := display.Skill(row.skill)
if view.Preview == "" {
return []string{dimStyle.Render("No preview available for this skill.")}
@@ -657,7 +582,7 @@ func (m appModel) detailLines(width int) []string {
return m.metadataLines(width)
}
row := rows[m.selected]
- if row.isHeader || row.isAvailable {
+ if row.isHeader {
return m.metadataLines(width)
}
view := display.Skill(row.skill)
@@ -1120,9 +1045,7 @@ func (m appModel) footerText(width int) string {
if len(rows) > 0 && m.selected >= 0 && m.selected < len(rows) {
row := rows[m.selected]
if row.isHeader {
- text = "enter details · c source actions · h/- collapse · l/+ expand · d discover · ? help"
- } else if row.isAvailable {
- text = "enter preview · c install actions · ? help"
+ text = "enter browse · d scan · c source actions · h/- collapse · l/+ expand · ? help"
} else {
text = "enter open · c skill actions · o edit · u update · x remove · ? help"
}
@@ -1237,19 +1160,12 @@ func (m appModel) detailModalTitle() string {
if row.isHeader {
return "Source Detail View"
}
- if row.isAvailable {
- return "Available Skill Detail View"
- }
return "Skill Detail View"
}
func (m appModel) detailModalHelpLine() string {
if m.modalSource != "" {
- return "esc/q close · ↑/↓ select skill · c actions · o/u/x installed actions"
- }
- rows := m.visibleRows()
- if len(rows) > 0 && m.selected >= 0 && m.selected < len(rows) && rows[m.selected].isAvailable {
- return "esc/q close · c install actions · ↑/↓ scroll"
+ return "esc/q close · ↑/↓ select skill · d scan · c actions · o/u/x installed actions"
}
return "esc/q close · o open in editor · c command picker · ↑/↓ scroll"
}