Repository navigation
ALI-2598: Show a folder's item count in the Size column - #63
Conversation
A folder's Size cell now says how many items it holds: "8 items", "1 item", "Empty", or "10,000+ items" past the cap, where counting stops. It follows the show-hidden setting, and a screen reader reads it as the cell's text. - Counting is one listing of the folder, done on the listing's stat thread after each chunk's stats, only for rows on screen, so first paint is unchanged. Counts are kept per listing in a small map, so a folder of files costs nothing. - Each counted folder gets a one-shot inotify watch in a set the window polls. A change marks the count stale, and it's counted again 100 ms later; the old count shows meanwhile. Reading the folder again keeps the counts on screen showing until they're recounted. - Network places aren't counted: the folder's real path and the mount table decide, so NFS, SMB, GVfs and other FUSE mounts (but not fuseblk), autofs points and links into them stay blank. - Sorting by size counts every folder and orders folders by their count, still before files. Toggling hidden files re-sorts when sorted by size. - A long count reaches left of its column, and the name beside it is cut short of it.
|
Review round 1. The code-review skill ran, and its findings were checked against the code. Being fixed:
Confirmed fine:
|
- A folder counted for the Size sort isn't watched, so once it's on screen it's opened, watched, and read again only if its inode or modified time changed since it was counted. The same goes for a listing shown again from the cache, and for a folder that found no room for a watch. - A change heard while a folder is being read marks it to count again: each entry keeps a mark that `recount` bumps, even before the row has a count, and a count that sees it moved leaves the row stale. - Reading a folder again starts from the last listing's counts by name. The row's stat checks each against the folder's inode and modified time, so sorted by size only folders that changed are read again. - A folder that keeps changing waits twice as long each time, up to 2 s, and goes back to 100 ms once it's quiet for a second. The waits are motion tokens: recount-after, recount-quiet and recount-max-wait. - Counting stops after reading 100,000 entries, saying "10,000+ items". - Links are followed a step at a time with readlink, up to 40, and each path on the way is checked against the mount table first, so a chain of links or a linked folder can't lead into a network place. - Showing a hidden file from Quick View re-sorts when sorted by size. - The stat thread looks for a newer request between folders it counts.
The design README keeps timings that pace work, not what's seen, in the code, so recount-after, recount-quiet and recount-max-wait leave the token file for named constants in app.rs, and the README lists them with the other behaviour values.
|
Round 1 fixes are in 4653da6, with 0234a2b moving the timings back into code. 11 fixed, 1 declined.
Unit tests: 940. Clippy: 0 warnings. |
|
Review round 2. The code-review skill ran, and its findings were checked. Being fixed:
Confirmed fine:
|
- A sort by size goes by the items that show, so showing hidden files during a load sorts again, and a folder shown again from the cache sorts again if hidden files were shown or hidden since its order was kept. - A watched folder deleted, or its disk unmounted, says only IGNORED: that frees its place and counts its row again. - A watch the system won't add (its limit, or no /proc) isn't tried again on every scroll, only once a watch has been let go of, or on a new listing. - A folder read only as far as the 100,000-entry ceiling says how many that show it found, "3+ items", and sorts by that, rather than "10,000+". - A stamp carries the folder's disk, and is trusted only once its modified time is 2 s old, for disks that keep times to the second or two. A count without one is still shown from the last listing, and read again. - A link to a folder whose count came from the last listing is opened to check its target's stamp, and read only if that changed. - The rename field is as narrow as the name beside a wide count. - Counting every folder for a sort checks for a cancel between folders.
|
Round 2 fixes are in 92fb568.
Unit tests: 948. Clippy: 0 warnings. |
|
Review round 3 (code-review ran) on 92fb568: no P1 or P2. Confirmed:
Small cleanup coming for the P3s:
|
- "N+ items" only when an entry follows the 100,000th: a folder of exactly that many is counted whole. - The rename field beside a wide count keeps at least a target's width or four letters, and covers the count while it's open if there's no room beside it. The e2e checks it at 480 px wide and twice the scale. - The 1,024-watch limit counts only new watches, so a link to a folder already watched isn't refused at the limit. - A stamp carries the folder's changed time (ctime) as well, which rsync -t, tar -p and touch -r can't set back, and is trusted once both times are 2 s old. - A count that fails for want of file descriptors, or is interrupted, keeps what it showed and is tried again; no permission or nothing there stays blank.
…der-counts # Conflicts: # crates/core/src/lib.rs
… filesystems counts::uncounted now asks complete::avoided_fs, so both avoid the same network, autofs and FUSE (but not fuseblk) mounts, which adds sshfs and afs to what isn't counted. The root is always counted, even as a container's fuse-overlayfs, as the path bar's suggestions treat it.
|
Round 3 cleanup (d0eb52b and e431490), the merge of main (a6bee69), and one shared filesystem list (41190ab):
Unit tests: 968. Clippy: 0 warnings. |
…der-counts # Conflicts: # crates/app/src/main.rs
Fixes ALI-2598.
A folder's Size cell was blank, so a folder full of folders showed nothing in that column. It now says how many items the folder holds, as Nautilus and Folio do.
Behaviour
listing::Staterthread after each chunk's stats. No new thread is started per folder.fuseblk(NTFS) is counted.Measurements
Median of 5 warm runs, headless sway, alternating with main. Idle is measured over 3 s.
First-paint differences are under 1 ms in both directions, which is noise. The extra 4 MiB in the last row is the window's second 4 MB drawing buffer, used because the counts cause one more paint (checked in smaps). main uses it too wherever sizes arrive after first paint.
Not measured: a slow or cold drive.
Accessibility
Counts use the muted colour that file sizes use. The lowest WCAG ratio is 4.54:1 (muted on hover); on base it's 5.21:1.
design/build --checkpasses.Checks
a_folders_size_says_how_many_items_it_holdscovers counts, a 10,001-file folder, live updates, hidden files and sorting, and fails against main. The screen-reader check now expects "1 item".Hardened in review (three rounds, recorded in the comments)
complete::avoided_fsrule path suggestions use.