@@ -10,6 +10,7 @@ import { useState } from "react";
1010import { reviewLineRangeLabel } from "@t3tools/client-runtime/review-selection" ;
1111import { Button } from "../ui/button" ;
1212import { Badge } from "../ui/badge" ;
13+ import { Toggle , ToggleGroup } from "../ui/toggle-group" ;
1314import { Popover , PopoverPopup , PopoverTrigger , PopoverTitle } from "../ui/popover" ;
1415import {
1516 getReviewPositionAnchor ,
@@ -47,7 +48,9 @@ export function PullRequestCommentsPopover({
4748 onAddPendingToComposer ?: ( ( comment : PendingReviewComment ) => void ) | undefined ;
4849} ) {
4950 const [ open , setOpen ] = useState ( false ) ;
50- const [ showResolved , setShowResolved ] = useState ( false ) ;
51+ const [ selectedStatus , setSelectedStatus ] = useState < "resolved" | "unresolved" | "pending" > (
52+ "unresolved" ,
53+ ) ;
5154 const pending = usePendingReviewComments ( reference , detail . reviewThreads ) ;
5255 const actions = useReviewThreadActions ( environmentId , reference , detail , onRefresh ) ;
5356 // Hosted drafts are represented by the merged pending list, so they get one checklist entry.
@@ -58,6 +61,11 @@ export function PullRequestCommentsPopover({
5861 const unresolved = threads . filter ( ( thread ) => ! thread . isResolved ) ;
5962 const resolved = threads . filter ( ( thread ) => thread . isResolved ) ;
6063 const openCount = unresolved . length + pending . length ;
64+ const status =
65+ selectedStatus === "pending" && pending . length === 0 ? "unresolved" : selectedStatus ;
66+ if ( status !== selectedStatus ) setSelectedStatus ( status ) ;
67+ const visibleThreads =
68+ status === "resolved" ? resolved : status === "unresolved" ? unresolved : [ ] ;
6169 const jump = ( location : CommentLocation ) => {
6270 setOpen ( false ) ;
6371 onOpenComment ( location ) ;
@@ -75,12 +83,9 @@ export function PullRequestCommentsPopover({
7583 </ Badge >
7684 </ PopoverTrigger >
7785 < PopoverPopup align = "end" padding = "none" width = "auto" >
78- < div className = "flex max-h-[min(75vh,48rem)] w-[min(32rem ,calc(100vw-2rem))] flex-col" >
86+ < div className = "flex max-h-[min(75vh,48rem)] w-[min(36rem ,calc(100vw-2rem))] min-w-0 flex-col" >
7987 < div className = "flex items-center gap-2 border-b border-border/60 px-3 py-2" >
8088 < PopoverTitle > Comments</ PopoverTitle >
81- < span className = "text-xs text-muted-foreground" >
82- { unresolved . length } unresolved · { pending . length } pending
83- </ span >
8489 < Button
8590 size = "icon-xs"
8691 variant = "ghost-muted"
@@ -91,15 +96,50 @@ export function PullRequestCommentsPopover({
9196 < XIcon className = "size-3.5" />
9297 </ Button >
9398 </ div >
94- < div className = "min-h-0 overflow-y-auto py-2" >
99+ < div className = "border-b border-border/60 px-3 py-2" >
100+ < ToggleGroup
101+ variant = "segmented"
102+ className = "w-full"
103+ aria-label = "Comment status"
104+ value = { [ status ] }
105+ onValueChange = { ( values ) => {
106+ const next = values [ 0 ] ;
107+ if ( next === "resolved" || next === "unresolved" || next === "pending" )
108+ setSelectedStatus ( next ) ;
109+ } }
110+ >
111+ < Toggle value = "unresolved" className = "flex-1" >
112+ Unresolved{ " " }
113+ < Badge variant = "secondary" size = "sm" >
114+ { unresolved . length }
115+ </ Badge >
116+ </ Toggle >
117+ < Toggle value = "resolved" className = "flex-1" >
118+ Resolved{ " " }
119+ < Badge variant = "secondary" size = "sm" >
120+ { resolved . length }
121+ </ Badge >
122+ </ Toggle >
123+ { pending . length > 0 ? (
124+ < Toggle value = "pending" className = "flex-1" >
125+ Pending{ " " }
126+ < Badge variant = "secondary" size = "sm" >
127+ { pending . length }
128+ </ Badge >
129+ </ Toggle >
130+ ) : null }
131+ </ ToggleGroup >
132+ </ div >
133+ < div className = "min-h-0 min-w-0 overflow-x-hidden overflow-y-auto py-2 [overflow-wrap:anywhere]" >
95134 { open ? (
96135 < >
97- { [ ... unresolved , ... ( showResolved ? resolved : [ ] ) ] . map ( ( thread ) => (
136+ { visibleThreads . map ( ( thread ) => (
98137 < div key = { thread . id } >
99138 < div className = "mx-3 mt-2" >
100139 < Button
101140 size = "xs"
102141 variant = "ghost-muted"
142+ className = "max-w-full"
103143 onClick = { ( ) =>
104144 jump ( {
105145 path : thread . path ,
@@ -132,12 +172,13 @@ export function PullRequestCommentsPopover({
132172 />
133173 </ div >
134174 ) ) }
135- { pending . map ( ( comment ) => (
175+ { ( status === " pending" ? pending : [ ] ) . map ( ( comment ) => (
136176 < div key = { comment . id } >
137177 < div className = "mx-3 mt-2" >
138178 < Button
139179 size = "xs"
140180 variant = "ghost-muted"
181+ className = "max-w-full"
141182 onClick = { ( ) =>
142183 jump ( {
143184 path : comment . path ,
@@ -163,24 +204,12 @@ export function PullRequestCommentsPopover({
163204 />
164205 </ div >
165206 ) ) }
166- { openCount === 0 && ( ! showResolved || resolved . length === 0 ) ? (
167- < p className = "px-4 py-5 text-sm text-muted-foreground" > No open comments.</ p >
207+ { visibleThreads . length === 0 && ( status !== "pending" || pending . length === 0 ) ? (
208+ < p className = "px-4 py-5 text-sm text-muted-foreground" > No { status } comments.</ p >
168209 ) : null }
169210 </ >
170211 ) : null }
171212 </ div >
172- { resolved . length ? (
173- < div className = "border-t border-border/60 px-3 py-2" >
174- < Button
175- size = "xs"
176- variant = "ghost-muted"
177- onClick = { ( ) => setShowResolved ( ( previous ) => ! previous ) }
178- >
179- { showResolved ? "Hide" : "Show" } { resolved . length } resolved{ " " }
180- { resolved . length === 1 ? "thread" : "threads" }
181- </ Button >
182- </ div >
183- ) : null }
184213 </ div >
185214 </ PopoverPopup >
186215 </ Popover >
0 commit comments