@@ -15,6 +15,7 @@ import iconDelete from '../../public/svg/delete-icon.svg?raw';
1515import iconCancel from '../../public/svg/cancel-icon.svg?raw' ;
1616import iconSend from '../../public/svg/send-icon.svg?raw' ;
1717import iconClose from '../../public/svg/close-icon.svg?raw' ;
18+ import iconUp from '../../public/svg/chevron-up-icon.svg?raw' ;
1819
1920import './loading-indicator.js' ;
2021import './voice-input-button.js' ;
@@ -26,6 +27,7 @@ import './chat-thread-component.js';
2627import './chat-action-button.js' ;
2728import { type TabContent } from './tab-component.js' ;
2829import { ChatController } from './chat-controller.js' ;
30+ import { ChatHistoryController } from './chat-history-controller.js' ;
2931
3032/**
3133 * A chat component that allows the user to ask questions and get answers from an API.
@@ -78,6 +80,7 @@ export class ChatComponent extends LitElement {
7880 isResetInput = false ;
7981
8082 private chatController = new ChatController ( this ) ;
83+ private chatHistoryController = new ChatHistoryController ( this ) ;
8184
8285 // Is showing thought process panel
8386 @state ( )
@@ -155,6 +158,10 @@ export class ChatComponent extends LitElement {
155158 stream : this . useStream ,
156159 } ,
157160 ) ;
161+
162+ if ( this . interactionModel === 'chat' ) {
163+ this . chatHistoryController . saveChatHistory ( this . chatThread ) ;
164+ }
158165 }
159166
160167 // Reset the input field and the current question
@@ -173,6 +180,8 @@ export class ChatComponent extends LitElement {
173180 this . isDefaultPromptsEnabled = true ;
174181 this . selectedCitation = undefined ;
175182 this . chatController . reset ( ) ;
183+ // clean up the current session content from the history too
184+ this . chatHistoryController . saveChatHistory ( this . chatThread ) ;
176185 this . collapseAside ( event ) ;
177186 this . handleUserChatCancel ( event ) ;
178187 }
@@ -309,6 +318,27 @@ export class ChatComponent extends LitElement {
309318 }
310319 }
311320
321+ renderChatThread ( chatThread : ChatThreadEntry [ ] ) {
322+ return html `< chat-thread-component
323+ .chatThread ="${ chatThread } "
324+ .actionButtons ="${ [
325+ {
326+ id : 'chat-show-thought-process' ,
327+ label : globalConfig . SHOW_THOUGH_PROCESS_BUTTON_LABEL_TEXT ,
328+ svgIcon : iconLightBulb ,
329+ isDisabled : this . isShowingThoughtProcess ,
330+ } ,
331+ ] as any } "
332+ .isDisabled ="${ this . isDisabled } "
333+ .isProcessingResponse ="${ this . chatController . isProcessingResponse } "
334+ .selectedCitation ="${ this . selectedCitation } "
335+ @on-action-button-click ="${ this . handleChatEntryActionButtonClick } "
336+ @on-citation-click ="${ this . handleCitationClick } "
337+ @on-followup-click ="${ this . handleQuestionInputClick } "
338+ >
339+ </ chat-thread-component > ` ;
340+ }
341+
312342 // Render the chat component as a web component
313343 override render ( ) {
314344 return html `
@@ -318,6 +348,7 @@ export class ChatComponent extends LitElement {
318348 ${ this . isChatStarted
319349 ? html `
320350 < div class ="chat__header ">
351+ ${ this . interactionModel === 'chat' ? this . chatHistoryController . renderHistoryButton ( ) : '' }
321352 < chat-action-button
322353 .label ="${ globalConfig . RESET_CHAT_BUTTON_TITLE } "
323354 actionId ="chat-reset-button "
@@ -326,24 +357,15 @@ export class ChatComponent extends LitElement {
326357 >
327358 </ chat-action-button >
328359 </ div >
329- < chat-thread-component
330- .chatThread ="${ this . chatThread } "
331- .actionButtons ="${ [
332- {
333- id : 'chat-show-thought-process' ,
334- label : globalConfig . SHOW_THOUGH_PROCESS_BUTTON_LABEL_TEXT ,
335- svgIcon : iconLightBulb ,
336- isDisabled : this . isShowingThoughtProcess ,
337- } ,
338- ] as any } "
339- .isDisabled ="${ this . isDisabled } "
340- .isProcessingResponse ="${ this . chatController . isProcessingResponse } "
341- .selectedCitation ="${ this . selectedCitation } "
342- @on-action-button-click ="${ this . handleChatEntryActionButtonClick } "
343- @on-citation-click ="${ this . handleCitationClick } "
344- @on-followup-click ="${ this . handleQuestionInputClick } "
345- >
346- </ chat-thread-component >
360+ ${ this . chatHistoryController . showChatHistory
361+ ? html `< div class ="chat-history__container ">
362+ ${ this . renderChatThread ( this . chatHistoryController . chatHistory ) }
363+ < div class ="chat-history__footer ">
364+ ${ unsafeSVG ( iconUp ) } ${ globalConfig . CHAT_HISTORY_FOOTER_TEXT } ${ unsafeSVG ( iconUp ) }
365+ </ div >
366+ </ div > `
367+ : '' }
368+ ${ this . renderChatThread ( this . chatThread ) }
347369 `
348370 : '' }
349371 ${ this . chatController . isAwaitingResponse
0 commit comments