@@ -361,6 +361,29 @@ function Section({
361361 ) ;
362362}
363363
364+ function CommentGroup ( {
365+ label,
366+ children,
367+ onOpenChange,
368+ } : {
369+ label : ReactNode ;
370+ children : ReactNode ;
371+ onOpenChange ?: ( open : boolean ) => void ;
372+ } ) {
373+ return (
374+ < Collapsible className = "border-t border-border/60 pt-1" onOpenChange = { onOpenChange } >
375+ < CollapsibleTrigger className = "group flex w-full items-center gap-2 rounded-md px-2 py-2.5 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground" >
376+ < ChevronRightIcon
377+ aria-hidden
378+ className = "size-3.5 shrink-0 transition-transform group-data-panel-open:rotate-90"
379+ />
380+ < span > { label } </ span >
381+ </ CollapsibleTrigger >
382+ < CollapsiblePanel keepMounted > { children } </ CollapsiblePanel >
383+ </ Collapsible >
384+ ) ;
385+ }
386+
364387/**
365388 * What a first render of the conversation carries. A pull request with two hundred comments is
366389 * two hundred markdown documents, and the ones worth arriving for are the recent ones.
@@ -888,102 +911,90 @@ export function PullRequestSummaryTab({
888911 </ Button >
889912 ) : null }
890913 { botComments . length > 0 ? (
891- < Collapsible
914+ < CommentGroup
892915 key = { `bots:${ detail . url } ` }
893- className = "border-t border-border/60 pt-1"
916+ label = {
917+ < >
918+ { botComments . length } bot comment{ botComments . length === 1 ? "" : "s" }
919+ </ >
920+ }
894921 onOpenChange = { ( open ) => {
895922 if ( open ) setOpenedBotGroup ( detail . url ) ;
896923 } }
897924 >
898- < CollapsibleTrigger className = "group flex w-full items-center gap-2 rounded-md px-2 py-2.5 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground" >
899- < ChevronRightIcon
900- aria-hidden
901- className = "size-3.5 shrink-0 transition-transform group-data-panel-open:rotate-90"
902- />
903- < span >
904- { botComments . length } bot comment{ botComments . length === 1 ? "" : "s" }
905- </ span >
906- </ CollapsibleTrigger >
907- < CollapsiblePanel keepMounted >
908- < div className = "space-y-3 pt-2" >
909- { openedBotGroup === detail . url
910- ? orderPullRequestComments ( recentBotComments , commentOrder ) . map (
911- renderComment ,
912- )
913- : null }
914- { hiddenBotCommentCount > 0 ? (
915- < Button
916- size = "sm"
917- variant = "outline"
918- className = "w-full"
919- onClick = { ( ) =>
920- setShownBots ( {
921- url : detail . url ,
922- count : shownBotComments + COMMENT_PAGE ,
923- } )
924- }
925- >
926- Show { Math . min ( hiddenBotCommentCount , COMMENT_PAGE ) } older bot comment
927- { hiddenBotCommentCount === 1 ? "" : "s" } ({ hiddenBotCommentCount } { " " }
928- hidden)
929- </ Button >
930- ) : null }
931- { shownBotComments > COMMENT_PAGE ? (
932- < Button
933- size = "sm"
934- variant = "ghost"
935- className = "w-full"
936- onClick = { ( ) => setShownBots ( { url : detail . url , count : COMMENT_PAGE } ) }
937- >
938- Show only { COMMENT_PAGE } recent bot comments
939- </ Button >
940- ) : null }
941- </ div >
942- </ CollapsiblePanel >
943- </ Collapsible >
925+ < div className = "space-y-3 pt-2" >
926+ { openedBotGroup === detail . url
927+ ? orderPullRequestComments ( recentBotComments , commentOrder ) . map (
928+ renderComment ,
929+ )
930+ : null }
931+ { hiddenBotCommentCount > 0 ? (
932+ < Button
933+ size = "sm"
934+ variant = "outline"
935+ className = "w-full"
936+ onClick = { ( ) =>
937+ setShownBots ( {
938+ url : detail . url ,
939+ count : shownBotComments + COMMENT_PAGE ,
940+ } )
941+ }
942+ >
943+ Show { Math . min ( hiddenBotCommentCount , COMMENT_PAGE ) } older bot comment
944+ { hiddenBotCommentCount === 1 ? "" : "s" } ({ hiddenBotCommentCount } hidden)
945+ </ Button >
946+ ) : null }
947+ { shownBotComments > COMMENT_PAGE ? (
948+ < Button
949+ size = "sm"
950+ variant = "ghost"
951+ className = "w-full"
952+ onClick = { ( ) => setShownBots ( { url : detail . url , count : COMMENT_PAGE } ) }
953+ >
954+ Show only { COMMENT_PAGE } recent bot comments
955+ </ Button >
956+ ) : null }
957+ </ div >
958+ </ CommentGroup >
944959 ) : null }
945960 { finishedComments . length > 0 ? (
946- < Collapsible key = { detail . url } className = "border-t border-border/60 pt-1" >
947- < CollapsibleTrigger className = "group flex w-full items-center gap-2 rounded-md px-2 py-2.5 text-left text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground" >
948- < ChevronRightIcon
949- aria-hidden
950- className = "size-3.5 shrink-0 transition-transform group-data-panel-open:rotate-90"
951- />
952- < span >
961+ < CommentGroup
962+ key = { detail . url }
963+ label = {
964+ < >
953965 { finishedComments . length } resolved or dismissed comment
954966 { finishedComments . length === 1 ? "" : "s" }
955- </ span >
956- </ CollapsibleTrigger >
957- < CollapsiblePanel keepMounted >
958- < div className = "space-y-2 pt-2" >
959- { orderPullRequestComments ( finishedComments , commentOrder ) . map ( ( comment ) => {
960- const thread = threadByCommentId . get ( comment . id ) ;
961- return (
962- < CollapsedComment
963- key = { comment . id }
964- comment = { comment }
965- editing = { commentEditing }
966- detail = { detail }
967- thread = { thread }
968- label = { thread ?. isResolved ? "Resolved" : "Review dismissed" }
969- body = { visibleBody ( comment . body ) }
970- reactionBar = {
971- < PullRequestReactionBar
972- className = "ml-auto justify-end"
973- reactions = { comment . reactions ?? [ ] }
974- canReact = { detail . capabilities . reactions === true }
975- subjectId = { comment . id }
976- environmentId = { environmentId }
977- reference = { reference }
978- onRefresh = { onRefresh }
979- />
980- }
981- />
982- ) ;
983- } ) }
984- </ div >
985- </ CollapsiblePanel >
986- </ Collapsible >
967+ </ >
968+ }
969+ >
970+ < div className = "space-y-2 pt-2" >
971+ { orderPullRequestComments ( finishedComments , commentOrder ) . map ( ( comment ) => {
972+ const thread = threadByCommentId . get ( comment . id ) ;
973+ return (
974+ < CollapsedComment
975+ key = { comment . id }
976+ comment = { comment }
977+ editing = { commentEditing }
978+ detail = { detail }
979+ thread = { thread }
980+ label = { thread ?. isResolved ? "Resolved" : "Review dismissed" }
981+ body = { visibleBody ( comment . body ) }
982+ reactionBar = {
983+ < PullRequestReactionBar
984+ className = "ml-auto justify-end"
985+ reactions = { comment . reactions ?? [ ] }
986+ canReact = { detail . capabilities . reactions === true }
987+ subjectId = { comment . id }
988+ environmentId = { environmentId }
989+ reference = { reference }
990+ onRefresh = { onRefresh }
991+ />
992+ }
993+ />
994+ ) ;
995+ } ) }
996+ </ div >
997+ </ CommentGroup >
987998 ) : null }
988999 </ div >
9891000 ) }
0 commit comments