The best way to control Claude Code, Codex and more from any computer or phone
fix(connect): stop reporting a loading cloud session as a sign-in change (#11013)
Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
project516 committed
Oct 19, 2026 at 00:50 UTC
2bae2b14dfa9382b178c76183c2604339522c5c8
3 files changed
+35
-8
packages/client-runtime/src/authorization/layer.test.ts
+23
-7
@@ -888,6 +888,29 @@ describe("RemoteEnvironmentAuthorization", () => {
888
}),
889
);
890
891
+ it.effect("retries instead of blocking while the cloud session has not loaded", () =>
892
+ Effect.gen(function* () {
893
+ const harness = yield* makeHarness({
894
+ responses: [Response.json(DESCRIPTOR), accessToken("loaded-token")],
895
+ });
896
+ yield* Ref.set(harness.session, Option.none());
897
+ yield* Effect.gen(function* () {
898
+ const remote = yield* RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization;
899
+ const pending = yield* remote
900
+ .authorizeDpopHttp({ expectedEnvironmentId: ENVIRONMENT_ID })
901
+ .pipe(Effect.flip);
902
+ expect(pending).toMatchObject({
903
+ _tag: "ConnectionTransientError",
904
+ reason: "session-pending",
905
+ });
906
+ yield* Ref.set(harness.session, Option.some({ accountId: "account-1" }));
907
+ const loaded = yield* remote.authorizeDpopHttp({ expectedEnvironmentId: ENVIRONMENT_ID });
908
+ expect(loaded.httpAuthorization.accessToken).toBe("loaded-token");
909
+ }).pipe(Effect.provide(harness.layer));
910
+ expect(yield* Ref.get(harness.bootstrapCalls)).toBe(1);
911
+ }),
912
+ );
913
+
914
it.effect("does not return or persist credentials after logout during renewal", () =>
915
Effect.gen(function* () {
916
const started = yield* Deferred.make<void>();
@@ -1005,13 +1028,6 @@ describe("RemoteEnvironmentAuthorization", () => {
1028
const remote = yield* RemoteEnvironmentAuthorization.RemoteEnvironmentAuthorization;
1029
yield* remote.authorizeDpopHttp({ expectedEnvironmentId: ENVIRONMENT_ID });
1030
yield* Ref.set(harness.session, Option.none());
1008
- const signedOut = yield* remote
1009
- .authorizeDpopHttp({ expectedEnvironmentId: ENVIRONMENT_ID })
1010
- .pipe(Effect.flip);
1011
- expect(signedOut).toMatchObject({
1012
- _tag: "ConnectionBlockedError",
1013
- reason: "authentication",
1014
- });
1031
yield* Ref.set(harness.session, Option.some({ accountId: "account-1" }));
1032
const signedIn = yield* remote.authorizeDpopHttp({ expectedEnvironmentId: ENVIRONMENT_ID });
1033
expect(signedIn.httpAuthorization.accessToken).toBe("new-session-token");
packages/client-runtime/src/authorization/service.ts
+11
-1
@@ -251,6 +251,15 @@ export const make = Effect.gen(function* () {
251
detail: "Your cloud sign-in changed. Sign in again to authorize the environment.",
252
});
253
254
+ // A missing identity before the attempt captures one means the cloud session
255
+ // is still loading, not a sign-out. Only a captured identity that goes away
256
+ // or changes is evidence of one.
257
+ const sessionPending = () =>
258
+ new ConnectionTransientError({
259
+ reason: "session-pending",
260
+ detail: "Waiting for the T3 Connect sign-in to load.",
261
+ });
262
+
263
const assertSession = Effect.fnUntraced(function* (
264
identity: ClientCapabilities.CloudSessionIdentity,
265
) {
@@ -362,7 +371,7 @@ export const make = Effect.gen(function* () {
371
) {
372
const session = yield* cloudSession.identity;
373
if (Option.isNone(session)) {
365
- return yield* sessionChanged();
374
+ return yield* sessionPending();
375
}
376
const identity = session.value;
377
const thumbprint = yield* signer.thumbprint.pipe(
@@ -518,6 +527,7 @@ export const make = Effect.gen(function* () {
527
if (endpoint !== undefined && cachedSocket.failure._tag !== "EnvironmentAuthInvalidError") {
528
return yield* mapDpopSocketError(cachedSocket.failure);
529
}
530
+ yield* assertSession(selected.identity);
531
selected = yield* getDpopToken({
532
...input,
533
rejectedAccessToken: selected.token.accessToken,
packages/client-runtime/src/connection/model.ts
+1
@@ -64,6 +64,7 @@ export const ConnectionTransientReason = Schema.Literals([
64
"endpoint-unavailable",
65
"relay-unavailable",
66
"remote-unavailable",
67
+ "session-pending",
68
]);
69
export type ConnectionTransientReason = typeof ConnectionTransientReason.Type;
70