Skip to content

The agent that grows with you

fix(webapp): report every item a mixed drop could not attach

unsupportedpastelsb50770dfa44f
diff --git a/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts b/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts
index f0356e2014b..bef75451b19 100644
--- a/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts
+++ b/apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts
@@ -426,6 +426,51 @@ describe('useComposerActions native image drops', () => {
expect($notifications.get().at(-1)?.message).toContain("Could not attach shots.png: Folders can't be attached")
})
+ // A drop that attached some files must still name the ones it left out.
+ it('reports the items a mixed drop could not attach alongside the ones it did', async () => {
+ const stageFileForAttach = vi.fn(async (file: File) => {
+ if (file.name === 'big.zip') {
+ throw new Error('Upload request is too large')
+ }
+
+ return `/srv/uploads/web-${file.name}`
+ })
+
+ const value = { getPathForFile: () => '', stageFileForAttach }
+ Object.defineProperty(window, 'hermesDesktop', { configurable: true, value })
+
+ const add = vi.fn()
+
+ const { result } = renderHook(() =>
+ useComposerActions({
+ activeSessionId: null,
+ currentCwd: '/w',
+ requestGateway: vi.fn(),
+ scope: { add, remove: vi.fn(() => null), target: 'main', update: vi.fn(() => true), updateIfCurrent: vi.fn(() => true) }
+ })
+ )
+
+ let attached = false
+
+ await act(async () => {
+ attached = await result.current.attachDroppedItems([
+ { file: new File(['x'], 'notes.txt'), path: '' },
+ { file: new File(['x'], 'big.zip'), path: '' },
+ { file: new File([], 'my-repo'), isDirectory: true, path: '' }
+ ])
+ })
+
+ expect(attached).toBe(true)
+ expect(add).toHaveBeenCalledOnce()
+ expect(add).toHaveBeenCalledWith(expect.objectContaining({ path: '/srv/uploads/web-notes.txt' }))
+
+ const warning = $notifications.get().find(notice => notice.message.includes('big.zip'))
+
+ expect(warning).toMatchObject({ kind: 'warning' })
+ expect(warning?.message).toContain('Could not attach big.zip: Upload request is too large')
+ expect(warning?.message).toContain("Could not attach my-repo: Folders can't be attached")
+ })
+
it('copies dropped screenshot bytes before trusting a transient macOS path', async () => {
const transientPath =
'/var/folders/x7/example/T/TemporaryItems/NSIRD_screencaptureui_4roSuW/Screen Shot 2026-08-11.png'
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 59386210144..b5821cbacf4 100644
--- a/apps/desktop/src/app/chat/hooks/use-composer-actions.ts
+++ b/apps/desktop/src/app/chat/hooks/use-composer-actions.ts
@@ -798,7 +798,8 @@ export function useComposerActions({
}
let attached = false
- let lastFailure: string | null = null
+ // Every item that failed, so a drop that attached some files still names the rest.
+ const failures: string[] = []
for (const candidate of candidates) {
const { file, isDirectory, path: knownPath } = candidate
@@ -812,7 +813,7 @@ export function useComposerActions({
continue
}
- lastFailure = `Could not attach folder ${knownPath || ''}`
+ failures.push(`Could not attach folder ${knownPath || ''}`)
continue
}
@@ -824,7 +825,7 @@ export function useComposerActions({
continue
}
- lastFailure = `Could not attach ${knownPath}`
+ failures.push(`Could not attach ${knownPath}`)
continue
}
@@ -835,7 +836,7 @@ export function useComposerActions({
continue
}
- lastFailure = `Could not attach ${knownPath || 'file'}`
+ failures.push(`Could not attach ${knownPath || 'file'}`)
continue
}
@@ -861,7 +862,7 @@ export function useComposerActions({
continue
}
- lastFailure = `Could not attach ${file.name || 'image'}`
+ failures.push(`Could not attach ${file.name || 'image'}`)
continue
}
@@ -875,11 +876,11 @@ export function useComposerActions({
continue
}
- lastFailure = staged.failure
+ failures.push(staged.failure)
}
- if (!attached && lastFailure) {
- notify({ kind: 'warning', title: copy.dropFiles, message: lastFailure })
+ if (failures.length) {
+ notify({ kind: 'warning', title: copy.dropFiles, message: failures.join('; ') })
}
return attached