The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): report a folder dropped on the composer instead of ignoring it
David Dudok de Wit1978171b83d8
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.tsindex 02ac9961e3a..f0356e2014b 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@@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react'import { afterEach, describe, expect, it, vi } from 'vitest'import { $composerAttachments, type ComposerAttachment, updateComposerAttachment } from '@/store/composer'+import { $notifications } from '@/store/notifications'import { $connection } from '@/store/session'import { droppedFileInlineRefs } from '../composer/inline-refs'@@ -13,6 +14,7 @@ import {HERMES_PATHS_MIME,partitionDroppedFiles,resolveImageAttachmentPreview,+ stageDroppedFilePath,useComposerActions} from './use-composer-actions'@@ -268,6 +270,18 @@ describe('extractDroppedFiles', () => {expect(result[0]?.url).toBeUndefined()})+ // The browser Webapp has no host path for a dropped folder: report it, never drop it silently.+ it('keeps a path-less dropped folder on the attach pipeline, where it is reported', async () => {+ const transfer = stubTransfer([{ path: 'my-repo', isDirectory: true }])+ stubBridge(transfer)++ const result = extractDroppedFiles(transfer)++ expect(result).toEqual([{ file: expect.any(File), isDirectory: true, path: '' }])+ expect(partitionDroppedFiles(result).osDrops).toHaveLength(1)+ await expect(stageDroppedFilePath(result[0]!)).rejects.toThrow("Folders can't be attached by dropping them")+ })+it('does not duplicate a folder that appears in both items and files', () => {// Chromium lists a dropped folder in transfer.files too (as a size-0 File);// the items pass claims its path first so the files fallback skips it.@@ -391,6 +405,27 @@ describe('useComposerActions native image drops', () => {expect(add).not.toHaveBeenCalled()})+ it('warns about a dropped folder it cannot attach instead of staging its File', async () => {+ const stageFileForAttach = vi.fn(async () => '/srv/uploads/web-my-repo')+ const value = { getPathForFile: () => '', stageFileForAttach }+ Object.defineProperty(window, 'hermesDesktop', { configurable: true, value })++ const { result } = renderHook(() =>+ useComposerActions({ activeSessionId: null, currentCwd: '/w', requestGateway: vi.fn() })+ )++ let attached = true++ await act(async () => {+ attached = await result.current.attachDroppedItems([{ file: new File([], 'shots.png'), isDirectory: true, path: '' }])+ })++ expect(attached).toBe(false)+ expect(stageFileForAttach).not.toHaveBeenCalled()+ expect($notifications.get().at(-1)).toMatchObject({ kind: 'warning' })+ expect($notifications.get().at(-1)?.message).toContain("Could not attach shots.png: 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.tsindex b0e87b8500a..59386210144 100644--- a/apps/desktop/src/app/chat/hooks/use-composer-actions.ts+++ b/apps/desktop/src/app/chat/hooks/use-composer-actions.ts@@ -47,6 +47,11 @@ export function isImagePath(filePath: string): boolean {return IMAGE_EXTENSION_PATTERN.test(filePath)}+/** A dropped File the composer sends as an image; never a folder, which has no bytes. */+function isDroppedImage(file: File, filePath: string, isDirectory?: boolean): boolean {+ return !isDirectory && (file.type.startsWith('image/') || isImagePath(file.name) || isImagePath(filePath))+}+/*** Read an attachment's thumbnail preview, local disk first. Paperclip picks,* clipboard saves, and OS drops always hand us paths on THIS machine — the@@ -119,6 +124,11 @@ export async function stageDroppedFilePath(candidate: DroppedFile): Promise<strireturn candidate.path}+ // A folder without a host path has no bytes to stage.+ if (candidate.isDirectory) {+ throw new Error("Folders can't be attached by dropping them. Use Attach → Folder… instead.")+ }+if (!candidate.file || !window.hermesDesktop?.stageFileForAttach) {return ''}@@ -240,10 +250,10 @@ export function extractDroppedFiles(transfer: DataTransfer): DroppedFile[] {seenPaths.add(path)}+ // A folder with no host path (the browser Webapp) keeps its File, so the+ // drop reaches the attach pipeline and is reported there, not dropped.if (isDirectory) {- if (path) {- result.push({ isDirectory: true, path })- }+ result.push(path ? { isDirectory: true, path } : { file, isDirectory: true, path })return}@@ -834,7 +844,7 @@ export function useComposerActions({!knownPath && window.hermesDesktop?.getPathForFile ? window.hermesDesktop.getPathForFile(file) : ''const filePath = knownPath || fallbackPath || ''- const isImage = file.type.startsWith('image/') || isImagePath(file.name) || (filePath && isImagePath(filePath))+ const isImage = isDroppedImage(file, filePath, isDirectory)if (isImage) {// Persist the File bytes into Desktop's durable composer-image cache