From 32ba9287b6c0333cd46c58c9a7169824c3c8722a Mon Sep 17 00:00:00 2001 From: Shoubhit Dash Date: Mon, 23 Mar 2026 13:00:49 +0530 Subject: [PATCH] tui: warn about attachment limits immediately instead of batch processing --- .../src/components/prompt-input/attachments.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/app/src/components/prompt-input/attachments.ts b/packages/app/src/components/prompt-input/attachments.ts index 83c79eeaf2..0ff123bf05 100644 --- a/packages/app/src/components/prompt-input/attachments.ts +++ b/packages/app/src/components/prompt-input/attachments.ts @@ -34,6 +34,8 @@ type PromptAttachmentsInput = { readClipboardImage?: () => Promise } +type AddState = "added" | "failed" | "unsupported" | "limit" + export function createPromptAttachments(input: PromptAttachmentsInput) { const prompt = usePrompt() const language = useLanguage() @@ -52,7 +54,7 @@ export function createPromptAttachments(input: PromptAttachmentsInput) { }) } - const add = async (file: File) => { + const add = async (file: File): Promise => { const mime = await attachmentMime(file) if (!mime) { return "unsupported" as const @@ -80,17 +82,16 @@ export function createPromptAttachments(input: PromptAttachmentsInput) { } const addAttachments = async (list: File[]) => { - const result = { added: false, limit: false, unsupported: false } + const result = { added: false, unsupported: false } for (const file of list) { const state = await add(file) + if (state === "limit") { + warnLimit() + return result.added + } result.added = result.added || state === "added" - result.limit = result.limit || state === "limit" result.unsupported = result.unsupported || state === "unsupported" } - if (result.limit) { - warnLimit() - return result.added - } if (!result.added && result.unsupported) warn() return result.added }