Skip to content
Sign in
CodeReview commentMenu

Review commentPro

One review comment from an agent, anchored to its lines: the code around them, a bracket in the severity's hue, the rationale and a suggested fix in place. Apply, dismiss with a reason, or discuss.

ProA critical finding on a payout split, bracketed on its lines with the fix in place. Ask why and the reviewer answers; Apply lands it.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/review-comment

Usage

tsx
import { ReviewComment } from "@/components/ui/chatcn/pro/review-comment"

<ReviewComment
  severity="critical"
  title="A ledger with every weight at 0 loses the payout"
  path="src/payouts/allocate.ts"
  line={18}
  code={excerpt}
  codeStart={17}
  suggestion={fix}
  onApply={apply}
/>

Pass the lines around the anchor as code with codeStart, and the anchored range as line and endLine. A suggestion replaces the anchored lines and shows in place as red and green. state moves through open, applying, applied, dismissed and outdated; for a pull request's full review use Pull request review.

Examples

States

ProStill writing, a nit with no suggestion, applied, dismissed, outdated, a failed apply and loading.

Props

PropTypeNotes
severity"critical" | "warning" | "suggestion" | "nit"A glyph and a word, hue as backup
title, rationaleReactNodeWhat is wrong, and why
path, line, endLinestring, numberThe anchor
code, codeStartstring, numberContext lines and the number of the first
suggestionstringReplacement for the anchored lines
author{ name, kind?: "agent" | "person" }
stateReviewCommentStateDefault open
dismissReason, appliedInDismissReason, stringShown on a closed comment
errorReactNodeWhy Apply failed, with how to fix it
streaming, loading, disabledboolean
replies, onReplyReviewReply[], (text) => voidThe discussion
discussOpen, defaultDiscussOpen, onDiscussOpenChangeboolean
onApply, onDismiss, onUndo, onLineSelectonDismiss receives the reason

Keyboard

KeyAction
TabApply suggestion, Discuss, Dismiss
EnterSend a reply
Shift EnterNew line in a reply

Accessibility

  • The comment is an article named by its title, with the severity read first. The anchored range is read as Commented lines, and diff lines as Added and Removed.
  • Dismiss is a menu of reasons, so the reviewer learns why. Replies are a polite live region; a reply never sends while an IME is composing.

Motion

The discussion rises 4 px over 180 ms. Applying swaps the lines in place with no animation, so the code never moves under the reader. Reduced motion drops the travel.