Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

composerContextRecords.test.ts

751 lines23.0 KB

1import {
2 type ComposerContextId,
3 EnvironmentId,
4 MessageId,
5 OrchestrationMessageContext,
6 ThreadId,
7 type PreviewAnnotationPayload,
8} from "@t3tools/contracts";
9import * as Schema from "effect/Schema";
10import { upgradeLegacyContextMessage } from "@t3tools/shared/composerContextLegacy";
11​
12import {
13 formatInlineContextReference,
14 removeInlineContextReference,
15} from "./composerContextReferences";
16import { describe, expect, it } from "vite-plus/test";
17​
18import {
19 asKnownContextRecord,
20 attachmentContextRecord,
21 buildMessageContext,
22 composerContextImportLookupIds,
23 isPullRequestSummaryContext,
24 isSameComposerContextPayload,
25 pullRequestContextDisplayState,
26 pullRequestContextKindLabel,
27 previewAnnotationContextLabel,
28 previewAnnotationContextRecord,
29 previewAnnotationFromRecord,
30 resolveUserMessageContext,
31 selectedMessageContextFragment,
32 reviewCommentContextLabel,
33 reviewCommentContextRecord,
34 reviewCommentFromRecord,
35 terminalContextRecord,
36 terminalContextReference,
37 terminalContextDraftFromRecord,
38 uploadedAttachmentContextRecord,
39} from "./composerContextRecords";
40​
41const decodeMessageContext = Schema.decodeUnknownSync(OrchestrationMessageContext);
42​
43const annotation: PreviewAnnotationPayload = {
44 id: "ann_1",
45 pageUrl: "http://localhost:3000/checkout",
46 pageTitle: "Checkout",
47 comment: " Make this bigger ",
48 elements: [
49 {
50 id: "el_1",
51 rect: { x: 0, y: 0, width: 10, height: 10 },
52 element: {
53 pageUrl: "http://localhost:3000/checkout",
54 pageTitle: "Checkout",
55 tagName: "BUTTON",
56 selector: "#pay",
57 htmlPreview: '<button id="pay">Pay</button>',
58 componentName: "Button",
59 source: null,
60 stack: [],
61 styles: "color: red;",
62 pickedAt: "2026-01-01T00:00:00.000Z",
63 },
64 },
65 ],
66 regions: [],
67 strokes: [],
68 styleChanges: [
69 { targetId: "el_1", selector: "#pay", property: "font-size", previousValue: "", value: "20px" },
70 ],
71 screenshot: null,
72 createdAt: "2026-01-01T00:00:00.000Z",
73};
74​
75describe("composerContextRecords", () => {
76 it("copies only ready or persisted server-side attachment IDs", () => {
77 const environmentId = EnvironmentId.make("env");
78 const image = {
79 type: "image" as const,
80 id: "local-image",
81 name: "shot.png",
82 mimeType: "image/png",
83 sizeBytes: 1,
84 file: new File(["x"], "shot.png"),
85 previewUrl: "blob:shot",
86 };
87 expect(uploadedAttachmentContextRecord(image, undefined)).toBeNull();
88 expect(
89 uploadedAttachmentContextRecord(image, { status: "uploading", environmentId, progress: 0.5 }),
90 ).toBeNull();
91 expect(
92 uploadedAttachmentContextRecord(image, {
93 status: "failed",
94 environmentId,
95 reason: "offline",
96 attachmentId: "unfinished",
97 }),
98 ).toBeNull();
99 expect(
100 uploadedAttachmentContextRecord(image, {
101 status: "ready",
102 environmentId,
103 attachmentId: "uploaded-image",
104 }),
105 ).toMatchObject({ attachmentId: "uploaded-image", contextId: "image_local-image" });
106 const file = {
107 type: "file" as const,
108 id: "local-file",
109 name: "notes.txt",
110 mimeType: "text/plain",
111 sizeBytes: 1,
112 file: null,
113 };
114 expect(uploadedAttachmentContextRecord(file, undefined)).toBeNull();
115 expect(
116 uploadedAttachmentContextRecord(
117 { ...file, uploadedAttachmentId: "persisted-file", uploadEnvironmentId: environmentId },
118 undefined,
119 ),
120 ).toMatchObject({ attachmentId: "persisted-file", contextId: "file_local-file" });
121 });
122 it("does not bind an annotation screenshot to a same-ID file", () => {
123 const context = buildMessageContext({
124 terminalContexts: [],
125 reviewComments: [],
126 previewAnnotations: [annotation],
127 attachments: [
128 {
129 attachment: {
130 type: "file",
131 id: annotation.id,
132 name: "notes.txt",
133 mimeType: "text/plain",
134 sizeBytes: 1,
135 file: null,
136 },
137 attachmentId: "uploaded-file",
138 },
139 ],
140 })!;
141 expect(context.records.map((record) => record.kind)).toEqual(["preview-annotation", "file"]);
142 expect(context.records[0]).not.toHaveProperty("screenshotContextId");
143 });
144 it.each(["x", "terminal_x"])(
145 "preserves canonical terminal IDs across repeated imports: %s",
146 (id) => {
147 const threadId = ThreadId.make("t1");
148 const record = terminalContextRecord({
149 id,
150 threadId,
151 terminalId: "default",
152 terminalLabel: "Terminal",
153 lineStart: 1,
154 lineEnd: 1,
155 text: "output",
156 createdAt: "2026-01-01T00:00:00.000Z",
157 });
158 const restored = terminalContextRecord(terminalContextDraftFromRecord(record, threadId));
159 expect(restored).toEqual(record);
160 expect(terminalContextRecord(terminalContextDraftFromRecord(restored, threadId))).toEqual(
161 record,
162 );
163 },
164 );
165​
166 it.each(["x", "review-comment_x"])("preserves canonical review IDs across imports: %s", (id) => {
167 const record = reviewCommentContextRecord({
168 id,
169 sectionId: "s",
170 sectionTitle: "Review",
171 filePath: "a.ts",
172 startIndex: 0,
173 endIndex: 0,
174 rangeLabel: "L1",
175 text: "Review",
176 diff: "",
177 });
178 expect(reviewCommentContextRecord(reviewCommentFromRecord(record))).toEqual(record);
179 });
180​
181 it.each(["x", "preview-annotation_x"])(
182 "preserves canonical annotation IDs across imports: %s",
183 (id) => {
184 const record = previewAnnotationContextRecord({ ...annotation, id });
185 expect(previewAnnotationContextRecord(previewAnnotationFromRecord(record)).contextId).toBe(
186 record.contextId,
187 );
188 },
189 );
190 it("builds distinct records for producer IDs that differ by a kind prefix", () => {
191 const context = buildMessageContext({
192 terminalContexts: [],
193 reviewComments: [],
194 previewAnnotations: [],
195 attachments: ["x", "image_x"].map((id) => ({
196 attachment: {
197 type: "image" as const,
198 id,
199 name: `${id}.png`,
200 mimeType: "image/png",
201 sizeBytes: 1,
202 file: new File(["x"], `${id}.png`, { type: "image/png" }),
203 previewUrl: `blob:${id}`,
204 },
205 attachmentId: `uploaded-${id}`,
206 })),
207 })!;
208 expect(decodeMessageContext(context).records.map((record) => record.contextId)).toEqual([
209 "image_x",
210 "image_image_x",
211 ]);
212 });
213 it("scopes colliding producer ids and links the annotation to its screenshot record", () => {
214 const id = "same.id:1";
215 const context = buildMessageContext({
216 terminalContexts: [
217 {
218 id,
219 threadId: ThreadId.make("t1"),
220 terminalId: "default",
221 terminalLabel: "Terminal",
222 lineStart: 1,
223 lineEnd: 1,
224 text: "output",
225 createdAt: "2026-01-01T00:00:00.000Z",
226 },
227 ],
228 reviewComments: [
229 {
230 id,
231 sectionId: "s",
232 sectionTitle: "Review",
233 filePath: "file.ts",
234 startIndex: 0,
235 endIndex: 0,
236 rangeLabel: "L1",
237 text: "Review",
238 diff: "",
239 },
240 ],
241 previewAnnotations: [{ ...annotation, id }],
242 attachments: [
243 {
244 attachment: {
245 type: "image",
246 id,
247 name: "shot.png",
248 mimeType: "image/png",
249 sizeBytes: 1,
250 file: new File(["x"], "shot.png"),
251 previewUrl: "blob:shot",
252 },
253 attachmentId: "uploaded-image",
254 },
255 {
256 attachment: {
257 type: "file",
258 id,
259 name: "file.txt",
260 mimeType: "text/plain",
261 sizeBytes: 1,
262 file: null,
263 },
264 attachmentId: "uploaded-file",
265 },
266 ],
267 })!;
268 expect(decodeMessageContext(context).records).toHaveLength(5);
269 const preview = context.records.find((record) => record.kind === "preview-annotation");
270 const image = context.records.find((record) => record.kind === "image");
271 expect(preview).toMatchObject({ screenshotContextId: image!.contextId });
272 expect(image).toMatchObject({ attachmentId: "uploaded-image" });
273 });
274​
275 it("restores multiple edits on one target without parsing display strings", () => {
276 const styleChanges = [
277 ...annotation.styleChanges,
278 {
279 targetId: "el_1",
280 selector: "#pay",
281 property: "content",
282 previousValue: "a → b",
283 value: "first\nsecond → third",
284 },
285 ];
286 const restored = previewAnnotationFromRecord(
287 previewAnnotationContextRecord({ ...annotation, styleChanges }),
288 );
289 expect(restored.styleChanges).toEqual(styleChanges);
290 expect(restored.elements[0]?.id).toBe("el_1");
291 });
292 it.each([
293 ["+181", "a.ts L181"],
294 ["+181 to +183", "a.ts L181 to L183"],
295 ["-63", "a.ts L63 (before)"],
296 ["L4", "a.ts L4"],
297 ])("presents review range %s consistently as %s", (rangeLabel, expected) => {
298 expect(
299 reviewCommentContextLabel({
300 id: "review-1",
301 sectionId: "file:src/a.ts",
302 sectionTitle: "File comment",
303 filePath: "src/a.ts",
304 startIndex: 0,
305 endIndex: 0,
306 rangeLabel,
307 text: "",
308 diff: "",
309 }),
310 ).toBe(expected);
311 });
312​
313 it("distinguishes a PR summary from a comment on its diff", () => {
314 const summary = {
315 id: "review-1",
316 sectionId: "pull-request:42",
317 sectionTitle: "PR #42",
318 filePath: "PR #42",
319 startIndex: 0,
320 endIndex: 0,
321 rangeLabel: "Improve context chips",
322 text: "Pull request details",
323 diff: "",
324 pullRequest: {
325 number: 42,
326 title: "Improve context chips",
327 url: "https://github.com/pingdotgg/t3code/pull/42",
328 headBranch: "feat/context-chips",
329 baseBranch: "main",
330 state: "open" as const,
331 isDraft: false,
332 },
333 };
334​
335 expect(isPullRequestSummaryContext(summary)).toBe(true);
336 expect(reviewCommentContextLabel(summary)).toBe("#42");
337 expect(pullRequestContextDisplayState(summary)).toBe("open");
338 expect(pullRequestContextKindLabel(summary)).toBe("Open pull request");
339 expect(
340 pullRequestContextDisplayState({
341 ...summary,
342 pullRequest: { ...summary.pullRequest, isDraft: true },
343 }),
344 ).toBe("draft");
345 expect(
346 isPullRequestSummaryContext({
347 ...summary,
348 pullRequest: undefined,
349 filePath: "src/a.ts",
350 rangeLabel: "+12",
351 diff: "+const answer = 42;",
352 }),
353 ).toBe(false);
354 });
355​
356 it("builds a preview annotation record with element details and readable style changes", () => {
357 expect(previewAnnotationContextLabel(annotation)).toBe("Make this bigger");
358 expect(previewAnnotationContextRecord(annotation, { screenshotContextId: "ann_1" })).toEqual({
359 version: 1,
360 contextId: "preview-annotation_ann_1",
361 kind: "preview-annotation",
362 label: "Make this bigger",
363 annotationId: "ann_1",
364 pageUrl: "http://localhost:3000/checkout",
365 pageTitle: "Checkout",
366 comment: "Make this bigger",
367 targetSummary: "1 selected element",
368 styleChanges: ["font-size: (unset) → 20px"],
369 styleChangeDetails: annotation.styleChanges,
370 elementIds: ["el_1"],
371 screenshotContextId: "image_ann_1",
372 elements: [
373 {
374 pageUrl: "http://localhost:3000/checkout",
375 pageTitle: "Checkout",
376 tagName: "button",
377 selector: "#pay",
378 htmlPreview: '<button id="pay">Pay</button>',
379 componentName: "Button",
380 source: null,
381 styles: "color: red;",
382 },
383 ],
384 });
385 });
386​
387 it("removes an expired terminal chip by its kind-scoped id, not the producer id", () => {
388 const context = {
389 id: "term-1",
390 threadId: ThreadId.make("t"),
391 createdAt: "2026-01-01T00:00:00.000Z",
392 terminalId: "default",
393 terminalLabel: "Terminal 1",
394 lineStart: 3,
395 lineEnd: 4,
396 text: "boom",
397 };
398 const reference = terminalContextReference(context);
399 expect(reference.contextId).toBe("terminal_term-1");
400​
401 const prompt = `prose ${formatInlineContextReference(reference)} tail`;
402 expect(removeInlineContextReference(prompt, context.id).prompt).toBe(prompt);
403 expect(removeInlineContextReference(prompt, reference.contextId).prompt).toBe("prose tail");
404 });
405​
406 it("clamps an oversized review selection so the record still encodes", () => {
407 const build = (diffLength: number) =>
408 reviewCommentContextRecord({
409 id: "rc-big",
410 sectionId: "file:a/b.ts",
411 sectionTitle: "File comment",
412 filePath: "a/b.ts",
413 startIndex: 0,
414 endIndex: 1,
415 rangeLabel: "L1",
416 text: "Why?",
417 diff: "d".repeat(diffLength),
418 });
419​
420 const atLimit = build(32_000);
421 expect(atLimit.diff).toHaveLength(32_000);
422 const overLimit = build(32_001);
423 expect(overLimit.diff.length).toBeLessThanOrEqual(32_000);
424 expect(overLimit.diff.endsWith("… truncated …")).toBe(true);
425 expect(() => decodeMessageContext({ version: 1, records: [atLimit] })).not.toThrow();
426 expect(() => decodeMessageContext({ version: 1, records: [overLimit] })).not.toThrow();
427 });
428​
429 it("keeps a region-only annotation's target summary and screenshot across a round trip", () => {
430 const regionOnly: PreviewAnnotationPayload = {
431 ...annotation,
432 elements: [],
433 styleChanges: [],
434 regions: [{ id: "rg_1", rect: { x: 1, y: 2, width: 3, height: 4 } }],
435 };
436 const record = previewAnnotationContextRecord(regionOnly, { screenshotContextId: "ann_1" });
437 expect(record.targetSummary).toBe("1 marked region");
438 expect(record.screenshotContextId).toBe("image_ann_1");
439​
440 const reencoded = previewAnnotationContextRecord(previewAnnotationFromRecord(record), {
441 screenshotContextId: "ann_1",
442 });
443 expect(reencoded.targetSummary).toBe("1 marked region");
444 expect(reencoded.screenshotContextId).toBe("image_ann_1");
445 });
446​
447 it("treats colliding ids with different payloads as distinct records", () => {
448 const base = terminalContextRecord({
449 id: "term-1",
450 threadId: ThreadId.make("t"),
451 createdAt: "2026-01-01T00:00:00.000Z",
452 terminalId: "default",
453 terminalLabel: "Terminal 1",
454 lineStart: 1,
455 lineEnd: 2,
456 text: "A",
457 });
458 expect(isSameComposerContextPayload(base, { ...base })).toBe(true);
459 expect(isSameComposerContextPayload(base, { ...base, label: "different" })).toBe(true);
460 expect(isSameComposerContextPayload(base, { ...base, text: "B" })).toBe(false);
461 });
462​
463 it("finds the destination collision for different legacy terminal messages", () => {
464 const legacy = (text: string) =>
465 asKnownContextRecord(
466 upgradeLegacyContextMessage(
467 `Inspect this\n\n<terminal_context>\n- Terminal 1 line 1:\n 1 | ${text}\n</terminal_context>`,
468 ).records[0],
469 )!;
470 const first = legacy("A");
471 const second = legacy("B");
472 if (first.kind !== "terminal" || second.kind !== "terminal") {
473 throw new Error("Expected legacy terminal records");
474 }
475 const destinationId = terminalContextReference(
476 terminalContextDraftFromRecord(first, ThreadId.make("t")),
477 ).contextId;
478​
479 expect(destinationId).toBe("terminal_legacy_terminal_1");
480 expect(composerContextImportLookupIds(second)[0]).toBe(destinationId);
481 expect(isSameComposerContextPayload(first, second)).toBe(false);
482 });
483​
484 it("treats an imported legacy id and its canonical reconstruction as the same excerpt", () => {
485 const draft = {
486 id: "term-1",
487 threadId: ThreadId.make("t"),
488 createdAt: "2026-01-01T00:00:00.000Z",
489 terminalId: "default",
490 terminalLabel: "Terminal 1",
491 lineStart: 1,
492 lineEnd: 2,
493 text: "A",
494 };
495 const canonical = terminalContextRecord(draft);
496 const imported = { ...canonical, contextId: "legacy_terminal_1" as ComposerContextId };
497​
498 expect(isSameComposerContextPayload(canonical, imported)).toBe(true);
499 expect(isSameComposerContextPayload(canonical, { ...canonical, text: "B" })).toBe(false);
500 });
501​
502 it("compares nested annotation element and source payloads", () => {
503 const base = previewAnnotationContextRecord(annotation);
504 expect(isSameComposerContextPayload(base, { ...base, label: "Different display label" })).toBe(
505 true,
506 );
507 expect(
508 isSameComposerContextPayload(base, {
509 ...base,
510 elements: base.elements!.map((element) => ({
511 ...element,
512 htmlPreview: '<button id="pay">Changed</button>',
513 })),
514 }),
515 ).toBe(false);
516 expect(
517 isSameComposerContextPayload(base, {
518 ...base,
519 elements: base.elements!.map((element) => ({
520 ...element,
521 source: {
522 functionName: "Checkout",
523 fileName: "src/Checkout.tsx",
524 lineNumber: 20,
525 columnNumber: 4,
526 },
527 })),
528 }),
529 ).toBe(false);
530 });
531​
532 it("builds terminal and review records and a message context in draft order", () => {
533 const terminal = terminalContextRecord({
534 id: "term-1",
535 threadId: ThreadId.make("t"),
536 createdAt: "2026-01-01T00:00:00.000Z",
537 terminalId: "default",
538 terminalLabel: "Terminal 1",
539 lineStart: 3,
540 lineEnd: 4,
541 text: "\nboom\n",
542 });
543 expect(terminal).toMatchObject({
544 kind: "terminal",
545 label: "Terminal 1 lines 3-4",
546 text: "boom",
547 });
548 const review = reviewCommentContextRecord({
549 id: "rc-1",
550 sectionId: "file:a/b.ts",
551 sectionTitle: "File comment",
552 filePath: "a/b.ts",
553 startIndex: 3,
554 endIndex: 3,
555 rangeLabel: "L4",
556 text: "Why?",
557 diff: "const x = 1;",
558 fenceLanguage: "ts",
559 });
560 expect(review).toMatchObject({ kind: "review-comment", label: "b.ts L4", fenceLanguage: "ts" });
561 const context = buildMessageContext({
562 terminalContexts: [],
563 reviewComments: [
564 {
565 id: "rc-1",
566 sectionId: "s",
567 sectionTitle: "t",
568 filePath: "a/b.ts",
569 startIndex: 0,
570 endIndex: 0,
571 rangeLabel: "L1",
572 text: "",
573 diff: "",
574 },
575 ],
576 previewAnnotations: [annotation],
577 });
578 expect(context?.records.map((record) => record.contextId)).toEqual([
579 "review-comment_rc-1",
580 "preview-annotation_ann_1",
581 ]);
582 expect(
583 buildMessageContext({ terminalContexts: [], reviewComments: [], previewAnnotations: [] }),
584 ).toBeUndefined();
585 });
586​
587 it("resolves structured context directly and upgrades legacy text otherwise", () => {
588 const structured = resolveUserMessageContext({
589 text: "hi [b.ts L4](t3-context://v1/review-comment/rc-1)",
590 context: {
591 version: 1,
592 records: [
593 reviewCommentContextRecord({
594 id: "rc-1",
595 sectionId: "s",
596 sectionTitle: "t",
597 filePath: "a/b.ts",
598 startIndex: 3,
599 endIndex: 3,
600 rangeLabel: "L4",
601 text: "",
602 diff: "",
603 }),
604 ],
605 },
606 });
607 expect(structured.recordsById.get("review-comment_rc-1")?.kind).toBe("review-comment");
608 const legacy = resolveUserMessageContext({
609 text: "hi\n\n<terminal_context>\n- T line 1:\n 1 | x\n</terminal_context>",
610 });
611 expect(legacy.text).toBe("hi\n\n[T line 1](t3-context://v1/terminal/legacy_terminal_1)");
612 expect(legacy.recordsById.get("legacy_terminal_1")?.kind).toBe("terminal");
613 });
614});
615​
616describe("attachment context records", () => {
617 it("binds image and file records to the given attachment id", () => {
618 const image = attachmentContextRecord({
619 attachment: {
620 type: "image",
621 id: "img-1",
622 name: "shot.png",
623 mimeType: "image/png",
624 sizeBytes: 10,
625 previewUrl: "blob:x",
626 file: new File(["x"], "shot.png", { type: "image/png" }),
627 },
628 attachmentId: "pending-abc",
629 });
630 expect(image).toEqual({
631 version: 1,
632 contextId: "image_img-1",
633 kind: "image",
634 label: "shot.png",
635 attachmentId: "pending-abc",
636 name: "shot.png",
637 mimeType: "image/png",
638 sizeBytes: 10,
639 });
640 const file = attachmentContextRecord({
641 attachment: {
642 type: "file",
643 id: "file-1",
644 name: "notes.txt",
645 mimeType: "text/plain",
646 sizeBytes: 3,
647 file: null,
648 uploadedAttachmentId: "pending-def",
649 },
650 attachmentId: "pending-def",
651 });
652 expect(file).toMatchObject({
653 kind: "file",
654 contextId: "file_file-1",
655 attachmentId: "pending-def",
656 });
657 const context = buildMessageContext({
658 terminalContexts: [],
659 reviewComments: [],
660 previewAnnotations: [],
661 attachments: [
662 {
663 attachment: {
664 type: "file",
665 id: "file-1",
666 name: "n",
667 mimeType: "text/plain",
668 sizeBytes: 1,
669 file: null,
670 },
671 attachmentId: "file-1",
672 },
673 ],
674 });
675 expect(context?.records.map((record) => record.kind)).toEqual(["file"]);
676 });
677});
678​
679describe("producer ids that do not fit the grammar", () => {
680 it("folds review comment ids and keeps the raw id in the draft shape", () => {
681 const record = reviewCommentContextRecord({
682 id: "pull-request-finding:42",
683 sectionId: "s",
684 sectionTitle: "t",
685 filePath: "a/b.ts",
686 startIndex: 0,
687 endIndex: 0,
688 rangeLabel: "L1",
689 text: "",
690 diff: "",
691 });
692 expect(record.contextId).toMatch(/^review-comment_pull-request-finding-42-[0-9a-f]{16}$/);
693 expect(
694 resolveUserMessageContext({
695 text: `[b.ts L1](t3-context://v1/review-comment/${record.contextId})`,
696 context: { version: 1, records: [record] },
697 }).recordsById.has(record.contextId),
698 ).toBe(true);
699 });
700});
701​
702describe("selectedMessageContextFragment", () => {
703 const terminal = terminalContextRecord({
704 id: "term-1",
705 threadId: ThreadId.make("t"),
706 createdAt: "2026-01-01T00:00:00.000Z",
707 terminalId: "default",
708 terminalLabel: "Terminal 1",
709 lineStart: 1,
710 lineEnd: 1,
711 text: "A",
712 });
713 const review = reviewCommentContextRecord({
714 id: "rc-1",
715 sectionId: "s",
716 sectionTitle: "t",
717 filePath: "a/b.ts",
718 startIndex: 3,
719 endIndex: 3,
720 rangeLabel: "L4",
721 text: "",
722 diff: "",
723 });
724 const input = {
725 records: [terminal, review],
726 environmentId: EnvironmentId.make("env"),
727 threadId: ThreadId.make("t"),
728 messageId: MessageId.make("msg-1"),
729 };
730​
731 it("carries only records for chips inside the selection", () => {
732 const fragment = selectedMessageContextFragment({
733 ...input,
734 markdown: `see [b.ts L4](t3-context://v1/review-comment/${review.contextId})`,
735 });
736​
737 expect(fragment).toContain(review.contextId);
738 expect(fragment).not.toContain(terminal.contextId);
739 });
740​
741 it("returns null when no selected chip has backing records", () => {
742 expect(selectedMessageContextFragment({ ...input, markdown: "just prose" })).toBeNull();
743 expect(
744 selectedMessageContextFragment({
745 ...input,
746 records: [],
747 markdown: `[b.ts L4](t3-context://v1/review-comment/${review.contextId})`,
748 }),
749 ).toBeNull();
750 });
751});