Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

When a workflow file exists during interactive creation, the builder now shows a confirmation dialog instead of erroring out and forcing the user to restart with --force.

Changes

  • pkg/cli/interactive.go: Replace error return with huh.NewConfirm() dialog when file exists

    • Shows "Yes, overwrite" / "No, cancel" options
    • Respects --force flag to bypass confirmation
    • Supports accessible mode via isAccessibleMode()
  • pkg/cli/interactive_test.go: Add tests for CI environment protection and force flag behavior

Example

if _, err := os.Stat(destFile); err == nil && !force {
    var overwrite bool
    huh.NewConfirm().
        Title(fmt.Sprintf("Workflow file '%s' already exists. Overwrite?", filepath.Base(destFile))).
        Affirmative("Yes, overwrite").
        Negative("No, cancel").
        Value(&overwrite).
        WithAccessible(isAccessibleMode()).
        Run()
    if !overwrite {
        return fmt.Errorf("workflow creation cancelled")
    }
}

Selecting "No" exits gracefully with clear cancellation message. The --force flag continues to skip the prompt entirely.

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Add Confirm field for file overwrite in interactive workflow builder</issue_title>
<issue_description>## Objective

Replace the error-based file overwrite handling with an interactive confirmation dialog using huh.NewConfirm().

Context

Currently, if a workflow file already exists, the interactive builder returns an error unless the --force flag is used. This interrupts the user flow and requires restarting the entire interactive session.

Approach

Add a Confirm field that asks the user whether to overwrite when a file exists:

if _, err := os.Stat(destFile); err == nil && !force {
    var overwrite bool
    huh.NewConfirm().
        Title(fmt.Sprintf("Workflow file '%s' already exists. Overwrite?", filepath.Base(destFile))).
        Affirmative("Yes, overwrite").
        Negative("No, cancel").
        Value(&overwrite).
        WithAccessible(isAccessibleMode()).
        Run()
    if !overwrite {
        return fmt.Errorf("workflow creation cancelled")
    }
}

Files to Modify

  • Update: pkg/cli/interactive.go - Add confirmation logic in the file write section

Acceptance Criteria

  • When a workflow file exists, users see an interactive confirmation prompt
  • Selecting "Yes, overwrite" proceeds with file creation
  • Selecting "No, cancel" exits gracefully with a clear message
  • Confirmation works in both accessible and standard modes
  • The --force flag still bypasses the confirmation when used
    Related to [plan] Enhance interactive workflow builder with huh v0.7.0+ features #7216

AI generated by Plan Command for discussion #7214

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add confirm field for file overwrite in workflow builder Add interactive confirmation dialog for file overwrite in workflow builder Dec 22, 2025
Copilot AI requested a review from mnkiefer December 22, 2025 08:05
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] Add Confirm field for file overwrite in interactive workflow builder

2 participants