Skip to content

mission control for agent skills

Improve confirmation prompts

Alvin Unrealaaa6bcec4273
diff --git a/internal/tui/discovery.go b/internal/tui/discovery.go
index cb7256d..2592cac 100644
--- a/internal/tui/discovery.go
+++ b/internal/tui/discovery.go
@@ -456,7 +456,7 @@ func defaultGitClone(url, ref, tempDir string) error {
cmd := exec.Command("git", "clone", "--depth", "1", url, tempDir)
if err := cmd.Run(); err != nil {
- return fmt.Errorf("failed to clone repository: %w", err)
+ return fmt.Errorf("failed to scan source: %w", err)
}
if ref != "" {
diff --git a/internal/tui/state.go b/internal/tui/state.go
index ca41a25..836b18d 100644
--- a/internal/tui/state.go
+++ b/internal/tui/state.go
@@ -350,7 +350,7 @@ func (m appModel) sourceActions(group string) []actions.CommandPreview {
desc := "Scan the local source root for uninstalled skills."
if isRemote {
title = "Check remote source for available skills"
- desc = "Clone and scan the remote repository for available skills."
+ desc = "Scan this source for available skills."
}
discPreview := actions.CommandPreview{
ID: "source_discover",
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index d09e0e3..7a22fc4 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -369,7 +369,7 @@ func TestConfirmationAcceptsDefaultYAndYes(t *testing.T) {
}
}
-func TestConfirmationRejectsEmptyInput(t *testing.T) {
+func TestSafeConfirmationAcceptsEmptyInput(t *testing.T) {
called := false
old := runExec
runExec = func(spec runner.ExecSpec) runner.Result { called = true; return runner.Result{ExitCode: 0} }
@@ -381,14 +381,15 @@ func TestConfirmationRejectsEmptyInput(t *testing.T) {
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- // Just press Enter with empty/whitespace input
+ // Safe actions accept empty Enter as the default confirmation.
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || m.running || !m.confirming {
- t.Fatalf("expected empty/whitespace input to be rejected, running=%v confirming=%v cmd=%v", m.running, m.confirming, cmd)
+ if cmd == nil || !m.running || m.confirming {
+ t.Fatalf("expected empty input to run safe confirmation, running=%v confirming=%v cmd=%v", m.running, m.confirming, cmd)
}
- if called {
- t.Fatalf("expected command execution to not occur")
+ cmd()
+ if !called {
+ t.Fatalf("expected command execution")
}
}
@@ -399,7 +400,7 @@ func TestConfirmationRendersCenteredModal(t *testing.T) {
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
out := m.View()
- if !strings.Contains(out, "Confirm") || !strings.Contains(out, "press Enter to confirm") || strings.Contains(out, "Bulk actions") {
+ if !strings.Contains(out, "Reinstall/update selected skill") || !strings.Contains(out, "Press Enter to continue") || strings.Contains(out, "Bulk actions") {
t.Fatalf("expected standalone confirmation modal, got %q", out)
}
}
@@ -1082,11 +1083,95 @@ 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 yes") || m.actionResult != nil {
+ if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, `Type "deploy-skill" exactly`) || 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) {
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result {
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
+ }
+ t.Cleanup(func() { runExec = old })
+
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Remove selected skill")
+ 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})
+ 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)
+ }
+
+ for _, r := range []rune("deploy-skill") {
+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{r}})
+ m = updated.(appModel)
+ }
+ 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)
+ }
+}
+
+func TestConfirmationAllowsSkillNamesStartingWithN(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ m.result.Skills[0].CanonicalPath = "/tmp/next-auth"
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'x'}})
+ m = updated.(appModel)
+ if cmd != nil || !m.confirming || m.currentActions()[m.action].ConfirmValue != "next-auth" {
+ t.Fatalf("expected remove confirmation for next-auth, confirming=%v action=%#v cmd=%v", m.confirming, m.currentActions()[m.action], cmd)
+ }
+ updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'n'}})
+ m = updated.(appModel)
+ if cmd != nil || !m.confirming || m.confirmInput != "n" {
+ t.Fatalf("expected first n to be typed, not cancel confirmation; confirming=%v input=%q cmd=%v", m.confirming, m.confirmInput, cmd)
+ }
+}
+
+func TestDirectSafeConfirmationAcceptsEmptyEnter(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}
+ }
+ t.Cleanup(func() { runExec = old })
+
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ if cmd == nil || !m.running {
+ t.Fatalf("expected empty Enter to run safe action, running=%v cmd=%v", m.running, cmd)
+ }
+}
+
+func TestConfirmationOverlayCopyMatchesRisk(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
+ m.confirming = true
+ safeOut := m.confirmationOverlay(appLayout{Width: 120, Height: 32})
+ if !strings.Contains(safeOut, "Press Enter to continue, or Esc to cancel.") || strings.Contains(safeOut, "Type ") {
+ t.Fatalf("expected safe confirmation copy, got %q", safeOut)
+ }
+
+ 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)
+ }
+}
+
func actionTestModel(cwd string) appModel {
return appModel{cwd: cwd, width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{{
Name: "Deploy Skill",
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 9a1df50..584ace1 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -227,13 +227,6 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.confirmInput = ""
m.confirmError = ""
m.pendingAction = nil
- case "n":
- if m.confirmInput == "" {
- m.confirming = false
- m.confirmInput = ""
- m.confirmError = ""
- m.pendingAction = nil
- }
case "pgdown", "ctrl+d", "pgup", "ctrl+u":
var cmd tea.Cmd
m.viewport, cmd = m.viewport.Update(msg)
@@ -727,8 +720,8 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
}
action = acts[m.action]
}
- if !confirmationAccepted(m.confirmInput, action.ConfirmValue) {
- m.confirmError = "Type yes, y, or the displayed phrase. Press Esc to cancel."
+ if !confirmationAccepted(m.confirmInput, action) {
+ m.confirmError = confirmationError(action)
m.confirmInput = ""
m.syncViewport()
return m, nil
@@ -737,12 +730,22 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
return m.executeAction(action)
}
-func confirmationAccepted(input, confirmValue string) bool {
+func confirmationAccepted(input string, action actions.CommandPreview) bool {
+ if action.Dangerous {
+ return input == action.ConfirmValue && action.ConfirmValue != ""
+ }
value := strings.TrimSpace(strings.ToLower(input))
if value == "" {
- return false
+ return true
+ }
+ return value == "y" || value == "yes" || input == action.ConfirmValue
+}
+
+func confirmationError(action actions.CommandPreview) string {
+ if action.Dangerous {
+ return fmt.Sprintf("Type %q exactly, or press Esc to cancel.", action.ConfirmValue)
}
- return value == "y" || value == "yes" || input == confirmValue
+ return "Press Enter to continue, or Esc to cancel."
}
func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.Cmd) {
diff --git a/internal/tui/view.go b/internal/tui/view.go
index 3e8d4c3..f297b30 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -552,7 +552,7 @@ func (m appModel) previewLines(width int) []string {
case !discOk:
lines = append(lines, sectionHeaderStyle.Render("Available"), dimStyle.Render(" press d to scan this source"))
case disc.Status == DiscoveryLoading && isRemote:
- lines = append(lines, sectionHeaderStyle.Render("Available"), dimStyle.Render(" cloning & scanning…"))
+ lines = append(lines, sectionHeaderStyle.Render("Available"), dimStyle.Render(" scanning…"))
case disc.Status == DiscoveryLoading:
lines = append(lines, sectionHeaderStyle.Render("Available"), dimStyle.Render(" scanning…"))
case disc.Status == DiscoveryFailed:
@@ -743,7 +743,7 @@ func (m appModel) sourceModalDetailLines(width int) []string {
switch disc.Status {
case DiscoveryLoading:
if isRemote {
- lines = append(lines, dimStyle.Render(" Cloning & scanning…"))
+ lines = append(lines, dimStyle.Render(" Scanning…"))
} else {
lines = append(lines, dimStyle.Render(" Scanning…"))
}
@@ -1235,48 +1235,47 @@ func (m appModel) confirmationOverlay(layout appLayout) string {
title := "Confirm action"
phrase := ""
command := ""
+ dangerous := 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
} 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
+ }
+ headerStyle := sectionHeaderStyle
+ borderColor := actionBorderColor
+ placeholder := "Enter"
+ instruction := "Press Enter to continue, or Esc to cancel."
+ if dangerous {
+ headerStyle = errorStyle.Bold(true)
+ borderColor = lipgloss.Color("203")
+ placeholder = phrase
+ instruction = fmt.Sprintf("Type %q to confirm, or Esc to cancel.", phrase)
}
lines := []string{
- errorStyle.Bold(true).Render("Confirm Action"),
- "",
- sectionHeaderStyle.Render("Action:"),
- wrapText(title, 48),
- "",
- sectionHeaderStyle.Render("Command:"),
- dimStyle.Render(wrapText(command, 48)),
+ headerStyle.Render(title),
"",
}
- if phrase == "yes" || phrase == "y" {
- lines = append(lines, "Type 'y' or 'yes' and press Enter to confirm.")
- } else if phrase != "" {
- lines = append(lines, "Type 'y', 'yes', or '"+phrase+"' and press Enter to confirm.")
- } else {
- lines = append(lines, "Type 'y' or 'yes' and press Enter to confirm.")
+ if command != "" {
+ lines = append(lines, sectionHeaderStyle.Render("Command"), dimStyle.Render(wrapText(command, 48)), "")
}
- lines = append(lines, "Press Esc to cancel.")
+ lines = append(lines, wrapText(instruction, 48))
if m.confirmError != "" {
lines = append(lines, "", errorStyle.Render(m.confirmError))
}
input := compat.SanitizeMetadata(m.confirmInput)
if input == "" {
- placeholder := "y / yes"
- if phrase != "yes" && phrase != "y" && phrase != "" {
- placeholder = fmt.Sprintf("y / yes / %s", phrase)
- }
input = dimStyle.Render(placeholder)
}
lines = append(lines, "", "> "+input+"_")
- box := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(actionBorderColor).Padding(1, 2).Width(52).Render(strings.Join(lines, "\n"))
+ box := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(borderColor).Padding(1, 2).Width(52).Render(strings.Join(lines, "\n"))
return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)
}