From 0c3afde6eea38c7438885fcaaf21fc52d60eae64 Mon Sep 17 00:00:00 2001 From: joelhulen Date: Sat, 21 Dec 2024 14:17:52 -0500 Subject: [PATCH 1/5] Update the timestamp on the agent message --- src/dotnet/Core/Services/CoreService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotnet/Core/Services/CoreService.cs b/src/dotnet/Core/Services/CoreService.cs index 750941905..20b016640 100644 --- a/src/dotnet/Core/Services/CoreService.cs +++ b/src/dotnet/Core/Services/CoreService.cs @@ -864,7 +864,8 @@ private async Task ProcessCompletionResponse( { "/contentArtifacts", completionResponse.ContentArtifacts }, { "/content", newContent }, { "/analysisResults", completionResponse.AnalysisResults }, - { "/status", operationStatus } + { "/status", operationStatus }, + { "/timeStamp", DateTime.UtcNow } } }, new PatchOperationItem From 7e4c0ea772520a0411992c34e1e7215c67d96d6a Mon Sep 17 00:00:00 2001 From: joelhulen Date: Sat, 21 Dec 2024 14:18:20 -0500 Subject: [PATCH 2/5] Calculate and display agent response times --- src/ui/UserPortal/components/ChatMessage.vue | 10 ++++++++-- src/ui/UserPortal/js/types/index.ts | 1 + src/ui/UserPortal/stores/appStore.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ui/UserPortal/components/ChatMessage.vue b/src/ui/UserPortal/components/ChatMessage.vue index 1099ed8f9..d6e15c0b3 100644 --- a/src/ui/UserPortal/components/ChatMessage.vue +++ b/src/ui/UserPortal/components/ChatMessage.vue @@ -34,7 +34,7 @@ }} @@ -409,7 +409,7 @@ export default { messageDisplayStatus() { if ( this.message.status === 'Failed' || - (this.message.status === 'Completed' && !this.isRenderingMessage) + (this.message.status === 'Completed') ) return null; @@ -681,6 +681,12 @@ export default { return date.toLocaleString(undefined, options); }, + buildTimeStampTooltip(timeStamp: string, processingTime: number) { + const date = this.formatTimeStamp(timeStamp); + const processingTimeSeconds = processingTime / 1000; + return `Message sent at ${date}\nProcessing time: ${processingTimeSeconds.toFixed(2)} seconds`; + }, + getDisplayName() { return this.message.sender === 'User' ? this.message.senderDisplayName diff --git a/src/ui/UserPortal/js/types/index.ts b/src/ui/UserPortal/js/types/index.ts index f2771efb7..6d194ef09 100644 --- a/src/ui/UserPortal/js/types/index.ts +++ b/src/ui/UserPortal/js/types/index.ts @@ -66,6 +66,7 @@ export interface Message { attachments: Array; attachmentDetails: Array; analysisResults: Array; + processingTime: number; // Calculated in milliseconds - not from the API } export interface MessageRatingRequest diff --git a/src/ui/UserPortal/stores/appStore.ts b/src/ui/UserPortal/stores/appStore.ts index eaa1fe177..05cced0a8 100644 --- a/src/ui/UserPortal/stores/appStore.ts +++ b/src/ui/UserPortal/stores/appStore.ts @@ -297,6 +297,15 @@ export const useAppStore = defineStore('app', { this.startPolling(latestMessage, this.currentSession.id); } } + + // Calculate the processing time for each message + this.currentMessages.forEach((message, index) => { + if (message.sender === 'Agent' && this.currentMessages[index - 1]?.sender === 'User') { + const previousMessageTimeStamp = new Date(this.currentMessages[index - 1].timeStamp).getTime(); + const currentMessageTimeStamp = new Date(message.timeStamp).getTime(); + message.processingTime = currentMessageTimeStamp - previousMessageTimeStamp; + } + }); }, async getMessage(messageId: string) { From cc0c6d3b558a67576333b9c1b5c354a80b25efb2 Mon Sep 17 00:00:00 2001 From: joelhulen Date: Mon, 23 Dec 2024 12:04:05 -0500 Subject: [PATCH 3/5] Create TimeAgo component to better handle automatic updates --- src/ui/UserPortal/components/ChatMessage.vue | 12 +++--- src/ui/UserPortal/components/TimeAgo.vue | 42 ++++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/ui/UserPortal/components/TimeAgo.vue diff --git a/src/ui/UserPortal/components/ChatMessage.vue b/src/ui/UserPortal/components/ChatMessage.vue index d6e15c0b3..1bd13ded9 100644 --- a/src/ui/UserPortal/components/ChatMessage.vue +++ b/src/ui/UserPortal/components/ChatMessage.vue @@ -29,9 +29,9 @@ }" /> - {{ - $filters.timeAgo(new Date(message.timeStamp)) - }} + + +