Skip to content

List other drives' trash in Trash - #138

Merged
dhh merged 6 commits into
omacom:mainfrom
neheb:trash-other-drives
Nov 16, 2026
Merged

dhh merged 6 commits into
omacom:mainfrom
neheb:trash-other-drives

Conversation

@neheb

@neheb neheb commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Fixes #137.

Something deleted on another mounted drive goes to that drive's own trash (.Trash-$uid at its top), but Trash only listed ~/.local/share/Trash/files. Those items couldn't be seen, restored or deleted one at a time, and when the home trash was empty the Empty Trash bar (visible: pane.inTrash && backend.folder.count > 0) disappeared, so there was nothing to click.

Change

  • FolderModel::list() sends the home trash's files folder to a new FolderModel::listTrash(), which lists every folder FileOps::trashDirs() finds and sorts them all together. This runs on the background listing thread, so the mount sweep stays off the GUI thread (see UI freezes on every navigation: inTrash() sweeps all mounts on the GUI thread (dead sshfs mount = multi-second hangs) #80).
  • After a Trash listing finishes, the other drives' files folders that have items in them are watched too.
  • Nothing else needed to change: restoreOne, deleteTrashed/infoFileFor and emptyTrash already handle every trash folder. Because the listing count now includes other drives, Empty Trash shows up whenever any trash has items.

Testing

  • New test trashListsEveryDrivesTrash: one item in the home trash and two in another drive's trash are listed and sorted together, a drive with no trash folder is skipped, and the listing stops when it's interrupted.
  • bin/test: all pass (191 passed, 12 skipped).
  • On a machine with a real NFSv4.2 mount: after trashing a file there, the Trash listing includes <mount>/.Trash-1000/files/<file>, and deleting it removes both the item and its note.

🤖 Generated with Claude Code

What's deleted on another mounted drive goes to that drive's own trash
(.Trash-$uid at its top), which Trash never listed: it couldn't be seen,
restored or deleted, and with the home trash empty there was no Empty
Trash to press either.

Trash now lists every trash folder FileOps::trashDirs() finds, sorted
together, and watches those with something in them. Restore, Delete and
Empty Trash already worked on any of them.

Fixes omacom#137

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge; both numbered previous findings are fixed.

Summary

The PR combines home and mounted-drive trash in one listing and searches them together.

  • The Trash view lists items from every drive’s trash.

Reviews (5) · Last reviewed commit: "Share a search's limit across the trashe..." · Reviewed by Greptile

Comment thread src/foldermodel.cpp Resolved
Comment thread src/foldermodel.cpp Resolved
A search in Trash looked only in the home trash, missing what Trash
lists from other drives. And another drive's trash was watched only once
it had something in it, so what was trashed there into an empty trash,
or a drive's first trash, didn't show until Trash was opened again.

Trash's search now runs over every trash's files folder, sorted together
and limited in all. Its listing, off the window's thread, also says what
to watch: each trash's files folder, empty or not, and the top of each
writable drive without a trash yet, where the first trash on it is made.
A folder watched for the first time is read once more, for anything that
arrived before it was watched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/foldermodel.cpp Resolved
A drive's first trash is made a folder at a time: .Trash-<uid>, then its
files folder. Trash watched the drive's top until the files folder was
there, and a top folder isn't told what's made in its folders, so what
was trashed after a listing that ran in between didn't show. Trash now
watches the deepest folder of a drive's trash there is so far (and the
drive's shared .Trash, or its folder for the user, when there's one).

And once a drive has its trash, its top is no longer watched: Trash
stops watching what its latest listing doesn't name, so changes there
don't list every trash again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the bug Something isn't working label Nov 16, 2026
The maintainer asked for this to be as simple as it can be. Trash lists and searches every trash's files folder through one listTrash(), on the listing thread, and watches another drive's trash once it has shown something from it.

Trash no longer watches the top of every writable drive for a first trash to appear. That watched /tmp and /run/user/<uid>, so ordinary activity there re-listed Trash, and each re-listing looked over every mount again. A drive's first trash, made while Trash is open, now shows the next time Trash is opened.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Watching only the trashes something was listed from missed an empty one: what another app, or another Folio pane, trashed onto that drive while the trash was open didn't show until it was opened again. The listing now hands back the trash folders it found, and each one's files folder is watched, as the home trash's is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Contributor

Reviewed and run on a disposable Omarchy worker. #137 is real and this fixes it. The maintainer asked for this pull request to be as simple as it can be, so I pushed a smaller version of it to your branch, plus one fix. One problem is left, and the maintainer needs to decide how to fix it.

The bug. I loop-mounted a user-owned ext4 image at /mnt/d138 and trashed one file there and one at home. On main, Trash lists only the home item. With this branch merged into current main, it lists both, sorted together. On that drive, Delete for good, Restore and Empty Trash all worked and stayed on the drive. Restore put the file back at /mnt/d138, and each item's note went with it. The view updated after each action. With only the other drive's item left, the Empty Trash bar still shows, and its count matches the list.

Before, on main: Trash lists only from-home.txt
After, this branch merged into main: Trash lists from-home.txt, from-second-drive.txt, keep-me.txt and restore-me.txt

Pushed: a321d55, "List every drive's trash with less." The approach is still yours: list each trash's files folder on the listing thread, then sort them together. One listTrash() now does both the listing and the search, and the reload reuses the existing list() and search(). Trash watches every trash folder it finds. It no longer watches the top of each writable drive, so trashWatchPaths() and the fileops changes are gone. On the worker, those drive tops included /tmp and /run/user/1000. Touching files in /tmp with Trash open re-listed Trash over and over, and each pass checked every mount again (statfs on the loop drive went from 5 to 25 for 10 touches). The trade-off: a drive's very first trash, if it is made while Trash is open, shows the next time Trash is opened. A search now applies its 1000-result limit to each trash separately instead of to all of them together. The test is now one listing and one search over two trash folders plus one missing folder. It fails if only the first trash is read, if the search term is ignored, or if the combined list isn't sorted. Against the base, src/ goes from +138/-7 to +34/-3 and tests/ from +49 to +19. The pull request description still describes the earlier version.

Pushed: a3abbca, "Watch every drive's trash while the trash is shown." In the smaller version, another drive's trash was watched only once it had shown an item. If that trash was empty when Trash opened, anything trashed there later (by another app or another Folio pane) didn't show. On the worker, a file trashed with gio into an empty /mnt/d138/.Trash-1000 stayed hidden before this commit and appeared after it. The listing now returns the trash folders it found, and each one is watched.

Conflict. The branch conflicted with main's f5cbc03 (#93, "Tell the trash from the path, without asking every drive") in src/fileops.cpp. trashWatchPaths() sat right next to #93's new trashFor(). The smaller version doesn't touch src/fileops.*, so GitHub now reports the branch as mergeable. I resolved no conflict. Nothing here repeats #93 or depends on it. With #93 merged, FileOps::inTrash() no longer checks every drive on the window's thread. This branch only checks the drives' trash on the listing thread.

Left for the maintainer: a drive that stops answering. Each Trash listing now checks every mounted drive, on the app's shared thread pool. I froze an rclone FUSE mount at /mnt/f138 by sending its daemon SIGSTOP, opened Trash, and trashed six files one at a time. Each re-listing got stuck on the frozen mount: five pool threads waited on FUSE. After that, every folder in the window showed empty until the mount answered again. The window itself stayed responsive. Main, given the same steps, listed folders normally. This is #80's failure in another form. Your original version behaves the same way. Both reviewers suggested running Trash listings on a pool of their own, with one thread. Then a dead drive holds up only Trash. That is a choice about thread pools, and it overlaps #116, so I haven't made it.

Frozen mount, this branch merged into main: after six trashings, every column of ~/Documents/listing-check is empty

Clicking Empty Trash still counts every drive's trash on the window's thread through trashCount(). Main does the same. The difference is that the button now shows up more often.

Tests. The full suite passed on a worker: 203 passed at this head, and 209 passed and 1 skipped with this branch merged into current main. One earlier merged run hit the known 5 s timeout in pluginCommandsRunInTheirFolderAndEndWhole, and the two reruns passed. CI's Test workflow is waiting for a maintainer to approve running it on this fork.

Second opinion. Codex (medium effort) and muse-wonder (via pi, high thinking) reviewed this in two rounds. Codex found the missing watch on an empty trash, which is why a3abbca exists. Both confirmed the frozen-mount problem from the code and agree that fixing it is a design decision. I rejected one Codex claim. It said Folio's own operations reload the pane, but that connection is the translator's, and the pane updates only through the watcher. In the second round, both found nothing more to change. Both models could read this review's working notes, so their agreement isn't fully independent.

This now waits on the maintainer: whether to keep Trash listings off the shared pool before merging, and approval to run CI.

Comment thread src/foldermodel.cpp Resolved
Comment thread src/foldermodel.cpp Resolved
Simplifying listTrash() dropped two things the original searchTrash() and listTrash() had. Each trash got a fresh 1000-match limit, so a search kept going through later drives after earlier ones had filled it. And nothing checked stop between trashes, so a listing left behind still went on to read each remaining drive. One limit now covers every trash, no further drive is searched once it is reached, and a listing that is stopped returns before the next drive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Contributor

Greptile's two notes on a3abbca were right, and the fault was ours. When we simplified this pull request in a321d55, we dropped two things your searchTrash() and listTrash() had. Our earlier comment listed them as noted and left unchanged, and that was the wrong call. Pushed: 8a78e70, "Share a search's limit across the trashes, and stop between them," which puts both back:

  • One search limit for every trash. Each trash is searched with what's left of the 1000-match limit, and once it's used up no further drive is searched.
  • A check of stop before each trash. A listing or search that has been left behind (Trash closed, or the query changed) returns before it reads another drive.

Two assertions were added to trashListsEveryDrivesTrash. Each one failed on a worker with its fix removed. Removing only the early exit once the limit is reached leaves the test green, since search() with nothing left returns nothing. That line saves a stat() of each remaining drive, which is why it stays. The full suite passed on a fresh worker: 203 at this head; with this branch merged into current main, 214 passed and 1 skipped (one run hit the known 5 s timeout in pluginCommandsRunInTheirFolderAndEndWhole, and two reruns passed).

Codex (medium effort) and muse-wonder (via pi, high thinking) reviewed the commit and found nothing wrong with it. They also compared your original version line by line with the simplified one, looking for anything else it shouldn't have dropped. What else was dropped, and why:

  • Watching the top of every writable drive. Dropped on purpose. A drive's first trash, made while Trash is open, shows after F5 or the next time Trash is opened.
  • Removing old watches. There are no drive-top watches left to remove.
  • The previewer's merged list. Your version merged the list only when the preview started from a home-trash item.
  • The extra read after a new watch is added. The reviewers split on this one. Codex says it should come back, because anything another app does on a drive between that drive's listing and its watch being added is missed until the next change. Muse-wonder says the window is small and the extra read would list every trash twice each time Trash opens. That trade-off is left for the maintainer.
  • Muse-wonder also asked for isTrash() to cover every drive's trash, and for the home trash to be watched again from the listing. Your version didn't do either, so neither was lost here.

I've replied on each Greptile thread with the commit that answers it. Both models could read this review's notes, so their agreement isn't fully independent.

This still waits on the maintainer. They need to decide whether Trash listings move off the shared thread pool before merging: a drive that stops answering can tie up every listing thread. They also need to approve the CI run for this fork.

@greptile-apps

greptile-apps Bot commented Nov 16, 2026

Copy link
Copy Markdown

Want your agent to iterate on Greptile's feedback? Try greploops.

@dhh
dhh merged commit 795e741 into omacom:main Nov 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working verified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trash ignores other drives' trash folders: their items aren't listed and Empty Trash disappears when the home trash is empty

3 participants