The best way to control Claude Code, Codex and more from any computer or phone
fix(relay): preserve conversation routing in iOS push responses (#16350)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Danny committed
Oct 19, 2026 at 15:24 UTC
58af7ac1eebd946971562904bbf8ab354ff84568
2 files changed
+41
-8
infra/relay/src/agentActivity/ApnsClient.test.ts
+35
-5
@@ -18,6 +18,7 @@ import * as HttpClientResponse from "effect/http/HttpClientResponse";
18
19
import type { ApnsCredentials } from "../Config.ts";
20
import * as ApnsClient from "./ApnsClient.ts";
21
+import { sanitizeApnsNotificationPayload } from "./agentActivityPayloads.ts";
22
import * as ApnsProviderTokens from "./ApnsProviderTokens.ts";
23
24
const isApnsJwtSigningError = Schema.is(ApnsClient.ApnsJwtSigningError);
@@ -164,7 +165,7 @@ describe("ApnsClient", () => {
165
}).pipe(Effect.provide(layerTest)),
166
);
167
167
- it.effect("builds a standard APNs alert payload with routing metadata", () =>
168
+ it.effect("puts remote routing metadata only in Expo's body field", () =>
169
Effect.gen(function* () {
170
const apns = yield* ApnsClient.ApnsClient;
171
const request = apns.makePushNotificationRequest({
@@ -179,7 +180,7 @@ describe("ApnsClient", () => {
180
});
181
182
expect(request.priority).toBe("10");
182
- expect(request.payload).toMatchObject({
183
+ expect(request.payload).toEqual({
184
aps: {
185
alert: {
186
title: "Thread",
@@ -188,9 +189,38 @@ describe("ApnsClient", () => {
189
sound: "default",
190
"thread-id": "env/thread",
191
},
191
- environmentId: "env",
192
- threadId: "thread",
193
- deepLink: "/threads/env/thread",
192
+ body: {
193
+ environmentId: "env",
194
+ threadId: "thread",
195
+ deepLink: "/threads/env/thread",
196
+ },
197
+ });
198
+ }).pipe(Effect.provide(layerTest)),
199
+ );
200
+
201
+ it.effect("fits long routing metadata and multibyte alerts within the APNs 4096-byte limit", () =>
202
+ Effect.gen(function* () {
203
+ const apns = yield* ApnsClient.ApnsClient;
204
+ const environmentId = "é".repeat(191);
205
+ const threadId = "t".repeat(512);
206
+ const notification = sanitizeApnsNotificationPayload({
207
+ title: "界".repeat(120),
208
+ body: "界".repeat(120),
209
+ environmentId,
210
+ threadId,
211
+ deepLink: `/threads/${encodeURIComponent(environmentId)}/${threadId}`,
212
+ });
213
+ const request = apns.makePushNotificationRequest({ token: "push-token", notification });
214
+
215
+ expect(
216
+ new TextEncoder().encode(JSON.stringify(request.payload)).byteLength,
217
+ ).toBeLessThanOrEqual(4096);
218
+ expect(request.payload).toMatchObject({
219
+ body: {
220
+ environmentId,
221
+ threadId,
222
+ deepLink: notification.deepLink,
223
+ },
224
});
225
}).pipe(Effect.provide(layerTest)),
226
);
infra/relay/src/agentActivity/ApnsClient.ts
+6
-3
@@ -186,9 +186,12 @@ function makePushNotificationRequest(input: {
186
sound: "default",
187
"thread-id": notificationThreadId(input.notification),
188
},
189
- environmentId: input.notification.environmentId,
190
- threadId: input.notification.threadId,
191
- deepLink: input.notification.deepLink,
189
+ // Expo iOS exposes userInfo.body as notification.content.data for remote pushes.
190
+ body: {
191
+ environmentId: input.notification.environmentId,
192
+ threadId: input.notification.threadId,
193
+ deepLink: input.notification.deepLink,
194
+ },
195
},
196
};
197
}