Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
π€ Plandex β Refactor reject command to utilize survey multiselect and forked survey package for file selection
Dane Schneider3ad5a5e51485
diff --git a/app/cli/cmd/reject.go b/app/cli/cmd/reject.goindex fc6314ac..864b8587 100644--- a/app/cli/cmd/reject.go+++ b/app/cli/cmd/reject.go@@ -1,3 +1,4 @@+package cmdimport (@@ -9,6 +10,7 @@ import ("plandex/term""sort"+ "github.com/plandex-ai/survey/v2""github.com/spf13/cobra")@@ -51,44 +53,13 @@ func reject(cmd *cobra.Command, args []string) {term.OutputErrorAndExit("No pending changes to reject")}- if rejectAll || len(args) == 0 {+ if rejectAll {numToReject := len(currentFiles)suffix := ""if numToReject > 1 {suffix = "s"}- if !rejectAll {- term.StopSpinner()-- // output list of pending files- fmt.Println("Files with pending changes:")-- pathsToSort := make([]string, 0, len(currentFiles))-- for path := range currentFiles {- pathsToSort = append(pathsToSort, path)- }-- sort.Strings(pathsToSort)-- for _, path := range pathsToSort {- fmt.Println(" β’ ", path)- }- fmt.Println()-- shouldContinue, err := term.ConfirmYesNo("Reject changes to %d file%s?", numToReject, suffix)-- if err != nil {- term.OutputErrorAndExit("failed to get confirmation user input: %s", err)- }-- if !shouldContinue {- os.Exit(0)- }- term.ResumeSpinner()- }-apiErr := api.Client.RejectAllChanges(lib.CurrentPlanId, lib.CurrentBranch)if apiErr != nil {@@ -98,7 +69,6 @@ func reject(cmd *cobra.Command, args []string) {term.StopSpinner()fmt.Printf("β Rejected changes to %d file%s\n", numToReject, suffix)-return}@@ -109,20 +79,61 @@ func reject(cmd *cobra.Command, args []string) {term.OutputErrorAndExit("File %s not found in plan or has no changes to reject", path)}}++ numToReject := len(args)+ suffix := ""+ if numToReject > 1 {+ suffix = "s"+ }++ apiErr = api.Client.RejectFiles(lib.CurrentPlanId, lib.CurrentBranch, args)+ term.StopSpinner()++ if apiErr != nil {+ term.OutputErrorAndExit("Error rejecting changes: %v", apiErr)+ }++ fmt.Printf("β Rejected changes to %d file%s\n", numToReject, suffix)+ return}- numToReject := len(args)- suffix := ""- if numToReject > 1 {- suffix = "s"+ // No args provided - use survey multiselect+ term.StopSpinner()++ pathsToSort := make([]string, 0, len(currentFiles))+ for path := range currentFiles {+ pathsToSort = append(pathsToSort, path)}+ sort.Strings(pathsToSort)- apiErr = api.Client.RejectFiles(lib.CurrentPlanId, lib.CurrentBranch, args)+ var selectedFiles []string+ prompt := &survey.MultiSelect{+ Message: "Select files to reject:",+ Options: pathsToSort,+ }++ err := survey.AskOne(prompt, &selectedFiles)+ if err != nil {+ term.OutputErrorAndExit("Error getting file selection: %v", err)+ }++ if len(selectedFiles) == 0 {+ fmt.Println("No files selected")+ return+ }++ term.StartSpinner("")+ apiErr = api.Client.RejectFiles(lib.CurrentPlanId, lib.CurrentBranch, selectedFiles)term.StopSpinner()if apiErr != nil {term.OutputErrorAndExit("Error rejecting changes: %v", apiErr)}- fmt.Printf("β Rejected changes to %d file%s\n", numToReject, suffix)+ suffix := ""+ if len(selectedFiles) > 1 {+ suffix = "s"+ }+ fmt.Printf("β Rejected changes to %d file%s\n", len(selectedFiles), suffix)}+