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
store context body with result to avoid versioning issues with replacements
Dane Schneider3435e577e171
diff --git a/app/server/db/models.go b/app/server/db/models.goindex 04deb484..4b598017 100644--- a/app/server/db/models.go+++ b/app/server/db/models.go@@ -386,6 +386,7 @@ type PlanFileResult struct {PlanBuildId string `json:"planBuildId"`Path string `json:"path"`ContextSha string `json:"contextSha"`+ ContextBody string `json:"contextBody"`Content string `json:"content,omitempty"`Replacements []*shared.Replacement `json:"replacements"`AnyFailed bool `json:"anyFailed"`@@ -403,6 +404,7 @@ func (res *PlanFileResult) ToApi() *shared.PlanFileResult {ConvoMessageId: res.ConvoMessageId,Path: res.Path,ContextSha: res.ContextSha,+ ContextBody: res.ContextBody,Content: res.Content,AnyFailed: res.AnyFailed,AppliedAt: res.AppliedAt,diff --git a/app/server/model/plan/build.go b/app/server/model/plan/build.goindex 2d6e50f4..6d187ae3 100644--- a/app/server/model/plan/build.go+++ b/app/server/model/plan/build.go@@ -604,6 +604,7 @@ func getPlanResult(params planResultParams) (*db.PlanFileResult, bool) {Path: filePath,Replacements: replacements,ContextSha: contextSha,+ ContextBody: contextPart.Body,AnyFailed: !allSucceeded,}, allSucceeded}diff --git a/app/shared/plan_result.go b/app/shared/plan_result.goindex 11f4ab6f..ed75773a 100644--- a/app/shared/plan_result.go+++ b/app/shared/plan_result.go@@ -121,26 +121,11 @@ func (planState *CurrentPlanState) GetFiles() (*CurrentPlanFiles, error) {func (planState *CurrentPlanState) GetFilesBeforeReplacement(replacementId string,) (*CurrentPlanFiles, error) {- contexts := planState.ContextsplanRes := planState.PlanResultfiles := make(map[string]string)shas := make(map[string]string)- for _, contextPart := range contexts {-- if contextPart.FilePath == "" {- continue- }-- _, hasPath := planRes.FileResultsByPath[contextPart.FilePath]-- if hasPath {- files[contextPart.FilePath] = contextPart.Body- shas[contextPart.FilePath] = contextPart.Sha- }- }-for path, planResults := range planRes.FileResultsByPath {updated := files[path]@@ -159,12 +144,9 @@ func (planState *CurrentPlanState) GetFilesBeforeReplacement(updated = planRes.Contentfiles[path] = updatedcontinue- }-- contextSha := shas[path]-- if contextSha != "" && planRes.ContextSha != contextSha {- return nil, fmt.Errorf("result sha doesn't match context sha: %s", path)+ } else if updated == "" {+ updated = planRes.ContextBody+ shas[path] = planRes.ContextSha}replacements := []*Replacement{}