Skip to content

fix(desktop): handle OS-dropped folders — detect directories via stat, route to attachContextFolderPath - #44606

Closed
thedavidweng wants to merge 1 commit into
NousResearch:mainfrom
thedavidweng:fix/desktop-folder-drop-attach
Closed

fix(desktop): handle OS-dropped folders — detect directories via stat, route to attachContextFolderPath#44606
thedavidweng wants to merge 1 commit into
NousResearch:mainfrom
thedavidweng:fix/desktop-folder-drop-attach

Conversation

@thedavidweng

Copy link
Copy Markdown
Contributor

What

When a folder is dragged from Finder/Explorer into the Desktop composer, the browser File API does not expose isDirectory, so the drop handler treated it as a regular file. On submit, readFileDataUrl threw EISDIR, and the gateway received no data_url — producing:

file not found on gateway and no data_url provided

Changes

  1. main.cjs — new hermes:fs:isDirectory IPC handler that stat-checks the resolved path (uses existing resolveRequestedPathForIpc for path safety).

  2. preload.cjs — expose the new IPC method as window.hermesDesktop.isDirectory(path).

  3. use-composer-actions.ts — in attachDroppedItems, before the image/file branch for OS drops, check isDirectory via the new IPC call. If true, route through attachContextFolderPath — matching the existing in-app folder drag behavior (creates a kind: 'folder' attachment with @folder: ref).

  4. global.d.ts — add isDirectory to the hermesDesktop type definition.

What is NOT included

  • Copy-paste of folders — the clipboard handler (handlePaste in composer/index.tsx) only processes image blobs. Detecting folder paste events requires a different approach (the clipboard API doesn't expose file-system paths for pasted directories). This is a separate concern.
  • Remote gateway folder support — when the gateway is remote, the folder path from the client machine won't resolve on the server. The existing in-app folder drag already has this limitation; extending it to OS drops is out of scope here.

Testing

  1. Drag a folder from Finder into the Desktop composer → should appear as a folder attachment (not a file)
  2. Send a message → agent should receive the @folder: reference and be able to list its contents
  3. Drag a file from Finder → should still work as before (image or file attachment)
  4. In-app folder drag from project tree → should still work as before

Closes #44581

When a folder is dragged from Finder/Explorer into the Desktop composer,
the browser File API does not expose isDirectory, so the drop handler
treated it as a regular file. On submit, readFileDataUrl threw EISDIR,
and the gateway received no data_url — producing the error:

  file not found on gateway and no data_url provided

Add a lightweight hermes:fs:isDirectory IPC call that stat-checks the
resolved path. In attachDroppedItems, use it to detect OS-dropped
directories before the image/file branch and route them through
attachContextFolderPath, matching the existing in-app folder drag
behavior.

Copy-paste of folders from Finder remains unhandled (the clipboard
handler only processes image blobs); that is a separate concern.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have labels Jun 15, 2026
@alt-glitch alt-glitch added comp/desktop Electron desktop app (apps/desktop/*) and removed comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels Jun 26, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Desktop reproduction and fix direction. This is an automated hermes-sweeper review; the reported behavior is already implemented on current main through a more direct drop-time detector.

  • a488fcf107d1c61400db4274c0baf357b908c772 (fix(desktop): detect dropped folders so they attach as @folder refs) detects folders with DataTransferItem.webkitGetAsEntry() in apps/desktop/src/app/chat/hooks/use-composer-actions.ts:176-205.
  • The current code emits dropped directories as path-only isDirectory entries at apps/desktop/src/app/chat/hooks/use-composer-actions.ts:165-173, then routes them to attachContextFolderPath at :527-539, producing @folder: attachments.
  • Regression coverage is present at apps/desktop/src/app/chat/hooks/use-composer-actions.test.ts:124-187, including folder, file, mixed-drop, and deduplication cases.
  • The fix is included in v2026.7.1; the timeline's related merged PR fix(desktop): detect dropped folders so they attach as @folder refs #56029 delivered the current implementation.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users labels Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:implemented-on-main Sweeper: behavior already present on current main sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Desktop folder attach fails — drag-and-drop errors with 'file not found on gateway and no data_url provided', copy-paste silently ignored

3 participants