Skip to content

The agent that grows with you

fix(webapp): report a refused Attach → Files pick instead of failing silently

unsupportedpastels3406295052b5
diff --git a/apps/desktop/src/app/chat/hooks/use-composer-actions.ts b/apps/desktop/src/app/chat/hooks/use-composer-actions.ts
index 39fb2a34278..d69a7b92ec3 100644
--- a/apps/desktop/src/app/chat/hooks/use-composer-actions.ts
+++ b/apps/desktop/src/app/chat/hooks/use-composer-actions.ts
@@ -513,11 +513,21 @@ export function useComposerActions({
const pickContextPaths = useCallback(
async (kind: 'file' | 'folder') => {
- const paths = await selectDesktopPaths({
- title: kind === 'file' ? 'Add files as context' : 'Add folders as context',
- defaultPath: currentCwd || undefined,
- directories: kind === 'folder'
- })
+ let paths: string[]
+
+ try {
+ paths = await selectDesktopPaths({
+ title: kind === 'file' ? 'Add files as context' : 'Add folders as context',
+ defaultPath: currentCwd || undefined,
+ directories: kind === 'folder'
+ })
+ } catch (err) {
+ // As in pickImages: the browser stages a pick before returning its path, and a refused
+ // stage (a file over the upload limit) is reported here, not left as an unhandled rejection.
+ notifyError(err, copy.attachFailed)
+
+ return
+ }
if (!paths?.length) {
return
@@ -536,7 +546,7 @@ export function useComposerActions({
})
}
},
- [attachToMain, currentCwd]
+ [attachToMain, copy.attachFailed, currentCwd]
)
const insertContextPathInlineRef = useCallback(
diff --git a/apps/desktop/src/i18n/ar_chat.ts b/apps/desktop/src/i18n/ar_chat.ts
index e9479b249aa..2fa532e3563 100644
--- a/apps/desktop/src/i18n/ar_chat.ts
+++ b/apps/desktop/src/i18n/ar_chat.ts
@@ -465,6 +465,7 @@ export const arChat = {
imageAttach: 'إرفاق الصورة',
imageWriteFailed: 'فشل كتابة الصورة',
imageAttachFailed: 'فشل إرفاق الصورة',
+ attachFailed: 'فشل الإرفاق',
pastedContent: 'محتوى ملصق',
pasteAttachFailed: 'تعذر إرفاق النص الملصق',
attachImages: 'إرفاق الصور',
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 7175c61ae95..d366f8701df 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -5413,6 +5413,7 @@ export const deOverrides = {
imageAttach: 'Bild anhängen',
imageWriteFailed: 'Bild konnte nicht auf die Festplatte geschrieben werden.',
imageAttachFailed: 'Bild-Anhängen fehlgeschlagen',
+ attachFailed: 'Anhängen fehlgeschlagen',
pastedContent: 'Eingefügter Inhalt',
pasteAttachFailed: 'Eingefügter Text konnte nicht angehängt werden',
attachImages: 'Bilder anhängen',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index d8d00b4aa0d..abaf846b37e 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -4750,6 +4750,7 @@ export const en: Translations = {
imageAttach: 'Image attach',
imageWriteFailed: 'Failed to write image to disk.',
imageAttachFailed: 'Image attach failed',
+ attachFailed: 'Attach failed',
pastedContent: 'Pasted content',
pasteAttachFailed: 'Could not attach pasted text',
attachImages: 'Attach images',
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index 2abe7056910..214fe509e83 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -5397,6 +5397,7 @@ export const esOverrides = {
imageAttach: 'Adjuntar imagen',
imageWriteFailed: 'No se pudo escribir la imagen en disco.',
imageAttachFailed: 'No se pudo adjuntar la imagen',
+ attachFailed: 'No se pudo adjuntar',
pastedContent: 'Contenido pegado',
pasteAttachFailed: 'No se pudo adjuntar el texto pegado',
attachImages: 'Adjuntar imágenes',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index d0c02b2cb40..c7234f2a21b 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -5420,6 +5420,7 @@ export const frOverrides = {
imageAttach: 'Image jointe',
imageWriteFailed: "Échec de l'écriture de l'image sur le disque.",
imageAttachFailed: "Échec de l'ajout de l'image",
+ attachFailed: "Échec de l'ajout",
pastedContent: 'Contenu collé',
pasteAttachFailed: 'Impossible de joindre le texte collé',
attachImages: 'Joindre des images',
diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.ts
index f4362cce7e0..656c08d6b4b 100644
--- a/apps/desktop/src/i18n/ja.ts
+++ b/apps/desktop/src/i18n/ja.ts
@@ -3636,6 +3636,7 @@ export const jaOverrides = {
imageAttach: '画像を添付',
imageWriteFailed: '画像のディスクへの書き込みに失敗しました。',
imageAttachFailed: '画像の添付に失敗しました',
+ attachFailed: '添付に失敗しました',
pastedContent: '貼り付けた内容',
pasteAttachFailed: '貼り付けたテキストを添付できませんでした',
attachImages: '画像を添付',
diff --git a/apps/desktop/src/i18n/ru.ts b/apps/desktop/src/i18n/ru.ts
index 1c0af102eed..1fa8127263a 100644
--- a/apps/desktop/src/i18n/ru.ts
+++ b/apps/desktop/src/i18n/ru.ts
@@ -3785,6 +3785,7 @@ export const ruOverrides = {
imageAttach: 'Прикрепление изображения',
imageWriteFailed: 'Не удалось записать изображение на диск.',
imageAttachFailed: 'Прикрепление изображения не удалось',
+ attachFailed: 'Прикрепление не удалось',
attachImages: 'Прикрепить изображения',
clipboard: 'Буфер обмена',
noClipboardImage: 'Изображение в буфере обмена не найдено',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 05d4247c3ff..3977ed3fabd 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -4194,6 +4194,7 @@ catalog: CatalogTranslations
imageAttach: string
imageWriteFailed: string
imageAttachFailed: string
+ attachFailed: string,
pastedContent: string
pasteAttachFailed: string
attachImages: string
diff --git a/apps/desktop/src/i18n/zh-hant_chat.ts b/apps/desktop/src/i18n/zh-hant_chat.ts
index 9c55c122dc4..4788b2411bd 100644
--- a/apps/desktop/src/i18n/zh-hant_chat.ts
+++ b/apps/desktop/src/i18n/zh-hant_chat.ts
@@ -487,6 +487,7 @@ export const zhHantChat = {
imageAttach: '附加圖片',
imageWriteFailed: '無法將圖片寫入磁碟。',
imageAttachFailed: '附加圖片失敗',
+ attachFailed: '附加失敗',
pastedContent: '貼上內容',
pasteAttachFailed: '無法附加貼上的文字',
attachImages: '附加圖片',
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index ad3e6221885..3ae27ad9899 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -4610,6 +4610,7 @@ export const zhOverrides = {
imageAttach: '附加图片',
imageWriteFailed: '无法将图片写入磁盘。',
imageAttachFailed: '附加图片失败',
+ attachFailed: '附加失败',
pastedContent: '粘贴内容',
pasteAttachFailed: '无法附加粘贴的文本',
attachImages: '附加图片',
diff --git a/apps/desktop/src/lib/browser-uploads.test.ts b/apps/desktop/src/lib/browser-uploads.test.ts
index 2797ac12d00..58ca7596a64 100644
--- a/apps/desktop/src/lib/browser-uploads.test.ts
+++ b/apps/desktop/src/lib/browser-uploads.test.ts
@@ -108,6 +108,26 @@ describe('browser file stage size', () => {
expect($notifications.get()).toContainEqual(expect.objectContaining({ kind: 'error', message: limitMessage }))
})
+ // Attach → Files… used to leave the refused stage as an unhandled rejection, with nothing shown.
+ it('refuses a picked file over the limit with one notice naming the limit, and uploads nothing', async () => {
+ const { uploads } = await installBrowser()
+ const { result } = renderComposer()
+
+ vi.spyOn(HTMLInputElement.prototype, 'click').mockImplementation(function (this: HTMLInputElement) {
+ Object.defineProperty(this, 'files', { configurable: true, value: [tooLarge('huge.zip', 'application/zip')] })
+ this.dispatchEvent(new Event('change'))
+ })
+
+ await act(async () => {
+ await result.current.pickContextPaths('file')
+ })
+
+ expect(uploads()).toHaveLength(0)
+ expect($notifications.get()).toEqual([
+ expect.objectContaining({ kind: 'error', message: limitMessage, title: 'Attach failed' })
+ ])
+ })
+
it('names the limit when a dropped file over it cannot be attached', async () => {
const { uploads } = await installBrowser()
const { result } = renderComposer()
diff --git a/locales/_keys.desktop.json b/locales/_keys.desktop.json
index 4da70362320..32c0634695c 100644
--- a/locales/_keys.desktop.json
+++ b/locales/_keys.desktop.json
@@ -1501,6 +1501,7 @@
"cron.weekdaysAt",
"desktop.archiveFailed",
"desktop.archived",
+ "desktop.attachFailed",
"desktop.attachImages",
"desktop.audioReadFailed",
"desktop.branchFailed",