From e542134b9f768c516e30029670ebd31d688aa793 Mon Sep 17 00:00:00 2001 From: Andrew Beal Date: Sun, 19 Apr 2026 21:01:24 +0100 Subject: [PATCH] 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. --- Components/ChatInput.svelte | 26 +++++++++++++++++++++++--- Enums/Copy.ts | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Components/ChatInput.svelte b/Components/ChatInput.svelte index e75a4b1..f10aac2 100644 --- a/Components/ChatInput.svelte +++ b/Components/ChatInput.svelte @@ -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 @@