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
if plan tell is stopped due to error or not updating context, output prompt before exiting so it isn't lost-fixes #109 and #182
Dane Schneider769375700071
diff --git a/app/cli/cmd/build.go b/app/cli/cmd/build.goindex 01084e7c..9f40cb10 100644--- a/app/cli/cmd/build.go+++ b/app/cli/cmd/build.go@@ -44,8 +44,8 @@ func build(cmd *cobra.Command, args []string) {CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,ApiKeys: apiKeys,- CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool) {- return lib.MustCheckOutdatedContext(false, maybeContexts)+ CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool, error) {+ return lib.CheckOutdatedContextWithOutput(false, maybeContexts)},}, buildBg)diff --git a/app/cli/cmd/changes.go b/app/cli/cmd/changes.goindex 0b2f4787..0f6a32e4 100644--- a/app/cli/cmd/changes.go+++ b/app/cli/cmd/changes.go@@ -84,8 +84,8 @@ func changes(cmd *cobra.Command, args []string) {CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,ApiKeys: apiKeys,- CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool) {- return lib.MustCheckOutdatedContext(true, maybeContexts)+ CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool, error) {+ return lib.CheckOutdatedContextWithOutput(true, maybeContexts)},}, false)diff --git a/app/cli/cmd/continue.go b/app/cli/cmd/continue.goindex 2da9e487..38db8b60 100644--- a/app/cli/cmd/continue.go+++ b/app/cli/cmd/continue.go@@ -42,8 +42,8 @@ func doContinue(cmd *cobra.Command, args []string) {CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,ApiKeys: apiKeys,- CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool) {- return lib.MustCheckOutdatedContext(false, maybeContexts)+ CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool, error) {+ return lib.CheckOutdatedContextWithOutput(false, maybeContexts)},}, "", tellBg, tellStop, tellNoBuild, true)}diff --git a/app/cli/cmd/tell.go b/app/cli/cmd/tell.goindex c36bb055..591d0c74 100644--- a/app/cli/cmd/tell.go+++ b/app/cli/cmd/tell.go@@ -79,8 +79,8 @@ func doTell(cmd *cobra.Command, args []string) {CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,ApiKeys: apiKeys,- CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool) {- return lib.MustCheckOutdatedContext(false, maybeContexts)+ CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool, error) {+ return lib.CheckOutdatedContextWithOutput(false, maybeContexts)},}, prompt, tellBg, tellStop, tellNoBuild, false)}diff --git a/app/cli/cmd/update.go b/app/cli/cmd/update.goindex 76aa6d42..eb793f0c 100644--- a/app/cli/cmd/update.go+++ b/app/cli/cmd/update.go@@ -40,5 +40,5 @@ func update(cmd *cobra.Command, args []string) {return}- lib.MustUpdateContext(nil)+ lib.UpdateContextWithOutput(nil)}diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.goindex 97099086..bf17b627 100644--- a/app/cli/lib/apply.go+++ b/app/cli/lib/apply.go@@ -62,7 +62,11 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {}}- anyOutdated, didUpdate := MustCheckOutdatedContext(true, nil)+ anyOutdated, didUpdate, err := CheckOutdatedContextWithOutput(true, nil)++ if err != nil {+ term.OutputErrorAndExit("error checking outdated context: %v", err)+ }if anyOutdated && !didUpdate {term.StopSpinner()diff --git a/app/cli/lib/context_update.go b/app/cli/lib/context_update.goindex db056058..64f9bdf9 100644--- a/app/cli/lib/context_update.go+++ b/app/cli/lib/context_update.go@@ -20,7 +20,7 @@ import ("github.com/plandex/plandex/shared")-func MustCheckOutdatedContext(quiet bool, maybeContexts []*shared.Context) (contextOutdated, updated bool) {+func CheckOutdatedContextWithOutput(quiet bool, maybeContexts []*shared.Context) (contextOutdated, updated bool, err error) {if !quiet {term.StartSpinner("π¬ Checking context...")}@@ -28,7 +28,7 @@ func MustCheckOutdatedContext(quiet bool, maybeContexts []*shared.Context) (contoutdatedRes, err := CheckOutdatedContext(maybeContexts)if err != nil {term.StopSpinner()- term.OutputErrorAndExit("failed to check outdated context: %s", err)+ return false, false, fmt.Errorf("failed to check outdated context: %s", err)}term.StopSpinner()@@ -37,7 +37,7 @@ func MustCheckOutdatedContext(quiet bool, maybeContexts []*shared.Context) (contif !quiet {fmt.Println("β Context is up to date")}- return false, false+ return false, false, nil}if len(outdatedRes.UpdatedContexts) > 0 {types := []string{}@@ -142,28 +142,31 @@ func MustCheckOutdatedContext(quiet bool, maybeContexts []*shared.Context) (cont}if confirmed {- MustUpdateContext(maybeContexts)- return true, true+ err = UpdateContextWithOutput(maybeContexts)+ if err != nil {+ return false, false, fmt.Errorf("error updating context: %v", err)+ }+ return true, true, nil} else {- return true, false+ return true, false, nil}}-func MustUpdateContext(maybeUpdateContexts []*shared.Context) {+func UpdateContextWithOutput(maybeUpdateContexts []*shared.Context) error {term.StartSpinner("π Updating context...")updateRes, err := UpdateContext(maybeUpdateContexts)if err != nil {- term.StopSpinner()- term.OutputErrorAndExit("Error updating context: %v", err)+ return err}term.StopSpinner()fmt.Println("β " + updateRes.Msg)+ return nil}func UpdateContext(maybeContexts []*shared.Context) (*types.ContextOutdatedResult, error) {diff --git a/app/cli/main.go b/app/cli/main.goindex 33b16ff8..d44514e7 100644--- a/app/cli/main.go+++ b/app/cli/main.go@@ -35,8 +35,8 @@ func init() {CurrentPlanId: lib.CurrentPlanId,CurrentBranch: lib.CurrentBranch,ApiKeys: apiKeys,- CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool) {- return lib.MustCheckOutdatedContext(true, maybeContexts)+ CheckOutdatedContext: func(maybeContexts []*shared.Context) (bool, bool, error) {+ return lib.CheckOutdatedContextWithOutput(true, maybeContexts)},}, false)})diff --git a/app/cli/plan_exec/build.go b/app/cli/plan_exec/build.goindex 19a56d9d..f65c0d27 100644--- a/app/cli/plan_exec/build.go+++ b/app/cli/plan_exec/build.go@@ -22,7 +22,11 @@ func Build(params ExecParams, buildBg bool) (bool, error) {term.OutputErrorAndExit("Error getting context: %v", apiErr)}- anyOutdated, didUpdate := params.CheckOutdatedContext(contexts)+ anyOutdated, didUpdate, err := params.CheckOutdatedContext(contexts)++ if err != nil {+ term.OutputErrorAndExit("error checking outdated context: %v", err)+ }if anyOutdated && !didUpdate {term.StopSpinner()diff --git a/app/cli/plan_exec/params.go b/app/cli/plan_exec/params.goindex f4a8dd5d..fbe99c52 100644--- a/app/cli/plan_exec/params.go+++ b/app/cli/plan_exec/params.go@@ -6,5 +6,5 @@ type ExecParams struct {CurrentPlanId stringCurrentBranch stringApiKeys map[string]string- CheckOutdatedContext func(maybeContexts []*shared.Context) (bool, bool)+ CheckOutdatedContext func(maybeContexts []*shared.Context) (bool, bool, error)}diff --git a/app/cli/plan_exec/tell.go b/app/cli/plan_exec/tell.goindex ff5e48bd..889f3690 100644--- a/app/cli/plan_exec/tell.go+++ b/app/cli/plan_exec/tell.go@@ -11,6 +11,7 @@ import (streamtui "plandex/stream_tui""plandex/term"+ "github.com/fatih/color""github.com/plandex/plandex/shared")@@ -22,14 +23,34 @@ func TellPlan(tellNoBuild,isUserContinue bool,) {++ outputPromptIfTell := func() {+ if isUserContinue || prompt == "" {+ return+ }++ term.StopSpinner()+ // print prompt so it isn't lost+ color.New(term.ColorHiCyan, color.Bold).Println("\nYour prompt π")+ fmt.Println()+ fmt.Println(prompt)+ fmt.Println()+ }+term.StartSpinner("")contexts, apiErr := api.Client.ListContext(params.CurrentPlanId, params.CurrentBranch)if apiErr != nil {+ outputPromptIfTell()term.OutputErrorAndExit("Error getting context: %v", apiErr)}- anyOutdated, didUpdate := params.CheckOutdatedContext(contexts)+ anyOutdated, didUpdate, err := params.CheckOutdatedContext(contexts)++ if err != nil {+ outputPromptIfTell()+ term.OutputErrorAndExit("Error checking outdated context: %v", err)+ }if anyOutdated && !didUpdate {term.StopSpinner()@@ -38,12 +59,17 @@ func TellPlan(} else {log.Println("Prompt not sent")}++ outputPromptIfTell()+ color.New(term.ColorHiRed, color.Bold).Println("π Plan won't continue due to outdated context")+os.Exit(0)}paths, err := fs.GetProjectPaths(fs.GetBaseDirForContexts(contexts))if err != nil {+ outputPromptIfTell()term.OutputErrorAndExit("Error getting project paths: %v", err)}@@ -98,6 +124,7 @@ func TellPlan(res, err := term.ConfirmYesNo("Upgrade now?")if err != nil {+ outputPromptIfTell()term.OutputErrorAndExit("Error prompting upgrade trial: %v", err)}@@ -106,9 +133,12 @@ func TellPlan(// retry action after converting trialreturn fn()}++ outputPromptIfTell()return false}+ outputPromptIfTell()term.OutputErrorAndExit("Prompt error: %v", apiErr.Msg)} else if apiErr != nil && isUserContinue && apiErr.Type == shared.ApiErrorTypeContinueNoMessages {fmt.Println("π€·ββοΈ There's no plan yet to continue")@@ -122,6 +152,7 @@ func TellPlan(err := streamtui.StartStreamUI(prompt, false)if err != nil {+ outputPromptIfTell()term.OutputErrorAndExit("Error starting stream UI: %v", err)}@@ -145,6 +176,7 @@ func TellPlan(}if tellBg {+ outputPromptIfTell()fmt.Println("β Plan is active in the background")fmt.Println()term.PrintCmds("", "ps", "connect", "stop")diff --git a/app/cli/term/prompt.go b/app/cli/term/prompt.goindex 5400209e..f94f6bec 100644--- a/app/cli/term/prompt.go+++ b/app/cli/term/prompt.go@@ -73,9 +73,9 @@ func ConfirmYesNo(fmtStr string, fmtArgs ...interface{}) (bool, error) {return false, fmt.Errorf("failed to get user input: %s", err)}+ // ctrl+c == noif key == keyboard.KeyCtrlC {- fmt.Println()- os.Exit(0)+ return false, nil}fmt.Println(string(char))@@ -99,9 +99,9 @@ func ConfirmYesNoCancel(fmtStr string, fmtArgs ...interface{}) (bool, bool, erroreturn false, false, fmt.Errorf("failed to get user input: %s", err)}+ // ctrl+c == cancelif key == keyboard.KeyCtrlC {- fmt.Println()- os.Exit(0)+ return false, true, nil}fmt.Println(string(char))diff --git a/test/pong/main.c b/test/pong/main.cindex 463b8aa0..594e319d 100644--- a/test/pong/main.c+++ b/test/pong/main.c@@ -30,6 +30,8 @@ void init() {initBall();}++void display() {glClear(GL_COLOR_BUFFER_BIT);renderPaddle();