@@ -119,6 +119,10 @@ const UIStringsNotTranslate = {
119119 *@description Title for the send icon button.
120120 */
121121 sendButtonTitle : 'Send' ,
122+ /**
123+ *@description Title for the start new chat
124+ */
125+ startNewChatButtonTitle : 'Start new chat' ,
122126 /**
123127 *@description Title for the cancel icon button.
124128 */
@@ -292,6 +296,7 @@ export interface Props {
292296 onFeedbackSubmit : ( rpcId : number , rate : Host . AidaClient . Rating , feedback ?: string ) => void ;
293297 onCancelClick : ( ) => void ;
294298 onContextClick : ( ) => void | Promise < void > ;
299+ onNewConversation : ( ) => void ;
295300 inspectElementToggled : boolean ;
296301 state : State ;
297302 aidaAvailability : Host . AidaClient . AidaAccessPreconditions ;
@@ -874,6 +879,10 @@ export class FreestylerChatUi extends HTMLElement {
874879 // clang-format on
875880 } ;
876881
882+ #onNewConversation( ) : void {
883+ this . #props. onNewConversation ( ) ;
884+ }
885+
877886 #getEmptyStateSuggestions = ( ) : string [ ] => {
878887 if ( ! this . #props. agentType ) {
879888 return [ ] ;
@@ -927,6 +936,61 @@ export class FreestylerChatUi extends HTMLElement {
927936 }
928937 }
929938
939+ #renderChatInputButton( ) : LitHtml . TemplateResult {
940+ if ( this . #props. isLoading ) {
941+ // clang-format off
942+ return html `< devtools-button
943+ class ="chat-input-button "
944+ aria-label =${ lockedString ( UIStringsNotTranslate . cancelButtonTitle ) }
945+ @click =${ this . #handleCancel}
946+ .data=${
947+ {
948+ variant : Buttons . Button . Variant . ICON ,
949+ size : Buttons . Button . Size . REGULAR ,
950+ iconName : 'record-stop' ,
951+ title : lockedString ( UIStringsNotTranslate . cancelButtonTitle ) ,
952+ jslogContext : 'stop' ,
953+ } as Buttons . Button . ButtonData
954+ }
955+ > </ devtools-button > ` ;
956+ // clang-format on
957+ }
958+ if ( this . #props. blockedByCrossOrigin ) {
959+ // clang-format off
960+ return html `< devtools-button
961+ class ="chat-input-button "
962+ aria-label =${ lockedString ( UIStringsNotTranslate . startNewChatButtonTitle ) }
963+ @click =${ this . #onNewConversation}
964+ .data=${
965+ {
966+ variant : Buttons . Button . Variant . PRIMARY ,
967+ size : Buttons . Button . Size . REGULAR ,
968+ title : lockedString ( UIStringsNotTranslate . startNewChatButtonTitle ) ,
969+ jslogContext : 'start-new-chat' ,
970+ } as Buttons . Button . ButtonData
971+ }
972+ > ${ lockedString ( UIStringsNotTranslate . startNewChatButtonTitle ) } </ devtools-button > ` ;
973+ // clang-format on
974+ }
975+ // clang-format off
976+ return html `< devtools-button
977+ class ="chat-input-button "
978+ aria-label =${ lockedString ( UIStringsNotTranslate . sendButtonTitle ) }
979+ .data =${
980+ {
981+ type : 'submit' ,
982+ variant : Buttons . Button . Variant . ICON ,
983+ size : Buttons . Button . Size . REGULAR ,
984+ disabled : this . #isTextInputDisabled( ) ,
985+ iconName : 'send' ,
986+ title : lockedString ( UIStringsNotTranslate . sendButtonTitle ) ,
987+ jslogContext : 'send' ,
988+ } as Buttons . Button . ButtonData
989+ }
990+ > </ devtools-button > ` ;
991+ // clang-format on
992+ }
993+
930994 #renderChatInput = ( ) : LitHtml . TemplateResult => {
931995 // clang-format off
932996 return html `
@@ -937,37 +1001,7 @@ export class FreestylerChatUi extends HTMLElement {
9371001 @keydown=${ this . #handleTextAreaKeyDown}
9381002 placeholder=${ this . #getInputPlaceholderString( ) }
9391003 jslog=${ VisualLogging . textField ( 'query' ) . track ( { keydown : 'Enter' } ) } > </ textarea >
940- ${ this . #props. isLoading
941- ? html `< devtools-button
942- class ="chat-input-button "
943- aria-label =${ lockedString ( UIStringsNotTranslate . cancelButtonTitle ) }
944- @click =${ this . #handleCancel}
945- .data=${
946- {
947- variant : Buttons . Button . Variant . ICON ,
948- size : Buttons . Button . Size . REGULAR ,
949- disabled : this . #isTextInputDisabled( ) ,
950- iconName : 'record-stop' ,
951- title : lockedString ( UIStringsNotTranslate . cancelButtonTitle ) ,
952- jslogContext : 'stop' ,
953- } as Buttons . Button . ButtonData
954- }
955- > </ devtools-button > `
956- : html `< devtools-button
957- class ="chat-input-button "
958- aria-label =${ lockedString ( UIStringsNotTranslate . sendButtonTitle ) }
959- .data =${
960- {
961- type : 'submit' ,
962- variant : Buttons . Button . Variant . ICON ,
963- size : Buttons . Button . Size . REGULAR ,
964- disabled : this . #isTextInputDisabled( ) ,
965- iconName : 'send' ,
966- title : lockedString ( UIStringsNotTranslate . sendButtonTitle ) ,
967- jslogContext : 'send' ,
968- } as Buttons . Button . ButtonData
969- }
970- > </ devtools-button > ` }
1004+ ${ this . #renderChatInputButton( ) }
9711005 </ div > ` ;
9721006 // clang-format on
9731007 } ;
0 commit comments