From 13eca24da8e732d14bbfb733d7bd158475279647 Mon Sep 17 00:00:00 2001 From: XnneHang Date: Wed, 4 Feb 2026 18:40:10 +0800 Subject: [PATCH 1/7] feat: Add file attachment handling for chat input (#1) --- src/renderer/src/components/footer/footer.tsx | 35 ++++++++++- src/renderer/src/hooks/footer/use-footer.ts | 4 ++ .../src/hooks/footer/use-text-input.tsx | 63 +++++++++++++++++-- .../src/hooks/utils/use-media-capture.tsx | 4 +- src/renderer/src/locales/en/translation.json | 8 ++- src/renderer/src/locales/zh/translation.json | 8 ++- 6 files changed, 110 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/components/footer/footer.tsx b/src/renderer/src/components/footer/footer.tsx index 7c058614..ab584526 100644 --- a/src/renderer/src/components/footer/footer.tsx +++ b/src/renderer/src/components/footer/footer.tsx @@ -5,7 +5,7 @@ import { import { BsMicFill, BsMicMuteFill, BsPaperclip } from 'react-icons/bs'; import { IoHandRightSharp } from 'react-icons/io5'; import { FiChevronDown } from 'react-icons/fi'; -import { memo } from 'react'; +import { memo, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { InputGroup } from '@/components/ui/input-group'; import { footerStyles } from './footer-styles'; @@ -35,6 +35,8 @@ interface MessageInputProps { onKeyDown: (e: React.KeyboardEvent) => void onCompositionStart: () => void onCompositionEnd: () => void + onAttachFiles: (files: FileList | null) => void + attachedCount: number } // Reusable components @@ -81,8 +83,11 @@ const MessageInput = memo(({ onKeyDown, onCompositionStart, onCompositionEnd, + onAttachFiles, + attachedCount, }: MessageInputProps) => { const { t } = useTranslation(); + const fileInputRef = useRef(null); return ( @@ -91,9 +96,22 @@ const MessageInput = memo(({ aria-label="Attach file" variant="ghost" {...footerStyles.footer.attachButton} + onClick={() => fileInputRef.current?.click()} > + { + onAttachFiles(event.target.files); + event.target.value = ''; + }} + aria-label={t('footer.attachFile')} + />