@@ -4,9 +4,11 @@ import {
44 type ProviderApprovalOption ,
55} from "@t3tools/contracts" ;
66import { memo } from "react" ;
7- import { TriangleAlertIcon } from "lucide-react" ;
7+ import { ChevronDownIcon , 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,39 @@ 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+ < ChevronDownIcon />
77+ </ MenuTrigger >
78+ < MenuPopup
79+ { ...composerFloatingLayerProps }
80+ side = "top"
81+ align = "end"
82+ className = "max-w-[min(22rem,calc(100vw-2rem))]"
83+ >
84+ { moreOptions . map ( ( option ) => (
85+ < MenuItem
86+ key = { option . decision }
87+ disabled = { isResponding }
88+ onClick = { ( ) => void onRespondToApproval ( requestId , option . decision ) }
89+ className = "items-start"
90+ >
91+ { option . warning ? < TriangleAlertIcon className = "mt-0.5 text-warning" /> : null }
92+ < span className = "min-w-0 whitespace-normal wrap-break-word" >
93+ { option . label }
94+ { option . warning ? (
95+ < span className = "mt-1 block text-xs text-warning" > { option . warning } </ span >
96+ ) : null }
97+ </ span >
98+ </ MenuItem >
99+ ) ) }
100+ </ MenuPopup >
101+ </ Menu >
102+ ) : null }
73103 </ >
74104 ) ;
75105} ) ;
0 commit comments