diff --git a/src/renderer/src/components/right-sidebar/pr-comment-presentation.test.ts b/src/renderer/src/components/right-sidebar/pr-comment-presentation.test.ts index b85c7085d..388ad914d 100644 --- a/src/renderer/src/components/right-sidebar/pr-comment-presentation.test.ts +++ b/src/renderer/src/components/right-sidebar/pr-comment-presentation.test.ts @@ -15,8 +15,8 @@ describe('pr-comment-presentation', () => { it('returns card layout tokens for cards and focus variants', () => { const cards = getPRCommentPresentationClasses('cards') expect(cards.useCardLayout).toBe(true) - expect(cards.commentBody).toContain('text-xs') - expect(cards.commentBody).toContain('leading-5') + expect(cards.commentBody).toContain('text-[13px]') + expect(cards.commentBody).toContain('leading-relaxed') expect(cards.commentBody).toContain('text-foreground') expect(cards.group).toContain('bg-secondary') expect(cards.group).toContain('shadow-xs') @@ -25,10 +25,10 @@ describe('pr-comment-presentation', () => { const focus = getPRCommentPresentationClasses('focus') expect(focus.useCardLayout).toBe(true) - expect(focus.commentBody).toContain('text-xs') - expect(focus.commentBody).toContain('leading-5') - expect(focus.commentBodyReply).toContain('text-xs') - expect(focus.commentBodyReply).toContain('leading-5') + expect(focus.commentBody).toContain('text-[13px]') + expect(focus.commentBody).toContain('leading-relaxed') + expect(focus.commentBodyReply).toContain('text-[13px]') + expect(focus.commentBodyReply).toContain('leading-relaxed') expect(focus.author).toContain('text-[13px]') expect(focus.list).toContain('gap-2') expect(focus.commentBody).toContain('px-4 py-2.5') @@ -39,6 +39,66 @@ describe('pr-comment-presentation', () => { expect(focus.commentHeaderMetaWithSelection).toContain('pl-[3.25rem]') }) + it('restores block flow for span-rendered markdown paragraphs and headings', () => { + for (const variant of ['cards', 'focus', 'flat'] as const) { + const markdown = getPRCommentPresentationClasses(variant).commentBodyMarkdown + // The compact renderer emits no
, so a [&_p] rule would be dead code.
+ expect(markdown).not.toContain('[&_p]:')
+ expect(markdown).toContain('[&_.comment-md-p]:block')
+ expect(markdown).toContain('[&_.comment-md-p+.comment-md-p]:mt-2')
+ // Rhythm must key off every top-level block: a stacks two -0.25em shifts; text subscripts keep theirs.
+ expect(markdown).toContain('[&_sub:has(img)]:bottom-0')
+ expect(markdown).toContain('[&_sub:has(img)]:align-middle')
+ expect(markdown).not.toContain('[&_sub]:bottom-0')
+ })
+
+ it('gives headings a perceptible step over the 13px body', () => {
+ const markdown = getPRCommentPresentationClasses('cards').commentBodyMarkdown
+ // 13px headings over a 12px body was a 1.08x ratio — invisible. Match the
+ // document variant's scale instead.
+ expect(markdown).toContain('[&_.comment-md-h1]:text-[18px]')
+ expect(markdown).toContain('[&_.comment-md-h2]:text-[16px]')
+ expect(markdown).toContain('[&_.comment-md-h3]:text-[15px]')
+ expect(markdown).not.toContain('[&_.comment-md-h1]:text-[13px]')
+ })
+
+ it('promotes bold-then-linebreak labels but not mid-sentence emphasis', () => {
+ const markdown = getPRCommentPresentationClasses('cards').commentBodyMarkdown
+ const label = '[&_.comment-md-p>strong:first-child:has(+br)'
+ expect(markdown).toContain(`${label}]:text-[15px]`)
+ expect(markdown).toContain(`${label}]:block`)
+ expect(markdown).toContain('[&_.comment-md-p:first-child>strong:first-child:has(+br)]:mt-0')
+ // Blocking the label makes its own
a duplicate break.
+ expect(markdown).toContain(`${label}+br]:hidden`)
+ })
+
it('preserves the legacy flat layout tokens', () => {
const flat = getPRCommentPresentationClasses('flat')
expect(flat.useCardLayout).toBe(false)
diff --git a/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts b/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts
index 6ce3560f6..aa754f61e 100644
--- a/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts
+++ b/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts
@@ -72,8 +72,36 @@ export function getPRCommentGroupSurfaceClasses(
return classes.join(' ')
}
-const MARKDOWN_BASE =
- 'break-words [&_p]:my-1.5 [&_pre]:max-h-none [&_pre]:max-w-full [&_pre]:whitespace-pre-wrap [&_table]:w-full [&_table]:max-w-full'
+// Why: compact p/h spans weld onto one line; scope block flow here so the
+// renderer's other consumers retain their dense layout.
+const MARKDOWN_BASE = cn(
+ 'break-words',
+ // Why: rhythm keys off every top-level block, not adjacent paragraphs — a
would double the break once it is block-level.
+ '[&_.comment-md-p>strong:first-child:has(+br)+br]:hidden',
+ // Why: compact sizes code/pre/tables at 10px inside the prose, shrinking the densest
+ // content. 0.92em mirrors the document variant's inline-code ratio.
+ '[&_code]:text-[0.92em] [&_pre]:text-xs [&_pre_code]:text-[1em] [&_table]:text-[12px]',
+ // Why: bots use sub/sup as small-print, and the browser's 75% compounds when nested
+ // (13px -> 7.3px). An absolute size stops the compounding at the caption tier.
+ '[&_sub]:text-[11px] [&_sup]:text-[11px]',
+ // Why: a badge wrapped in inherits both -0.25em shifts (5.5px of sag).
+ // Only neutralize wrappers holding an image; real text subscripts keep their offset.
+ '[&_sub:has(img)]:bottom-0 [&_sub:has(img)]:align-middle',
+ '[&_sup:has(img)]:top-0 [&_sup:has(img)]:align-middle',
+ '[&_pre]:max-h-none [&_pre]:max-w-full [&_pre]:whitespace-pre-wrap',
+ '[&_table]:w-full [&_table]:max-w-full'
+)
// Why: in light mode card and canvas are both #fff, so border-border alone disappears.
// overflow-clip preserves rounded clipping without letting focused row actions scroll content.
@@ -89,8 +117,9 @@ const COMMENT_AVATAR =
const RESOLVED_SECTION_LABEL =
'text-[11px] font-semibold uppercase tracking-wider text-muted-foreground'
-// Why: markdown bodies need the secondary sidebar scale; 13px relaxed copy reads oversized in narrow comment cards.
-const CARD_COMMENT_BODY_SIZE = 'text-xs leading-5'
+// Why: matches the document-variant body (PullRequestPage/GitHubItemDialog) so the same
+// bot markdown reads the same everywhere; 12px left no room for a heading step above it.
+const CARD_COMMENT_BODY_SIZE = 'text-[13px] leading-relaxed'
const CARD_COMMENT_AUTHOR_SIZE = 'text-[13px]'
const CARD_COMMENT_LIST_GAP = 'gap-2'
const CARD_COMMENT_BODY_PADDING = 'px-4 py-2.5'
diff --git a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx
index b64d10a04..4ca6323a8 100644
--- a/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx
+++ b/src/renderer/src/components/sidebar/CommentMarkdown.test.tsx
@@ -3,6 +3,33 @@ import { describe, expect, it } from 'vitest'
import CommentMarkdown, { remarkGitHubReferences } from './CommentMarkdown'
describe('CommentMarkdown', () => {
+ it('marks compact headings so a parent can opt into block flow', () => {
+ const markup = renderToStaticMarkup(
+ More
\n\nFirst paragraph.\n\nSecond paragraph.\n\n'
+ }
+ />
+ )
+
+ expect(markup).toContain(
+ 'First paragraph.\nSecond paragraph.'
+ )
+ })
+
it('autolinks same-repo GitHub issue references when repo context is provided', () => {
const markup = renderToStaticMarkup(
,
// Compact blockquotes