diff --git a/django_app/frontend/src/js/custom-events.md b/django_app/frontend/src/js/custom-events.md
index f9ade309f..36d525f7d 100644
--- a/django_app/frontend/src/js/custom-events.md
+++ b/django_app/frontend/src/js/custom-events.md
@@ -7,6 +7,6 @@ Custom events are used for communication between web components. Here is a list
| chat-response-start | /chats | (none) | When the streaming connection is opened |
| chat-response-end | /chats | title: string
session_id: string | When the stream "end" event is sent from the server |
| doc-complete | /chats
/documents | file-status: HTMLElement | When a document status changes to "complete" |
-| selected-docs-change | /chats | string[] of document IDs | When a user selects or deselects a document |
+| selected-docs-change | /chats | {id: string, name: string}[] | When a user selects or deselects a document |
| stop-streaming | /chats | (none) | When a user presses the stop-streaming button, or an unexpected disconnection has occured |
| chat-title-change | /chats | title: string
session_id: string
sender: string | When the chat title is changed by the user |
diff --git a/django_app/frontend/src/js/web-components/chats/chat-controller.js b/django_app/frontend/src/js/web-components/chats/chat-controller.js
index fb55a0ffd..1e891e3e2 100644
--- a/django_app/frontend/src/js/web-components/chats/chat-controller.js
+++ b/django_app/frontend/src/js/web-components/chats/chat-controller.js
@@ -31,6 +31,10 @@ class ChatController extends HTMLElement {
`You selected ${selectedDocuments.length || "no"} document${selectedDocuments.length === 1 ? "" : "s"}`,
"You sent this prompt"
];
+ // add filename to activity if only one file
+ if (selectedDocuments.length === 1) {
+ activites[0] += ` (${selectedDocuments[0].name})`;
+ }
activites.forEach((activity) => {
userMessage.addActivity(activity, "user");
});
@@ -47,7 +51,7 @@ class ChatController extends HTMLElement {
aiMessage.stream(
userText,
- selectedDocuments,
+ selectedDocuments.map(doc => doc.id),
activites,
llm,
this.dataset.sessionId,
diff --git a/django_app/frontend/src/js/web-components/chats/document-selector.js b/django_app/frontend/src/js/web-components/chats/document-selector.js
index 1ccea7105..c68136cf0 100644
--- a/django_app/frontend/src/js/web-components/chats/document-selector.js
+++ b/django_app/frontend/src/js/web-components/chats/document-selector.js
@@ -10,7 +10,10 @@ class DocumentSelector extends HTMLElement {
let selectedDocuments = [];
documents.forEach((document) => {
if (document.checked) {
- selectedDocuments.push(document.value);
+ selectedDocuments.push({
+ id: document.value,
+ name: this.querySelector(`[for="${document.id}"]`)?.textContent
+ });
}
});
const evt = new CustomEvent("selected-docs-change", {