The best way to control Claude Code, Codex and more from any computer or phone
fix(server): a T3 Connect preferences save finishes even if the client disconnects (#16266)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Julius Marminge committed
Oct 5, 2026 at 17:04 UTC
ee6991ad502c7c8979ab47b6a8fc645498f5b4ce
3 files changed
+36
-16
apps/server/src/cloud/CloudPreferences.test.ts
+29
@@ -217,3 +217,32 @@ it.effect("changes nothing when the current hold setting can't be read", () =>
217
}),
218
),
219
);
220
+
221
+it.effect("an update the client walks away from still finishes", () => {
222
+ let release!: () => void;
223
+ let started!: () => void;
224
+ const released = new Promise<void>((resolve) => {
225
+ release = resolve;
226
+ });
227
+ const atRelay = new Promise<void>((resolve) => {
228
+ started = resolve;
229
+ });
230
+ return withService({ holdFirstRelayCall: { started, released } }, ({ preferences, stored }) =>
231
+ Effect.gen(function* () {
232
+ const update = yield* preferences
233
+ .update({ publishAgentActivity: true, holdWebhooksWhileOffline: true })
234
+ .pipe(Effect.forkChild);
235
+ yield* Effect.promise(() => atRelay);
236
+ // The interrupt is in flight before the relay answers.
237
+ const interrupted = yield* Fiber.interrupt(update).pipe(Effect.forkChild);
238
+ yield* Effect.yieldNow;
239
+ release();
240
+ yield* Fiber.join(interrupted);
241
+ assert.equal(new TextDecoder().decode(stored.get(PUBLISH_AGENT_ACTIVITY_SECRET)), "true");
242
+ assert.equal(
243
+ new TextDecoder().decode(stored.get(HOLD_WEBHOOKS_WHILE_OFFLINE_SECRET)),
244
+ "true",
245
+ );
246
+ }),
247
+ );
248
+});
apps/server/src/cloud/CloudPreferences.ts
+3
@@ -121,6 +121,9 @@ const make = Effect.gen(function* () {
121
}
122
yield* awarenessRelay.requestCatchUp();
123
},
124
+ // A client that disconnects mid-update must not stop it between a save and
125
+ // its rollback, so an update always finishes or undoes itself.
126
+ Effect.uninterruptible,
127
updateLock.withPermits(1),
128
);
129
apps/server/src/secrets/SecretRequests.ts
+4
-16
@@ -105,11 +105,7 @@ const make = Effect.gen(function* () {
105
turnItemTypes: ["secret_request"],
106
messageRoles: [],
107
})
108
- .pipe(
109
- Effect.mapError(
110
- (cause) => new SecretRequestError({ reason: "load_failed", cause: cause }),
111
- ),
112
- );
108
+ .pipe(Effect.mapError((cause) => new SecretRequestError({ reason: "load_failed", cause })));
109
const item = records.turnItems.find((candidate) => candidate.id === input.turnItemId);
110
if (item?.type !== "secret_request" || item.runId === null || item.nodeId === null) {
111
return yield* new SecretRequestError({ reason: "not_found" });
@@ -160,9 +156,7 @@ const make = Effect.gen(function* () {
156
secretStatus,
157
})
158
.pipe(
163
- Effect.mapError(
164
- (cause) => new SecretRequestError({ reason: "record_failed", cause: cause }),
165
- ),
159
+ Effect.mapError((cause) => new SecretRequestError({ reason: "record_failed", cause })),
160
// The card still says pending, so the user can save again; the value
161
// stored above would make that retry look already answered.
162
Effect.tapError(() =>
@@ -181,9 +175,7 @@ const make = Effect.gen(function* () {
175
messageRoles: [],
176
})
177
.pipe(
184
- Effect.mapError(
185
- (cause) => new SecretRequestError({ reason: "record_failed", cause: cause }),
186
- ),
178
+ Effect.mapError((cause) => new SecretRequestError({ reason: "record_failed", cause })),
179
);
180
const card = recorded.turnItems.find((candidate) => candidate.id === item.id);
181
if (card?.type === "secret_request" && card.secretStatus !== "saved") {
@@ -229,11 +221,7 @@ const make = Effect.gen(function* () {
221
return yield* new SecretRequestError({ reason: "invalid_ref" });
222
const stored = yield* store
223
.get(storeName(input.ref))
232
- .pipe(
233
- Effect.mapError(
234
- (cause) => new SecretRequestError({ reason: "read_failed", cause: cause }),
235
- ),
236
- );
224
+ .pipe(Effect.mapError((cause) => new SecretRequestError({ reason: "read_failed", cause })));
225
const decoded = Option.flatMap(stored, (bytes) =>
226
decodeStored(new TextDecoder().decode(bytes)),
227
);