@devries-cameron20 / t3code Mirror · read-only / commits / afa8309806
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 15:15 UTC

fix(clients): reconnect after credentials fail during remote server updates (#7953)

Theo Browne committed Aug 22, 2026 at 23:25 UTC afa83098064e7dca524a1e42dea3de03a883a0b6
2 files changed +40 -2
packages/client-runtime/src/state/server.test.ts
+24
@@ -124,6 +124,30 @@ describe("update restart reconnect nudges", () => {
124 yield* Fiber.join(fiber);
125 }).pipe(Effect.provide(TestClock.layer())),
126 );
127 +
128 + it.effect("retries rejected credentials only while the update restart is in progress", () =>
129 + Effect.gen(function* () {
130 + const retries = yield* Ref.make(0);
131 +
132 + yield* nudgeReconnectDuringUpdateRestart({
133 + stateChanges: Stream.fromIterable([
134 + { phase: "blocked", lastFailure: { reason: "permission" } },
135 + {
136 + phase: "blocked",
137 + lastFailure: {
138 + reason: "authentication",
139 + detail: "The environment credential is invalid.",
140 + },
141 + },
142 + { phase: "blocked", lastFailure: { reason: "configuration" } },
143 + ]),
144 + retryNow: Ref.update(retries, (count) => count + 1),
145 + interval: Duration.zero,
146 + });
147 +
148 + expect(yield* Ref.get(retries)).toBe(1);
149 + }),
150 + );
151 });
152
153 describe("server state projection", () => {
packages/client-runtime/src/state/server.ts
+16 -2
@@ -160,16 +160,30 @@ export function validateServerUpdateReadyEvent(
160 * each nudge is the pacer: a connection that fails instantly re-enters backoff
161 * immediately and would otherwise spin a tight retry loop.
162 *
163 + * A newly restarted server can also reject the first environment credential.
164 + * Authentication blocks need the same paced retry during this known restart;
165 + * permission and configuration failures remain blocked.
166 + *
167 * Callers fork this as a child of the update command so it is interrupted as
168 * soon as the update settles, whether it succeeds, fails, or times out.
169 */
170 export function nudgeReconnectDuringUpdateRestart(input: {
167 - readonly stateChanges: Stream.Stream<{ readonly phase: string }, unknown>;
171 + readonly stateChanges: Stream.Stream<
172 + {
173 + readonly phase: string;
174 + readonly lastFailure?: { readonly reason: string } | null;
175 + },
176 + unknown
177 + >;
178 readonly retryNow: Effect.Effect<void>;
179 readonly interval?: Duration.Duration;
180 }): Effect.Effect<void> {
181 return input.stateChanges.pipe(
172 - Stream.filter((state) => state.phase === "backoff"),
182 + Stream.filter(
183 + (state) =>
184 + state.phase === "backoff" ||
185 + (state.phase === "blocked" && state.lastFailure?.reason === "authentication"),
186 + ),
187 Stream.runForEach(() =>
188 Effect.sleep(input.interval ?? Duration.seconds(1)).pipe(Effect.andThen(input.retryNow)),
189 ),