@@ -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 { ChevronDownIcon , ZapIcon } from "lucide-react" ;
2020import { Button , buttonVariants } from "../ui/button" ;
2121import {
2222 Menu ,
@@ -379,6 +379,41 @@ export const TraitsMenuContent = memo(function TraitsMenuContentImpl({
379379 ) ;
380380} ) ;
381381
382+ /**
383+ * Build the traits trigger's text label plus whether the fast-mode bolt should
384+ * render. Fast mode is a lightning bolt when on and nothing at all when off —
385+ * "Normal" is the near-universal case and isn't worth the horizontal space. The
386+ * one exception is when fast mode is the only trait, where a bare bolt (or bare
387+ * chevron) would leave the trigger unreadable.
388+ */
389+ export function buildTraitsTriggerDisplay ( input : {
390+ descriptors : ReadonlyArray < ProviderOptionDescriptor > ;
391+ primarySelectDescriptorId : string | null ;
392+ ultrathinkPromptControlled : boolean ;
393+ fastModeEnabled : boolean ;
394+ } ) : { label : string ; showFastModeIcon : boolean } {
395+ const labels : Array < string > = [ ] ;
396+ for ( const descriptor of input . descriptors ) {
397+ if ( descriptor . id === "fastMode" && descriptor . type === "boolean" ) {
398+ continue ;
399+ }
400+ const label =
401+ input . ultrathinkPromptControlled && descriptor . id === input . primarySelectDescriptorId
402+ ? "Ultrathink"
403+ : descriptor . type === "boolean"
404+ ? `${ descriptor . label } ${ descriptor . currentValue === true ? "On" : "Off" } `
405+ : getProviderOptionCurrentLabel ( descriptor ) ;
406+ if ( typeof label === "string" && label . length > 0 ) {
407+ labels . push ( label ) ;
408+ }
409+ }
410+
411+ if ( labels . length === 0 ) {
412+ return { label : input . fastModeEnabled ? "Fast" : "Normal" , showFastModeIcon : false } ;
413+ }
414+ return { label : labels . join ( " · " ) , showFastModeIcon : input . fastModeEnabled } ;
415+ }
416+
382417export const TraitsPicker = memo ( function TraitsPicker ( {
383418 provider,
384419 instanceId,
@@ -393,7 +428,7 @@ export const TraitsPicker = memo(function TraitsPicker({
393428 ...persistence
394429} : TraitsMenuContentProps & TraitsPersistence ) {
395430 const [ isMenuOpen , setIsMenuOpen ] = useState ( false ) ;
396- const { descriptors, primarySelectDescriptor, ultrathinkPromptControlled } =
431+ const { descriptors, primarySelectDescriptor, ultrathinkPromptControlled, fastModeEnabled } =
397432 getTraitsSectionVisibility ( {
398433 provider,
399434 models,
@@ -415,23 +450,18 @@ export const TraitsPicker = memo(function TraitsPicker({
415450 return null ;
416451 }
417452
418- const triggerLabels : Array < string > = [ ] ;
419- for ( const descriptor of descriptors ) {
420- const label =
421- ultrathinkPromptControlled && descriptor . id === primarySelectDescriptor ?. id
422- ? "Ultrathink"
423- : descriptor . type === "boolean"
424- ? descriptor . id === "fastMode"
425- ? descriptor . currentValue === true
426- ? "Fast"
427- : "Normal"
428- : `${ descriptor . label } ${ descriptor . currentValue === true ? "On" : "Off" } `
429- : getProviderOptionCurrentLabel ( descriptor ) ;
430- if ( typeof label === "string" && label . length > 0 ) {
431- triggerLabels . push ( label ) ;
432- }
433- }
434- const triggerLabel = triggerLabels . join ( " · " ) ;
453+ const { label : triggerLabel , showFastModeIcon } = buildTraitsTriggerDisplay ( {
454+ descriptors,
455+ primarySelectDescriptorId : primarySelectDescriptor ?. id ?? null ,
456+ ultrathinkPromptControlled,
457+ fastModeEnabled,
458+ } ) ;
459+ const fastModeIcon = showFastModeIcon ? (
460+ < >
461+ < ZapIcon aria-hidden = "true" className = "size-3 shrink-0 text-foreground/80 opacity-100" />
462+ < span className = "sr-only" > Fast mode on</ span >
463+ </ >
464+ ) : null ;
435465
436466 const isCodexStyle = provider === "codex" ;
437467
@@ -457,12 +487,14 @@ export const TraitsPicker = memo(function TraitsPicker({
457487 }
458488 >
459489 { isCodexStyle ? (
460- < span className = "flex min-w-0 w-full items-center gap-2 overflow-hidden" >
461- { triggerLabel }
490+ < span className = "flex min-w-0 w-full items-center gap-1.5 overflow-hidden" >
491+ { fastModeIcon }
492+ < span className = "min-w-0 truncate" > { triggerLabel } </ span >
462493 < ChevronDownIcon aria-hidden = "true" className = "size-3 shrink-0 opacity-60" />
463494 </ span >
464495 ) : (
465496 < >
497+ { fastModeIcon }
466498 < span > { triggerLabel } </ span >
467499 < ChevronDownIcon aria-hidden = "true" className = "size-3 opacity-60" />
468500 </ >
0 commit comments