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
fix refresh token logic for api calls. make initial repl api calls serially in case re-auth needed
Dane Schneider2daecbd39918
diff --git a/app/cli/api/errors.go b/app/cli/api/errors.goindex 733b3b2a..ad91b76b 100644--- a/app/cli/api/errors.go+++ b/app/cli/api/errors.go@@ -31,6 +31,11 @@ func HandleApiError(r *http.Response, errBody []byte) *shared.ApiError {}}+ // return error for authentication/retry+ if apiError.Type == shared.ApiErrorTypeInvalidToken {+ return &apiError+ }+term.HandleApiError(&apiError)return &apiErrordiff --git a/app/cli/cmd/repl.go b/app/cli/cmd/repl.goindex bd30e3c2..a089b93a 100644--- a/app/cli/cmd/repl.go+++ b/app/cli/cmd/repl.go@@ -99,6 +99,7 @@ func runRepl(cmd *cobra.Command, args []string) {if err != nil {color.New(term.ColorHiRed).Printf("Error getting project paths: %v\n", err)}+replWelcome(afterNew, false)var p *prompt.Prompt@@ -716,33 +717,15 @@ func completer(in prompt.Document) ([]prompt.Suggest, pstrings.RuneNumber, pstrifunc replWelcome(afterNew, isHelp bool) {// print REPL welcome message and basic info- errCh := make(chan error, 2)- var plan *shared.Plan- var config *shared.PlanConfig-- go func() {- var apiErr *shared.ApiError- plan, apiErr = api.Client.GetPlan(lib.CurrentPlanId)- if apiErr != nil {- errCh <- fmt.Errorf("Error getting plan: %v", apiErr.Msg)- }- errCh <- nil- }()-- go func() {- var apiErr *shared.ApiError- config, apiErr = api.Client.GetPlanConfig(lib.CurrentPlanId)- if apiErr != nil {- errCh <- fmt.Errorf("Error getting plan config: %v", apiErr.Msg)- }- errCh <- nil- }()-- for i := 0; i < 2; i++ {- err := <-errCh- if err != nil {- term.OutputErrorAndExit("%v", err)- }+ // have to make these requests serially in case re-authentication is needed++ plan, apiErr := api.Client.GetPlan(lib.CurrentPlanId)+ if apiErr != nil {+ term.OutputErrorAndExit("Error getting plan: %v", apiErr.Msg)+ }+ config, apiErr := api.Client.GetPlanConfig(lib.CurrentPlanId)+ if apiErr != nil {+ term.OutputErrorAndExit("Error getting plan config: %v", apiErr.Msg)}term.StopSpinner()