From 2b0a4aaa5a6af6750f892a1aec382c7ff486305e Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Sun, 16 Aug 2026 20:35:09 -0700 Subject: [PATCH] refactor(native-chat): hoist the prose remark plugin list to module scope Every chat row renders through one of the two lists, so build both once instead of allocating a fresh array per CommentMarkdown instance. --- src/renderer/src/components/sidebar/CommentMarkdown.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/components/sidebar/CommentMarkdown.tsx b/src/renderer/src/components/sidebar/CommentMarkdown.tsx index 4db2ed35411..7d2abee36b3 100644 --- a/src/renderer/src/components/sidebar/CommentMarkdown.tsx +++ b/src/renderer/src/components/sidebar/CommentMarkdown.tsx @@ -62,6 +62,9 @@ const commentMarkdownFileUriUrlTransform: UrlTransform = (value, key, node) => { // remark-breaks converts single newlines to
, keeping backward compat // with existing plain-text comments that rely on newline formatting. const remarkPlugins = [remarkGfm, remarkBreaks] +// Every chat row renders one of these, so keep both lists module-level rather +// than allocating a fresh array per instance. +const proseRemarkPlugins = [...remarkPlugins, remarkDisableDefinitions] const GITHUB_REFERENCE_PATTERN = /(?:\b([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+))?#([1-9][0-9]*)\b/g @@ -223,10 +226,8 @@ const CommentMarkdown = React.memo( : createCompactCommentMarkdownComponents(onLinkClick, expandImages) }, [expandImages, variant, onLinkClick]) const activeRemarkPlugins = React.useMemo(() => { - const active = githubRepo - ? [...remarkPlugins, remarkGitHubReferences(githubRepo)] - : remarkPlugins - return disableLinkDefinitions ? [...active, remarkDisableDefinitions] : active + const base = disableLinkDefinitions ? proseRemarkPlugins : remarkPlugins + return githubRepo ? [...base, remarkGitHubReferences(githubRepo)] : base }, [disableLinkDefinitions, githubRepo]) return (