Skip to content

feat: remove a whole folder from the library at once - #62

Merged
bencode merged 2 commits into
mainfrom
feat/remove-folder
Oct 1, 2026
Merged

bencode merged 2 commits into
mainfrom
feat/remove-folder

Conversation

@bencode

@bencode bencode commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Why

After a folder import (#58/#61), the library could hold hundreds of files under one folder, but they could only be removed one at a time.

What changes

  • Folder rows get the same hover remove button as file rows (Remove folder <path> from Files).
  • Confirmation: "Remove this folder from Files? This removes the browser copies of the N files in …". It also warns when any of them has unsaved source changes.
  • data/file-store.ts: removeStoredFiles(ids) deletes files and their contents in one transaction, so a folder never goes half way. The single-file removeStoredFile was only a test convenience after this and is gone. Its callers now pass [id].
  • use-file-library.ts: removeFile(id) → removeFiles(ids).
  • resource-panel.tsx: one removal state for a file or a folder.
    • onRemoved now takes the removed ids, and workbench.tsx passes workspace.closeDocuments, so every open tab of the folder closes.
    • Drafts for the removed files are forgotten by the existing workspace effect.
  • file-tree.ts: folder nodes carry their path as first spelled. A pure filesInFolder(files, path) matches the folder ignoring case, the same way the tree groups folders. The removal state keeps only the folder path, so the dialog's count and the removed files are read at render and confirm time. A file landing in the folder while the dialog is open is included.

Repository fix

  • .gitignore had data/, which also matched ui-packages/web/src/data/. New files there were silently not committed. That is how fix: let a newer tab upgrade the library instead of waiting silently #54's workspace-database.test.ts never reached main, despite its PR description.
    • The rule was meant for the server's local quota database: GAMMA_DATA_DIR defaults to data relative to the server package.
    • It now reads /data/ and /web-packages/server/data/, which covers the server run from its package or from the repo root. I checked that both are ignored and that the web src/data is not.
  • data/workspace-database.test.ts is restored: the library gives way to a newer page's upgrade, and does not give way to a deletion. The upgrade version moves from 8 to 9 because the library is now at 8.

Review

I read the diff before opening this PR. An independent review found nothing serious. It raised two low-severity edge cases, both fixed in the second commit:

  • the root data/ folder, used when the server is started from the repo root;
  • the folder's file list being fixed when the dialog opened, rather than when it is confirmed.

Also confirmed:

  • Removal is atomic and leaves other files untouched.
  • Tabs close through the existing bulk close path.
  • The confirmation counts files at any depth.
  • Attachments have no folders, so their list is unchanged.

Not handled: a folder export already on disk keeps its files (export never deletes, as before).

Tests

  • file-store: removing several files together leaves the rest.
  • file-library-ui integration: removing a folder whose file is open shows the dialog with the right count, closes the tab and removes the folder, and other files stay.
  • Checked in Chromium: imported src/core (32 files), removed it from its row, and the folder was gone.

pnpm check passes.

A folder imported with hundreds of files could only be removed file by file.
Folder rows now carry a remove action that deletes every file in the folder in
one transaction, after a confirmation naming how many files go, and closes
their tabs.

The ignore rule for data/ also matched the web package's src/data, so new files
there were silently left out; it now names only the server's quota database
folder, and the two workspace database tests lost to it are back.
…older

The files to remove were fixed when the dialog opened, so a file landing in the
folder meanwhile stayed behind; the dialog now counts and removes the folder's
files as they are when it renders and confirms. The server writes its quota
database to data/ beside wherever it runs, so the repository root's data/ is
ignored as well.
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