Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

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.go
index 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.go
index 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.go
index 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.go
index 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.go
index 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.go
index 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.go
index 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) (cont
outdatedRes, 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) (cont
if !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.go
index 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.go
index 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.go
index 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 string
CurrentBranch string
ApiKeys 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.go
index 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 trial
return 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.go
index 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 == no
if 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, erro
return false, false, fmt.Errorf("failed to get user input: %s", err)
}
+ // ctrl+c == cancel
if 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.c
index 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();