The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 23:30 UTC
fix(web): render Claude insight blocks as a callout (#22239)
Co-authored-by: macodev00 <macodev00@users.noreply.github.com> Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>
maco committed
Nov 11, 2026 at 11:25 UTC
2c74ea6915e4f8013992816697c4b27905e88e7e
9 files changed
+291
-15
apps/web/src/components/ChatMarkdown.browser.test.tsx
+34
@@ -481,6 +481,40 @@ describe("ChatMarkdown skill chips", () => {
481
});
482
483
describe("ChatMarkdown headings", () => {
484
+ it("keeps insight streaming, reference links, and heading anchors in one message", async () => {
485
+ setup();
486
+ const rule = "─".repeat(20);
487
+ const text = `## Setup\n\nBefore [source][src].\n\n★ Insight ${rule}\nA **streaming** note.`;
488
+ const message = (text: string, isStreaming: boolean) => (
489
+ <ChatMarkdown
490
+ cwd={undefined}
491
+ text={text}
492
+ renderInsights
493
+ lineBreaks
494
+ isStreaming={isStreaming}
495
+ />
496
+ );
497
+ await using screen = await render(message(text, true));
498
+ await expect.element(screen.getByRole("note")).toHaveTextContent("Insight A streaming note.");
499
+ await screen.rerender(
500
+ message(
501
+ `${text}\n${rule}\n\n## Setup\n\nAfter [source][src].\n\n[src]:\n https://example.com`,
502
+ false,
503
+ ),
504
+ );
505
+ await expect.element(screen.getByRole("note")).toHaveTextContent("Insight A streaming note.");
506
+ expect([...screen.container.querySelectorAll("h2")].map((heading) => heading.id)).toEqual([
507
+ "user-content-setup",
508
+ "user-content-setup-1",
509
+ ]);
510
+ expect(
511
+ [...screen.container.querySelectorAll("a")].filter(
512
+ (link) => link.href === "https://example.com/",
513
+ ),
514
+ ).toHaveLength(2);
515
+ await expect.element(screen.getByRole("note")).not.toHaveTextContent("After");
516
+ });
517
+
518
it("never gives two headings the same id, even when a suffix matches another heading", async () => {
519
setup();
520
await using screen = await renderText(
apps/web/src/components/ChatMarkdown.tsx
+20
-1
@@ -19,6 +19,7 @@ import {
19
CHAT_MARKDOWN_REMARK_PLUGINS,
20
CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS,
21
CHAT_MARKDOWN_REHYPE_PLUGINS,
22
+ remarkAssistantInsights,
23
} from "@t3tools/shared/markdownPipeline";
24
import { useAtomValue } from "@effect/atom-react";
25
import {
@@ -37,6 +38,7 @@ import {
38
MessageSquareWarningIcon,
39
OctagonAlertIcon,
40
PresentationIcon,
41
+ StarIcon,
42
TriangleAlertIcon,
43
type LucideIcon,
44
} from "lucide-react";
@@ -224,6 +226,7 @@ import { reportMarkdownActionFailure } from "./chat/markdownActionFailure";
226
const isAssetNotFoundError = Schema.is(AssetWorkspaceAssetNotFoundError);
227
228
interface ChatMarkdownProps {
229
+ renderInsights?: boolean;
230
/** Compact markdown transforms remove blocks before rendering inside a label. */
231
inline?: boolean;
232
text: string;
@@ -342,6 +345,12 @@ const GITHUB_ALERT_PRESENTATIONS: Record<
345
string,
346
{ label: string; Icon: typeof InfoIcon; borderClassName: string; titleClassName: string }
347
> = {
348
+ insight: {
349
+ label: "Insight",
350
+ Icon: StarIcon,
351
+ borderClassName: "border-info",
352
+ titleClassName: "text-info",
353
+ },
354
note: {
355
label: "Note",
356
Icon: InfoIcon,
@@ -1680,6 +1689,8 @@ const CHAT_MARKDOWN_REMARK_PLUGIN_SETS = {
1689
const combinedPlugins = new WeakMap<PluggableList, WeakMap<PluggableList, PluggableList>>();
1690
1691
// One combined list per pair, so a stable extra list shares a renderer and its parse cache.
1692
+const INSIGHT_REMARK_PLUGINS: PluggableList = [remarkAssistantInsights];
1693
+
1694
function withExtraPlugins(shared: PluggableList, extra: PluggableList): PluggableList {
1695
if (extra.length === 0) return shared;
1696
let byShared = combinedPlugins.get(extra);
@@ -1746,10 +1757,12 @@ function ChatMarkdown({
1757
lineBreaks = false,
1758
parseRawHtml = true,
1759
extraRemarkPlugins = EMPTY_REMARK_PLUGINS,
1760
+ renderInsights = false,
1761
...props
1762
}: ChatMarkdownProps) {
1763
const { componentState, handleCopy, markdownRef, localMediaPreview, closeLocalMediaPreview } =
1764
useChatMarkdownState({ text, inline, ...props });
1765
+ const hasInsights = renderInsights && text.includes("★ Insight");
1766
// Streaming re-renders only the last block; offsets for task edits need the whole text.
1767
const streamingBlocks =
1768
props.isStreaming === true &&
@@ -1760,6 +1773,7 @@ function ChatMarkdown({
1773
: null;
1774
const incrementalParsing =
1775
props.isStreaming === true &&
1776
+ !hasInsights &&
1777
streamingBlocks === null &&
1778
extraRemarkPlugins.length === 0 &&
1779
/(?:^|\n) {0,3}(?:`{3}|~{3})/.test(text);
@@ -1781,7 +1795,12 @@ function ChatMarkdown({
1795
const uncachedPlugins = incrementalParsing;
1796
const remarkPlugins = incrementalParsing
1797
? [...sharedRemarkPlugins, ...extraRemarkPlugins, createIncrementalMarkdownPlugin()]
1784
- : withExtraPlugins(sharedRemarkPlugins, extraRemarkPlugins);
1798
+ : withExtraPlugins(
1799
+ hasInsights
1800
+ ? withExtraPlugins(INSIGHT_REMARK_PLUGINS, sharedRemarkPlugins)
1801
+ : sharedRemarkPlugins,
1802
+ extraRemarkPlugins,
1803
+ );
1804
const blocks = streamingBlocks ?? [text];
1805
1806
return (
apps/web/src/components/chat/TimelineAssistantRows.tsx
+1
@@ -49,6 +49,7 @@ export function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind
49
>
50
<ChatMarkdown
51
text={messageText}
52
+ renderInsights
53
cwd={ctx.markdownCwd}
54
threadRef={ctx.threadRef ?? undefined}
55
isStreaming={Boolean(row.message.streaming)}
apps/web/src/components/chat/markdownStreamBlocks.test.tsx
+3
-1
@@ -1,6 +1,7 @@
1
import {
2
CHAT_MARKDOWN_REHYPE_PLUGINS,
3
CHAT_MARKDOWN_REMARK_PLUGINS,
4
+ remarkAssistantInsights,
5
} from "@t3tools/shared/markdownPipeline";
6
import { renderToStaticMarkup } from "react-dom/server";
7
import ReactMarkdown from "react-markdown";
@@ -12,7 +13,7 @@ import { splitMarkdownBlocks } from "./markdownStreamBlocks";
13
const html = (source: string) =>
14
renderToStaticMarkup(
15
<ReactMarkdown
15
- remarkPlugins={CHAT_MARKDOWN_REMARK_PLUGINS}
16
+ remarkPlugins={[remarkAssistantInsights, ...CHAT_MARKDOWN_REMARK_PLUGINS]}
17
rehypePlugins={CHAT_MARKDOWN_REHYPE_PLUGINS}
18
>
19
{source}
@@ -33,6 +34,7 @@ describe("splitMarkdownBlocks", () => {
34
"Setext\n===\n\nnext\n---\n\n- [ ] task\n- [x] done",
35
"- a\n\n ```\n x\n\n```\n\nb",
36
"- a\n\n ```\n x\n\ny\n\n ```\n\nb",
37
+ "intro\n\n★ Insight ─────\nfirst\n\n```\n─────\n```\n\n- point\n─────\n\nafter\n\n`★ Insight ─────`\nsecond\n`─────`\n\nend",
38
])("renders each block as the whole text renders it, at every streamed prefix: %j", (text) => {
39
for (let end = 0; end <= text.length; end++) {
40
const source = text.slice(0, end);
apps/web/src/components/chat/markdownStreamBlocks.ts
+14
-1
@@ -3,6 +3,9 @@ const DOCUMENT_WIDE_SYNTAX = /^ {0,3}(?:\[[^\]\n]+\]:|<[A-Za-z!?/]|:::|\$\$)|\[\
3
const FENCE_PATTERN = /^ {0,3}(`{3,}|~{3,})/;
4
// After a blank line these still continue the previous block: a list item or indented content.
5
const CONTINUATION_PATTERN = /^(?:[ \t]|(?:[-*+]|\d{1,9}[.)])(?:[ \t]|$))/;
6
+// Claude insight fences render as one callout, so they stay in one block until the closing rule.
7
+const INSIGHT_OPEN_PATTERN = /^( {0,3})(`?)★ Insight[ \t]+─{3,}\2[ \t]*$/u;
8
+const INSIGHT_CLOSE_PATTERN = /^( {0,3})(`?)─{3,}\2[ \t]*$/u;
9
10
/**
11
* Cuts Markdown at blank lines that close every open block, so each piece renders exactly as it
@@ -16,6 +19,7 @@ export function splitMarkdownBlocks(text: string): string[] | null {
19
let fence: string | null = null;
20
let fenceIndent = 0;
21
let afterBlankLine = false;
22
+ let insightIndent: string | null = null;
23
for (const line of text.split("\n")) {
24
const opener = FENCE_PATTERN.exec(line)?.[1];
25
if (fence !== null) {
@@ -29,14 +33,23 @@ export function splitMarkdownBlocks(text: string): string[] | null {
33
) {
34
fence = null;
35
}
36
+ } else if (insightIndent !== null && INSIGHT_CLOSE_PATTERN.exec(line)?.[1] === insightIndent) {
37
+ insightIndent = null;
38
+ afterBlankLine = false;
39
} else if (line.trim() === "") {
40
afterBlankLine = true;
41
} else {
35
- if (afterBlankLine && lineStart > blockStart && !CONTINUATION_PATTERN.test(line)) {
42
+ if (
43
+ afterBlankLine &&
44
+ insightIndent === null &&
45
+ lineStart > blockStart &&
46
+ !CONTINUATION_PATTERN.test(line)
47
+ ) {
48
blocks.push(text.slice(blockStart, lineStart));
49
blockStart = lineStart;
50
}
51
afterBlankLine = false;
52
+ if (insightIndent === null) insightIndent = INSIGHT_OPEN_PATTERN.exec(line)?.[1] ?? null;
53
fence = opener ?? null;
54
if (opener) fenceIndent = line.indexOf(opener);
55
}
packages/shared/src/markdownPipeline.test.ts
+109
@@ -8,6 +8,7 @@ import {
8
CHAT_MARKDOWN_REHYPE_PLUGINS,
9
CHAT_MARKDOWN_REMARK_PLUGINS,
10
CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS,
11
+ remarkAssistantInsights,
12
remarkEnableOrderedListNumbers,
13
} from "./markdownPipeline.ts";
14
@@ -119,6 +120,114 @@ it.each([
120
}
121
});
122
123
+const insightRule = "─".repeat(20);
124
+const insightFence = (body: string, wrap = "") =>
125
+ [`${wrap}★ Insight ${insightRule}${wrap}`, body, `${wrap}${insightRule}${wrap}`].join("\n");
126
+
127
+it.each(["", "`"])("groups %j insight fences while preserving surrounding markdown", (wrap) => {
128
+ const markdown = [
129
+ "Before **bold** and [reference][src].",
130
+ "",
131
+ insightFence("- Also [reference][src].", wrap),
132
+ "",
133
+ "After.",
134
+ "",
135
+ '[src]:\n https://example.com\n "Source"',
136
+ ].join("\n");
137
+ const processor = unified()
138
+ .use(remarkParse)
139
+ .use(CHAT_MARKDOWN_REMARK_PLUGINS)
140
+ .use(remarkAssistantInsights)
141
+ .use(remarkRehype)
142
+ .use(CHAT_MARKDOWN_REHYPE_PLUGINS);
143
+ const tree = processor.runSync(processor.parse(markdown), markdown);
144
+ expect(
145
+ tree.children.filter((node) => node.type === "element").map((node) => node.tagName),
146
+ ).toEqual(["p", "blockquote", "p"]);
147
+ expect(
148
+ tree.children.find((node) => node.type === "element" && node.tagName === "blockquote"),
149
+ ).toMatchObject({ properties: { dataAlert: "insight" } });
150
+ expect(JSON.stringify(tree).match(/"href":"https:\/\/example.com"/g)).toHaveLength(2);
151
+ expect(JSON.stringify(tree)).toContain('"tagName":"strong"');
152
+ expect(JSON.stringify(tree)).not.toContain(insightRule);
153
+});
154
+
155
+it.each([
156
+ ["```text", "★ Insight " + insightRule, "literal", insightRule, "```"].join("\n"),
157
+ ["- ```text", " ★ Insight " + insightRule, " literal", " " + insightRule, " ```"].join("\n"),
158
+ [" ★ Insight " + insightRule, " literal", " " + insightRule].join("\n"),
159
+ ["Paragraph.", " ★ Insight " + insightRule, " literal", " " + insightRule].join("\n"),
160
+ ["`example", "★ Insight " + insightRule, "literal", insightRule, "`"].join("\n"),
161
+ insightFence("quoted")
162
+ .split("\n")
163
+ .map((line) => "> " + line)
164
+ .join("\n"),
165
+])("leaves literal and nested insight examples unchanged: %s", (markdown) => {
166
+ const processor = unified().use(remarkParse).use(remarkAssistantInsights);
167
+ const tree = processor.parse(markdown);
168
+ expect(processor.runSync(structuredClone(tree), markdown)).toEqual(tree);
169
+});
170
+
171
+it("groups streaming bodies and several insights without losing code or headings", () => {
172
+ const markdown = [
173
+ "## Setup",
174
+ "",
175
+ insightFence("```text\n" + insightRule + "\n```"),
176
+ "",
177
+ "## Setup",
178
+ "",
179
+ "★ Insight " + insightRule,
180
+ "Still **streaming**",
181
+ ].join("\n");
182
+ const processor = unified().use(remarkParse).use(remarkAssistantInsights);
183
+ const tree = processor.parse(markdown);
184
+ processor.runSync(tree, markdown);
185
+ expect(tree.children.map((node) => node.type)).toEqual([
186
+ "heading",
187
+ "blockquote",
188
+ "heading",
189
+ "blockquote",
190
+ ]);
191
+ expect(tree.children[1]).toMatchObject({ children: [{ type: "code", value: insightRule }] });
192
+ expect(tree.children[3]).toMatchObject({
193
+ children: [
194
+ { type: "paragraph", children: [{ type: "text", value: "Still " }, { type: "strong" }] },
195
+ ],
196
+ });
197
+});
198
+
199
+it("keeps reference definitions out of unfinished streaming code", () => {
200
+ const markdown = `[src]: https://example.com\n\n★ Insight ${insightRule}\n\`\`\`ts\nconst value = 1`;
201
+ const processor = unified().use(remarkParse).use(remarkAssistantInsights);
202
+ const tree = processor.parse(markdown);
203
+ processor.runSync(tree, markdown);
204
+ expect(tree.children.find((node) => node.type === "blockquote")).toMatchObject({
205
+ children: [{ type: "code", value: "const value = 1" }],
206
+ });
207
+});
208
+
209
+it("preserves footnotes and original code positions across a callout", () => {
210
+ const code = "```sh\necho hello\n```";
211
+ const markdown = ["Before[^n].", "", insightFence(code), "", "[^n]: Footnote."].join("\n");
212
+ const processor = unified()
213
+ .use(remarkParse)
214
+ .use(remarkAssistantInsights)
215
+ .use(CHAT_MARKDOWN_REMARK_PLUGINS);
216
+ const tree = processor.parse(markdown);
217
+ processor.runSync(tree, markdown);
218
+ expect(tree.children[0]).toMatchObject({
219
+ children: [
220
+ { type: "text", value: "Before" },
221
+ { type: "footnoteReference", identifier: "n" },
222
+ { type: "text", value: "." },
223
+ ],
224
+ });
225
+ expect(tree.children.at(-1)).toMatchObject({ type: "footnoteDefinition", identifier: "n" });
226
+ const note = tree.children.find((node) => node.type === "blockquote");
227
+ const block = note?.children[0];
228
+ expect(markdown.slice(block?.position?.start.offset, block?.position?.end.offset)).toBe(code);
229
+});
230
+
231
it("preserves in-app thread links through the shared Markdown sanitizer", () => {
232
const processor = unified()
233
.use(remarkParse)
packages/shared/src/markdownPipeline.ts
+78
@@ -495,6 +495,84 @@ export function shouldPreserveAssistantLineBreaks(text: string): boolean {
495
return /^★ Insight(?:\s|─)/mu.test(text);
496
}
497
498
+export function remarkAssistantInsights(this: Processor) {
499
+ return (tree: Root, file: { value: unknown }) => {
500
+ const source = String(file.value);
501
+ if (!source.includes("★ Insight")) return;
502
+ const protectedRanges: { start: number; end: number; code: boolean }[] = [];
503
+ const inspect = (node: RootContent | PhrasingContent) => {
504
+ const start = node.position?.start.offset;
505
+ const end = node.position?.end.offset;
506
+ if (start !== undefined && end !== undefined) {
507
+ const code =
508
+ node.type === "code" ||
509
+ node.type === "html" ||
510
+ (node.type === "inlineCode" && node.position?.start.line !== node.position?.end.line);
511
+ if (code || node.type === "list" || node.type === "blockquote")
512
+ protectedRanges.push({ start, end, code });
513
+ }
514
+ if ("children" in node) node.children.forEach(inspect);
515
+ };
516
+ tree.children.forEach(inspect);
517
+ const starts = new Set<number>();
518
+ const offsets: { original: number; rewritten: number; prefix: number }[] = [];
519
+ let indent: string | undefined;
520
+ let original = 0;
521
+ let rewritten = 0;
522
+ const lines = source.split(/(?<=\n)|(?<=\r)(?!\n)/u).map((line, index) => {
523
+ const value = line.replace(/[\r\n]+$/u, "");
524
+ const blocked = protectedRanges.some(
525
+ (range) =>
526
+ original >= range.start && original < range.end && (indent === undefined || range.code),
527
+ );
528
+ const opening =
529
+ indent === undefined && !blocked
530
+ ? /^( {0,3})(`?)★ Insight[ \t]+─{3,}\2[ \t]*$/u.exec(value)
531
+ : null;
532
+ const closing =
533
+ indent !== undefined && !blocked ? /^( {0,3})(`?)─{3,}\2[ \t]*$/u.exec(value) : null;
534
+ let prefix = 0;
535
+ let output = line;
536
+ if (opening) {
537
+ indent = opening[1] ?? "";
538
+ starts.add(index + 1);
539
+ output = ">" + line.slice(value.length);
540
+ } else if (closing && closing[1] === indent) {
541
+ indent = undefined;
542
+ output = line.slice(value.length);
543
+ } else if (indent !== undefined) {
544
+ prefix = 2;
545
+ output = "> " + line;
546
+ }
547
+ offsets.push({ original, rewritten, prefix });
548
+ original += line.length;
549
+ rewritten += output.length;
550
+ return output;
551
+ });
552
+ if (starts.size === 0) return;
553
+ const parsed = this.parse(lines.join("")) as Root;
554
+ const restorePosition = (node: RootContent | PhrasingContent) => {
555
+ if (node.position) {
556
+ for (const point of [node.position.start, node.position.end]) {
557
+ const offset = offsets[point.line - 1];
558
+ if (!offset) continue;
559
+ point.column = Math.max(1, point.column - offset.prefix);
560
+ if (point.offset !== undefined)
561
+ point.offset += offset.original - offset.rewritten - offset.prefix;
562
+ }
563
+ }
564
+ if ("children" in node) node.children.forEach(restorePosition);
565
+ };
566
+ for (const node of parsed.children) {
567
+ if (node.type === "blockquote" && starts.has(node.position?.start.line ?? 0)) {
568
+ node.data = { ...node.data, hProperties: { dataAlert: "insight" } };
569
+ }
570
+ restorePosition(node);
571
+ }
572
+ tree.children = parsed.children;
573
+ };
574
+}
575
+
576
const imageSourceProcessor = unified()
577
.use(remarkParse)
578
.use(CHAT_MARKDOWN_REMARK_PLUGINS)
packages/shared/src/threadFindText.test.ts
+11
-1
@@ -2,7 +2,7 @@ import { EnvironmentId, MessageId, ThreadId } from "@t3tools/contracts";
2
import { expect, it } from "vite-plus/test";
3
import { serializeAssistantCitation } from "./assistantCitations.ts";
4
import { ATTACHMENT_ONLY_BOOTSTRAP_PROMPT } from "./composerContextReferences.ts";
5
-import { searchableMessageSegments } from "./threadFindText.ts";
5
+import { searchableMessageSegments, searchablePlanSegments } from "./threadFindText.ts";
6
7
it("excludes review attachments rendered as context chips", () => {
8
const text = [
@@ -117,3 +117,13 @@ it("indexes the citation chip label instead of its link text", () => {
117
"my note",
118
]);
119
});
120
+
121
+it("indexes insight bodies without hidden fences and keeps user and plan text literal", () => {
122
+ const text = "★ Insight ─────\nVisible body.\n─────";
123
+ expect(assistantSegments(text)).toEqual(["Visible body."]);
124
+ expect(searchableMessageSegments({ role: "user", text, streaming: false })?.join("\n")).toContain(
125
+ "★ Insight",
126
+ );
127
+ expect(searchablePlanSegments(text).join("\n")).toContain("★ Insight");
128
+ expect(assistantSegments(`\`\`\`text\n${text}\n\`\`\``)?.join("\n")).toContain("★ Insight");
129
+});
packages/shared/src/threadFindText.ts
+21
-11
@@ -33,6 +33,7 @@ import remarkParse from "remark-parse";
33
import remarkRehype from "remark-rehype";
34
import {
35
shouldPreserveAssistantLineBreaks,
36
+ remarkAssistantInsights,
37
CHAT_MARKDOWN_REHYPE_PLUGINS,
38
CHAT_MARKDOWN_REMARK_PLUGINS,
39
CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS,
@@ -78,16 +79,18 @@ export const THREAD_FIND_BLOCK_TAGS = new Set([
79
"ul",
80
]);
81
81
-const assistantProcessor = unified()
82
- .use(remarkParse)
83
- .use(CHAT_MARKDOWN_REMARK_PLUGINS)
84
- .use(remarkRehype, { allowDangerousHtml: true })
85
- .use(CHAT_MARKDOWN_REHYPE_PLUGINS);
86
-const assistantBreaksProcessor = unified()
87
- .use(remarkParse)
88
- .use(CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS)
89
- .use(remarkRehype, { allowDangerousHtml: true })
90
- .use(CHAT_MARKDOWN_REHYPE_PLUGINS);
82
+function assistantTextProcessor(lineBreaks = false, renderInsights = false) {
83
+ return unified()
84
+ .use(remarkParse)
85
+ .use(renderInsights ? [remarkAssistantInsights] : [])
86
+ .use(lineBreaks ? CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS : CHAT_MARKDOWN_REMARK_PLUGINS)
87
+ .use(remarkRehype, { allowDangerousHtml: true })
88
+ .use(CHAT_MARKDOWN_REHYPE_PLUGINS);
89
+}
90
+const assistantProcessor = assistantTextProcessor();
91
+const assistantBreaksProcessor = assistantTextProcessor(true);
92
+const insightProcessor = assistantTextProcessor(false, true);
93
+const insightBreaksProcessor = assistantTextProcessor(true, true);
94
const userProcessor = unified()
95
.use(remarkParse)
96
.use(CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS)
@@ -111,13 +114,19 @@ function markdownThreadFindText(
114
cwd?: string,
115
skills: readonly InlineSkill[] = [],
116
lineBreaks = false,
117
+ renderInsights = false,
118
): string[] {
119
const processor = userMessage
120
? userProcessor
121
: lineBreaks
122
? assistantBreaksProcessor
123
: assistantProcessor;
120
- const tree = processor.runSync(processor.parse(markdown));
124
+ const renderer = renderInsights
125
+ ? lineBreaks
126
+ ? insightBreaksProcessor
127
+ : insightProcessor
128
+ : processor;
129
+ const tree = renderer.runSync(renderer.parse(markdown), markdown);
130
const paths = [
131
...extractMarkdownLinkHrefs(renderCodexInlineDirectivesAsMarkdown(markdown)),
132
...extractInlineCodeSpans(markdown).flatMap((span) => inlineCodeFilePathCandidate(span) ?? []),
@@ -231,5 +240,6 @@ export function searchableMessageSegments(
240
cwd,
241
skills,
242
shouldPreserveAssistantLineBreaks(message.text),
243
+ true,
244
);
245
}