File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 "
77 >
88 <h3 :class =" h3Style" >{{ $t('Chat history') }}</h3 >
9- <Button @click =" agentStore .createPreSession ()" :disabled =" agentStore .isResponseInProgress " class="w-[360px] mx-4 my-2 mb-4 rounded-3xl text-gray-800 dark:text-gray-200 ">
9+ <Button @click =" agentStore .createPreSession (); agentStore . setSessionHistoryOpen ( false ) " :disabled =" agentStore .isResponseInProgress " class="w-[360px] mx-4 my-2 mb-4 rounded-3xl text-gray-800 dark:text-gray-200 ">
1010 <IconPlusOutline class="w-5 h-5" />
1111 {{ $t('New chat') }}
1212 </Button >
1313 <div class =" w-full border-b border-gray-200 dark:border-gray-700" />
1414 <div class =" absolute w-full h-full flex flex-col items-center justify-center bg-gray-100/50 dark:bg-gray-700/50 z-10" v-if =" agentStore.isResponseInProgress" >
1515 <Spinner class="w-8 h-8" v-if =" agentStore .isResponseInProgress " />
16- <p class =" mt-2 text-gray-800 dark:text-gray-200" >generation in progress...</p >
16+ <p class =" mt-2 text-gray-800 dark:text-gray-200" >{{ $t('Generation in progress...') }} </p >
1717 </div >
1818 <div v-for =" group in groupedSessions" :key =" group.dayKey" class =" w-full py-2" >
1919 <div class =" px-4 pb-2 text-xs font-semibold uppercase tracking-[0.2em] text-gray-500 dark:text-gray-400" >
3838 v-if =" !groupedSessions || groupedSessions.length === 0"
3939 class =" w-full h-full flex items-center justify-center text-gray-800 dark:text-gray-200"
4040 >
41- There is no previous chat sessions
41+ {{ $t(' There are no previous chat sessions') }}
4242 </p >
4343 </div >
4444</template >
Original file line number Diff line number Diff line change @@ -120,6 +120,10 @@ export const useAgentStore = defineStore('agent', () => {
120120 } ) ;
121121 const blockCloseOfChat = ref ( false ) ;
122122
123+ function sortSessionsListByTimestamp ( sessionsList : ISessionsListItem [ ] ) {
124+ return [ ...sessionsList ] . sort ( ( a : ISessionsListItem , b : ISessionsListItem ) => b . timestamp . localeCompare ( a . timestamp ) ) ;
125+ }
126+
123127 async function sendMessage ( ) {
124128 const message = trimmedUserMessage . value ;
125129 if ( ! message || isResponseInProgress . value ) {
@@ -128,6 +132,11 @@ export const useAgentStore = defineStore('agent', () => {
128132 if ( ! currentSession . value || currentSession . value . sessionId === 'pre-session' ) {
129133 await createNewSession ( message ) ;
130134 }
135+ currentSession . value . timestamp = new Date ( ) . toISOString ( ) ;
136+ sessionList . value = sortSessionsListByTimestamp ( sessionList . value . map ( ( s : ISessionsListItem ) => s . sessionId === currentSession . value ?. sessionId ? {
137+ ...s ,
138+ timestamp : currentSession . value ?. timestamp || s . timestamp ,
139+ } : s ) ) ;
131140 lastMessage . value = message ;
132141 currentChat . value ?. sendMessage ( {
133142 text : message ,
Original file line number Diff line number Diff line change @@ -87,6 +87,13 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
8787 return { ok : true } ;
8888 }
8989
90+ private async updateSessionDate ( sessionId : string ) {
91+ await this . adminforth . resource ( this . options . sessionResource . resourceId ) . update ( sessionId , {
92+ [ this . options . sessionResource . createdAtField ] : new Date ( ) . toISOString ( ) ,
93+ } ) ;
94+ return { ok : true } ;
95+ }
96+
9097 private async getSessionTurns ( sessionId : string ) {
9198 const turns = await this . adminforth . resource ( this . options . turnResource . resourceId ) . list (
9299 [ Filters . EQ ( this . options . turnResource . sessionIdField , sessionId ) ] ,
@@ -150,6 +157,7 @@ export default class AdminForthAgentPlugin extends AdminForthPlugin {
150157 const userTimeZone = ( body . timeZone as string | undefined ) ?? 'UTC' ;
151158 const sessionId = body . sessionId || adminUser ?. pk || adminUser ?. username || 'default' ;
152159 const turnId = await this . createNewTurn ( sessionId , prompt ) ;
160+ await this . updateSessionDate ( sessionId ) ;
153161 let fullResponse = "" ;
154162 let isStreamClosed = false ;
155163 const sequenceDebugCollector = createSequenceDebugCollector ( ) ;
You can’t perform that action at this time.
0 commit comments