Skip to content

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

working on pending changes message issue

Dane Schneiderad7b1aa85c04
diff --git a/app/cli/lib/apply.go b/app/cli/lib/apply.go
index 7e0c52a1..e37366f4 100644
--- a/app/cli/lib/apply.go
+++ b/app/cli/lib/apply.go
@@ -8,8 +8,6 @@ import (
"plandex/api"
"plandex/fs"
"plandex/term"
-
- "github.com/davecgh/go-spew/spew"
)
func MustApplyPlan(planId, branch string, autoConfirm bool) {
@@ -102,37 +100,10 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {
var errArgs []interface{}
var unformattedErrMsg string
- defer func() {
- if aborted {
- // clear any partially applied changes before popping the stash
- err := GitClearUncommittedChanges()
- if err != nil {
- log.Printf("Failed to clear uncommitted changes: %v", err)
- }
- }
-
- if stashed {
- err := GitStashPop(true)
- if err != nil {
- log.Printf("Failed to pop git stash: %v", err)
- }
- }
-
- if errMsg != "" {
- if unformattedErrMsg == "" {
- term.OutputErrorAndExit(errMsg, errArgs...)
- } else {
- term.OutputSimpleError(errMsg, errArgs...)
- term.OutputUnformattedErrorAndExit(unformattedErrMsg)
- }
- }
- }()
-
if len(toApply) == 0 {
fmt.Println("πŸ€·β€β™‚οΈ No changes to apply")
} else {
if !autoConfirm {
- fmt.Println()
numToApply := len(toApply)
suffix := ""
if numToApply > 1 {
@@ -145,11 +116,36 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {
}
if !shouldContinue {
- aborted = true
- return
+ os.Exit(0)
}
}
+ defer func() {
+ if aborted {
+ // clear any partially applied changes before popping the stash
+ err := GitClearUncommittedChanges()
+ if err != nil {
+ log.Printf("Failed to clear uncommitted changes: %v", err)
+ }
+ }
+
+ if stashed {
+ err := GitStashPop(true)
+ if err != nil {
+ log.Printf("Failed to pop git stash: %v", err)
+ }
+ }
+
+ if errMsg != "" {
+ if unformattedErrMsg == "" {
+ term.OutputErrorAndExit(errMsg, errArgs...)
+ } else {
+ term.OutputSimpleError(errMsg, errArgs...)
+ term.OutputUnformattedErrorAndExit(unformattedErrMsg)
+ }
+ }
+ }()
+
if isRepo && hasUncommittedChanges {
// If there are uncommitted changes, first checkout any files that will be applied, then stash the changes
@@ -243,12 +239,12 @@ func MustApplyPlan(planId, branch string, autoConfirm bool) {
if isRepo {
// Commit the changes
- msg := "πŸ€– Plandex" + currentPlanState.PendingChangesSummary()
+ msg := currentPlanState.PendingChangesSummaryForApply()
log.Println("Committing changes with message:")
log.Println(msg)
- spew.Dump(currentPlanState)
+ // spew.Dump(currentPlanState)
err := GitAddAndCommit(fs.ProjectRoot, msg, true)
if err != nil {
diff --git a/app/server/model/plan/build_finish.go b/app/server/model/plan/build_finish.go
index cacdb6a1..ea50d859 100644
--- a/app/server/model/plan/build_finish.go
+++ b/app/server/model/plan/build_finish.go
@@ -144,7 +144,7 @@ func (state *activeBuildStreamFileState) onFinishBuild() {
}
}
- err = db.GitAddAndCommit(currentOrgId, planId, branch, currentPlan.PendingChangesSummary())
+ err = db.GitAddAndCommit(currentOrgId, planId, branch, currentPlan.PendingChangesSummaryForBuild())
if err != nil {
log.Printf("Error committing plan build: %v\n", err)
diff --git a/app/shared/plan_result_pending_summary.go b/app/shared/plan_result_pending_summary.go
index 4bf82ba8..d39b6ed0 100644
--- a/app/shared/plan_result_pending_summary.go
+++ b/app/shared/plan_result_pending_summary.go
@@ -7,10 +7,19 @@ import (
"strings"
)
-func (state *CurrentPlanState) PendingChangesSummary() string {
+func (state *CurrentPlanState) PendingChangesSummaryForBuild() string {
+ return state.pendingChangesSummary(false)
+}
+
+func (state *CurrentPlanState) PendingChangesSummaryForApply() string {
+ return state.pendingChangesSummary(true)
+}
+
+func (state *CurrentPlanState) pendingChangesSummary(forApply bool) string {
var msgs []string
descByConvoMessageId := make(map[string]*ConvoMessageDescription)
+
for _, desc := range state.ConvoMessageDescriptions {
if desc.ConvoMessageId == "" {
log.Println("Warning: ConvoMessageId is empty for description:", desc)
@@ -54,7 +63,7 @@ func (state *CurrentPlanState) PendingChangesSummary() string {
for _, convoMessageId := range uniqueConvoIds {
if desc, ok := descByConvoMessageId[convoMessageId]; ok {
- if !ch.descsSet[convoMessageId] && (!desc.DidBuild || len(desc.BuildPathsInvalidated) > 0) {
+ if !ch.descsSet[convoMessageId] && (!(desc.DidBuild && !forApply) || len(desc.BuildPathsInvalidated) > 0) {
ch.descs = append(ch.descs, desc)
ch.descsSet[convoMessageId] = true
}
@@ -82,33 +91,38 @@ func (state *CurrentPlanState) PendingChangesSummary() string {
isRebuild := true
rebuildPathsSet := make(map[string]bool)
- for _, ch := range sortedChangesets {
- allRebuild := true
- for _, desc := range ch.descs {
- if len(desc.BuildPathsInvalidated) == 0 {
- allRebuild = false
- break
- } else {
- for path := range desc.BuildPathsInvalidated {
- rebuildPathsSet[path] = true
+
+ if forApply {
+ msgs = append(msgs, "πŸ€– Plandex β†’ apply pending changes")
+ } else {
+ for _, ch := range sortedChangesets {
+ allRebuild := true
+ for _, desc := range ch.descs {
+ if len(desc.BuildPathsInvalidated) == 0 {
+ allRebuild = false
+ break
+ } else {
+ for path := range desc.BuildPathsInvalidated {
+ rebuildPathsSet[path] = true
+ }
}
}
+ if !allRebuild {
+ isRebuild = false
+ break
+ }
}
- if !allRebuild {
- isRebuild = false
- break
- }
- }
- if isRebuild {
- msgs = append(msgs, "πŸ—οΈ Rebuild paths invalidated by context update")
- for path := range rebuildPathsSet {
- msgs = append(msgs, fmt.Sprintf(" β€’ rebuild β†’ %s", path))
+ if isRebuild {
+ msgs = append(msgs, "πŸ—οΈ Rebuild paths invalidated by context update")
+ for path := range rebuildPathsSet {
+ msgs = append(msgs, fmt.Sprintf(" β€’ rebuild β†’ %s", path))
+ }
+ return strings.Join(msgs, "\n")
}
- return strings.Join(msgs, "\n")
- }
- msgs = append(msgs, "πŸ—οΈ Build pending changes")
+ msgs = append(msgs, "πŸ—οΈ Build pending changes")
+ }
for _, ch := range sortedChangesets {
var descMsgs []string
@@ -146,6 +160,11 @@ func (state *CurrentPlanState) PendingChangesSummary() string {
msgs = append(msgs, descMsgs...)
+ // for an apply commit message, we don't need to list file updates
+ if forApply {
+ continue
+ }
+
var pendingNewFiles []string
var pendingReplacementPaths []string