Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webview-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"react-virtuoso": "^4.7.13",
"rehype-highlight": "^7.0.0",
"rehype-katex": "^7.0.1",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"remove-markdown": "^0.6.0",
Expand Down
2 changes: 2 additions & 0 deletions webview-ui/src/components/common/MarkdownBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { visit } from "unist-util-visit"
import rehypeKatex from "rehype-katex"
import remarkMath from "remark-math"
import remarkGfm from "remark-gfm"
import remarkBreaks from "remark-breaks"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a brief comment explaining why this plugin was added, for future maintainers:

Suggested change
import remarkBreaks from "remark-breaks"
import remarkBreaks from "remark-breaks" // Converts line breaks in markdown to <br> tags for better rendering in thinking output


import { vscode } from "@src/utils/vscode"

Expand Down Expand Up @@ -289,6 +290,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => {
remarkPlugins={[
remarkGfm,
remarkMath,
remarkBreaks,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a test case for line break rendering in the existing test file at webview-ui/src/components/common/__tests__/MarkdownBlock.spec.tsx. This would help ensure the remark-breaks plugin works as expected and prevent regressions.

For example:

it('should render line breaks correctly with remark-breaks', async () => {
  const markdown = 'First line\nSecond line\nThird line';
  const { container } = render(<MarkdownBlock markdown={markdown} />);
  
  // Wait for content to be processed
  await screen.findByText(/First line/, { exact: false });
  
  // Check that line breaks are rendered as <br> tags
  const brElements = container.querySelectorAll('br');
  expect(brElements.length).toBe(2);
});

Also, I noticed that the p tag styling already has white-space: pre-wrap (line 119), which preserves line breaks. Could this potentially conflict with or duplicate the behavior of remark-breaks? It might be worth verifying that these two approaches work well together.

() => {
return (tree: any) => {
visit(tree, "code", (node: any) => {
Expand Down
Loading