Skip to content

mission control for agent skills

Implement action picker modal overlay

alvinrealad240ba5640c
diff --git a/internal/actions/actions.go b/internal/actions/actions.go
index e5792cb..a8c8227 100644
--- a/internal/actions/actions.go
+++ b/internal/actions/actions.go
@@ -58,12 +58,12 @@ func ForSkillsWithResolver(skills []*model.Skill, resolve SkillsResolver) []Comm
removeBatch, removeOK, removeReason := bulkBatch(skills, resolve, "remove")
previews := []CommandPreview{}
if updateOK {
- previews = append(previews, newBatchPreview("bulk_reinstall_update", fmt.Sprintf("Reinstall/update %d selected skills", count), updateBatch, fmt.Sprintf("Run the official skills CLI update flow for %d selected skills.", count), fmt.Sprintf("update %d skills", count), false))
+ previews = append(previews, newBatchPreview("bulk_reinstall_update", fmt.Sprintf("Reinstall/update %d selected skills", count), updateBatch, "Refresh the selected skills.", fmt.Sprintf("update %d skills", count), false))
} else {
previews = append(previews, unavailablePreview(fmt.Sprintf("Reinstall/update %d selected skills", count), updateReason))
}
if removeOK {
- previews = append(previews, newBatchPreview("bulk_remove", fmt.Sprintf("Remove %d selected skills", count), removeBatch, fmt.Sprintf("Remove %d selected installed skills via the official skills CLI.", count), fmt.Sprintf("remove %d skills", count), true))
+ previews = append(previews, newBatchPreview("bulk_remove", fmt.Sprintf("Remove %d selected skills", count), removeBatch, "Delete the selected installed skills.", fmt.Sprintf("remove %d skills", count), true))
} else {
previews = append(previews, unavailablePreview(fmt.Sprintf("Remove %d selected skills", count), removeReason))
}
@@ -113,7 +113,7 @@ func ForSkillWithResolver(sk *model.Skill, resolve SkillsResolver) []CommandPrev
if sk.Scope == model.ScopeGlobal {
args = append(args, "-g")
}
- preview := newPreview("reinstall_update", "Reinstall/update selected skill", program, args, "Reinstall/update this skill via the official skills CLI after confirmation.", true, true, false, "yes")
+ preview := newPreview("reinstall_update", "Reinstall/update selected skill", program, args, "Refresh this skill from its source.", true, true, false, "yes")
previews = append(previews, preview)
} else {
previews = append(previews, unavailablePreview("Reinstall/update selected skill", reason))
@@ -126,7 +126,7 @@ func ForSkillWithResolver(sk *model.Skill, resolve SkillsResolver) []CommandPrev
if sk.Scope == model.ScopeGlobal {
args = append(args, "-g")
}
- previews = append(previews, newPreview("remove", "Remove selected skill", program, args, "Remove this installed skill via the official skills CLI after typing the exact target.", true, true, true, target))
+ previews = append(previews, newPreview("remove", "Remove selected skill", program, args, "Delete this installed skill.", true, true, true, target))
} else {
previews = append(previews, unavailablePreview("Remove selected skill", reason))
}
@@ -156,7 +156,7 @@ func openEditorAction(sk *model.Skill) (CommandPreview, bool, string) {
}
args := append([]string{}, parts[1:]...)
args = append(args, target)
- preview := newPreview("open_skill", "Open selected skill", parts[0], args, "Open this skill in $EDITOR. LazySkills releases the terminal while the editor runs.", false, false, false, "")
+ preview := newPreview("open_skill", "Open selected skill", parts[0], args, "Open in $EDITOR.", false, false, false, "")
if !preview.Available {
return CommandPreview{}, false, preview.Reason
}
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index 6c6f2b8..7420017 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -85,10 +85,14 @@ var (
runExec = runner.OSRunner{}.Run
// Action Mode UI Polish Styles
- actionTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62")).Padding(0, 1)
- activeActionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62"))
- actionNormalStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("255"))
- actionBorderColor = lipgloss.Color("62")
+ actionTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62")).Padding(0, 1)
+ activeActionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62"))
+ activeActionTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62"))
+ activeActionSubStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("250")).Background(lipgloss.Color("62"))
+ normalActionTitleStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("255"))
+ normalActionSubStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("243"))
+ actionNormalStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("255"))
+ actionBorderColor = lipgloss.Color("62")
runningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("208")).Bold(true)
successStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("114")).Bold(true)
@@ -140,6 +144,18 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.result = msg.result
sortSkills(m.result.Skills)
m.err = msg.err
+ if m.agent != "" {
+ detected := false
+ for _, filter := range m.agentFilters() {
+ if filter == m.agent {
+ detected = true
+ break
+ }
+ }
+ if !detected {
+ m.agent = ""
+ }
+ }
m.clampSelection()
m.pruneSelected()
m.actionResult = nil
@@ -230,14 +246,37 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}
+ if m.commands {
+ switch key {
+ case "esc", "c":
+ m.commands = false
+ case "q", "ctrl+c":
+ return m, tea.Quit
+ case "up", "k":
+ m.action--
+ m.clampAction()
+ case "down", "j":
+ m.action++
+ m.clampAction()
+ case "enter":
+ return m.startAction()
+ case "o":
+ return m.startCurrentSkillActionByID("open_skill")
+ case "u":
+ return m.startActionByID(preferredUpdateActionID(m.selectedCount()))
+ case "x":
+ return m.startActionByID(preferredRemoveActionID(m.selectedCount()))
+ }
+ m.syncViewport()
+ return m, nil
+ }
+
switch key {
case "esc":
if m.selectedCount() > 0 {
m.selectedKeys = nil
m.action = 0
m.actionResult = nil
- } else if m.commands {
- m.commands = false
} else if m.agent != "" {
m.agent = ""
m.selected = 0
@@ -268,10 +307,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.startActionByID(preferredRemoveActionID(m.selectedCount()))
case "/":
m.searching = true
- case "enter":
- if m.commands {
- return m.startAction()
- }
case "r":
m.viewport.GotoTop()
return m, loadSnapshot(m.cwd)
@@ -302,21 +337,13 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "left", "h":
m.jumpSourceGroup(-1)
case "down", "j":
- if m.commands {
- m.action++
- } else {
- m.selected++
- m.actionResult = nil
- m.viewport.GotoTop()
- }
+ m.selected++
+ m.actionResult = nil
+ m.viewport.GotoTop()
case "up", "k":
- if m.commands {
- m.action--
- } else {
- m.selected--
- m.actionResult = nil
- m.viewport.GotoTop()
- }
+ m.selected--
+ m.actionResult = nil
+ m.viewport.GotoTop()
case "pgdown", "ctrl+d":
var cmd tea.Cmd
m.viewport, cmd = m.viewport.Update(msg)
@@ -778,9 +805,6 @@ func (m appModel) View() string {
leftStyle := paneStyle(layout.Left)
listStyle := paneStyle(layout.List)
detailStyle := paneStyle(layout.Detail)
- if viewModel.commands {
- detailStyle = detailStyle.BorderForeground(actionBorderColor)
- }
left := leftStyle.Render(fitLines(viewModel.filterPane(layout.Left.ContentWidth), layout.Left.ContentHeight))
list := listStyle.Render(fitLines(viewModel.listPane(layout.List.ContentHeight, layout.List.ContentWidth), layout.List.ContentHeight))
detail := detailStyle.Render(viewModel.detailPane())
@@ -792,6 +816,9 @@ func (m appModel) View() string {
if viewModel.confirming {
return viewModel.confirmationOverlay(layout)
}
+ if viewModel.commands {
+ return viewModel.commandsOverlay(layout)
+ }
return view
}
@@ -916,14 +943,7 @@ func (m appModel) detailText(width int) string {
func (m appModel) detailLines(width int) []string {
items := m.filteredSkills()
if len(items) == 0 {
- lines := []string{titleStyle.Render("Details"), "", dimStyle.Render("Select a skill to inspect it.")}
- if m.commands && m.selectedCount() > 0 {
- lines = append(lines, "")
- divider := lipgloss.NewStyle().Foreground(lipgloss.Color("62")).Render(strings.Repeat("─", max(1, width)))
- lines = append(lines, divider)
- lines = append(lines, m.commandPreview(nil, max(1, width-4))...)
- }
- return lines
+ return []string{titleStyle.Render("Details"), "", dimStyle.Render("Select a skill to inspect it.")}
}
view := display.Skill(items[m.selected])
lines := []string{
@@ -944,15 +964,34 @@ func (m appModel) detailLines(width int) []string {
lines = append(lines, formatMetaLine("Agent:", m.agentLabel(), width))
}
lines = append(lines, m.visibilitySummary(view, width)...)
+ if len(view.Observed) > 0 && m.agent == "" {
+ agentsSet := map[string]bool{}
+ observedAgents := []string{}
+ for _, p := range view.Observed {
+ if p.Agent != "" && !agentsSet[p.Agent] {
+ agentsSet[p.Agent] = true
+ observedAgents = append(observedAgents, p.Agent)
+ }
+ }
+ if len(observedAgents) > 0 {
+ lines = append(lines, formatMetaLine("Observed:", strings.Join(observedAgents, ", "), width))
+ }
+ }
- if len(view.Observed) > 0 {
- lines = append(lines, "", sectionHeaderStyle.Render("Observed Paths"))
+ if len(view.Observed) > 0 && m.agent != "" {
+ showObservedSection := false
for _, p := range view.Observed {
- line := fmt.Sprintf("- %s %s %s", p.Agent, p.Scope, p.Status)
- if p.TargetPath != "" {
- line += " → " + p.TargetPath
+ if p.Agent == m.agent {
+ if !showObservedSection {
+ lines = append(lines, "", sectionHeaderStyle.Render("Observed Paths"))
+ showObservedSection = true
+ }
+ line := fmt.Sprintf("- %s %s %s", p.Agent, p.Scope, p.Status)
+ if p.TargetPath != "" {
+ line += " → " + p.TargetPath
+ }
+ lines = append(lines, wrapText(line, width))
}
- lines = append(lines, wrapText(line, width))
}
}
@@ -967,13 +1006,6 @@ func (m appModel) detailLines(width int) []string {
}
}
- if m.commands {
- lines = append(lines, "")
- divider := lipgloss.NewStyle().Foreground(lipgloss.Color("62")).Render(strings.Repeat("─", max(1, width)))
- lines = append(lines, divider)
- lines = append(lines, m.commandPreview(items[m.selected], max(1, width-4))...)
- return lines
- }
if view.Preview != "" {
lines = append(lines, "")
previewDivider := lipgloss.NewStyle().Foreground(lipgloss.Color("241")).Render(strings.Repeat("─", max(1, width)))
@@ -1018,13 +1050,34 @@ func (m appModel) visibilitySummary(view display.SkillView, width int) []string
return []string{formatMetaLine("Visibility:", val, width)}
}
+func (m appModel) commandsOverlay(layout appLayout) string {
+ modalWidth := 70
+ if layout.Width < modalWidth+4 {
+ modalWidth = layout.Width - 4
+ }
+ if modalWidth < 20 {
+ modalWidth = 20
+ }
+
+ lines := m.commandPreview(nil, modalWidth-4)
+
+ box := lipgloss.NewStyle().
+ Border(lipgloss.RoundedBorder()).
+ BorderForeground(actionBorderColor).
+ Padding(1, 2).
+ Width(modalWidth).
+ Render(strings.Join(lines, "\n"))
+
+ return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)
+}
+
func (m appModel) commandPreview(sk *model.Skill, width int) []string {
title := " Actions "
if count := m.selectedCount(); count > 0 {
title = fmt.Sprintf(" Bulk actions · %d selected ", count)
}
lines := []string{actionTitleStyle.Render(title)}
- lines = append(lines, dimStyle.Render(" j/k choose, enter run, o/u/x shortcuts, c hide"))
+ lines = append(lines, dimStyle.Render(" ↑/↓ choose · enter run · c/esc close"))
if m.running {
lines = append(lines, "", " "+runningStyle.Render("Running action..."))
}
@@ -1043,41 +1096,62 @@ func (m appModel) commandPreview(sk *model.Skill, width int) []string {
if !preview.Available {
titleText := fmt.Sprintf("%s (unavailable)", compat.SanitizeMetadata(preview.Title))
if i == m.action {
- lines = append(lines, "", activeActionStyle.Render(selector+titleText))
+ titleLine := activeActionTitleStyle.Render(padRight(selector+titleText, width))
+ lines = append(lines, "", titleLine)
+ if preview.Reason != "" {
+ reasonText := wrap(compat.SanitizeMetadata(preview.Reason), width-4)
+ for _, reasonLine := range strings.Split(reasonText, "\n") {
+ lines = append(lines, activeActionSubStyle.Render(padRight(" "+reasonLine, width)))
+ }
+ }
} else {
- lines = append(lines, "", dimStyle.Render(selector+titleText))
- }
- if preview.Reason != "" {
- lines = append(lines, indent(wrap(compat.SanitizeMetadata(preview.Reason), width-2), " "))
+ titleLine := normalActionSubStyle.Render(selector + titleText)
+ lines = append(lines, "", titleLine)
+ if preview.Reason != "" {
+ reasonText := wrap(compat.SanitizeMetadata(preview.Reason), width-4)
+ for _, reasonLine := range strings.Split(reasonText, "\n") {
+ lines = append(lines, normalActionSubStyle.Render(" "+reasonLine))
+ }
+ }
}
continue
}
- marker := "read-only"
- if preview.Mutates {
- marker = "mutates"
- }
+ titleText := compat.SanitizeMetadata(preview.Title)
if preview.Dangerous {
- marker += ", dangerous"
+ titleText += " — removes skills"
+ } else if preview.Mutates {
+ titleText += " — changes skills"
}
-
- titleText := fmt.Sprintf("%s (%s)", compat.SanitizeMetadata(preview.Title), marker)
if i == m.action {
- lines = append(lines, "", activeActionStyle.Render(selector+titleText))
- lines = append(lines, " "+actionNormalStyle.Render(truncate(compat.SanitizeMetadata(preview.Command), width-2)))
- if preview.Description != "" {
- lines = append(lines, indent(wrap(compat.SanitizeMetadata(preview.Description), width-2), " "))
- }
+ // Selected Action Highlight Block (entire block has same purple background)
+ titleLine := activeActionTitleStyle.Render(padRight(selector+titleText, width))
+ lines = append(lines, "", titleLine)
+
+ cmdText := truncate(compat.SanitizeMetadata(preview.Command), width-4)
+ cmdLine := activeActionSubStyle.Render(padRight(" "+cmdText, width))
+ lines = append(lines, cmdLine)
+
} else {
- lines = append(lines, "", selector+titleText)
- lines = append(lines, dimStyle.Render(" "+truncate(compat.SanitizeMetadata(preview.Command), width-2)))
- if preview.Description != "" {
- lines = append(lines, indent(dimStyle.Render(wrap(compat.SanitizeMetadata(preview.Description), width-2)), " "))
- }
+ // Unselected Action (normal colors, subordinate metadata very dim)
+ titleLine := normalActionTitleStyle.Render(selector + titleText)
+ lines = append(lines, "", titleLine)
+
+ cmdText := truncate(compat.SanitizeMetadata(preview.Command), width-4)
+ cmdLine := normalActionSubStyle.Render(" "+cmdText)
+ lines = append(lines, cmdLine)
}
}
return lines
}
+func padRight(s string, width int) string {
+ w := lipgloss.Width(s)
+ if w >= width {
+ return s
+ }
+ return s + strings.Repeat(" ", width-w)
+}
+
func (m appModel) renderActionResult(width int) []string {
if m.actionResult == nil {
return nil
@@ -1156,7 +1230,7 @@ func (m appModel) footer() string {
if m.searching {
mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("212")).Bold(true).Render("SEARCH MODE") + " : type to filter, esc/enter to leave"
} else if m.commands {
- mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("117")).Bold(true).Render("ACTION MODE") + " : j/k choose, enter run, c hide"
+ mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("117")).Bold(true).Render("ACTION MODE") + " : j/k choose, enter run, c/esc close"
}
return dimStyle.Render("LazySkills "+appVersion) + selection + mode
}
@@ -1203,42 +1277,26 @@ func sortSkills(skills []*model.Skill) {
}
func (m appModel) agentFilters() []string {
- observed := map[string]bool{}
- for _, skill := range m.result.Skills {
- for _, path := range skill.ObservedPaths {
- observed[path.Agent] = true
- }
- }
+ var detected []string
if len(m.result.Agents) == 0 {
- ids := make([]string, 0, len(observed))
- for agent := range observed {
- if agent != "" && agent != "universal" {
- ids = append(ids, agent)
+ for _, agent := range agents.DetectInstalled(m.cwd) {
+ if agent.Name == "universal" {
+ continue
}
- }
- sort.Strings(ids)
- if len(ids) > 0 {
- return ids
- }
- return supportedAgentIDs()
- }
- detected, rest := []string{}, []string{}
- for _, agent := range m.result.Agents {
- if agent.Name == "universal" {
- continue
- }
- if agent.Detected || observed[agent.Name] {
detected = append(detected, agent.Name)
- } else {
- rest = append(rest, agent.Name)
+ }
+ } else {
+ for _, agent := range m.result.Agents {
+ if agent.Name == "universal" {
+ continue
+ }
+ if agent.Detected {
+ detected = append(detected, agent.Name)
+ }
}
}
sort.Strings(detected)
- sort.Strings(rest)
- if len(detected) > 0 {
- return detected
- }
- return append(detected, rest...)
+ return detected
}
func supportedAgentIDs() []string {
@@ -1311,6 +1369,9 @@ func agentVisibilityBadge(sk *model.Skill, agent string) string {
func (m appModel) agentLabel() string {
if m.agent == "" {
+ if len(m.agentFilters()) == 0 {
+ return "all (none detected)"
+ }
return "all"
}
for _, agent := range agents.InitialAgents() {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 669e81f..1c6c23e 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -58,18 +58,19 @@ func TestAgentFilterLimitsVisibleSkills(t *testing.T) {
}
}
-func TestNextAgentFilterCyclesThroughObservedAgents(t *testing.T) {
- m := appModel{result: model.ScanResult{Skills: []*model.Skill{
- {Name: "A", ObservedPaths: []model.ObservedPath{{Agent: "opencode"}, {Agent: "cursor"}}},
+func TestNextAgentFilterCyclesThroughDetectedAgents(t *testing.T) {
+ m := appModel{result: model.ScanResult{Agents: []model.AgentState{
+ {Name: "opencode", Detected: true},
+ {Name: "cursor", Detected: true},
}}}
first := m.nextAgentFilter()
if first != "cursor" {
- t.Fatalf("expected first observed agent cursor, got %q", first)
+ t.Fatalf("expected first detected agent cursor, got %q", first)
}
m.agent = first
second := m.nextAgentFilter()
if second != "opencode" {
- t.Fatalf("expected second observed agent opencode, got %q", second)
+ t.Fatalf("expected second detected agent opencode, got %q", second)
}
m.agent = second
if got := m.nextAgentFilter(); got != "" {
@@ -77,7 +78,7 @@ func TestNextAgentFilterCyclesThroughObservedAgents(t *testing.T) {
}
}
-func TestAgentFilterCyclesDetectedAgentsBeforeSupportedFallback(t *testing.T) {
+func TestAgentFilterCyclesDetectedAgentsNoSupportedFallback(t *testing.T) {
m := appModel{result: model.ScanResult{Agents: []model.AgentState{
{Name: "opencode", Display: "OpenCode", Detected: true},
{Name: "cursor", Display: "Cursor"},
@@ -87,8 +88,31 @@ func TestAgentFilterCyclesDetectedAgentsBeforeSupportedFallback(t *testing.T) {
t.Fatalf("expected only detected agents in rotation, got %#v", got)
}
m = appModel{result: model.ScanResult{Agents: []model.AgentState{{Name: "opencode", Display: "OpenCode"}}}}
- if got := m.agentFilters(); len(got) != 1 || got[0] != "opencode" {
- t.Fatalf("expected fallback to supported agents when none detected, got %#v", got)
+ if got := m.agentFilters(); len(got) != 0 {
+ t.Fatalf("expected no fallback to supported agents when none detected, got %#v", got)
+ }
+}
+
+func TestAgentClearedOnRefreshIfNoLongerDetected(t *testing.T) {
+ m := appModel{
+ agent: "opencode",
+ result: model.ScanResult{
+ Agents: []model.AgentState{
+ {Name: "opencode", Detected: true},
+ },
+ },
+ }
+ // Simulate a snapshotMsg where opencode is no longer detected (or not present in Agents)
+ updated, _ := m.Update(snapshotMsg{
+ result: model.ScanResult{
+ Agents: []model.AgentState{
+ {Name: "opencode", Detected: false},
+ },
+ },
+ })
+ next := updated.(appModel)
+ if next.agent != "" {
+ t.Fatalf("expected agent to be cleared when no longer detected after refresh, got %q", next.agent)
}
}
@@ -335,15 +359,21 @@ func TestSpaceMarksSkillsAndEscClearsSelection(t *testing.T) {
}
}
-func TestEscClearsSelectionBeforeLeavingActionModeOrAgentFilter(t *testing.T) {
+func TestEscClosesActionPickerOverlay(t *testing.T) {
m := bulkActionTestModel(t.TempDir())
m.commands = true
m.agent = "opencode"
m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true}
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEsc})
next := updated.(appModel)
- if next.selectedCount() != 0 || !next.commands || next.agent != "opencode" {
- t.Fatalf("expected esc to clear selection first, selected=%d commands=%v agent=%q", next.selectedCount(), next.commands, next.agent)
+ if next.commands {
+ t.Fatalf("expected esc to close action mode overlay, commands is still true")
+ }
+ if next.selectedCount() != 1 {
+ t.Fatalf("expected selection to be preserved when action mode is closed, got %d", next.selectedCount())
+ }
+ if next.agent != "opencode" {
+ t.Fatalf("expected agent to be preserved when action mode is closed, got %q", next.agent)
}
}