apache / apache/maka

bug(desktop): pasting a Finder folder stages it as a file and makes send fail

Open
#5,279 1 comment 0 reactions 1 assignee Claimed by @Totoro-qaq View on GitHub
bug
Dominant language
TypeScript
Stars
5.4k
Forks
502
Avg merge
1d 2h
Merged PRs (30d)
715

Description

### What happened

On macOS, copying a directory in Finder and pasting it into the Desktop composer creates a normal file-attachment chip. The chip looks sendable, but submitting the message fails with the generic send-failure toast ("Failed to send" / "Please try again").

Expected behavior: a pasted directory should either become the existing Host-bound folder reference used by **Reference folder**, or be rejected during paste with a clear localized explanation. It must not be staged as a normal file attachment that can only fail during submission.

This should not recursively upload or eagerly enumerate the directory.

### How to reproduce

1. Open Maka Desktop and an agent session with no turn running.
2. In macOS Finder, select a folder and press Cmd+C.
3. Focus the Desktop composer and press Cmd+V.
4. Observe that the folder appears as a normal file attachment.
5. Enter any text if needed and click Send.
6. Observe that submission fails with the generic send-failure toast.

### Environment

- Maka version or commit: observed in a downstream Desktop build at `3fe9ec9`; source inspection confirms the same path is still present in upstream `main` at `f109ccde9`
- OS and version: Darwin 25.6.0 (macOS, arm64)
- Surface: Desktop
- Electron: 43.4.1
- Chrome: 150.0.7871.224
- Node.js: 24.18.1
- Locale: zh-CN

### Logs, screenshots, or additional context

The visible toast is:

- Title: `发送失败`
- Description: `消息暂时无法发送,请稍后重试。`

The diagnostic report does not include the underlying renderer/preload exception. The source path explains why the folder first appears valid and only fails at send time:

- `packages/ui/src/composer.tsx`: `onInputFiles` forwards every clipboard `File` to `onAttachFilePaths` without distinguishing a directory.
- `packages/ui/src/use-composer-attachments.ts`: `sniffFileMimeType` catches a failed `file.slice(...).arrayBuffer()` read and still stages the item as an attachment.
- `apps/desktop/src/renderer/attachment-preflight.ts`: preflight checks only count and byte size, so a directory-shaped `File` is not rejected.
- `apps/desktop/src/preload/attachment-ingest-payload.ts`: submission later calls `file.arrayBuffer()` without mapping an unreadable/directory source to an expected attachment error, so the exception falls through to the generic send failure.

Related but not duplicate:

- #3994 defined directory context behavior.
- #4097 added the explicit **Reference folder** picker and Host-bound directory references, but the Finder paste path still goes through ordinary attachment ingestion.
- #4188 covered pasted images while a turn is running, not pasted directories.

A focused regression test could paste a directory-shaped clipboard item and assert that it is never staged as an ordinary attachment or allowed to reach `encodeIngestItems` as a file.

AI assistance: OpenAI Codex inspected the source paths, searched existing Issues and PRs, and drafted this report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.