Skip to content

Commit 3dbbe53

Browse files
amir20claude
andauthored
fix: re-establish cloud connection after pro plan upgrade (#4619)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 27fdd04 commit 3dbbe53

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

internal/cloud/client.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,14 @@ func (c *Client) Run(ctx context.Context) {
137137

138138
if err != nil {
139139
if isPermissionDenied(err) {
140-
log.Debug().Msg("cloud account does not have pro plan, stopping cloud client")
141-
return
140+
log.Debug().Msg("cloud account does not have pro plan, waiting for upgrade")
141+
select {
142+
case <-ctx.Done():
143+
return
144+
case <-c.startCh:
145+
}
146+
backoff = initialBackoff
147+
continue
142148
}
143149
if isUnauthenticated(err) {
144150
log.Warn().Err(err).Dur("pause", unauthenticatedPause).Msg("invalid API key, pausing before retry")

internal/web/cloud.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,27 @@ func (h *handler) cloudStatus(w http.ResponseWriter, r *http.Request) {
150150
return
151151
}
152152

153-
if h.config.OnCloudSetup != nil {
154-
h.config.OnCloudSetup()
153+
body, err := io.ReadAll(resp.Body)
154+
if err != nil {
155+
log.Error().Err(err).Msg("Failed to read cloud status response")
156+
writeError(w, http.StatusBadGateway, "failed to read cloud status")
157+
return
158+
}
159+
160+
var statusResp struct {
161+
Plan struct {
162+
Name string `json:"name"`
163+
} `json:"plan"`
164+
}
165+
if json.Unmarshal(body, &statusResp) == nil && statusResp.Plan.Name == "pro" {
166+
if h.config.OnCloudSetup != nil {
167+
h.config.OnCloudSetup()
168+
}
155169
}
156170

157171
w.Header().Set("Content-Type", "application/json")
158172
w.WriteHeader(http.StatusOK)
159-
io.Copy(w, resp.Body)
173+
w.Write(body)
160174
}
161175

162176
type cloudConfigResponse struct {

0 commit comments

Comments
 (0)