From c5e69a7415849469977b5820f6caaed41b89a3b2 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 06:37:38 -0700 Subject: [PATCH] fix: handle large comment markdown references (#3699) --- .../sidebar/CommentMarkdown.test.tsx | 29 ++++++++++++++++++- .../components/sidebar/CommentMarkdown.tsx | 6 +++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx index 0c632615285..e39f528552a 100644 --- a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx +++ b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx @@ -1,6 +1,6 @@ import { renderToStaticMarkup } from 'react-dom/server' import { describe, expect, it } from 'vitest' -import CommentMarkdown from './CommentMarkdown' +import CommentMarkdown, { remarkGitHubReferences } from './CommentMarkdown' describe('CommentMarkdown', () => { it('autolinks same-repo GitHub issue references when repo context is provided', () => { @@ -42,6 +42,33 @@ describe('CommentMarkdown', () => { expect(markup).not.toContain('href="https://github.com/stablyai/orca/issues/2317"') }) + it('autolinks very large generated GitHub reference comments', () => { + const referenceCount = 130_000 + const tree = { + type: 'root', + children: [ + { + type: 'paragraph', + children: [ + { + type: 'text', + value: Array.from({ length: referenceCount }, (_, index) => `#${index + 1}`).join(' ') + } + ] + } + ] + } + + const transform = remarkGitHubReferences({ owner: 'stablyai', repo: 'orca' })() + + expect(() => transform(tree)).not.toThrow() + expect(tree.children[0]?.children).toHaveLength(referenceCount * 2 - 1) + expect(tree.children[0]?.children[0]).toMatchObject({ + type: 'link', + url: 'https://github.com/stablyai/orca/issues/1' + }) + }) + it('contains long PR body markdown inside its available width', () => { const markup = renderToStaticMarkup(