Skip to content

Replace manual prompt with console.ConfirmAction() in remove command#11637

Merged
pelikhan merged 3 commits intomainfrom
copilot/replace-manual-prompt-console-confirm
Jan 24, 2026
Merged

Replace manual prompt with console.ConfirmAction() in remove command#11637
pelikhan merged 3 commits intomainfrom
copilot/replace-manual-prompt-console-confirm

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

The remove command used manual prompt handling (fmt.Print + fmt.Scanln) instead of the standardized console.ConfirmAction() helper used by other interactive commands.

Changes

pkg/cli/remove_command.go (lines 122-130):

  • Replaced manual string parsing with console.ConfirmAction()
  • Added proper error handling with error wrapping
  • Updated cancellation message to use console.FormatInfoMessage()

Before/After

// Before: Manual prompt handling
fmt.Print("\nAre you sure you want to remove these workflows? [y/N]: ")
reader := bufio.NewReader(os.Stdin)
response, _ := reader.ReadString('\n')
response = strings.TrimSpace(strings.ToLower(response))

if response != "y" && response != "yes" {
    fmt.Println("Operation cancelled.")
    return nil
}

// After: Standardized console helper
confirmed, err := console.ConfirmAction(
    "Are you sure you want to remove these workflows?",
    "Yes, remove",
    "No, cancel",
)
if err != nil {
    return fmt.Errorf("failed to get confirmation: %w", err)
}
if !confirmed {
    fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Operation cancelled."))
    return nil
}

Benefits

  • Consistent Huh-based interactive UI across commands
  • Automatic accessibility mode support via IsAccessibleMode()
  • Proper error propagation instead of silently ignoring errors
Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Replace bare prompt in remove_command.go with console.ConfirmAction()</issue_title>
<issue_description>## Objective

Replace the manual prompt/scanln pattern in remove_command.go with the proper console.ConfirmAction() helper for consistency and better UX.

Context

From discussion #11611: The remove_command.go file uses a bare prompt (fmt.Print + fmt.Scanln) instead of the Huh-based console.ConfirmAction() wrapper.

Current Issue: remove_command.go:118 uses manual prompt handling instead of the standardized console helper.

Approach

  1. Locate the prompt code around line 118 in pkg/cli/remove_command.go

  2. Replace with console.ConfirmAction():

    • Use existing console package function
    • Provide clear question text
    • Handle error case properly
  3. Test the change:

    • Verify interactive prompt works
    • Test with and without TTY
    • Ensure accessibility mode is respected

Files to Modify

  • Update: pkg/cli/remove_command.go (line ~118)

Implementation Example

// Before (remove_command.go:118):
fmt.Print("Are you sure you want to remove the workflow? (yes/no): ")
var response string
fmt.Scanln(&response)
if response != "yes" {
    return fmt.Errorf("workflow removal cancelled")
}

// After:
confirmed, err := console.ConfirmAction(
    "Remove workflow?",
    "Yes, remove",
    "No, cancel",
)
if err != nil {
    return fmt.Errorf("failed to get confirmation: %w", err)
}
if !confirmed {
    return fmt.Errorf("workflow removal cancelled")
}

Acceptance Criteria

  • Manual prompt replaced with console.ConfirmAction()
  • Error handling properly implemented
  • Interactive prompt works in terminal
  • Accessibility mode is respected
  • Code passes make fmt and make lint
  • make agent-finish completes successfully

Priority

Phase 1: Critical Fix (1-2 hours estimated)

AI generated by Plan Command for discussion #11611

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 24, 2026 11:59
…Action()

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace bare prompt in remove_command.go with console.ConfirmAction Replace manual prompt with console.ConfirmAction() in remove command Jan 24, 2026
Copilot AI requested a review from pelikhan January 24, 2026 12:12
@pelikhan pelikhan marked this pull request as ready for review January 24, 2026 12:15
@pelikhan pelikhan merged commit 9f58126 into main Jan 24, 2026
@pelikhan pelikhan deleted the copilot/replace-manual-prompt-console-confirm branch January 24, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Replace bare prompt in remove_command.go with console.ConfirmAction()

2 participants