Skip to content

mission control for agent skills

Relax single remove confirmation

Alvin Unreal1b97b2600c0e
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 7a22fc4..f6ad2db 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1070,7 +1070,7 @@ func TestFailedMutationDoesNotTriggerRescan(t *testing.T) {
}
}
-func TestRemoveRequiresExactTypedIdentity(t *testing.T) {
+func TestSingleRemoveRequiresYesConfirmation(t *testing.T) {
m := actionTestModel(t.TempDir())
m.result.Skills[0].CanonicalPath = "/tmp/deploy-skill"
m.commands = true
@@ -1083,12 +1083,12 @@ func TestRemoveRequiresExactTypedIdentity(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, `Type "deploy-skill" exactly`) || m.actionResult != nil {
+ if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, "Type y or yes") || m.actionResult != nil {
t.Fatalf("expected inline confirmation error without command, confirming=%v err=%q result=%#v cmd=%v", m.confirming, m.confirmError, m.actionResult, cmd)
}
}
-func TestDangerousConfirmationRejectsYesAndAcceptsExactPhrase(t *testing.T) {
+func TestSingleRemoveAcceptsYesConfirmation(t *testing.T) {
old := runExec
runExec = func(spec runner.ExecSpec) runner.Result {
return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
@@ -1106,18 +1106,26 @@ func TestDangerousConfirmationRejectsYesAndAcceptsExactPhrase(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, `Type "deploy-skill" exactly`) {
- t.Fatalf("expected yes to be rejected for dangerous confirmation, confirming=%v err=%q cmd=%v", m.confirming, m.confirmError, cmd)
+ if cmd == nil || !m.running {
+ t.Fatalf("expected yes to run single remove, running=%v cmd=%v", m.running, cmd)
}
+}
- for _, r := range []rune("deploy-skill") {
+func TestBulkRemoveRequiresExactPhrase(t *testing.T) {
+ m := bulkActionTestModel(t.TempDir())
+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true, skillKey(m.result.Skills[1]): true}
+ m.commands = true
+ m.action = actionIndex(t, m, "Remove 2 selected skills")
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ for _, r := range []rune("yes") {
updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{r}})
m = updated.(appModel)
}
- updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd == nil || !m.running {
- t.Fatalf("expected exact phrase to run dangerous action, running=%v cmd=%v", m.running, cmd)
+ if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, `Type "remove 2 skills" exactly`) {
+ t.Fatalf("expected bulk remove to require exact phrase, confirming=%v err=%q cmd=%v", m.confirming, m.confirmError, cmd)
}
}
@@ -1167,8 +1175,18 @@ func TestConfirmationOverlayCopyMatchesRisk(t *testing.T) {
m.action = actionIndex(t, m, "Remove selected skill")
dangerOut := m.confirmationOverlay(appLayout{Width: 120, Height: 32})
- if !strings.Contains(dangerOut, `deploy-skill`) || !strings.Contains(dangerOut, `to confirm`) || strings.Contains(dangerOut, "y / yes") {
- t.Fatalf("expected dangerous exact-phrase copy, got %q", dangerOut)
+ if !strings.Contains(dangerOut, "Type y or yes to confirm") || strings.Contains(dangerOut, `Type "deploy-skill"`) {
+ t.Fatalf("expected single-remove y/yes copy, got %q", dangerOut)
+ }
+
+ m = bulkActionTestModel(t.TempDir())
+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true, skillKey(m.result.Skills[1]): true}
+ m.commands = true
+ m.action = actionIndex(t, m, "Remove 2 selected skills")
+ m.confirming = true
+ bulkOut := m.confirmationOverlay(appLayout{Width: 120, Height: 32})
+ if !strings.Contains(bulkOut, `remove 2 skills`) || !strings.Contains(bulkOut, `to confirm`) || strings.Contains(bulkOut, "y / yes") {
+ t.Fatalf("expected bulk-remove exact-phrase copy, got %q", bulkOut)
}
}
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 584ace1..f72dbb3 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -731,23 +731,30 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
}
func confirmationAccepted(input string, action actions.CommandPreview) bool {
- if action.Dangerous {
+ if requiresExactConfirmation(action) {
return input == action.ConfirmValue && action.ConfirmValue != ""
}
value := strings.TrimSpace(strings.ToLower(input))
if value == "" {
- return true
+ return !action.Dangerous
}
return value == "y" || value == "yes" || input == action.ConfirmValue
}
func confirmationError(action actions.CommandPreview) string {
- if action.Dangerous {
+ if requiresExactConfirmation(action) {
return fmt.Sprintf("Type %q exactly, or press Esc to cancel.", action.ConfirmValue)
}
+ if action.Dangerous {
+ return "Type y or yes to confirm, or press Esc to cancel."
+ }
return "Press Enter to continue, or Esc to cancel."
}
+func requiresExactConfirmation(action actions.CommandPreview) bool {
+ return action.Dangerous && action.ID == "bulk_remove"
+}
+
func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.Cmd) {
if action.ID == "source_discover" {
m.commands = false
diff --git a/internal/tui/view.go b/internal/tui/view.go
index f297b30..637941a 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -1236,17 +1236,20 @@ func (m appModel) confirmationOverlay(layout appLayout) string {
phrase := ""
command := ""
dangerous := false
+ exact := false
if m.pendingAction != nil {
title = compat.SanitizeMetadata(m.pendingAction.Title)
phrase = compat.SanitizeMetadata(m.pendingAction.ConfirmValue)
command = compat.SanitizeMetadata(m.pendingAction.Command)
dangerous = m.pendingAction.Dangerous
+ exact = requiresExactConfirmation(*m.pendingAction)
} else if acts := m.currentActions(); len(acts) > 0 && m.action < len(acts) {
action := acts[m.action]
title = compat.SanitizeMetadata(action.Title)
phrase = compat.SanitizeMetadata(action.ConfirmValue)
command = compat.SanitizeMetadata(action.Command)
dangerous = action.Dangerous
+ exact = requiresExactConfirmation(action)
}
headerStyle := sectionHeaderStyle
borderColor := actionBorderColor
@@ -1255,8 +1258,12 @@ func (m appModel) confirmationOverlay(layout appLayout) string {
if dangerous {
headerStyle = errorStyle.Bold(true)
borderColor = lipgloss.Color("203")
- placeholder = phrase
- instruction = fmt.Sprintf("Type %q to confirm, or Esc to cancel.", phrase)
+ placeholder = "y / yes"
+ instruction = "Type y or yes to confirm, or Esc to cancel."
+ if exact {
+ placeholder = phrase
+ instruction = fmt.Sprintf("Type %q to confirm, or Esc to cancel.", phrase)
+ }
}
lines := []string{
headerStyle.Render(title),