Skip to content

Commit ad1e8c4

Browse files
saphidclaude
authored andcommitted
fix(relay): iOS notifications no longer cut an emoji in half at the title limit
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 89c2a5c commit ad1e8c4

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎infra/relay/src/agentActivity/ApnsClient.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,16 @@ describe("ApnsClient", () => {
151151
const environmentId = "é".repeat(191);
152152
const threadId = "t".repeat(512);
153153
const notification = sanitizeApnsNotificationPayload({
154-
title: "界".repeat(120),
154+
title: "😀".repeat(120),
155155
body: "界".repeat(120),
156156
environmentId,
157157
threadId,
158158
deepLink: `/threads/${encodeURIComponent(environmentId)}/${threadId}`,
159159
});
160160
const request = apns.makePushNotificationRequest({ token: "push-token", notification });
161161

162+
expect(notification.title).toBe(`${"😀".repeat(58)}...`);
163+
162164
expect(
163165
new TextEncoder().encode(JSON.stringify(request.payload)).byteLength,
164166
).toBeLessThanOrEqual(4096);

‎infra/relay/src/agentActivity/agentActivityPayloads.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ export function truncateText(value: string, maxLength: number): string {
5252
if (trimmed.length <= maxLength) {
5353
return trimmed;
5454
}
55-
return trimmed.slice(0, maxLength - 3).trimEnd() + "...";
55+
return (
56+
trimmed
57+
.slice(0, maxLength - 3)
58+
.replace(/[\uD800-\uDBFF]$/, "")
59+
.trimEnd() + "..."
60+
);
5661
}
5762

5863
function sanitizeDeepLink(value: string): string {

0 commit comments

Comments
 (0)