feat: implement file attachment button functionality

Add handleAttachments function to create file input dialog and process
selected files through inputService. Wire up attachment button click
handler and update aria-label to use Copy.ButtonAttachFiles enum value.
This commit is contained in:
Andrew Beal 2026-04-19 21:01:24 +01:00
parent f51f171da2
commit e542134b9f
2 changed files with 24 additions and 3 deletions

View file

@ -470,6 +470,27 @@
e.stopPropagation();
}
function handleAttachments() {
const input = document.createElement("input");
input.multiple = true;
input.type = "file";
input.onchange = async () => {
if (input.files) {
const dataTransfer = new DataTransfer();
for (let index = 0; index < input.files.length; index++) {
dataTransfer.items.add(input.files[index]);
}
const files = await inputService.getFilesFromDataTransfer(dataTransfer);
const newAttachments = files.filter(file => !attachments.some(a => a.base64 === file.base64));
attachments = [...attachments, ...newAttachments];
}
};
input.click();
}
function handleCursorPositionChange() {
if (!$searchState.active || $searchState.position === null) {
return;
@ -554,10 +575,9 @@
<button
id="chat-attachment-button"
bind:this={attachmentButton}
on:click={() => { }}
on:click={() => { handleAttachments() }}
disabled={isSubmitting}
aria-label={"Attachment"}>
<!-- Copy.AttachmentLabel -->
aria-label={Copy.ButtonAttachFiles}>
</button>
<button

View file

@ -119,6 +119,7 @@ export enum Copy {
ButtonTurnOffWebSearch = "Turn off Web Search",
ButtonTurnOnWebSearch = "Turn on Web Search",
ButtonUserInstruction = "User Instruction",
ButtonAttachFiles = "Attach Files",
// Agent file message
AttachedFile = `The user has attached the file {fileName}. The contents of the file are included below.