diff --git a/src/renderer/src/components/right-sidebar/checks-panel/comment-row.tsx b/src/renderer/src/components/right-sidebar/checks-panel/comment-row.tsx index c9cd3dfe477..f0a9ec75971 100644 --- a/src/renderer/src/components/right-sidebar/checks-panel/comment-row.tsx +++ b/src/renderer/src/components/right-sidebar/checks-panel/comment-row.tsx @@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useState } from 'react' import { Button } from '@/components/ui/button' import { cn } from '@/lib/utils' import CommentMarkdown from '@/components/sidebar/CommentMarkdown' +import { reviewCommentMarkdown } from './review-comment-markdown' import { CommentReactions } from '@/components/github/CommentReactions' import { isBotPRComment } from '../../../../../shared/pr-comment-audience' import type { GitHubReactionContent, PRComment } from '../../../../../shared/github/comment-types' @@ -322,7 +323,11 @@ export function CommentRow({ ) : (
- + Minor** · **Functional Correctness** · **Quick win** + +
Supported by static analysis + +The callback then discards the result from \`openChromeWebStore()\`. + +
+ +**Handle rejected Web Store tab creation before completing the tour.** + +\`performContextualTourStepAction\` calls \`finishTour()\` before it schedules \`openChromeWebStore()\`. + +** Major** · **Security & Privacy** + +** Critical** · **Functional Correctness**` + +export const narrow = defineFixture({ + width: 360, + render: () => ( +
+
+ +
+
+ ) +}) + +export const expanded = defineFixture({ + ...narrow, + width: 540, + interact: (frame) => { + frame.querySelector('summary')?.click() + } +}) diff --git a/src/renderer/src/components/right-sidebar/checks-panel/review-comment-markdown.test.tsx b/src/renderer/src/components/right-sidebar/checks-panel/review-comment-markdown.test.tsx new file mode 100644 index 00000000000..b3c73c2a35d --- /dev/null +++ b/src/renderer/src/components/right-sidebar/checks-panel/review-comment-markdown.test.tsx @@ -0,0 +1,102 @@ +import { renderToStaticMarkup } from 'react-dom/server' +import { describe, expect, it } from 'vitest' +import CommentMarkdown from '@/components/sidebar/CommentMarkdown' +import { reviewCommentMarkdown } from './review-comment-markdown' + +const iconBase = 'https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/' + +describe('review comment icons', () => { + it('renders CodeRabbit picture icons locally without loading images or source sets', () => { + const markup = renderToStaticMarkup( + Minor** · **Functional Correctness** · **Quick win** + +
Supported by static analysis + +Handle rejected Web Store tab creation before completing the tour. + +
`} + /> + ) + + expect(markup.match(/') + expect(markup).toContain('Supported by static analysis') + expect(markup).toContain('Handle rejected Web Store tab creation') + expect(markup).not.toMatch(/ { + const markup = renderToStaticMarkup( + + ) + expect(markup).toContain(' { + const markup = renderToStaticMarkup( + + ) + expect(markup).toContain('href="https://example.com/unknown.svg"') + expect(markup).toContain('>External image') + expect(markup).not.toMatch(/ { + const markup = renderToStaticMarkup( + + ) + expect(markup).toContain('>External image') + expect(markup).not.toMatch(/ { + const otherSurface = renderToStaticMarkup( + + ) + expect(otherSurface).toContain(`href="${iconBase}amber-16.svg"`) + expect(otherSurface).not.toContain(' + ) + expect(review).toContain('([ + ['book-open', BookOpen], + ['bot', Bot], + ['brush-cleaning', BrushCleaning], + ['ci-failure', CircleX], + ['clock-alert', ClockAlert], + ['cog', Cog], + ['common-learnings', BookOpen], + ['file-minus-corner', FileMinusCorner], + ['file-no-changes', FileCheck], + ['file-plus-corner', FilePlusCorner], + ['file-similar', Files], + ['file-too-large', FileWarning], + ['file-unavailable', FileX], + ['folders', Folders], + ['git-commit-horizontal', GitCommitHorizontal], + ['individual-learning', UserRound], + ['info', Info], + ['layers-plus', LayersPlus], + ['learnings', BookOpen], + ['linked-repositories', Link], + ['message-square-more', MessageSquareMore], + ['message-square-off', MessageSquareOff], + ['message-square-x', MessageSquareX], + ['network', Network], + ['plug', Plug], + ['review-details', SearchCode], + ['route', Route], + ['shield-plus', ShieldPlus], + ['wrench', Wrench] +]) + +const severityIcons = new Map([ + ['amber', CircleAlert], + ['critical', TriangleAlert], + ['high', TriangleAlert], + ['informational', Info], + ['major', TriangleAlert], + ['neutral', CircleMinus], + ['priority-low', CircleMinus], + ['priority-normal', CircleAlert], + ['priority-urgent', TriangleAlert], + ['risk-high', ShieldAlert], + ['risk-low', ShieldCheck], + ['risk-normal', ShieldAlert], + ['risk-unassessed', ShieldQuestion], + ['risk-urgent', ShieldAlert] +]) + +const CompactImage = compactCommentMarkdownComponents.img + +const components: Components = { + picture: ({ children }) => <>{children}, + source: () => null, + img: ({ src, alt }) => { + // Substitute local icons; review comments must not gain a remote-image fetch path. + const name = src + ?.match( + /^https:\/\/storage\.googleapis\.com\/coderabbit_public_assets\/review-comment-icons-v1\/([a-z0-9-]+)\.svg$/ + )?.[1] + ?.replace(/-dark$/, '') + const severity = name?.match(/^(.+)-(?:16|20)$/)?.[1] + const Icon = name + ? (icons.get(name) ?? (severity ? severityIcons.get(severity) : undefined)) + : undefined + if (!Icon) { + return CompactImage ? : null + } + + const color = + severity === 'critical' || severity?.endsWith('urgent') + ? 'text-destructive' + : severity === 'amber' || + severity === 'major' || + severity === 'high' || + severity === 'risk-high' + ? 'text-status-warning-text' + : 'text-muted-foreground' + + return ( + + + ) + } +} + +export const reviewCommentMarkdown: CommentMarkdownExtension = { + remarkPlugins: [], + sanitizeAttributes: {}, + components +} 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 6a738242f9a..35d8614a469 100644 --- a/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts +++ b/src/renderer/src/components/right-sidebar/pr-comment-presentation.ts @@ -88,9 +88,9 @@ const MARKDOWN_BASE = cn( '[&_code]:text-[0.92em] [&_pre]:text-xs [&_pre_code]:text-[1em] [&_table]:text-[12px]', // Use absolute caption sizes because nested sub/sup percentages compound into illegible text. '[&_sub]:text-[11px] [&_sup]:text-[11px]', - // Nested sub wrappers compound image offsets; neutralize only image wrappers, preserving real subscripts. - '[&_sub:has(img)]:bottom-0 [&_sub:has(img)]:align-middle', - '[&_sup:has(img)]:top-0 [&_sup:has(img)]:align-middle', + // Nested sub wrappers compound image/icon offsets; preserve real subscripts. + '[&_sub:has(img,svg)]:bottom-0 [&_sub:has(img,svg)]:align-middle', + '[&_sup:has(img,svg)]:top-0 [&_sup:has(img,svg)]:align-middle', '[&_pre]:max-h-none [&_pre]:max-w-full [&_pre]:whitespace-pre-wrap', '[&_table]:w-full [&_table]:max-w-full' ) diff --git a/src/renderer/src/components/sidebar/comment-markdown-element-renderers.tsx b/src/renderer/src/components/sidebar/comment-markdown-element-renderers.tsx index 3d7ada8158f..21afc08d1e2 100644 --- a/src/renderer/src/components/sidebar/comment-markdown-element-renderers.tsx +++ b/src/renderer/src/components/sidebar/comment-markdown-element-renderers.tsx @@ -225,7 +225,7 @@ export function createCompactCommentMarkdownComponents(
) - } + } satisfies Components } export function createDocumentCommentMarkdownComponents(