Skip to content

File Shelf: keep a dragged-out file's name - #35

Merged
havokentity merged 1 commit into
mainfrom
fix/file-shelf-drag-name
Aug 26, 2026
Merged

File Shelf: keep a dragged-out file's name#35
havokentity merged 1 commit into
mainfrom
fix/file-shelf-drag-name

Conversation

@havokentity

Copy link
Copy Markdown
Owner

Reported from testing 0.16.0 on a real machine: a file dragged out of the shelf arrives at its destination without its name.

Cause

NSItemProvider(contentsOf:) leaves suggestedName nil while registering the file's content type ahead of public.file-url. A receiver that takes the representation it is offered first therefore gets bytes with nothing to call them, and names the result itself.

Confirmed with a probe rather than inferred:

provider suggestedName registeredTypeIdentifiers
NSItemProvider(contentsOf:) — what shipped nil public.plain-text, public.file-url, public.url
NSItemProvider(object: url as NSURL) nil public.file-url, public.url
contentsOf: + suggestedName Quarterly Report.txt public.plain-text, public.file-url, public.url

Fix

FileShelfKit.dragProvider(for:) sets the suggested name and keeps every representation on offer. Deliberately not NSItemProvider(object: url as NSURL): that also fixes the name, but drops the content representation, so a receiver that wants the bytes rather than a path loses out.

It also returns nil for a file that has gone since the last resolve. The row is gated on isAvailable, but that answer is as old as the last check and contentsOf: returns a provider regardless — which starts a drag that delivers nothing. Found because a test I wrote assumed the opposite and failed.

Tests

1182 → 1185. The name, that both representations survive, and that a vanished file yields no payload.

Ships in the next release; 0.16.0 has the bug.

NSItemProvider(contentsOf:) leaves suggestedName nil while registering the
file's content type ahead of public.file-url, so a receiver taking the first
representation it is offered got the bytes with no name attached and invented
one. Verified with a probe: contentsOf: alone reports suggestedName nil and
types [public.plain-text, public.file-url, public.url].

Naming the provider fixes it without narrowing what is on offer — a receiver
that wants the URL and one that wants the contents both still get what they
ask for, which is why this is not simply NSItemProvider(object: url as NSURL).

Also returns nil for a file that has gone since the last resolve. The row is
gated on availability, but that answer is as old as the last check, and
contentsOf: hands back a provider either way — which would start a drag that
delivers nothing.
@havokentity
havokentity merged commit 6a79ccf into main Aug 26, 2026
1 check passed
@havokentity
havokentity deleted the fix/file-shelf-drag-name branch August 26, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant