@@ -16,7 +16,7 @@ import {
1616} from "@t3tools/shared/model" ;
1717import { memo , useCallback , useState } from "react" ;
1818import type { VariantProps } from "class-variance-authority" ;
19- import { ChevronDownIcon } from "lucide-react" ;
19+ import { CheckIcon , ChevronDownIcon } from "lucide-react" ;
2020import { Button , buttonVariants } from "../ui/button" ;
2121import {
2222 Menu ,
@@ -297,67 +297,90 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
297297
298298 return (
299299 < >
300- { selectDescriptors . map ( ( descriptor , index ) => (
301- < div key = { descriptor . id } >
302- { index > 0 ? < MenuDivider /> : null }
303- < MenuGroup >
304- < div className = "px-2 pt-1.5 pb-1 font-medium text-muted-foreground text-xs" >
305- { descriptor . label }
306- </ div >
307- { ultrathinkInBodyText && descriptor . id === primarySelectDescriptor ?. id ? (
308- < div className = "px-2 pb-1.5 text-muted-foreground/80 text-xs" >
309- Your prompt contains "ultrathink" in the text. Remove it to change this
310- option.
300+ { selectDescriptors . map ( ( descriptor , index ) => {
301+ const selectedValue =
302+ ultrathinkPromptControlled && descriptor . id === primarySelectDescriptor ?. id
303+ ? "ultrathink"
304+ : ( getDescriptorStringValue ( descriptor ) ?? "" ) ;
305+
306+ return (
307+ < div key = { descriptor . id } >
308+ { index > 0 ? < MenuDivider /> : null }
309+ < MenuGroup >
310+ < div className = "px-2 pt-1.5 pb-1 font-medium text-muted-foreground text-xs" >
311+ { descriptor . label }
312+ </ div >
313+ { ultrathinkInBodyText && descriptor . id === primarySelectDescriptor ?. id ? (
314+ < div className = "px-2 pb-1.5 text-muted-foreground/80 text-xs" >
315+ Your prompt contains "ultrathink" in the text. Remove it to change this
316+ option.
317+ </ div >
318+ ) : null }
319+ < MenuRadioGroup
320+ value = { selectedValue }
321+ onValueChange = { ( value ) => handleSelectChange ( descriptor , value ) }
322+ >
323+ { descriptor . options . map ( ( option ) => (
324+ < MenuRadioItem
325+ key = { option . id }
326+ value = { option . id }
327+ hideIndicator
328+ disabled = { ultrathinkInBodyText && descriptor . id === primarySelectDescriptor ?. id }
329+ >
330+ < span className = "flex w-full min-w-0 items-center justify-between gap-3" >
331+ < span className = "min-w-0 truncate" >
332+ { option . label }
333+ { option . isDefault ? (
334+ < >
335+ { " " }
336+ < DefaultBadge />
337+ </ >
338+ ) : null }
339+ </ span >
340+ { option . id === selectedValue ? (
341+ < CheckIcon className = "size-3.5 shrink-0 text-blue-400" />
342+ ) : null }
343+ </ span >
344+ </ MenuRadioItem >
345+ ) ) }
346+ </ MenuRadioGroup >
347+ </ MenuGroup >
348+ </ div >
349+ ) ;
350+ } ) }
351+ { booleanDescriptors . map ( ( descriptor , index ) => {
352+ const selectedValue = descriptor . currentValue === true ? "on" : "off" ;
353+
354+ return (
355+ < div key = { descriptor . id } >
356+ { index > 0 || selectDescriptors . length > 0 ? < MenuDivider /> : null }
357+ < MenuGroup >
358+ < div className = "px-2 py-1.5 font-medium text-muted-foreground text-xs" >
359+ { descriptor . label }
311360 </ div >
312- ) : null }
313- < MenuRadioGroup
314- value = {
315- ultrathinkPromptControlled && descriptor . id === primarySelectDescriptor ?. id
316- ? "ultrathink"
317- : ( getDescriptorStringValue ( descriptor ) ?? "" )
318- }
319- onValueChange = { ( value ) => handleSelectChange ( descriptor , value ) }
320- >
321- { descriptor . options . map ( ( option ) => (
322- < MenuRadioItem
323- key = { option . id }
324- value = { option . id }
325- disabled = { ultrathinkInBodyText && descriptor . id === primarySelectDescriptor ?. id }
326- >
327- { option . label }
328- { option . isDefault ? (
329- < >
330- { " " }
331- < DefaultBadge />
332- </ >
333- ) : null }
334- </ MenuRadioItem >
335- ) ) }
336- </ MenuRadioGroup >
337- </ MenuGroup >
338- </ div >
339- ) ) }
340- { booleanDescriptors . map ( ( descriptor , index ) => (
341- < div key = { descriptor . id } >
342- { index > 0 || selectDescriptors . length > 0 ? < MenuDivider /> : null }
343- < MenuGroup >
344- < div className = "px-2 py-1.5 font-medium text-muted-foreground text-xs" >
345- { descriptor . label }
346- </ div >
347- < MenuRadioGroup
348- value = { descriptor . currentValue === true ? "on" : "off" }
349- onValueChange = { ( value ) => {
350- updateDescriptors (
351- replaceDescriptorCurrentValue ( descriptors , descriptor . id , value === "on" ) ,
352- ) ;
353- } }
354- >
355- < MenuRadioItem value = "on" > On</ MenuRadioItem >
356- < MenuRadioItem value = "off" > Off</ MenuRadioItem >
357- </ MenuRadioGroup >
358- </ MenuGroup >
359- </ div >
360- ) ) }
361+ < MenuRadioGroup
362+ value = { selectedValue }
363+ onValueChange = { ( value ) => {
364+ updateDescriptors (
365+ replaceDescriptorCurrentValue ( descriptors , descriptor . id , value === "on" ) ,
366+ ) ;
367+ } }
368+ >
369+ { ( [ "on" , "off" ] as const ) . map ( ( value ) => (
370+ < MenuRadioItem key = { value } value = { value } hideIndicator >
371+ < span className = "flex w-full min-w-0 items-center justify-between gap-3" >
372+ < span > { value === "on" ? "On" : "Off" } </ span >
373+ { value === selectedValue ? (
374+ < CheckIcon className = "size-3.5 shrink-0 text-blue-400" />
375+ ) : null }
376+ </ span >
377+ </ MenuRadioItem >
378+ ) ) }
379+ </ MenuRadioGroup >
380+ </ MenuGroup >
381+ </ div >
382+ ) ;
383+ } ) }
361384 </ >
362385 ) ;
363386} ) ;
0 commit comments