@@ -4,9 +4,11 @@ import {
44 type ProviderApprovalOption ,
55} from "@t3tools/contracts" ;
66import { memo } from "react" ;
7- import { TriangleAlertIcon } from "lucide-react" ;
7+ import { EllipsisIcon , TriangleAlertIcon } from "lucide-react" ;
88import { Button } from "../ui/button" ;
9+ import { Menu , MenuItem , MenuPopup , MenuTrigger } from "../ui/menu" ;
910import { Tooltip , TooltipPopup , TooltipTrigger } from "../ui/tooltip" ;
11+ import { composerFloatingLayerProps } from "./composerEventScope" ;
1012
1113interface ComposerPendingApprovalActionsProps {
1214 requestId : ApprovalRequestId ;
@@ -18,7 +20,6 @@ interface ComposerPendingApprovalActionsProps {
1820 ) => Promise < unknown > ;
1921}
2022
21- const APPROVAL_ACTION_CLASS_NAME = "font-normal" ;
2223const DEFAULT_APPROVAL_OPTIONS = [
2324 { decision : "cancel" , label : "Cancel" } ,
2425 { decision : "decline" , label : "Decline" } ,
@@ -32,23 +33,21 @@ export const ComposerPendingApprovalActions = memo(function ComposerPendingAppro
3233 options = DEFAULT_APPROVAL_OPTIONS ,
3334 onRespondToApproval,
3435} : ComposerPendingApprovalActionsProps ) {
36+ const primaryOptions = options . filter (
37+ ( option ) => option . decision === "decline" || option . decision === "accept" ,
38+ ) ;
39+ const moreOptions = options . filter (
40+ ( option ) => option . decision !== "decline" && option . decision !== "accept" ,
41+ ) ;
42+
3543 return (
3644 < >
37- { options . map ( ( option ) => {
45+ { primaryOptions . map ( ( option ) => {
3846 const button = (
3947 < Button
4048 key = { option . decision }
41- size = "micro"
42- variant = "ghost-muted"
43- className = { `${ APPROVAL_ACTION_CLASS_NAME } ${
44- option . decision === "decline"
45- ? " text-destructive-foreground [:hover,[data-pressed]]:text-destructive-foreground"
46- : option . decision === "accept"
47- ? " text-foreground"
48- : option . warning
49- ? " text-warning"
50- : ""
51- } `}
49+ size = "xs"
50+ variant = { option . decision === "accept" ? "default" : "outline" }
5251 disabled = { isResponding }
5352 aria-description = { option . warning }
5453 onClick = { ( ) => void onRespondToApproval ( requestId , option . decision ) }
@@ -57,8 +56,6 @@ export const ComposerPendingApprovalActions = memo(function ComposerPendingAppro
5756 < span className = "max-w-40 truncate" > { option . label } </ span >
5857 </ Button >
5958 ) ;
60- // A provider caution, such as a prompt injection warning on "allow
61- // always", rides along as a tooltip so the row stays one line.
6259 return option . warning ? (
6360 < Tooltip key = { option . decision } >
6461 < TooltipTrigger render = { button } />
@@ -70,6 +67,48 @@ export const ComposerPendingApprovalActions = memo(function ComposerPendingAppro
7067 button
7168 ) ;
7269 } ) }
70+ { moreOptions . length > 0 ? (
71+ < Menu >
72+ < MenuTrigger
73+ disabled = { isResponding }
74+ render = { < Button size = "icon-xs" variant = "outline" aria-label = "More approval options" /> }
75+ >
76+ < EllipsisIcon />
77+ </ MenuTrigger >
78+ < MenuPopup
79+ { ...composerFloatingLayerProps }
80+ side = "top"
81+ align = "end"
82+ className = "w-56 max-w-[calc(100vw-2rem)]"
83+ >
84+ { moreOptions . map ( ( option ) => {
85+ const item = (
86+ < MenuItem
87+ key = { option . decision }
88+ disabled = { isResponding }
89+ aria-description = { option . warning }
90+ onClick = { ( ) => void onRespondToApproval ( requestId , option . decision ) }
91+ variant = "ghost"
92+ className = "mb-1 last:mb-0"
93+ >
94+ { option . warning ? < TriangleAlertIcon className = "size-3 text-warning" /> : null }
95+ < span className = "min-w-0 whitespace-normal wrap-break-word" > { option . label } </ span >
96+ </ MenuItem >
97+ ) ;
98+ return option . warning ? (
99+ < Tooltip key = { option . decision } >
100+ < TooltipTrigger render = { item } />
101+ < TooltipPopup side = "top" className = "max-w-64 text-xs leading-snug" >
102+ { option . warning }
103+ </ TooltipPopup >
104+ </ Tooltip >
105+ ) : (
106+ item
107+ ) ;
108+ } ) }
109+ </ MenuPopup >
110+ </ Menu >
111+ ) : null }
73112 </ >
74113 ) ;
75114} ) ;
0 commit comments