11import { t } from 'i18next' ;
22import { History , SquareArrowOutDownLeft , SquarePen } from 'lucide-react' ;
33import { ReactNode } from 'react' ;
4+ import { BlockIcon } from '../../components/block-icon/block-icon' ;
45import { TooltipWrapper } from '../../components/tooltip-wrapper' ;
56import { useTypingAnimation } from '../../hooks/use-typing-animation' ;
67import { cn } from '../../lib/cn' ;
@@ -17,6 +18,10 @@ type AssistantTopBarProps = {
1718 historyContent ?: ReactNode ;
1819 children : ReactNode ;
1920 chatId ?: string | null ;
21+ stepLogoUrl ?: string ;
22+ stepDisplayName ?: string ;
23+ stepIndex ?: number ;
24+ blockDisplayName ?: string ;
2025} ;
2126
2227const AssistantTopBar = ( {
@@ -29,6 +34,10 @@ const AssistantTopBar = ({
2934 children,
3035 chatId,
3136 isTitleDefault,
37+ stepLogoUrl,
38+ stepDisplayName,
39+ stepIndex,
40+ blockDisplayName,
3241} : AssistantTopBarProps ) => {
3342 const animatedTitle = useTypingAnimation ( {
3443 text : title ,
@@ -37,77 +46,106 @@ const AssistantTopBar = ({
3746 enableAnimation : ! isTitleDefault ,
3847 } ) ;
3948
49+ const isStepSettingsMode =
50+ stepLogoUrl !== undefined &&
51+ blockDisplayName !== undefined &&
52+ stepIndex !== undefined &&
53+ stepDisplayName !== undefined ;
54+
55+ const displayTitle = isStepSettingsMode
56+ ? t ( 'Generate with AI' )
57+ : animatedTitle ;
58+
4059 return (
41- < div className = "flex justify-between items-center px-4 py-2 gap-2 h-[61px] flex-shrink-0 text-md dark:text-primary font-bold border-b border-gray-200" >
42- < div className = "flex items-center gap-2" >
43- { onHistoryOpenChange && (
44- < Popover open = { isHistoryOpen } onOpenChange = { onHistoryOpenChange } >
45- < TooltipWrapper
46- tooltipText = {
47- isHistoryOpen ? t ( 'Close history' ) : t ( 'Open history' )
48- }
49- tooltipPlacement = { isHistoryOpen ? 'right' : 'bottom' }
50- align = "start"
60+ < div
61+ className = { cn (
62+ 'flex flex-col px-4 py-2 gap-2 flex-shrink-0 text-md dark:text-primary font-bold border-b border-gray-200' ,
63+ ) }
64+ >
65+ < div className = "flex justify-between items-center gap-2" >
66+ < div className = "flex items-center gap-2 flex-1 min-w-0" >
67+ { onHistoryOpenChange && (
68+ < Popover open = { isHistoryOpen } onOpenChange = { onHistoryOpenChange } >
69+ < TooltipWrapper
70+ tooltipText = {
71+ isHistoryOpen ? t ( 'Close history' ) : t ( 'Open history' )
72+ }
73+ tooltipPlacement = { isHistoryOpen ? 'right' : 'bottom' }
74+ align = "start"
75+ >
76+ < PopoverTrigger asChild >
77+ < Button
78+ variant = "secondary"
79+ size = "icon"
80+ className = { cn (
81+ 'text-outline size-[23px] rounded-xs bg-gray-100 enabled:hover:bg-gray-200' ,
82+ isHistoryOpen && 'bg-gray-200' ,
83+ ) }
84+ >
85+ < History size = { 13 } />
86+ </ Button >
87+ </ PopoverTrigger >
88+ </ TooltipWrapper >
89+ < PopoverContent
90+ className = "w-[272px] h-[265px] p-0"
91+ align = "start"
92+ side = "bottom"
93+ sideOffset = { 8 }
94+ onCloseAutoFocus = { ( e ) => e . preventDefault ( ) }
95+ >
96+ { historyContent }
97+ </ PopoverContent >
98+ </ Popover >
99+ ) }
100+ < TooltipWrapper
101+ tooltipText = { t ( 'New chat' ) }
102+ tooltipPlacement = { isHistoryOpen ? 'right' : 'bottom' }
103+ align = "start"
104+ >
105+ < Button
106+ onClick = { ( e ) => {
107+ e . stopPropagation ( ) ;
108+ onNewChat ( ) ;
109+ } }
110+ variant = "secondary"
111+ size = "icon"
112+ className = "text-outline size-[23px] rounded-xs bg-gray-100 enabled:hover:bg-gray-200"
51113 >
52- < PopoverTrigger asChild >
53- < Button
54- variant = "secondary"
55- size = "icon"
56- className = { cn (
57- 'text-outline size-[23px] rounded-xs bg-gray-100 enabled:hover:bg-gray-200' ,
58- isHistoryOpen && 'bg-gray-200' ,
59- ) }
60- >
61- < History size = { 13 } />
62- </ Button >
63- </ PopoverTrigger >
64- </ TooltipWrapper >
65- < PopoverContent
66- className = "w-[272px] h-[265px] p-0"
67- align = "start"
68- side = "bottom"
69- sideOffset = { 8 }
70- onCloseAutoFocus = { ( e ) => e . preventDefault ( ) }
114+ < SquarePen size = { 13 } />
115+ </ Button >
116+ </ TooltipWrapper >
117+ < span className = "min-w-0 max-w-[240px] truncate" > { displayTitle } </ span >
118+ </ div >
119+ < div className = "flex items-center gap-2" >
120+ { children }
121+ < TooltipWrapper tooltipText = { t ( 'Close' ) } >
122+ < Button
123+ size = "icon"
124+ variant = "basic"
125+ onClick = { ( e ) => {
126+ e . stopPropagation ( ) ;
127+ onClose ( ) ;
128+ } }
129+ className = "text-outline size-[36px]"
71130 >
72- { historyContent }
73- </ PopoverContent >
74- </ Popover >
75- ) }
76- < TooltipWrapper
77- tooltipText = { t ( 'New chat' ) }
78- tooltipPlacement = { isHistoryOpen ? 'right' : 'bottom' }
79- align = "start"
80- >
81- < Button
82- onClick = { ( e ) => {
83- e . stopPropagation ( ) ;
84- onNewChat ( ) ;
85- } }
86- variant = "secondary"
87- size = "icon"
88- className = "text-outline size-[23px] rounded-xs bg-gray-100 enabled:hover:bg-gray-200"
89- >
90- < SquarePen size = { 13 } />
91- </ Button >
92- </ TooltipWrapper >
93- < span className = "min-w-0 max-w-[240px] truncate" > { animatedTitle } </ span >
94- </ div >
95- < div className = "flex items-center gap-2" >
96- { children }
97- < TooltipWrapper tooltipText = { t ( 'Close' ) } >
98- < Button
99- size = "icon"
100- variant = "basic"
101- onClick = { ( e ) => {
102- e . stopPropagation ( ) ;
103- onClose ( ) ;
104- } }
105- className = "text-outline size-[36px]"
106- >
107- < SquareArrowOutDownLeft size = { 20 } />
108- </ Button >
109- </ TooltipWrapper >
131+ < SquareArrowOutDownLeft size = { 20 } />
132+ </ Button >
133+ </ TooltipWrapper >
134+ </ div >
110135 </ div >
136+ { isStepSettingsMode && (
137+ < div className = "flex items-center gap-2 min-w-0" >
138+ < BlockIcon
139+ logoUrl = { stepLogoUrl }
140+ displayName = { blockDisplayName }
141+ showTooltip = { false }
142+ size = "sm"
143+ />
144+ < span className = "min-w-0 truncate text-sm font-normal" >
145+ { blockDisplayName } ({ stepIndex } . { stepDisplayName } )
146+ </ span >
147+ </ div >
148+ ) }
111149 </ div >
112150 ) ;
113151} ;
0 commit comments