The best way to control Claude Code, Codex and more from any computer or phone
fix(web): preview annotation chip labels no longer end in a broken character (#30345)
spoukyii committed
Nov 5, 2026 at 20:29 UTC
e5193ac0a28afdca08ecefc1d6fdba55aa0c9e13
2 files changed
+14
-3
apps/web/src/lib/composerContextRecords.test.ts
+8
@@ -219,6 +219,14 @@ describe("composerContextRecords", () => {
219
expect(image).toMatchObject({ attachmentId: "uploaded-image" });
220
});
221
222
+ it("shortens a long annotation comment label without splitting an emoji", () => {
223
+ const record = previewAnnotationContextRecord({
224
+ ...annotation,
225
+ comment: `${"a".repeat(46)}😀 and make the button bigger`,
226
+ });
227
+ expect(record.label).toBe(`${"a".repeat(46)}…`);
228
+ });
229
+
230
it("restores multiple edits on one target without parsing display strings", () => {
231
const styleChanges = [
232
...annotation.styleChanges,
apps/web/src/lib/composerContextRecords.ts
+6
-3
@@ -117,9 +117,12 @@ export function pullRequestContextKindLabel(comment: ReviewCommentPresentation):
117
export function previewAnnotationContextLabel(annotation: PreviewAnnotationPayload): string {
118
const comment = annotation.comment.trim().replace(/\s+/g, " ");
119
if (comment) {
120
- return comment.length > PREVIEW_LABEL_MAX_CHARS
121
- ? `${comment.slice(0, PREVIEW_LABEL_MAX_CHARS - 1)}…`
122
- : comment;
120
+ if (comment.length <= PREVIEW_LABEL_MAX_CHARS) return comment;
121
+ let end = PREVIEW_LABEL_MAX_CHARS - 1;
122
+ const previous = comment.charCodeAt(end - 1);
123
+ const next = comment.charCodeAt(end);
124
+ if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) end -= 1;
125
+ return `${comment.slice(0, end)}…`;
126
}
127
return annotation.pageTitle?.trim() || "Preview annotation";
128
}