Retry hosted summary auth and wait out CloudSync drain - #7275
Merged
Conversation
✅ Deploy Preview for anarlog canceled.
|
Stable logs showed Pro summary hitting 401 invalid_token, then failing persist with cloudsync_activity_drain_timeout after re-login. Hosted LLM fetch now refreshes on 401, and enhance/chat drain waits 15s for in-flight witness repair instead of 2s.
A refreshed token for the already-admitted account is committed the moment the SDK emits it; it no longer queues behind earlier auth transitions, re-runs local account admission, or waits for the CloudSync handshake. Unadmitted sessions still fail closed, and admission that stalls behind the plugin queue preserves the local session after 15s and finishes admission late (rejecting a mismatch if it turns out to be another account). getHeaders and getSessionForRequest sign with the committed session ref so long-lived closures never send a stale token.
ComputelessComputer
force-pushed
the
fix/pro-summary-auth-drain
branch
from
September 3, 2026 06:53
6d07519 to
c564f37
Compare
…ction Late admission now runs the same tail as immediate admission: re-persist the session when storage was cleared since the event was enqueued and restart the SDK refresh ticker, and the ticker is also restarted as soon as a stalled session is preserved. rejectAuthChange revokes admission up front so a token that arrives during sign-out or account-mismatch cleanup re-runs admission instead of cancelling the rejection and keeping the account signed in.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1a9fb11. Configure here.
bindCloudsyncAccountForAuth now reports claimed, mismatch, or superseded instead of collapsing "a newer CloudSync generation preempted me" into true. A bind that actually ran keeps its real answer even if CloudSync moved on, so a concurrent window-focus refresh can no longer mask a mismatch. The auth provider retries a superseded bind up to three times and otherwise keeps the session visible but unadmitted, in both the immediate and the late-admission path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stable logs showed Pro summary hitting 401 invalid_token, then failing persist with cloudsync_activity_drain_timeout after re-login. Hosted LLM fetch now refreshes on 401, and enhance/chat drain waits 15s for in-flight witness repair instead of 2s.
Note
High Risk
Changes authentication admission semantics, session commit timing, and CloudSync queue interaction—areas that affect sign-in, multi-window auth, and hosted API access.
Overview
Addresses production issues where hosted summary calls failed with 401 invalid_token and summary/chat persistence hit cloudsync_activity_drain_timeout after re-login.
Hosted LLM auth:
createAuthFetchnow resolves tokens asynchronously, retries once on 401 afterrefreshAccessToken, and Anarlog-hosted models usegetSessionForRequest/refreshSessionso requests pick up rotated credentials without rebuilding the transport.Desktop auth / CloudSync admission: Local account binding returns
claimed|mismatch|supersededinstead of a boolean, so a superseded bind is not treated as admission and a completed bind still reports mismatch if the DB belongs to another account. The auth provider keeps a committed session ref for headers, admits accounts with a 15s timeout and retries, finishes admission in the background when stalled, and fast-pathsTOKEN_REFRESHEDfor already-admitted users so token updates do not sit behind a jammed CloudSync handshake queue.Native CloudSync: Non-capture local writes (enhance, chat, etc.) wait up to 15s for activity drain (capture stays at 2s), reducing premature drain timeouts during long witness/repair work.
Reviewed by Cursor Bugbot for commit b223474. Bugbot is set up for automated code reviews on this repo. Configure here.