Skip to content

Commit 9a9e31a

Browse files
saphidclaude
authored andcommitted
fix(web): long preview annotation comments are no longer dropped from the message
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ae1ccb1 commit 9a9e31a

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎apps/web/src/lib/composerContextRecords.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ describe("composerContextRecords", () => {
236236
expect(restored.elements[0]?.id).toBe("el_1");
237237
});
238238

239+
it("clamps an oversized annotation comment so the record still decodes", () => {
240+
const record = previewAnnotationContextRecord({ ...annotation, comment: "c".repeat(8_001) });
241+
expect(record.comment.endsWith("… truncated …")).toBe(true);
242+
expect(decodeMessageContext({ version: 1, records: [record] }).records).toEqual([record]);
243+
});
244+
239245
it("removes an expired terminal chip by its kind-scoped id, not the producer id", () => {
240246
const context = {
241247
id: "term-1",

‎apps/web/src/lib/composerContextRecords.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
sourceControlClients,
44
} from "@t3tools/client-runtime/source-control-clients";
55
import {
6+
COMPOSER_CONTEXT_PREVIEW_COMMENT_MAX_CHARS,
67
COMPOSER_CONTEXT_REVIEW_DIFF_MAX_CHARS,
78
COMPOSER_CONTEXT_REVIEW_TEXT_MAX_CHARS,
89
} from "@t3tools/contracts";
@@ -241,7 +242,10 @@ export function previewAnnotationContextRecord(
241242
annotationId: annotation.id,
242243
pageUrl: annotation.pageUrl,
243244
pageTitle: annotation.pageTitle,
244-
comment: annotation.comment.trim(),
245+
comment: clampContextText(
246+
annotation.comment.trim(),
247+
COMPOSER_CONTEXT_PREVIEW_COMMENT_MAX_CHARS,
248+
),
245249
targetSummary: previewAnnotationTargetSummary(annotation),
246250
styleChanges: annotation.styleChanges.map(
247251
(change) => `${change.property}: ${change.previousValue || "(unset)"} → ${change.value}`,

‎packages/contracts/src/composerContext.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const COMPOSER_CONTEXT_ELEMENT_HTML_MAX_CHARS = 8_000;
3939
const COMPOSER_CONTEXT_ELEMENT_STYLES_MAX_CHARS = 8_000;
4040
export const COMPOSER_CONTEXT_REVIEW_TEXT_MAX_CHARS = 16_000;
4141
export const COMPOSER_CONTEXT_REVIEW_DIFF_MAX_CHARS = 32_000;
42-
const COMPOSER_CONTEXT_PREVIEW_COMMENT_MAX_CHARS = 8_000;
42+
export const COMPOSER_CONTEXT_PREVIEW_COMMENT_MAX_CHARS = 8_000;
4343

4444
export const ComposerContextId = TrimmedNonEmptyString.check(
4545
Schema.isMaxLength(CONTEXT_ID_MAX_CHARS),

0 commit comments

Comments
 (0)