Elffuss BraidHub

kikocis/continue public

feat: parse for thinking tags and grey them
Changesetac220e7e5ff5bff20e44b930a04804d3a95cb3d2edfcf51f2a39afa8c59e3b8b
AuthorTing-Wai To <40179554+tingwai@users.noreply.github.com> · 2025-09-09 13:11 -07:00
CommitterTing-Wai To <40179554+tingwai@users.noreply.github.com> · 2025-09-09 13:47 -07:00
Parentsa5d630b3ddc6

Browse the files at this changeset

2 files changed

added extensions/cli/src/ui/MarkdownRenderer.thinking.test.tsx +36 −0
@@ -0,0 +1,36 @@
1+import { render } from "ink-testing-library";
2+import React from "react";
3+
4+import { MarkdownRenderer } from "./MarkdownRenderer.js";
5+
6+describe("MarkdownRenderer - thinking tags", () => {
7+ it("handles multiple thinking tags", () => {
8+ const content =
9+ "Text <think>First thought</think> middle <think>Second thought</think> end";
10+ const { lastFrame } = render(<MarkdownRenderer content={content} />);
11+
12+ expect(lastFrame()).toContain("First thought");
13+ expect(lastFrame()).toContain("Second thought");
14+ });
15+
16+ it("handles thinking tags with multiline content", () => {
17+ const content = `<think>
18+ This is a multiline
19+ thinking block
20+ </think>`;
21+ const { lastFrame } = render(<MarkdownRenderer content={content} />);
22+
23+ expect(lastFrame()).toContain("This is a multiline");
24+ expect(lastFrame()).toContain("thinking block");
25+ });
26+
27+ it("ignores thinking tags inside code blocks", () => {
28+ const content = "```\n<think>This should not be processed</think>\n```";
29+ const { lastFrame } = render(<MarkdownRenderer content={content} />);
30+
31+ // The thinking tag should appear as literal text within the code block
32+ expect(lastFrame()).toContain(
33+ "<think>This should not be processed</think>",
34+ );
35+ });
36+});
modified extensions/cli/src/ui/MarkdownRenderer.tsx +11 −4
@@ -2,10 +2,10 @@
22 import React from "react";
33
44 import {
5- highlightCode,
5+ defaultTheme,
66 detectLanguage,
7+ highlightCode,
78 SyntaxHighlighterTheme,
8- defaultTheme,
99 } from "./SyntaxHighlighter.js";
1010
1111 interface MarkdownRendererProps {
@@ -28,6 +28,14 @@
2828 return null; // This will be handled separately
2929 },
3030 },
31+ {
32+ regex: /<think>([\s\S]*?)<\/think>/g,
33+ render: (content, key) => (
34+ <Text key={key} color="gray">
35+ {content.trim()}
36+ </Text>
37+ ),
38+ },
3139 {
3240 regex: /^(#{1,6})\s+(.+)$/gm,
3341 render: (content, key) => (
@@ -225,6 +233,5 @@
225233
226234 MarkdownRenderer.displayName = "MarkdownRenderer";
227235
228-export { MarkdownRenderer };
236+export { defaultTheme, MarkdownRenderer };
229237 export type { SyntaxHighlighterTheme };
230-export { defaultTheme };