Skip to content

feat: read a dropped folder as Add folder reads a chosen one - #61

Merged
bencode merged 1 commit into
mainfrom
feat/drop-folder
Oct 1, 2026
Merged

bencode merged 1 commit into
mainfrom
feat/drop-folder

Conversation

@bencode

@bencode bencode commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Why

Dropping files onto the panel imports them, but a dropped folder was silently left out. The browser hands a dropped folder over as a File that cannot be read, so it used to be filtered away.

What changes

  • features/resources/pick-folder.ts: one walk for picked and dropped folders.
    • A small FolderNode shape (a directory lists its children; a file opens on request) has two thin adapters:
      • FileSystemDirectoryHandle, from Add folder in Chromium;
      • FileSystemEntry from webkitGetAsEntry(), from drops. This works in Chrome, Safari and Firefox. Entries are read batch by batch until readEntries returns an empty batch.
    • The walk is unchanged: ignored folders are never entered, it stops early past the limit, and it reports progress every hundred files.
    • readPickedFolder keeps its signature. readDroppedEntries is new.
  • resource-panel.tsx
    • On drop, the entries are taken during the event, because the transfer is emptied as soon as it ends.
    • If any entry is a folder, the drop goes through library.addFolder, with the same filtering, 5000 limit, progress and Replace / Skip existing dialog as Add folder.
    • Folders dropped together import together, each under its own name. Loose files in the same drop land at the root under the same rules.
    • A drop of only files works exactly as before.
    • The hint reads "Drop files or folders to add them".

Tests

  • pick-folder.test.ts: dropped folders are read across several batches, ignored folders are never opened (createReader is not called), and loose files keep root paths.
  • file-library-ui integration: dropping a file still adds it. Dropping a folder with node_modules plus a loose file shows the folder with its file, the loose file at the root, and no node_modules. This replaces the old test that asserted folders were left alone.
  • Not checked by hand: a real OS drag cannot be driven from the test browser.

pnpm check passes.

A folder dropped onto the panel was left out, because it arrives as a file
that cannot be read. It is now read entry by entry through the same walk as
Add folder, with the same filtering, limit, progress and duplicate choice.
Folders dropped together import together, and loose files dropped with them
land at the root. Dropping only files works as before.
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