Skip to content

Latest commit

Β 

History

History
1416 lines (1355 loc) Β· 120 KB

AGENTS.md

File metadata and controls

1416 lines (1355 loc) Β· 120 KB

AGENTS.md β€” Duscape Agentic Development Guide

Project Overview

Duscape is an interactive terminal disk space navigator (TUI) written in Rust. It visualizes disk usage via a squarify treemap, supports live scanning, and allows deleting large files in-place.

Workspace layout (Rust 2024 edition, version 0.2.1; duscape, a fork of diskonaut renamed after 0.2.0 so as not to clash with upstream's command β€” see README):

duscape/
β”œβ”€β”€ common/            # libduscape: what every viewer shares β€” model, treemap, scan protocol,
β”‚                      #   delete, preview reading, native clipboard, formatting, os
β”œβ”€β”€ scanners/          # duscape-scan: the walkers (Linux, macOS, Windows, portable), NTFS,
β”‚                      #   the parallel build, the second pass, rescan/refine threads
β”œβ”€β”€ viewers/
β”‚   β”œβ”€β”€ tui/           # duscape: the ratatui viewer (primary) β€” CLI, UI, input, config;
β”‚   β”‚                  #   its `duscape` binary holds the platform's window too (`front.rs`)
β”‚   β”œβ”€β”€ windows/       # duscape-windows: the Win32/GDI viewer
β”‚   β”œβ”€β”€ macos/         # duscape-mac: the AppKit viewer (objc2)
β”‚   β”œβ”€β”€ linux/         # duscape-linux: the Wayland/X11 viewer, no toolkit (wayland-client, x11rb, ab_glyph)
β”‚   β”œβ”€β”€ shared/        # duscape-viewer: what the desktop viewers share β€” the window's
β”‚   β”‚                  #   state and layout (`Viewer`), the first scan with its outline, the previewer
β”‚   └── dos/           # not a crate: the MS-DOS treemap in 16-bit FASM assembly, `make dos`
β”œβ”€β”€ docs/              # features.md (every feature, per viewer), sizes.md (how sizes are counted),
β”‚                      #   security.md (defenses against malicious/bad files), terminal.md, viewers.md,
β”‚                      #   benchmarking.md, scan-performance.md (the measurements),
β”‚                      #   packaging.md (static binary first; deb/rpm, Flatpak, Snap weighed),
β”‚                      #   probes/ (bench-matrix.sh and .ps1, drop-cache.ps1, bench-diskus.sh, cross-arch-tests.sh
β”‚                      #   (32-bit and big-endian under QEMU), the C/Python probes behind the measurements)
β”œβ”€β”€ installer/         # duscape.nsi (the Windows installer, NSIS) and path.ps1 (its PATH edit);
β”‚                      #   `make installer`
β”œβ”€β”€ packaging/linux/   # the .desktop file, AppStream metadata and hicolor icons, by the app ID;
β”‚                      #   in the Linux tarballs as share/ (docs/packaging.md: why static first)
β”œβ”€β”€ example/config.toml
└── Cargo.toml         # Workspace root

Dependencies run one way: duscape-scan β†’ libduscape, each viewer β†’ both, and the desktop viewers (Windows, macOS, Linux) β†’ duscape-viewer too. The terminal viewer β†’ the platform's window crate, by its gui feature (default): the window crates are libraries (run, and run_with for a command line read elsewhere) with a thin binary of their own each, and duscape is one program per platform. A feature that is not drawing or input goes in common (or scanners, if it reads the disk), so the other viewers get it by calling it; what is about the window but not about a toolkit (which entry is in hand, marks, the layout in points, what a delete changes) goes in viewers/shared, so the three desktop viewers behave alike. The scan protocol types (ScanOptions, EntryMeta, DirEntries, Outline, Found) are in common because the model consumes them; duscape-scan re-exports them, so duscape_scan::X works for either kind.

Performance goals (a soft spec)

What every change is held to, adapted to sane practical defaults rather than met to the letter:

  • Fast walkers and fast renderers. A feature is not done until its cost is measured on a real disk (--benchmark for the walk; tests/layout_speed.rs and DUSCAPE_PAINT_TIMES for the window β€” "Modifying treemap layout" below) and is small beside the work it sits in.
  • Fast time to first paint. Show what is cheap now and refine after: the outline during the scan, the tree when it is done, the second pass over small files (refine_N) after the tree is on screen.
  • About 60 fps while laying out again (a resize, a folder change, a zoom): a relayout within LAYOUT_BUDGET (10 ms) so the paint fits in the frame too.
  • Adapt, do not just degrade. A feature found to slow a frame is measured as it runs and put off to a second pass when it would overrun, not dropped; the second pass runs once input has stopped for IDLE (60 ms), each change putting it off again. Prefer that shape β€” coarse now, complete after β€” to a switch the user has to find. What does it now:
    • the nesting stops at the relayout's deadline, a level at a time across every folder so it is the deepest levels that wait, and lays out no more than FIRST_PASS_ROOM (1000) of any one folder's entries (Nesting::deadline, room_cap);
    • the specks of the "small files" corners come with the tiles only while the last complete layout with them, scaled by area to this one, would be inside the budget, and even then stop at half of it (Nesting::dust_deadline): a corner's specks grow far faster than the window (a cache of 256 folders: 5k at 1600Γ—1000 points, 119k at 2560Γ—1400), and before both a maximised first frame took 33 ms, now 7 (Viewer::defer_to_second_pass, finish_second_pass, second_pass_owed);
    • the first paint of a layout stops labelling the treemap's tiles at passes::LABEL_DEADLINE (4 ms spent on labels, Windows and Linux); the second pass paints in full, and a layout painted in full once stays so (passes::Paints, by Viewer::layout_generation), so labels never come and go on a hover.
  • And what is cheap should stay cheap: a folder tile is filled only around what its nested entries cover (Inside), not under them β€” filled whole, each level painted its parent's area again; and text is measured once and drawn with ExtTextOutW, not DrawTextW, which laid each line out again for its ellipsis.
  • Where it stands (2026-09-27, 1.5x, the Windows window resized about 1400–1850Γ—1000 px): the first frame after a relayout β€” the layout's first pass and a hurried paint β€” is 11–14 ms on C:\Windows (layout 4.7–5.3, paint 6.4–6.9), E:\ and the 87k-file Dell backup alike; the second pass's full paint is 6–12 ms. Before this round it was 18–21. The flat Dell folder's 87k-entry top level is still laid out whole in its first pass (6–8 ms).

Essential Commands

cargo build --workspace          # Build everything
cargo test --workspace           # Run all tests
cargo clippy --workspace --all-targets -- -D warnings   # Lint
cargo fmt --all                  # Format code
cargo fmt --all -- --check       # Format check (CI)

On Windows without make: .\make <target> runs the same Makefile β€” make.cmd starts make.ps1, which reads it and runs each recipe line in Git for Windows's bash (MAKE_SHELL names another). It interprets the subset of make this file uses and stops on anything else, so a recipe is written once. .\make -n <target> prints what it would run.

Windows setup and installer: .\make setup-windows is setup-ubuntu's counterpart β€” zig (the version deploy.yml pins) and NSIS into target/tools, each zip checked against a SHA-256 pinned in the Makefile, then cargo-zigbuild, typos, cargo-deny, cargo-llvm-cov; Rust with the MSVC build tools and Git for Windows come first, by hand. .\make installer builds the release's GNU exes with zig and installer/duscape.nsi around them, to target/installer/duscape-<version>-x86_64-setup.exe. The installer is per user (%LOCALAPPDATA%\Programs\duscape, HKCU only, no elevation: the window elevates itself when a volume wants it), with the Start menu shortcut on duscape-windows.exe (no console flash before 11 24H2), and the PATH and Explorer menu as ticked options. Its paths use backslashes: Windows's makensis does not find File "dir/name". The PATH edit is PowerShell (path.ps1), not NSIS, whose strings stop at 1024 characters and would cut a long PATH short. Not yet in deploy.yml, and not signed.

Static release binaries (what deploy.yml ships; see "Releases" below):

make static           # x86_64-unknown-linux-musl, needs musl-gcc (apt install musl-tools);
                      #   on macOS by cargo-zigbuild, jemalloc archived with `zig ar` (Apple's
                      #   `ar` drops ELF objects, and the link fails on `_rjem_malloc`);
                      #   on Windows the native MSVC build, crt-static by .cargo/config.toml
make static-aarch64   # aarch64-unknown-linux-musl, needs zig + cargo-zigbuild
make static-windows   # x86_64-pc-windows-gnu by cargo-zigbuild; on Windows the native build

Run the binary:

cargo run --bin duscape -- [FOLDER]
cargo run --bin duscape -- -a  # apparent size mode

Architecture

Thread Model

Six kinds of thread communicate via mpsc channels (bounded, except the previewer's inbox), plus parallel::SHARDS tree builders that share nothing:

Why (the performance goals): nothing that waits β€” on the disk, on a decode, on a timer β€” runs on the thread that draws, so the first paint comes while the walk is still going and no frame is held up by I/O. The channels are bounded so a fast walker cannot bury the renderer; what is sent to main is sized to the screen (the outline), not to the disk. Every desktop viewer keeps the same split: a scan thread, a previewer, rescans, and the window's own thread only laying out and painting.

Thread Role
stdin_handler Reads crossterm events β†’ Instruction::Keypress
hd_scanner Drives the walk (its own worker pool). Sends each directory to one tree_builder by path prefix, and feeds an Outline that sends main a folder-only view β†’ Instruction::AddScannedSummaries (batched, ~4096 entries). Directories deeper than Outline::DEFAULT_DEPTH are rolled up into the frontier folder above them rather than sent, so main does O(visible) work, not O(directories) β€” except under the folder shown (App::scan_focus, a scan::Focus the walkers and the outline watch): the walk reads toward it first (duscape_scan::focus), the outline sends what is under it whole to DEFAULT_DEPTH below it, the folder itself with its files, and a batch holding any of it goes every Outline::FOCUS_FLUSH (the desktop viewers': any batch every scan::FRAME). When the walk ends: merges the builders' trees, replays deferred shared blocks β†’ Instruction::ScanComplete(tree), then StartUi
tree_builder_N Owns a private FileTree in deferred-sharing mode and adds whatever hd_scanner sends it. Never touches another thread's memory
mft_reader Windows, elevated, a volume root: flushes the volume and reads the NTFS master file table (mft::walk_mft, Reading::run), handing each chunk's Charges (made on the parsers' threads) to mft_live and, once the table is read whole, the listing to hd_scanner as Audience::Tree. A read that fails part way reports through the walk and the kernel walk takes over
mft_live The view's running totals while the table is read (mft::Running): each directory's files so far, as one DirEntries of Audience::View with the sizes in its unlisted, every LIVE_EVERY (16 ms, a frame: in practice a flush a chunk), the last of a flush marked so the outline sends the batch at once β€” so the treemap is up and growing from the first chunk, not after the last. On the reading thread the flushes were a quarter of the read; here they cost it nothing (measured both ways, DUSCAPE_NO_LIVE_TOTALS)
mft_seeder Lists the top SEED_DEPTH (6) levels through the kernel, breadth first, beside the flush and the read, and seeds Running with each directory's record and place: the table's records are in no tree order (an upgraded Windows's C:\Windows is a late record, and every chain through it waited for its chunk), and through the kernel the levels the view shows are known in milliseconds. Ends with the read
event_executer Converts Event β†’ Instruction (visual feedback). A clipboard flash gets a short-lived clipboard_flash thread that asks for a redraw when it expires; the flash carries its own deadline, so a lost redraw cannot leave it on screen
loading_loop Toggles loading indicator while scanning
ticker Sends Instruction::Tick with try_send (late ticks are dropped): every ui::FRAME (16 ms) while App::ticker_pace says the help line is sliding, else every ui::IDLE_TICK (250 ms), looking again one frame after each resting tick since a slide begins on one β€” twice per resting interval, not at frame rate. App::tick moves the help line (ui::Ticker/Strip)
refine_N The second pass (duscape_scan::rescan::Refiner β†’ refine::refine, a few refine_* workers): FIEMAP on the small files the walk noted (SmallFiles, 4–64 KiB, nlink == 1, XFS/btrfs), directories under App::scan_focus (the folder shown) first β†’ Instruction::Refined(generation, Found, left); FileTree::apply_found charges them to the ledger. A new whole tree cancels it; folders rescanned meanwhile are skipped (refine_skip), since a folder rescan refines its own tree before grafting
rescan_N One per r/R (duscape_scan::rescan::Rescanner). A folder the whole scan would not enter (walk_would_enter: pseudo, network, -x, bind duplicate) or past --max-depth (counted from the scan root) is not rescanned (Outcome::NotWalked); a delete inside a folder being rescanned restarts that rescan. parallel::build_tree on the folder β†’ Instruction::Rescanned(id, Outcome). App::rescan_done grafts it (FileTree::graft, ancestors corrected by the difference) and leaks the old folder like finish_scan does. A rescan that another under way covers is not started; one the new rescan covers is cancelled and its result dropped
scan_recorder macOS: deflates and writes the scan's stream, trimmed, to the saved-scan file as it goes (cache::Recorder), one record a directory over a bounded channel, so the walk pays the encoding alone; the recorder renames the file into place when the stream ends, and removes it if the scan stops
rescan_N as the catch-up macOS, after a tree read from the saved scan as it was is on screen: a whole-tree rescan through Cache::CatchUp (Rescans::start_catch_up), whose tree replaces it by graft as R's would; the status line says "the saved scan, being brought up to date"
fill_N macOS, once the catch-up's tree has landed: lists the folders the saved scan trimmed, the one in view first, and reports batches of 256 (or every 100 ms) as Outcome::Filled under one id until left is None (Rescanner::spawn_fill, fill::fill); a delete does not restart it, and a fill adds only what the tree lacks
snapshots_N The last idle pass, macOS, root only (Rescans::start_idle, once nothing else reads the disk: the first scan, its catch-up and fill done; Rescanner::spawn_snapshots): each of the volume's local snapshots mounted read-only and nobrowse in a private folder (mount_apfs -s on the volume's device), read on the walk's thread count where the change log named folders since it (one replay on / for every snapshot, its id from .fseventsd; whole where the log does not reach) against the live volume by file id and, for a file written over in place, by its physical extents (snapshots::gone_from_live), unmounted, one tree for them all β†’ Outcome::Snapshots, grafted at the root's (local snapshots) folder. A whole rescan cancels it; the new tree's idle call starts it again
deleter The desktop viewers, one a delete (duscape_viewer::deleting::Deletion): removes the entries confirmed with delete::remove_counting (or a Trash's call), counting each into a shared Tally, and reports how each went β†’ the window's Viewer::delete_done. Meanwhile the window takes no input but Esc and the box's Cancel (Tally::stop), and draws the box (DeletionLayout) once it has run SHOW_AFTER (100 ms), every REDRAW_EVERY; a folder removed only in part (stopped, or a failure inside it) is rescanned. On the window's thread, a package cache's thousands of files froze the window for seconds
archives_N The archives' pass (Rescans::start_archives, from start_idle once a tree is in hand and nothing replaces it; archives::run): idle until a viewer says which noted archives are on screen (Rescans::want_archives, after every relayout, from Viewer::want_visible_archives and the TUI's App::want_visible_archives: an archive's tile, nested or not, large enough to show a nested level β€” 3 Γ— MIN_TILE_PIXELS either way β€” largest first, then the list's visible rows; the terminal's top-level tiles of 18Γ—9 cells and up, and its rows), then reads those indexes on a few threads that block while nothing is asked (Wanted, woken by want_archives and by a stop) β†’ Outcome::Archives, grafted by Rescans::finish (FileTree::expand_archive) and reported as a fill's batch (filled: the folders changed, the archives left). An archive no layout would change for is never read until one does: a zoom, a folder entered. It ends when none is left unread, and a stale pass's batches are dropped by id. Stopped by a whole-tree rescan, which notes the archives afresh; a folder's rescan brings its archives back unread (FileTree::graft), and they are read again when on screen (Wanted::done forgets an archive once reported: kept, a rescanned archive stayed a file). The graft is on the window's thread, its folder built whole there: not measured for an archive near MAX_MEMBERS (a million entries), owed
previewer Reads the file in hand for the preview: first 64 KB as text, or a picture decoded and scaled (PNG, JPEG, WebP, GIF, BMP, ICO, TIFF, QOI, HDR, PNM, DDS:
the image features in Cargo.toml, with why EXR, AVIF and TGA are not) after a 100 ms debounce (a newer request supersedes it) β†’ Instruction::PreviewReady(generation, _); answers to an older generation are dropped
main App state mutations + ratatui rendering. During the scan it renders from the outline; on ScanComplete it swaps in the finished tree, keeping the current folder

Synchronization: Arc<AtomicBool> for running/loaded flags; bounded sync channels (capacity 1–100).

Crate Responsibilities

libduscape (common/) β€” what every viewer shares, no user interface:

  • model/files/file_tree.rs β€” FileTree: hierarchical navigation, deletion tracking; deferring_shared_blocks / merge_from / replay_deferred for the parallel build; add_summary for the outline; graft, apply_found
  • model/file_to_delete.rs β€” FileToDelete::in_current_folder, what both viewers confirm
  • scan/mod.rs β€” the scan protocol: ScanOptions, EntryMeta, DirEntries (its later and extent_space are filled by the Linux walker for the second pass; a failure is counted with DirEntries::fail(action, name, error), never failed += 1, so that --issues can say why: Issues counts every one by kind and by the name of the folder holding it (folders: a Synology NAS's million @eaDir failures in one line; 64 kinds and 64 names at most, the rest as Issues::OTHER, so an error that names its path cannot make one kind a failure; which 64 names get lines of their own follows arrival, so it varies between runs), by where (scan/places.rs, Places: every failure counted at its path, the deepest paths counted at their parents once there are more than 4096, so the totals stay whole; the report a tree under the paths' common root whose 60 lines go to the folders holding most, largest first and not depth first, a folder of one folder sharing its line), and keeps a few examples β€” 8 a directory, 200 a scan β€” and FileTree::add_dir_entries/merge_from gather them into FileTree::issues), Outline/DirSummary (the depth-capped live view; following a Focus, exempt under the folder shown), Found/FoundFile; Focus/FocusWatch β€” the folder shown, shared with whatever still reads the disk, a move told by one atomic load; Audience β€” whom a DirEntries is for: Both (a listing, as every walker hands one on), View (a running total so far, as its unlisted sum, for the outline alone: build_tree passes it to progress and no builder) or Tree (a listing the outline skips, having had its totals) β€” how the NTFS table reader shows the volume while it reads (DirSummary::of counts unlisted as files of the directory's own)
  • model/files/hard_links.rs β€” charges shared blocks to each folder once, over interned directory ids; two ledgers, one keyed on inode (hard links) and one on physical extent (reflinks)
  • model/files/hash.rs β€” the fast hasher behind the folder and inode maps
  • tiles/treemap.rs β€” squarify algorithm, in a Grid's cells: Grid::TERMINAL (the cell's HEIGHT_WIDTH_RATIO = 2.5, an 8Γ—3 least tile; the TUI, and the DOS port's reference) or Grid::pixels(min) (square pixel cells, what the desktop viewers use). A loop over the children, linear in them β€” largest_after answers "is any child left big enough" β€” since a window's pixel grid gives tens of thousands; its layouts are the recursive version's exactly. A step reads only its row's two ends (worst_in_renderable_row): in a row every child has the same second side and a first in proportion to its size, so with the children largest first what renders and the worst ratio are decided there β€” read whole, a pixel grid's rows of thousands made each step cost the row (a flat 87k-file board, 13.5 β†’ 5.9 ms); and steady (TreeMap::populate_steady, Board::change_files_steady, nest_steady): a relayout of the same folder with new sizes keeps the last layout's rows by name (Plan), so while a scan runs a folder overtaking another grows in place instead of recutting the tiles after it; it lays out afresh when a tile would be thinner than 1:5, new entries take a quarter of the area, or a planned entry is too small for a tile after three tries without it. The arithmetic is Space (the room left, cut a row at a time by shares), apart from what the rows are made into (Lay): a TreeMap's tiles and corner, or scatter's motes. viewers/shared/tests/layout_stability.rs measures it (on ~: 8% of tiles jumping per relayout β†’ 2%, 14% of the area at the scan's end β†’ 2%)
  • tiles/board.rs β€” Board: tile selection, zoom stack, navigation; hidden, the entries in the "small files" corner (the treemap records them as it lays out, TreeMap::hidden); set_free_space, a volume's free space and the used space the scan has not found (FreeSpace, unzoomed only), cut first (cut_strip): the free space a band the board's width along its bottom, as tall as its share of the volume β€” its place and both its sides fixed through the scan, since they depend on nothing the scan finds (cut from one strip with the unscanned space before 2026-10-05, it kept its area but changed shape, as if the free space changed); the unscanned space a strip at the right of the rest, its share of the board, narrowing as the scan goes; the entries laid out in what is left, not ranked among them, growing into the unscanned space. Once the scan is over the unscanned strip's foot may be the purgeable part (purgeable_tile). The tiles come after the entries' (free_tile, unscanned_tile, by index, named FREE_SPACE_NAME and UNSCANNED_NAME, UNSEEN_NAME once the scan is over), never in the listing and never a stop for the selection (selectable, select_first); corner is the "small files" corner bounded by the entries' area, short of the strip, for every painter and hit test
  • tiles/dust.rs β€” scatter: the "small files" corner filled in β€” its entries laid out again inside it in one-pixel cells with no least tile, as many as it has pixels, largest first and in proportion to each other, so a flat folder of 87k small files shows as specks, not a grey box. Laid by the treemap's own Space straight into motes, no Tile made of each (a test holds them to where a treemap of stand-ins would put them): on /usr at 2560Γ—1400 pt, 47k specks, a relayout 10.8 β†’ 8.8 ms. The motes have no names and are no targets; Viewer::dust colours them by the rule their tiles would have (entry_color: tile_color by name, depth_shade darker a level in; a file's extension looked up once, and a run of one kind not looked up again: 8.8 β†’ 8.3 ms; no extension is not an empty one, Makefile grey and notes. hashed) and every desktop painter fills them in one pass: framed as a tile where one has room for a frame (Dust::framed), else SPECK_SHADE darker under the least tiles' grid (Dust::grid, lines every MIN_TILE_PIXELS aligned to the board) β€” plain, a corner read as a block of flat colour twice as bright as the framed tiles beside it (measured on Windows, 2026-10-05; now within 5% of them). Each corner comes as a Speck (where, the entry, its rank, its depth): the board's from Board::scatter_corner, each nested folder's from nest_with's speck (Nesting::dust). A folder is ranked once for its tiles and its corner (Ranking: one pass over the folder, ranked only as far as asked, names borrowed and copied only for the tiles laid out), and where the entries too small to rank left their room empty rather than a corner, that room is it (TreeMap::leftover). In a first pass the specks stop at Nesting::dust_deadline, half the relayout's budget, and the rest are the second pass's: how many a corner holds is not known until it is laid out
  • tiles/nested.rs β€” nest: the treemap nested β€” the same squarify run inside each folder tile (under its label rows, within a margin) on the folder's entries, and theirs in turn, down to the files wherever there is room: what ends it is an inside too small for two minimum tiles either way, and the tiles in all are bounded by the folder tiles' area at the minimum size β€” the screen bounds a relayout's and a paint's work (Nesting's depth and tile caps are guards beyond that). The minimum tile is Nesting::grid's. A folder too short for its label rows nests under its margin alone; Nesting::labelled says which have them, so a painter labels only those. Each folder is listed by largest_in_folder_from, only as many entries as its inside has room for and none under (least βˆ’ 1)Β² cells (which can never round to a tile), so a folder of fifty thousand entries is not named and sorted whole on every relayout; a level at a time across every folder (a queue, breadth first), so parents come before children and a painter draws in order, and a first pass's deadline (Nesting::deadline, after the top-level folders' own entries) cuts the deepest levels everywhere rather than the last folders whole; room_cap bounds one folder's share of a first pass, and nest_with says whether either cut. What a folder's entries cover β€” its inside less its corner β€” is kept as its Inside (NestedTile::inside, Nested::tops, Viewer::board_inside), so painters fill a folder only around it (Layout::fill_parts, the parts to fill in points, one helper for every painter). The terminal nests too (ui/display.rs's NESTING: two label rows and a margin of one cell, so a folder's entries are a block of their own inside its border; laid out again only when Board::generation moves, not every frame), drawn by RectangleGrid::nested. A NestedTile knows its parent and top by index, not its path (nested_path, nested_path_is): paths cloned per tile were half the nesting's time
  • archive.rs β€” zip archives and the formats that are zips by another name (EXTENSIONS: jar, apk, whl, nupkg, vsix…), as folders: read_index reads the central directory from the file's end (the end record searched in its last 64 KiB, Zip64, a self-extractor's stub before it shifting every offset, CP437 names unless flagged UTF-8; at most MAX_DIRECTORY bytes and MAX_MEMBERS entries, the rest truncated; a name going up (..) or with a part that is no plain name here β€” C: on Windows, which a join takes for the drive, so a delete of the entry reached it β€” is left out, member_path), never the entries; member_of splits a path inside an archive into the archive and the inner path (no file at the path, an archive above it), on_disk the file to open or reveal for it; read_member unpacks an entry's start or whole, stored or deflated (flate2, pure Rust), in memory. The walk notes an archive by its name (FileTree::archives) and reads nothing; FileTree::expand_archive turns the file into a folder of its entries sized by their compressed lengths (the first of a name kept, a file where a folder is left out: a zip may name a a file and hold a/b, which ended the build), the folder's sizes the file's (the headers stay in the folder's size, so a tiny archive's entry is a sliver beside them β€” honest, and no unlisted sum, which would make the macOS fill take it for a trimmed folder). An entry is refused by delete::refused, previewed by preview::read/picture_bytes from inside the archive, and a rescan of it rescans the folder holding the archive (Rescans::start)
  • delete.rs β€” remove (from disk, a link itself never its target) and refused (NTFS metadata); remove_counting, a walk of its own counting into a Tally and stoppable (remove_dir_all says nothing until done), a read-only file deleted ignoring the attribute as remove_dir_all deletes it (FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE): cleared, it was cleared on every hard link of the file
  • metafiles.rs β€” NTFS metadata names, for the Windows walker and for delete
  • snapshots.rs β€” a volume's local snapshots as one virtual folder at its root (FOLDER, (local snapshots)), a folder per snapshot: Noted (FileTree::snapshots, set by FileTree::note_snapshots, which adds the folders empty; is_snapshot_path), describe (asked by nas::describe, so every status line says what the folder is), and is_snapshot_source (<snapshot>@/dev/…, a mount's source). Unprivileged, the windows split the unseen space with FileTree::purgeable (os::volume_purgeable: available for important use less free, through CoreFoundation dlopened, asked beside the walk since its first answer costs up to a second), the board's purgeable_tile (PURGEABLE_NAME, "at most": it counts purgeable files the scan found too), only while the snapshots are unread. Nothing is at the folder's path on disk: delete::refused refuses what is in it, Rescans::start will not rescan it (a rescan would find it gone and take it off the tree), and a real entry of the name at the root means no folder is added
  • nas.rs β€” the folders a system keeps for itself, by name (KNOWN: Synology's #snapshot, #recycle, @eaDir, @docker, @ActiveBackup…, QNAP's @Recently-Snapshot, @Recycle, .@__thumb, .qpkg…, ZFS's .zfs, NetApp's .snapshot, Samba's .recycle, macOS's and Windows's metadata folders): left_out (snapshots, unless --snapshots), left_out_note, describe
  • preview.rs β€” read (sniff the first 64 KiB: text lines, info, or a picture), describe_picture, decode_picture (bounded). Scaling and encoding for display are the viewer's. A binary file is Contents::Binary: describe_binary (its size, then placement::describe) and hex_dump (HEX_LINES of sixteen bytes, a dash after the eighth, the characters beside); the terminal shows the description, the desktop viewers the dump (Preview::Hex, drawn with the monospace font shrunk until a line fits β€” Fonts::fitting on Windows, draw::hex on macOS and Linux, which put the description above it)
  • placement.rs β€” where a file's blocks are, for the preview of a file with nothing else to show. Linux: FIEMAP for its extents, sparseness and shared blocks, then sysfs for the disk β€” through a partition to the disk's model and SSD/HDD and the offset into it; the members of an LVM or md volume (the table that says which is root's); a loop device's file. The companion tool whereisthis follows every layer; this is the few lines that fit under a treemap. Windows: FSCTL_GET_RETRIEVAL_POINTERS for the runs (summed by runs::sum, tested everywhere), the volume's disk extents for the disk and offset, IOCTL_STORAGE_QUERY_PROPERTY for its model, bus and seek penalty β€” the volume and disk opened with no access rights, so unelevated. All three desktop viewers draw it wrapped above the hex dump
  • about.rs β€” what every viewer says about duscape itself, one source: the name, version, summary, homepage and issues link, LICENSE's copyright lines (copyrights), the lines of an About box (lines), and the licences in full (licenses, licenses_file for a window to open as text): LICENSE and THIRD-PARTY-LICENSES.txt, embedded (include_str!, 115 KB a binary). The latter is generated by make third-party (cargo-about, packaging/about/: every crate compiled into a shipped binary on any release target, then Rust's standard library, musl and jemalloc; offline, carriage returns dropped, so the file is the same on every platform) and checked in; deny.yml's third-party job regenerates it and fails if it differs β€” run make third-party after changing a dependency. Shown by duscape --licenses, the Windows window menu, the macOS app menu, the Linux right-click menu and F1; shipped in every package
  • clipboard.rs β€” native clipboard (pbcopy, Win32, wl-copy/xclip/xsel), base64
  • launch.rs β€” open (the default app) and reveal (the file manager, selected): open/ open -R on macOS; ShellExecuteW and explorer.exe /select,"…" (a raw argument: Explorer takes a comma in a plain one for a switch) on Windows; xdg-open and org.freedesktop.FileManager1 over dbus-send elsewhere, the bus call on a thread of its own since a file manager being started to answer can take seconds. Nothing waits on the window's thread, and every child is reaped by a thread that waits for it
  • format/display_size.rs β€” byte β†’ human-readable (B/K/M/G; G is the largest unit, so a volume of terabytes shows as thousands of gigabytes, its whole part grouped in thousands β€” 1,862.6G, never 1862.6G, which reads as a tenth of it); display_count.rs groups a count the same way. The DOS port's fmt_size is a port of the former without the grouping
  • os/unix.rs, os/windows.rs β€” is_user_admin(), size_on_disk_fast(), volume_id(), link_count(), volume_used()/volume_free() (on APFS a volume's own use by ATTR_VOL_SPACEUSED, since statvfs gives the container's, except at /, whose scan reaches the other volumes); os/mod.rs β€” canonical_root(), what every scan root and FileTree::new go through: canonical, and a network share's root (\\?\UNC\server\share, which canonicalize gives with nothing after the prefix) with its separator, so paths under it strip to names; scan::below_root strips a separator left in front of a name anyway. Canonical on Windows means verbatim (\\?\C:\), which no person writes: every path shown β€” a window's title, a dialog, a status line, the chooser, the terminal's title and panels, --issues β€” goes through format::shown_path (C:\, \\server\share), and a copied path through quote_path_for_shell, which drops the prefix too
  • os/volumes.rs β€” volumes(): what is mounted, its device or label, filesystem, size and use β€” /proc/self/mounts sifted (block devices and the known network filesystems, one line a source, tested) and statvfs; getmntinfo on macOS; the drive letters on Windows, a mapped network drive named by its share and its provider (network_filesystem: cifs, nfs, webdav), and the drives the user mapped that this session has no letter for β€” an elevated window's, which Windows does not give them β€” by their shares, from HKCU\Network (with_mapped, MappedDrive; scanned by the share's path, listed unsized where an elevated session cannot reach it yet); never by the server's filesystem, which Windows reports as the volume's (NTFS). For the windows' chooser

duscape-scan (scanners/) β€” reading the disk:

  • lib.rs β€” scan_directories(): per-directory batches, the seam every walker plugs into; parallel::build_tree(): the app's tree build β€” shard by path prefix, merge, replay; walk_would_enter, thread_count, scan_into_tree
  • portable.rs β€” the portable walk on std::fs: a shared queue of directories, a few workers, one DirEntries a directory. The BSDs' walker (no native one), the benchmark's portable-* baseline (scan_folder), compiled and tested everywhere. It replaced dua-core (2026-10-04), which Debian does not package; with -x on /usr it finds what the native walk finds, 3.6x faster than dua-core's walk did (docs/scan-performance.md)
  • macos.rs β€” macOS walker on getattrlistbulk(2) (see docs/scan-performance.md). APFS clones go through the ledger as reflinks do: the bulk call also asks ATTR_CMNEXT_CLONEID and ATTR_CMNEXT_EXT_FLAGS (FSOPT_ATTR_CMN_EXTENDED), and a file whose blocks are a clone's β€” EF_SHARES_ALL_BLOCKS, or a clone id that is not its own inode, which is how the system's own clones on Preboot show, with no flags β€” gets shared_extent from the id and the device (clone_identity); no cost to the walk's rate, measured. A mount that is a disk image's volume, its image inside the scan, is left empty and noted (disk_image.rs). It knows nothing of Linux filesystems, by choice: linux/ and ext4.rs are Linux-only, and an ext4 or btrfs USB drive on a Mac is walked through its driver like any folder (docs/features.md)
  • disk_image.rs β€” macOS: whether a mounted volume is read from a disk image the scan counts as a file (counted_by_the_scan): the device's image-path (attached by hdiutil or the Finder) or DiskImageURL (by the system: the iOS simulator's runtime) up IOKit's registry, IOKit and CoreFoundation dlopened when a mount is first crossed; paths compared with firmlinks undone (real_path, ATTR_CMNEXT_NOFIRMLINKPATH), so a scan of / and of /System/Volumes/Data agree. walk_would_enter on macOS does not ask it, so a rescan of such a volume walks it (as it walks a share): owed. So is the Linux rule: a loop device's volume from a file inside the scan (/sys/block/loopN/loop/backing_file, which placement.rs reads already) is walked there and counted twice; it wants make test-fs, whose fixtures are loop images
  • ext4.rs β€” as root on ext4, the walk read from the block device: directory blocks and inodes swept in device order a generation at a time, every run advised before any is read, parsed and batched on several threads; one DirEntries per directory like any walker. Declines up front (and the kernel walk runs) for a filesystem it cannot follow (META_BG, a device that will not open); a mount point inside, or a directory of a shape it does not read, goes to the kernel walker whole; rescans and --no-device-read never use it. --bench-stage ext4-raw is the inode survey alone. Last seconds of writes may be missing: it reads the device's page cache
  • linux.rs β€” Linux walker on getdents64/statx, own thread pool: the walk itself (Job, inspect, read_directory, walk_linux); what it asks along the way is in linux/, one file each.
    • linux/stat.rs β€” every statx goes through its own statx, which on ENOSYS (a kernel before 4.11 β€” Synology DSM's 4.4) or a seccomp EPERM answers with fstatat in statx's shape (statx_from_stat) and stays on it (NO_STATX): basic fields only, no attributes or mount id. Those the kernel gives only from 5.8 (STATX_ATTR_MOUNT_ROOT, stx_mnt_id), and before it mount_of takes both from the mount table (Shared::mounted_at, mounts::points: the last mount at a point shows), so bind-mount duplicates are still found; mount_at likewise. DUSCAPE_NO_STATX=1 makes a scan read as a pre-4.11 kernel would β€” the fixtures run their totals and mount layouts that way too β€” and strace -e inject=statx:error=ENOSYS reproduces such a kernel from outside
    • linux/mounts.rs β€” /proc/self/mountinfo (read, parse, points), bind mounts reached elsewhere (reached_elsewhere), mount_of
    • linux/filesystem.rs β€” classify: one statfs per mount crossed says pseudo, network (FUSE by its subtype), reflinks, ext, btrfs, and whether compressed sizes can be read
    • linux/crossing.rs β€” the rules at a mount point that a rescan must keep too: walk_would_enter, -x's boundary (same_filesystem), mount loops (loops_back)
    • linux/btrfs.rs β€” btrfs's own ioctls: the filesystem's UUID (fsid, BTRFS_IOC_FS_INFO), compressed sizes (btrfs/extents.rs, BTRFS_IOC_TREE_SEARCH_V2), read-only subvolumes (btrfs/subvolume.rs, BTRFS_IOC_SUBVOL_GETFLAGS, no privilege needed). A read-only btrfs snapshot inside the scan is left empty unless ScanOptions::snapshots (--snapshots): snapshot_left_out, which the walk and walk_would_enter (a rescan, and the ext4 device reader's mount points, the scan's own root excepted) both ask. Every subvolume has a device of its own, so one is always a crossing, onto btrfs (filesystem::Kind::btrfs), at a root numbered 256 β€” only there is the directory opened to ask, never off btrfs, where opening an automount point would mount it. Synology keeps a share's snapshots under its #snapshot, one an hour, and walking them walked the share once each
    • linux/reflink.rs β€” the FS_IOC_FIEMAP reflink probe, on files of 64 KiB and up, and not at all under a folder whose snapshots are left out ("Snapshots" below); linux/dirblocks.rs β€” directory blocks read ahead through the device; linux/environment.rs β€” what --issues says about the machine
  • ntfs.rs β€” NTFS file-record parser: sizes $MFT and the other metadata files the Windows walker adds at a volume root when elevated (records fetched with FSCTL_GET_NTFS_FILE_RECORD). Platform-independent so its tests run on Linux CI
  • mft.rs β€” NTFS read from its master file table, elevated (docs/scan-roadmap.md step 2 for Windows, what WizTree does): the whole $MFT read in 32 MiB chunks along its runs and parsed on a few threads into (parent, name, sizes) per record β€” every $FILE_NAME (one per hard link, the DOS name dropped beside a Win32 one), the unnamed $DATA's length and allocation (resident: 0 on disk; compressed or sparse: the compressed size), directory and junction flags, extension records merged into their base β€” then handed on breadth-first from the scan root's record as one DirEntries per directory, exactly as the kernel walk would. Hard links arrive counted, so only files with several names go through the ledger; NTFS's own files are sized by their clusters as ntfs.rs sizes them. scan_directories picks it when read_device is on, the scan root is a volume root (a subtree is a fraction of the volume and the table costs all of it), the volume opens (\.\C:, elevated) and flushes, and a sample of the table says its directories are small enough for the table to pay (TABLE_UP_TO entries a directory: the walk costs a handle per directory, the table a record per file); else the kernel walk. --no-device-read opts out. The parser and the tree run and are tested on every platform; only mft::volume is Windows. The table is read on its own thread (mft_reader), and since nothing can be listed until it is read whole (a directory's files are scattered through it: 1.7 s on this C:\, then 0.9 s to assemble, with nothing on screen before this), the view gets running totals meanwhile (Running, Charges, on mft_live): each chunk's files charged to their directory's record on the parser's thread, and every LIVE_EVERY (the first chunk's at once) each directory's total since last time handed on as one DirEntries of Audience::View β€” the sizes as its unlisted, the flush's last marked β€” at the path its ancestors' records give (resolved once and kept), a directory whose ancestors are not all read yet waiting for a later flush, and nothing charged where the listing would not go (--max-depth, a snapshot folder left out by name, a link). The top levels' places come from the kernel's listing (mft_seeder, Running::seed), since the records are in no tree order. The listing that follows is Audience::Tree, which the outline skips; the tests hold the totals to the listing's sums, hard links and NTFS's own files included. The gate's sample is fetched by FSCTL_GET_NTFS_FILE_RECORD, 1024 records spread over the table, not read as a slice: a volume handle's first read costs 0.4–0.8 s whatever its size, as the volume's flush does, and the two do not overlap β€” the 0.85 s before the first running total on this C:\ is those two, measured on 2026-10-01 (docs/scan-performance.md, "First paint")
  • windows.rs β€” Windows walker: one handle per directory, entries read in bulk with GetFileInformationByHandleEx(FileIdExtdDirectoryInfo). No listing carries a link count, so files in hard-link hot spots (or all files β‰₯ --hard-link-threshold) are sent with LINKS_UNKNOWN and the ledger dedupes them by file id β€” memory instead of a file open each
  • cache.rs β€” the saved scan (roadmap step 9), in three modes (ScanOptions::cache, a Cache): Recorder, a tee on whatever walker ran, writing each DirEntries trimmed (folders, hard-linked and shared-extent files, and files of KEEP_FROM = 1 MiB and up kept one by one; the rest of each folder as one Unlisted sum β€” about one entry in fifty kept, 3–4 bytes an entry deflated, so a terabyte's file is 10–30 MB; APFS clones are kept one by one too, about 27 bytes each, since summed they would be counted in full again: / on a Mac with 830k clones is 61 MB, read back whole in 0.9 s) as tagged records naming each directory by its parent's record index, deflated on a thread of its own (scan_recorder), to ~/Library/Caches/duscape/<key>.scan, renamed into place only when the stream ends; the key and stamp in the clear at the front (peek), the counts and checksum in a footer record. SavedStream (Cache::Saved, the viewers' first scan): the file read as it is, inflating as it goes, the first directory in milliseconds, the root noted NOTE_OWED so FileTree::from_saved_scan says a catch-up is owed. Saved (Cache::CatchUp, the whole-tree rescan a viewer starts behind that tree): the file read whole and checked, the log replayed on a thread while it inflates, then CachedScan, a walker like the others β€” the folders the log named listed again first on a pool (Lister, threads), so a hard-linked file's fresh size and link count patch every saved copy (the ledger keys on the disk size), then the stream with folders gone dropped and folders new walked (Walker), the root noted NOTE_CAUGHT_UP. too_stale says when a walk costs less. Platform-independent and tested on Linux CI with a std::fs lister; only the log is macOS. Off for rescans, --issues, the benchmark (cached and saved stages excepted) and --no-cache. Swept (cache/sweep.rs, sweep) on the recorder's thread when it starts and again after its rename: removed are part files whose process is gone (kill(pid, 0) β†’ ESRCH), an older format, a file that is no saved scan, one saved under another system version, one whose device's log was reset; the rest kept within ROOM (256 MiB), least recently saved out first, never the file just saved nor a newer format (another build's). Not by age nor by the folder being gone β€” a rarely scanned archive disk, an unplugged one, is where a saved scan pays most; the catch-up's too_stale judges use. wait_for_saves lets a process that ends with its scan (the terminal viewer, the benchmark's cached stage) wait for the writer: before it, a short scan's save was lost and its part file left. clear is duscape --clear-cache
  • snapshots.rs β€” macOS: a volume's local snapshots (volume_for: an APFS mount point, the data volume for /; list/list_with_times, fs_snapshot_list, unprivileged) and, as root (can_read), what each alone keeps (read, snapshots/macos.rs) β€” none for a dataless one (Listed::dataless, ATTR_CMN_FLAGS 0x20: trimmed to its metadata, it lists files it no longer holds; read, one listed 267.6 GB on a volume with 142 GB unseen): its Scope from the change log (snapshots/log.rs: the id before it from .fseventsd's names and times, since FSEventsGetLastEventIdForDeviceBeforeTime gives 0; one replay on /, taken onto the volume through /usr/share/firmlinks; whole where the log does not reach or lost events under the root), mounted, read by gone_from_live β€” a folder the log named compared one level and only its subfolders moved or gone walked (same_place), whole otherwise with a folder the same by time as its live counterpart not compared; a seen-set so start points and walks never add a folder twice, which still lets a walk whole take every subfolder of a folder first reached as named (Visit::Deeper: else what was under it went unread, the totals varying with the threads' order); a panic in a folder counted unreadable, since a dead worker left the others waiting with the snapshot mounted; a file kept when its id is nowhere live (LINKS_UNKNOWN, no shared_extent, so the ledger counts by id one several snapshots keep once above them), and in a named folder a live file written over since counted by its blocks (written_over: snapshots/extents.rs, F_LOG2PHYS_EXT extents less the live file's less a Ranges of what the pass counted) β€” and unmounted (Mounted's drop; a pass first unmounts what one in a process since gone left behind, sweep_left_behind, since a quit does not wait for the pass). build, one tree for every snapshot, and a Reading each, which --issues prints. The walk, the log's rules and the extents' arithmetic are tested on plain folders everywhere unix; the mount and the root path have not been run. The macOS walker leaves a snapshot mount empty unless --snapshots (macos.rs, snapshot_left_out). What it cannot see is in docs/sizes.md, "Local snapshots"
  • fill.rs β€” the fill pass: the folders a saved scan trimmed (FileTree::unfilled_folders) listed again on a pool, the folder in view first (Focus), a batch at a time as rescan::Outcome::Filled through the rescan channel every viewer has; FileTree::fill puts each folder's smaller files in by name and takes the sum back. Started by a viewer once the catch-up's tree has landed (Rescans::start_fill). Until a folder is filled its sizes are right and its small files' tiles missing; a small file hard-linked since the save is counted in the sum and once more where it was listed afresh, until the fill
  • fsevents.rs β€” macOS: the volume's change log, CoreServices dlopened when asked (the viewers keep frameworks out of their load commands): current_event_id (the stamp, taken before the walk starts), log_uuid (the log's identity for the device: reset means nothing since is known; None, no log, means nothing is saved), system_version, and replay, the stream since an id on a dispatch queue, ended by HistoryDone or a time bounded by the walk it would save; MustScanSubDirs/dropped β†’ walked whole, wrapped or root changed β†’ lost
  • focus.rs β€” steering a walk toward the folder shown: arrange puts a worker's jobs toward the focus (under it, or on the way down to it) where its stack pops them next, take_toward a steal's pick from the shared queue; the macOS walker partitions its one queue as it fills (QueueState::toward). With no focus, one atomic load a directory
  • archives.rs β€” the archives' pass (run, behind Rescanner::spawn_archives): Wanted, the archives a viewer has on screen, replaced whole each time it asks (Rescans::want_archives, in the order asked: the viewers ask largest tile first), a few workers reading indexes and a coordinator that sends what they read every GATHER (30 ms) as one Outcome::Archives
  • refine.rs β€” the second pass (SmallFiles, refine)
  • rescan.rs β€” Rescanner and Refiner: rescans and the second pass on threads of their own, results through a callback, for any viewer

duscape-windows (viewers/windows/) β€” the Win32/GDI viewer, over duscape-viewer, at feature parity with the TUI bar configurable keys (docs/features.md). Behaviour goes in the shared Viewer, not in win/:

  • preview.rs β€” prepare_picture: a picture decoded and scaled to the pixels it will take, as BGRA rows blended over the panel, for libduscape::preview::Reader; no Win32, tested everywhere
  • cli.rs β€” the TUI's scan flags, and --no-elevate
  • elevate.rs β€” a whole volume unelevated asks to run as administrator: wanted decides, relaunch_args and command_line (Win32 quoting, tested) make the new process's arguments β€” this process's plus --no-elevate, so it never asks in turn, plus the folder if it was picked in the dialog β€” and relaunch starts it through the shell's runas; declined (Refused::Declined) the scan goes on unelevated; failed, so does it, and the status bar says why. Only a local disk (is_local_disk: fixed or removable, by GetDriveTypeW) asks β€” a share, a CD or a RAM disk gains nothing from it
  • win/mod.rs β€” the window: input β†’ Viewer calls (points are pixels over the DPI scale), then changed() (a preview request at the drawn size β€” wanted_preview_sized β€” title, redraw). Messages the window does nothing with go to DefWindowProcW outside the re-entrancy guard (HANDLED is the list; an arm added to dispatch goes there too, or it never runs): the frame's own loops (an edge dragged, maximise, the system menu) run inside that call and send WM_SIZE and WM_PAINT re-entrantly, which the guard would drop. Threads post one boxed AppMsg; one arriving during a modal loop (message box, context menu) is queued FIFO in PENDING and handled when the handler returns β€” order matters, the outline's last batch comes before the finished tree. Outline batches are absorbed as they come and the view laid out once a frame (scan::FRAME, 16 ms): by the batch that finds the frame up, or OUTLINE_TIMER for the last of a burst (WM_TIMER comes only when the queue is empty, on 15.6 ms ticks), then painted at once (PAINT_NOW, UpdateWindow once the guard is down, since WM_PAINT too waits for an empty queue). Laid out per batch (15–25 ms each, then) the window answered nothing until the scan ended; 100 ms after a burst it moved at 8 fps. Now 56 fps median on a warm C:\Users scan (2026-10-05: layout 2.6 ms, paint 7.7 ms)
  • win/paint.rs β€” double-buffered in a 32-bit DIB section, by Viewer::layout; returns the breadcrumbs for clicks. Canvas::fill/frame write the section's pixels directly (a GdiFlush first when GDI has drawn since): as FillRect/FrameRect calls, the nested treemap's thousands of overdrawn tiles cost 30 ms a frame; and a folder tile is filled only around what its entries cover (fill_tile, Layout::fill_parts). Text and pictures are GDI's: text measured once (GetTextExtentExPointW, whose partial extents say where to cut for the ellipsis, measured once a font) and drawn with ExtTextOutW, the font selected only when it changes β€” DrawTextW cost half as much again. The fonts are the system's message font (SPI_GETNONCLIENTMETRICS) and a treemap label size that fits the label band whole. DUSCAPE_PAINT_TIMES=1 (passes::paint_times, the Linux window's too) prints each frame's time, and each resize's layout, on stderr (redirect it: no console). paint takes the back buffer out of the Window for the frame, no RefCell. The buffer (BackBuffer, a DIB section in a memory DC) is kept between paints and made again only when the size changes: made fresh, its pages faulted in on every frame. A first paint of a layout stops the treemap's labels at passes::LABEL_DEADLINE; then SECOND_PASS_TIMER (set by each change and by a paint that stopped, so it fires once input has stopped for IDLE) runs Paints::second_pass and paints in full; Paints says which paints are in full, as it does for the Linux viewer
  • resources.rs β€” the binaries' own resources, written without a resource compiler (the zig cross-build has none) and include!d by this crate's build.rs and the TUI's: the icon (duscape.ico, RT_ICON a size and the RT_GROUP_ICON Explorer reads) and the version (RT_VERSION, from the package's: Explorer's Details tab, Task Manager's name for the process, the file version an installer compares) as a .res file for link.exe on MSVC; on GNU one COFF object with a .rsrc resource tree, the manifest in it too (a second .rsrc object does not link). The manifest is a resource there on both (RT_MANIFEST 1), as link.exe makes none of its own unless asked; embed-manifest, which MSVC used before 2026-10-04, is gone (Debian does not package it). Both manifests (viewers/tui/windows.manifest, duscape-windows.manifest) say asInvoker: the program raises itself through runas when a volume wants it, never at its start. duscape.ico is duscape_viewer::icon at ten sizes, PNG-compressed and checked in; icon::tests::the_icon_file_is_the_one_drawn fails when the drawing changed and the file did not (DUSCAPE_WRITE_ICON=1 writes it). src/resources_tests.rs tests the writer on every platform The list is drawn as the tree (Viewer::rows): each level indented ROW_INDENT, a folder's expander (β–Έ/β–Ύ) in the EXPANDER column before its name, the "% of parent" bar from its level's indent. The treemap is drawn nested (draw_nested, after the top-level tiles and before the corner and the frames): each level a shade darker, a label where there is room, the hovered tile framed

duscape-viewer (viewers/shared/) β€” what the desktop viewers share, with no toolkit:

  • state.rs β€” Viewer: everything the window shows and how it answers input β€” Layout (points; tiles in 2.4Γ—6 pt cells, the treemap's 2.5 ratio, until the viewer says its pixels per point with set_pixel_scale: then one-pixel square cells, Grid::pixels(MIN_TILE_PIXELS), and the nesting's TILE_LABEL band and TILE_MARGIN kept in points; every desktop viewer does, and the scale is taken at the resize it calls with it), the entry in hand kept by name so a relayout cannot move it, the details panel following the pointer (PEEK: a tile rested on 100 ms is shown and previewed until 100 ms after the pointer leaves; peek_due says when a viewer is to wake for peek_tick β€” the Linux loop's wait, a Win32 timer, a sleeping thread on macOS), marks, navigation, zoom, delete (delete, delete_prompt, and removed for a Trash), rescans (through duscape_scan::rescan::Rescans), the status bar's words; absorb_summaries takes outline batches in without a relayout and catch_up lays the view out for them (add_summaries is both). It keeps the TUI's rules from "Key Patterns": chosen says whether the entry in hand was picked or placed, and only a picked one seeds a Ctrl+click selection; a Shift run adds its range to the marks it started from (mark_run) and shrinks when reversed; every change to the marks copies their paths once the viewer has called set_clipboard (Windows does; macOS and Linux copy through their toolkits and read target_paths). Its tests run on every platform; a behaviour the windows should share goes here first. The list can be a tree (WizTree's view, tree_view): libduscape::tiles::tree_rows keeps which folders are open in place and makes the rows (each open folder's entries indented under it, largest first, Row::path from the listed folder); the cursor is a row's path, its first name being selected, so the board's selection follows the row's top-level entry. A mark is a row's path too (marked, a Marks: the order and a set beside it, so a painter's question of a row or tile is a lookup β€” passes over the marks after Ctrl+A on 87k entries were billions of comparisons a frame; is_marked_row, marked_nested for the nested tiles, worked out once a paint; marked_count and marked_size, the outermost marks, kept until the marks or the rows change): a ⇧ range runs over the rows on show, a folder's opened in place with the rest; a folder closed takes the marks inside it off; a delete or a size takes a marked folder and not also the rows marked in it (target_rows). Until 2026-10-05 marks were top-level names, and a range among a folder's rows marked the folder. β†’ opens the folder in hand and then goes down into it, ← goes up to the folder and then closes it, a click on the expander (Hit::Expander) toggles; a nested row is what is previewed, copied, entered (down through the folders above it) or deleted. With it the treemap is nested (nested, rebuilt with the board): a tile inside a folder's (Hit::Nested) is a target like any other β€” a click opens the folders above it and puts its row in hand, Ctrl and Shift mark its row β€” and hovering one names it (hover_nested, cleared by every relayout since the tiles moved). Off by default (set_tree_view); all three desktop viewers turn it on for every scan, and a viewer that does not draw depth sees the flat listing and the flat tiles. At the root of a volume the volume's free space is on the board too (free_space, on by default; toggle_free_space; Board::set_free_space at each relayout, the free and used bytes asked of os::volume_free and os::volume_used afresh since a delete frees some; the unscanned share is the used less what the scan has found, none where it found more, and counted on disk whatever size is shown, since the volume counts blocks): free_toggle gives the words and state of the toggle every window draws at Layout::free_toggle, the path bar's right, while the root of a volume is shown and nowhere else; the free tile is FREE_SPACE_COLOR, the unscanned UNSCANNED_COLOR (board_color), and both Hit::Nothing (set_volume_free_source stands in for the OS in tests)
  • state/tween.rs β€” tiles sliding (TWEEN, 200 ms, keyed by path) from one steady layout to the next: set_animation turns it on, and a viewer that does calls animate once a frame while animating. Off by default; only the macOS window drives it (DUSCAPE_ANIMATE=1; DUSCAPE_NO_STEADY=1 there turns the steady layout off, for comparing). A zoom or a change of scale ends a slide first (before_zoom), since the board is laid out again under it. Tiles keep their labels while they slide β€” without them the motion is unreadable, and during a scan the tiles slide nearly all the time β€” so a viewer that drives it draws labels as when still (10.9 ms a sliding frame on ~ on macOS). Folders are painted whole while sliding (their insides taken off) and the second pass snaps the slide to its end, which is why the Windows and Linux windows, whose second pass runs after IDLE, do not drive it yet
  • icon.rs β€” the app's icon, drawn by the treemap: a folder of three files beside five more, squarified at the size asked for (so sharp at every size) in the tiles' colours, round cornered from 24 px; rgba for a window system that takes pixels, png for one that takes a file's bytes (image's encoder, fast: 512 px in 4.5 ms at macOS's start-up; the checked-in .ico holds its best-compressed images). A placeholder until a drawn one. Windows sets it on the class and with WM_SETICON (win::app_icon, at SM_CXICON/SM_CXSMICON), and the .exes carry it as a resource (viewers/windows/resources.rs); X11 as _NET_WM_ICON (16–128 px); macOS as the application icon image (Dock, switcher), set once launching is done, and Duscape.app's file icon, viewers/macos/duscape.icns (icns, checked in and tested like the .ico; make mac-app copies it, Info.plist names it). Wayland takes it from the .desktop file of the window's app ID: packaging/linux/icons, the PNG files at HICOLOR_SIZES, tested the same way. APP_ID (lib.rs, io.github.angch.duscape) is that ID, the Wayland app ID and X11 class the Linux window sets, and the name of every file in packaging/linux (tests/packaging.rs holds them to it and the metadata's newest release to the version)
  • passes.rs β€” a layout's paints, first in a hurry and then in full, for every viewer: LABEL_DEADLINE and LabelBudget (which tiles a paint has time to label), Paints (which layout was painted in full, whether a second pass is owed, and second_pass, what a viewer runs once input has stopped for IDLE). A viewer only draws, and wakes after IDLE
  • menu.rs β€” the context menu every desktop viewer opens on a right-click: Viewer:: context_menu(&Platform) gives its Entrys (an Action, the words, whether it can be chosen) for what is targeted, the counts following the marks; Platform says what the viewer adds (the file manager's name, Quick Look, Copy as Pathname, a Trash). A viewer draws the entries (Win32 TrackPopupMenu, an NSMenu, the Linux viewer's draw::menu), adds its own key hints, and carries out the action chosen; an item offered on one window is offered on all. open_in_hand is Open: a folder goes in, a file's path comes back to be opened
  • chooser.rs β€” a window opened with no folder, or the path bar's button (Layout::chooser_button, at its left): Chooser, the volumes (each with how full it is), the home folder and, where the viewer has one, the folder dialog (Target::Dialog); opened over a scan, with_cancel ends it with a Cancel row (Target::Cancel) back to that scan, which Esc takes too (cancellable), where opened with no folder Esc closes the window. Laid out as rows in points (layout, hit, hover_at, arrow, words); each window draws the rows and starts the scan on the target chosen β€” Windows through its elevation prompt (scan_chosen, which stops the scan shown and numbers the new one so a replaced scan's reports are dropped, as macOS and Linux do), macOS show_chooser/choose_row, Linux App::choose_row
  • deleting.rs β€” a delete on a thread of its own (Deletion, through Viewer::start_delete, deleting, cancel_delete, delete_done), its box's words and layout in points (DeletionLayout), and what failed as a Failure; every desktop viewer draws the box
  • scan.rs β€” the first scan with the live Outline, results through callbacks on the scan's thread; preview.rs β€” the latest-wins preview reader (pictures are handed over as bytes for the viewer to decode: NSImage on macOS, the image crate on Linux; a binary file as its description and hex dump, Loaded::Binary)

duscape-linux (viewers/linux/) β€” the Wayland and X11 viewer, pure Rust, no C library (not libwayland, not Xlib), so it builds static for musl and runs on any compositor or X server:

  • backend.rs β€” the Backend trait (present a canvas, set the title, own the clipboard, move/ maximise/minimise for the app's own title bar) and Input, what either windowing system reports, in points; keys has the non-character keysyms both speak; level_keysym picks the shifted level (Caps Lock only on letters); open chooses: DUSCAPE_BACKEND, else Wayland when WAYLAND_DISPLAY or WAYLAND_SOCKET is set, else X11, trying the other if the first fails
  • wayland.rs β€” wayland-client's pure-Rust protocol: the compositor by connect_to_env (WAYLAND_SOCKET, else WAYLAND_DISPLAY under XDG_RUNTIME_DIR or a path), else wayland-0 there as libwayland defaults when WAYLAND_DISPLAY is unset and wayland-client 0.31 does not (default_socket, tested); wl_shm double buffers in a memfd, xdg_shell (configure β†’ Input::Resized, close), xdg-decoration asking for a server title bar and reporting Input::Decorated(false) where there is none, wl_seat keyboard (xkb keymap by xkb, repeat done here since the compositor leaves it to clients) and pointer (cursor from the theme via wayland-cursor; discrete or smooth wheel), wl_output/preferred_buffer_scale for the scale, wl_data_device offering the clipboard with the last input serial. Events are dispatched on a thread of their own; the app thread sends requests to the same connection
  • xkb.rs β€” reads the compositor's xkb keymap text: xkb_keycodes names β†’ codes (aliases too) and xkb_symbols first-group levels β†’ keysyms, by name; keys it lacks fall back to a US layout by evdev code, keys it has but cannot name mean nothing. Tested against a keymap dumped by xkbcomp (xkb_test_keymap.xkb)
  • x11.rs β€” X11 on x11rb: the display opened x11rb's way (the socket file, then TCP), else by the Linux abstract socket of the same name (abstract_socket, with the .Xauthority cookie), which x11rb never tries and Xlib tries first β€” a user's own Xorg (Chrome Remote Desktop's, -nolisten tcp) cannot make the file in root's /tmp/.X11-unix and listens on the abstract name alone, so every client worked there but this one; and unix:20, Xlib's spelling of a local socket, which x11rb reads as a socket's path. connects_where_the_file_is_missing keeps it. Then the window, its properties and size hints, the events (read on a thread of their own into Input), the frame put up whole with PutImage (re-encoded only for an unusual visual), the core keyboard mapping, and the clipboard: when no wl-copy/xclip/ xsel is installed the window owns CLIPBOARD itself and answers SelectionRequest. The scale (pixels per point) is DUSCAPE_SCALE, else GDK_SCALE, else Xft.dpi/96, read again when the root's RESOURCE_MANAGER property changes (xrdb, a desktop's scaling setting) and reported as a resize at the new scale: X11 has one DPI for the server, so that change is what moving to another display amounts to; a monitor's RandR millimetres are not trusted. Wayland's scale follows wl_surface.enter/leave, preferred_buffer_scale and each output's scale, an unplugged output forgotten. The window has no background and north-west bit gravity: with a background pixel and forget gravity the server cleared it at every ConfigureNotify, a near-black flash a pixel of a slow drag on the resize handle
  • canvas.rs β€” the software framebuffer in points: fills with alpha, gradients, strokes, anti-aliased rounded rectangles, and blit (a picture fitted by box-filtering)
  • font.rs β€” Fonts::system finds the sans, bold and mono faces through fc-match (else well-known paths, else DUSCAPE_FONT*); Face caches ab_glyph glyphs by character and quarter-pixel size, sized by the em as every toolkit is (ab_glyph scales by the line height: em_to_height; fontdue before 2026-10-04, which Debian does not package β€” a snapshot differs by anti-aliasing alone, at most 21 levels in 255); Pen draws into a rect, aligned, vertically centred, cut with "…"
  • draw.rs β€” the frame, by Layout: the same panels as mac/draw.rs, in a fixed dark theme β€” the list as the tree (rows: each level indented ROW_INDENT, a folder's expander where Viewer::hit looks for it), the treemap nested (nested, after the top-level tiles and before the marks, the corner and the frames), a tile's label its name at the left and its size at the right (tile_label; a file's size at the bottom right when there is room); dialog paints the confirm/notice box and returns its buttons for clicks; title_bar the app's own title bar (Viewer::top_inset, Layout::with_top) where the compositor draws none
  • trash.rs β€” freedesktop Trash: gio trash if present, else ~/.local/share/Trash or .Trash-<uid> at the filesystem's top, with the .trashinfo
  • app.rs β€” the loop over one mpsc channel (Msg: Input from the backend, scan batches, the finished tree, rescans, decoded previews, ticks, snapshot), draining what has piled up before one redraw β€” outline batches are absorbed as they come and laid out once for the lot (outline_behind); keys and mouse β†’ Viewer calls like mac/view.rs's (a click on an expander toggles before click, the wheel over the treemap zooms, the back button goes up); Dialog for asking before a removal; the title bar's buttons, drag and double-click β†’ the backend. The second pass (Paints::second_pass) runs once nothing has changed on screen for IDLE, a message that changes nothing not putting it off, as the Windows timer is put off by each change. DUSCAPE_SNAPSHOT=out.png writes the frame after the scan and quits β€” how the drawing was checked here: X11 on an Xvfb (-listen tcp -ac, from before the window could reach an abstract socket; a plain Xvfb does now) with xdotool for keys and clicks; Wayland on a headless weston --backend=headless-backend.so --shell=kiosk-shell.so, unpacked from its .deb, with weston-screenshooter (it has no input to inject, so keys are covered by xkb's tests)

duscape-mac (viewers/macos/) β€” the AppKit viewer, on objc2/objc2-app-kit, over duscape-viewer:

  • mac/view.rs β€” the one NSView: events, menu commands, dialogs, Trash, pasteboard, Finder, Quick Look, drag and drop. Other threads come back through on_main (the main dispatch queue). The Viewer is in a RefCell; never hold a borrow across a modal (NSAlert::runModal, the open panel), which runs the event loop inside the call. DUSCAPE_MAC_SNAPSHOT=out.png writes the view to a PNG after the scan and quits β€” how to look at the drawing without screen access
  • mac/appkit.rs β€” AppKit loaded when the window starts, not when duscape does: both binaries link with -dead_strip_dylibs (build.rs) and name no framework symbol, since objc2 finds classes by name, so load (first in run_with) dlopens AppKit and QuickLookUI and AppKit's data constants (attribute names, pasteboard types, font weights) are read by dlsym. Linked, the terminal viewer loaded fifteen frameworks at every start (cold: 0.41 s to --version, now 0.07). Take a new AppKit constant through it, never by its objc2-app-kit static, or the frameworks come back: otool -L target/release/duscape lists libSystem and libobjc alone. The debug build keeps AppKit in its load commands anyway, so smoke.sh runs the release
  • mac/script.rs β€” DUSCAPE_MAC_SCRIPT: synthetic keys, clicks and menu choices posted to the app's own event queue, and state dumps to assert on. tests/smoke.sh runs one on a fixture; run it after changing the viewer (macOS, logged-in session, no permissions needed)
  • mac/draw.rs β€” painting, by Layout: the same tree, nesting and labels as the Linux viewer's draw.rs; mac/mod.rs β€” the app, delegate, menus, window. In mac/view.rs a click on an expander toggles before click, a mouse's wheel (not a trackpad's) or a pinch over the treemap zooms, the back button goes up, and outline batches are laid out once per burst (outline_behind, a catch-up queued behind the batches waiting on the main queue)

MS-DOS (viewers/dos/) β€” FASM, real mode on a 286 (or 186) with no coprocessor, not part of the Cargo workspace: DUSCAPE.ASM (the program), PANEL.ASM (side panel), PREVIEW.ASM (text and half-block pictures, the six adaptive DAC colours), PNG.ASM and JPEG.ASM (decoders; a JPEG block's mean is its DC coefficient, so no IDCT), PVDATA.ASM (their data), SOFTFP.ASM/FPDATA.ASM (IEEE doubles in software, unpacked, rounded after each operation), J286.INC (conditional jumps as short-or-inverted macros). No 32-bit register, FS/GS, 386 or x87 instruction, and no dd/dq variable (FASM makes 32-bit code for those unasked): python3 viewers/dos/tests/lint286.py must say so, and test.py runs everything on an emulated 286 without an FPU. 16-bit addressing has no [si+di], and [bp+…] is in SS. A port, not a binding: the squarify layout, RectFloat::round, Board navigation, the tile text and the size formats are rewritten from common/ and the TUI's grid/, so a change to those should be carried over by hand. make dos fetches FASM and CWSDPMI into target/dos/ (hash-checked) and assembles inside DOSBox-X; make dos-run opens the repo as C:. -k KEYS -s FILE types keys and writes the screen and tiles; python3 viewers/dos/test.py runs the checks on fixtures that way, the layout ones against TreeMap through viewers/dos/tiles (a crate outside the workspace). Run it after changing the DOS viewer. DOSBox-X loses long-name search entries when two searches are open, so each folder is listed to the end before its subfolders are walked (a pending stack in its own segment), and the delete queues its entries the same way; keep it that way. Do not set attributes on host files needlessly: DOSBox-X stores them in .DBLOCALFILE_ATR_* files beside them. Decoding runs with ES = the line segment and FS = the window: a rep stos/movs into DS there must set ES first, and a table in the code segment is read through cs:.

duscape (viewers/tui/) β€” the ratatui viewer:

  • issues.rs β€” --issues: a scan with nothing drawn (parallel::build_tree, as the app scans), then duscape_scan::environment and FileTree::issues' report on stdout
  • front.rs β€” which viewer this duscape is: choose (pure, tested) on the arguments and Started β€” --tui/--gui; --benchmark, --issues, --help, --version the terminal's; a name ending -gui/-linux/-windows/-mac the window; then a terminal on stdin or stdout is the terminal viewer (so a redirected benchmark stays one), neither with a display the window, and on Windows no console, or one the process has alone (GetConsoleProcessList), is Explorer's start: the window, after FreeConsole. windows.manifest, embedded by build.rs (a resource, viewers/windows/resources.rs; bins only, gui feature), sets consoleAllocationPolicy to detached, so from Windows 11 24H2 Explorer makes no console at all and nothing flashes; older Windows ignores it and makes one, which is let go. The terminal viewer with no console (--tui from a shortcut) gets one (ensure_console, AllocConsole). lib.rs's run dispatches: the window gets the same Opt, parsed once (Opt::scan_options, the folder, --no-elevate), not the config file. The executable is console subsystem, or the terminal viewer would have no stdin; duscape-windows.exe alone keeps windows_subsystem = "windows". The window's elevated relaunch passes --gui (elevate::relaunch_args), since the program relaunched may be this one
  • main.rs β€” entry point, thread spawning, channel setup
  • app/mod.rs β€” App state machine, UiMode enum, render dispatch
  • input/controls.rs β€” per-mode keypress handlers
  • messages/instruction.rs β€” Instruction dispatch to App methods
  • ui/display.rs β€” ratatui rendering orchestration
  • ui/grid/ β€” the treemap (RectangleGrid): the board's tiles, the nesting inside them (nested, laid out in ui/display.rs by NESTING and cached by Board::generation), the "small files" corners (β–«, SMALL_FILE, one cell wide in every terminal), and the frames of highlighted tiles, drawn last (frame_on_grid)
  • ui/highlight.rs β€” highlight: how the entry in hand and the marks look, one rule for the list and the treemap (see "Colours")
  • ui/side_panel.rs β€” the list left of the treemap; screen_areas splits the screen (a third to the panel when β‰₯ 80 columns) and entry_at maps a cell to a row β€” used by both the renderer and the mouse, so they cannot disagree
  • config/mod.rs β€” TOML config (~/.config/duscape/config.toml)
  • preview.rs β€” the preview thread (debounce, then libduscape::preview), and kitty/sixel graphics output (Graphics: KittyGraphics writes after each frame, only on change; q=2 so the terminal never answers on stdin, z=-1 so dialogs cover it). SixelGraphics has nothing to delete a picture by and the frame never redraws cells it thinks blank, so prepare (before the frame) erases the old picture's cells when it changes; text over a sixel destroys it, so it is hidden while a dialog is up (stays_under_text), and cleared forgets it when a resize clears the screen. The encoder is a median-cut palette of 256 and the picture is cut to whole 6-pixel bands so none spills into the next row. side_panel::screen_areas sizes the preview 16:9 from the cell pixel size Display measures each frame (else the CSI 16 t answer, queried_cell_pixels). graphics_protocol decides once: env vars (kitty, Ghostty, WezTerm; tmux never kitty), else a graphics query + CSI 16 t + DA1 read straight off stdin β€” what finds it over ssh; sixels are DA1 attribute 4 (tmux answers for itself). Where nothing can be asked (Windows) Windows Terminal, foot, mlterm and iTerm2 are taken as sixel by name (WT with its fixed 10Γ—20 sixel cell, since the console reports no pixels). It must first run in raw mode before any thread reads stdin (try_main). pictures() picks Pictures::Kitty, Sixel, Blocks (the fallback: β–€ cells the previewer colours as Preview::Blocks and side_panel draws into the frame) or Described
  • clipboard.rs β€” libduscape::clipboard::copy, else the terminal's OSC 52; paths are quoted by libduscape::format::quote_path_for_shell before they get there
  • cli/mod.rs β€” clap CLI args

UI State Machine (UiMode)

Loading                     // Scan in progress
Normal                      // Main treemap view
ScreenTooSmall              // Terminal < 50Γ—15
DeleteFiles(Vec<FileToDelete>)  // Confirmation dialog: the marked entries, or the one in hand
ErrorMessage(String)        // Error display
Exiting { app_loaded: bool }

Key Patterns

  • Multi-selection: App::marked holds names in the order picked; mark_range is a Shift run's anchor and the marks it started from, so reversing shrinks the range. Every change calls copy_marked, which reuses right-click's shell_path. Plain moves, jumps, clicks and folder changes clear it. cursor_chosen says whether the entry in hand was picked (plain click, arrow, jump) or placed by the app (a folder's top row, a deleted entry's neighbour); only a picked one seeds a Ctrl+click selection, so d never deletes an entry nobody chose. d deletes every marked entry (get_files_to_delete), continuing past failures and naming the first.
  • Help line: an endless strip, legend and tips alternating (ui::bottom_line::Strip). It rests REST (5 s, from arrival or the last key, whichever is later) at each stop β€” one per segment, or a page at a time for one wider than the screen β€” and slides to the next in SLIDE (80 ms, eased), so every move finishes within 100 ms. The position is kept within a segment (Ticker), so a legend that changes length (scan done) does not make what is on screen jump. Keys named in it come from Keybinds, never literals. It ticks at frame rate only while it slides, and twice a rest otherwise (App::ticker_pace): 60 fps where something moves, next to nothing when idle.
  • Colours: no dark gray (unreadable on black) and no magenta on the light cursor bar. The list and the treemap highlight by one rule, ui::highlight::highlight: in the panel with the keyboard the entry in hand is a bar, white on blue for a folder and black on gray for a file; in the other it is white, bold and underlined, with no bar; marks are black on yellow either way, underlined when in hand too. A highlighted tile's border takes the same colours. side_panel and grid tests assert them.
  • Focus: the list has it by default (Focus::List; list_cursor: None means its top row, and while the list has focus render syncs the treemap's selection to it). App::focus says which panel the keyboard drives; it follows the last click, Tab, and Left off the treemap's left edge, and is always Treemap while the panel is hidden. In the desktop viewers that is derived, not set (Viewer::focus(): the panel last chosen, the treemap while the layout has no list), so a window narrowed and widened again, or minimised, gives the list back. The list's cursor is kept by name (the listing re-sorts during a scan); moving it selects the entry's tile, or nothing if it has none. Enter, Esc and delete go through selected_entry, so an entry without a tile can still be acted on.
  • One listing, two views: Board::listing is the folder's entries, largest first, unzoomed, sorted once per change_files; the side panel draws it every frame without re-sorting. Clicks are keyed by entry name, so a tile and a list row are the same target, and an entry with no tile can still be entered or copied.
  • Render-on-demand: Render only when an Instruction arrives; no continuous loop. Every frame is one something asked for, so the frame budget is spent on changes, not on repainting what is there; the desktop viewers likewise paint on a change, and drain what has piled up before painting once for all of it.
  • Live treemap update: while scanning, Board recomputes tiles from a folder-only outline (Outline β†’ FileTree::add_summary) β€” every folder to Outline::DEFAULT_DEPTH with a running size, shared blocks counted in full, deeper directories rolled up into the frontier folder above them. Files, and folders below the frontier, appear when the finished tree replaces the outline (App::finish_scan). Keep the outline O(visible): the first version sent every directory and saturated the rendering thread, which back-pressured the dispatcher and slowed the walk. This is the goals' time to first paint: the treemap is up in the first batch, coarse, and filled in as the walk goes. The desktop viewers' outline sends what it has every frame as well (Outline::flushing_every(scan::FRAME)), and a window lays the view out at most once a frame (OUTLINE_TIMER, outline_behind), so the live view moves at the frame rate and a scan never crowds out input. A folder entered during the scan is followed (scan::Focus, set by App::render_and_update_board and Viewer::relayout): the walkers read toward it before anything else, the outline is exempt from its depth cap under it and carries the folder's own files, and the treemap says "Scanning this folder…" rather than "empty" while there is nothing to draw (the outline holds no files, so a folder of files alone looks the same as one not read yet until the finished tree arrives).
  • Parallel build, no shared memory: each builder owns a tree; correctness rests on HardLinks::charge being order-independent, so deferring every charge to one final replay gives the same per-folder sizes as charging inline. Tested folder-by-folder against the inline tree (model::tests::sharded). Shard by SHARD_DEPTH path components, not the whole path β€” see docs/scan-performance.md for why the merge otherwise costs more than the parallelism saves. The point is the goals' fast walker: the build is hidden behind the walk instead of following it, so the scan takes the walk's time and no more.
  • Two sizes everywhere: EntryMeta carries size (on disk) and apparent (length); every walker fills both. model::File stores disk as u64 plus apparent as an i32 difference (FileSizes::Far boxes both when they are β‰₯ 2 GiB apart), keeping FileOrFolder at 16 bytes β€” asserted in model::tests; do not grow it. Folders hold sizes: Sizes. FileTree::shown and Board::show pick which is displayed; the ledger charges both kinds to the same ancestors and identifies files by the disk size. ScanOptions::show_apparent_size only sets the initial view.
  • Sizes are not additive: a folder's size counts each distinct set of blocks once, so hard links, XFS/btrfs reflinks and APFS clones all make it smaller than the sum of its entries. See docs/scan-performance.md and docs/sizes.md (what is still counted twice: a file sharing ranges of another, as Preboot's cryptexes share their image's).
  • Zoom as filter: Zoom level controls which nested folders are rendered.
  • Modal via enum: UiMode variant change = modal open/close; no separate stack.
  • Config merging: CLI --apparent-size ORs with config file setting.
  • Graceful degradation: Read errors counted but scan continues. A failed directory read ends that directory rather than retrying it β€” the error belongs to the descriptor, not the entry.
  • Per-filesystem attributes: a returned-attributes bitmap says an attribute is present, not that its value is real. msdosfs claims ATTR_FILE_ALLOCSIZE and packs zero, so the size attribute is chosen per device. See docs/scan-performance.md.
  • Pseudo-filesystems: crossing a mount point into /proc, /sys, cgroup, debugfs and friends is refused (by statfs magic); naming one as the scan root still scans it.
  • Loops: a mount of a directory inside itself, or of one above the scan inside it, is one of its own ancestors, and walked holds itself again (Synology's /volume1/@docker, a folder mounted onto itself, is not one: the synology fixture scenario lays out a real DSM mount table and passes with this check disabled). At every mount root or crossing β€” only a mount can loop, Linux having no directory hard links β€” linux::loops_back stats the ancestors up to / and compares device and inode; a match is not walked, and is noted (DirEntries::note, kind loop: in --issues, not in the failure count). walk_would_enter refuses such a folder to a rescan.
  • -x on btrfs: the boundary is the filesystem, not the subvolume (linux::same_filesystem: the same device, or btrfs with the root's extent_space, the filesystem's UUID hash). Every subvolume has its own st_dev, so by device -x stopped at each β€” every Synology share. Deliberately unlike du -x.
  • Snapshots: a read-only btrfs subvolume inside the scan is left empty by default, as a mount -x refuses; --snapshots walks it, the extent ledger counting what it shares once. Named as the scan root, it is scanned. Over the network a share shows its snapshots as plain folders (Synology's #snapshot, QNAP's @Recently-Snapshot, ZFS's .zfs, NetApp's .snapshot): every walker leaves those empty by name (libduscape::nas::left_out, a left out note in the directory, walk_would_enter refusing a rescan of one), and --snapshots walks them. A recycle bin (#recycle, @Recycle, .recycle) and the NAS's other folders (@docker, @eaDir, .@__thumb…) hold space and are walked; nas::describe says what each is, in the status line of every viewer. Over the network no walker can see a snapshot's blocks shared with the live file's, so at a volume root FileTree::counted_beyond_volume β€” the scan's total over the volume's used space β€” is what says they are, in the status line and the panel; it says "shared or compressed", since unprivileged btrfs sizes are uncompressed too. What of the volume the scan did not find (outside_scan, the windows' "Not seen by the scan" strip) is not said for a share (duscape_scan::is_network: Linux by its filesystem, macOS MNT_LOCAL, Windows a UNC path or a remote drive; FileTree::on_network, the viewer's network_root): the volume is the server's, and the rest of it the server's other shares. The rule itself is DirEntries::leave_out (noted only where the walk would have gone down), and the MFT reader asks it as the kernel walkers do. Under a folder whose snapshots are left out β€” one listing a snapshot folder by name, or under an ancestor that does (nas::snapshots_left_out_among, snapshots_left_out_above, asked once a scan for the root's ancestors, so a rescan agrees with the scan) β€” the Linux walk does not probe shared extents at all: every extent there is shared with the snapshots, which are not counted, and on a Synology's kernel 4.4 the FIEMAP probe cost 0.5–1.7 ms a file, 80–90% of the walk (/volume1/homes, 200k entries: 2.0 s β†’ 0.2 s; --issues notes not probed). A reflink pair inside such a share counts twice, once each; --snapshots walks the snapshots and probes again. The synology fixture asserts both.
  • Bind mounts: a mount root (STATX_ATTR_MOUNT_ROOT) is looked up in /proc/self/mountinfo by stx_mnt_id (linux::mounts); if an earlier mount of the same device shows the same directory at a path inside the scan β€” checked by device and inode β€” the mount is left empty.
  • btrfs compression (root only): linux::btrfs::extents::on_disk reads a file's EXTENT_DATA items with BTRFS_IOC_TREE_SEARCH_V2 on the directory fd (tree 0 = its subvolume) and sums what they occupy; it replaces stx_blocks as the disk size. Gated by filesystem::Compressed (decided per mount: Maybe if the superblock options say compress, Marked for STATX_ATTR_COMPRESSED files only, Never if not btrfs or not permitted), since it costs ~1 Β΅s a file. The FIEMAP identity pages through long extent maps (compressed files have one extent per 128 KiB).
  • The saved scan (macOS): the walk cannot be made faster than the kernel's floor there (docs/scan-performance.md, "macOS: what is left"), so every scan after the first starts from the last one's saved stream, in three steps that follow the goals' rule (coarse now, complete after): shown as it was, streaming from the file, the first directory in milliseconds (Cache::Saved, SavedStream); caught up behind that by a whole-tree rescan through Cache::CatchUp, the FSEvents log naming the folders that changed and only those listed again, the new tree swapped in as R's is; filled in after that, the folders the file had trimmed listed again, the one in view first (fill.rs). The file keeps folders, hard-linked files and files of a megabyte and up; a folder's smaller files travel as one sum (Unlisted, held by Folder::unlisted), so every size is right from the first frame and only the small tiles arrive with the fill. Whatever walker ran, the stream is recorded as it goes, stamped with the log's id from before the walk started, so a change made during it is replayed next time. Not a cache of the tree: the tree is built from the stream as on any scan, so the ledger charges hard links as it would have. The stream's order β€” parent before child β€” is the file's order, and what the replay keeps
  • The idle passes (Rescans::start_idle, called by every viewer when a tree lands and whenever a rescan reports): once nothing replaces the tree, a catch-up's fill (owed once per catch-up, fill_owed: a folder that will not list keeps its sum, and a fill started whenever one was left would never stop), then the volume's local snapshots β€” named at once, read as root behind that. The snapshots' folder is the last pass because it is the slowest (a walk a snapshot) and the least asked for.
  • Two passes: the walk probes shared extents only from 64 KiB; smaller files are noted in DirEntries::later and probed after the tree is shown (see the refine_N thread). The benchmark's refined stage is walk + second pass, and is what the fixtures measure. This is the pattern the goals ask of every costly feature β€” coarse now, complete after: the probe costs more than it changes, so it waits until the tree is on screen, the folder in view first. The window's deeper nesting, its specks and its first paint's labels (Viewer::defer_to_second_pass, LABEL_DEADLINE) follow it.
  • Network filesystems: refused the same way, whatever -x says β€” NFS, SMB, 9p, Ceph, AFS… by magic (linux::filesystem::NETWORK), and FUSE by its subtype in /proc/self/mountinfo, found by stx_mnt_id (NETWORK_FUSE: sshfs, rclone, s3fs…), since FUSE also serves local filesystems. macOS skips a mount point without MNT_LOCAL. Another machine's files are not this disk's space.
  • ManuallyDrop on FileTree: Avoids slow recursive drop on exit: freeing millions of nodes is work nobody waits for, so quitting is immediate; the TUI leaks a replaced tree, a desktop viewer hands it to drop_later's thread.
  • Threads are not joined at quit: the TUI's start lets its threads go when the app's loop ends, and the process's exit ends them. Joined, a quit during the scan waited for the walk to stop (a worker checks stop between directories, so each finished the one it was in, cold, a statx at a time) before the terminal was restored: up to 4 s on /. The desktop viewers never joined theirs. What a quit still waits for is the kernel: a thread blocked in a disk read (D) ends only when the read does, so the process lingers a few tenths of a second after the terminal is back β€” checking stop more often would not shorten that.
  • Folders know their ledger id: Folder::dir is the folder in HardLinks, given when a directory's path is first resolved (HardLinks::child(parent), no hashing) and NONE until then. Deferred sightings carry ids, not paths; a merge renumbers the folders it moves in (Folder::renumber, remapping the other tree's sightings) and so does a graft. Interning by path was 0.7 Β΅s a directory and a third of the ledger's time β€” see "The tree build" in docs/scan-performance.md. --benchmark --bench-profile shows the build phase by phase.

Default Keybinds

Action Key
Quit q
Delete d
Navigate h/j/k/l or arrow keys
Enter folder Enter
Go to parent Esc
Select tile left click
Enter folder double-click (same tile, within 500 ms)
Switch list / treemap Tab (← off the treemap's left edge, β†’ from the list)
Jump through list PgUp / PgDn / Home / End
Mark a range (copies) Shift+↑/↓ in the list
Mark / unmark (copies) Ctrl+click, either panel
Mark a range (copies) Shift+click, either panel (where the terminal reports it: most keep it for selecting text)
Copy relative path right-click
Copy absolute path double right-click
Zoom in/out + / -
Disk usage / apparent size a (no rescan)
Rescan selected folder / everything r / R (not during the first scan)
Reset zoom 0
Confirm y
Cancel n

Code Conventions

  • Every fence has its reason written down, so it can be taken down. A decision that is not obvious from the code β€” a constant's value, a call left out, an order kept, a branch that looks redundant, a walker that declines, a limit, a gate, a check β€” is a fence in a field (Chesterton's). The point of writing down why it stands is not to keep it standing: it is that when the situation changes (a kernel gains the call, the disk is faster, the format grows a field) whoever finds the fence can see at once whether its reason still holds, and remove it without fear if it does not. A fence with no reason recorded can neither be trusted nor removed. So the reason lives where it cannot be lost: as a test that fails when the decision is undone (preferred, since it cannot go stale β€” nothing_ changed_replays_the_saved_scan_whole, the_icon_file_is_the_one_drawn, the fixture oracles, model::tests::sharded's per-folder comparison), or as text beside the code (a comment saying what was tried and what it cost, or a dated section of docs/scan-performance.md with the numbers β€” "What did not work: opening directories relative to their parent", the six-worker table, the -x-on-btrfs rule in "Key Patterns" above). A negative result is recorded like a positive one, so it is not tried twice (docs/scan-roadmap.md, "Not worth revisiting"). What counts as recorded: a reader who did not write it can say what breaks if the code goes back to the simple thing. A change that removes a fence says, in its commit, which reason it found written down and why it no longer holds; one that finds a fence with no reason recorded writes the reason down first, or the test, then decides. This is the file's own rule: its "Key Patterns" and the crate map are those reasons, kept where every agent reads them.
  • Error handling: thiserror derives; ? propagation; distinct error enums per crate boundary.
  • Testing: #[cfg(test)] mod tests in same file; temp dirs via helpers; setup β†’ action β†’ assert.
  • Concurrency: Named threads; bounded channels; park_timeout (100ms) for polling. The thread model is what keeps the drawing thread free (see its "Why"), so new slow work gets a thread or a second pass, never a place in a frame.
  • Exports: pub use re-exports in mod.rs files.
  • No async runtime: Threads + channels only.
  • Cross-platform: Linux, macOS, and Windows supported. Windows consoles report key releases as events; TerminalEvents drops them, so handlers only ever see presses. It drops mouse movement, drags, releases and scrolls too (is_mouse_noise): mouse capture reports every movement, and the warning modal closes on any event. CI runs on Linux only β€” check other targets with cargo clippy --workspace --all-targets --target <triple>. The BSDs have no native walker: they scan with the portable walk (portable.rs). The Linux window is gated to Linux and FreeBSD and type-checks for x86_64-unknown-freebsd, but has never been run there; say so rather than claim BSD support.
  • musl: the release is built for musl, and libc types differ there. ioctl's request is c_ulong on glibc but c_int on musl, so request constants are libc::Ioctl. CI tests x86_64-unknown-linux-musl on every push (test-musl).
  • Docs per platform: a module exists on its platform alone, and so do its docs and its links: a doc comment in code every platform compiles names another platform's module only in a #[cfg_attr(target_os = "…", doc = "…")] line (scanners/src/lib.rs's walker list and scan_directories, cache.rs's FSEvents), so Linux's docs never mention the macOS walker. A public doc does not link a private item: the item is made public if it is part of what the doc explains (Places::LINES, the treemap's STEADY_*, portable), else the pointer goes in a // comment rustdoc does not read (windows.rs's links, macos.rs's image_left_out). The doc job runs cargo doc -D warnings for Linux, Windows and macOS.
  • Byte order: what a filesystem stores is little-endian on every machine β€” ext4, NTFS, btrfs β€” and is read with from_le_bytes; only what the kernel fills in itself (an ioctl's own structs, such as btrfs's search header) is in the CPU's order, from_ne_bytes. Mixing them up passes on x86 and fails on big-endian s390x: btrfs's extent items were read in the CPU's order until 2026-10-04 (11.6 exabytes for 108 KB). CI is x86 alone, so docs/probes/cross-arch-tests.sh runs the core and scanner tests on i686, armv7 and s390x under QEMU, no root; run it after touching a parser (docs/packaging.md).

Adding Features β€” Agent Guidance

Adding a new keybind

  1. Add field to KeybindConfig in viewers/tui/src/config/mod.rs
  2. Add parsing in viewers/tui/src/config/keybind.rs
  3. Add to Keybinds struct and wire in input/controls.rs
  4. Update example/config.toml

Adding a new UI mode

  1. Add variant to UiMode in app/mod.rs
  2. Add handle_keypress_<mode>() in input/controls.rs
  3. Add render arm in ui/display.rs
  4. Wire Instruction variants in messages/instruction.rs

Adding a scan option

  1. Add field to ScanOptions in common/src/scan/mod.rs
  2. Thread it through every walker in scanners/src/: macos.rs (macOS), linux.rs, windows.rs, and portable.rs (everywhere else, on std::fs). The portable walk is selected only off Linux, macOS and Windows, so there it is only ever run by its tests and the benchmark's portable-* stages β€” do not assume compiling it means it works.
  3. Expose via CLI in viewers/tui/src/cli/mod.rs and config if persistent
  4. Add a --benchmark stage if it changes how the walk performs

Filesystem fixtures β€” the standard for scan and accounting changes

make test-fs (root or the docker group) makes ext4, XFS, btrfs, f2fs, tmpfs, FAT32, exFAT and NTFS on loopback images, fills them with hard links, sparse files, reflinks, snapshots and compression, builds mount layouts (nested, proc, tmpfs, bind mounts, loopback NFS, fuse.rclone), runs both test suites on each with TMPDIR there, and checks totals against oracles that share no code with duscape. See fixtures/fs/README.md. Any change to the walkers, EntryMeta, the hard-link/reflink ledger or mount handling must pass it, and a behaviour that depends on the filesystem or the mount table gets a fixture there. CI runs it (fs-fixtures.yml). Remember: every btrfs subvolume and snapshot has its own st_dev and f_fsid β€” never key anything cross-file on the device alone there.

Touching filesystem attributes

Test against FAT as well as APFS β€” it is the filesystem that misreports. docs/scan-performance.md has the FAT section, and the volume test is:

cargo test -p libduscape --lib -- --ignored fat32

Changing the scan

The walk is the first of the performance goals β€” the time to first paint starts with it, and the whole scan is the walk wherever the build hides behind it β€” so a change to it is measured, not reasoned about. Read docs/scan-performance.md first, and docs/scan-roadmap.md for what is planned and the rules each step follows: measure with docs/probes/bench-matrix.sh before and after (it writes docs/benchmarks/<host>-<date>.md; commit it), totals identical, fixtures green. It records what was measured, what turned out not to matter, and how to reproduce the numbers with --benchmark. The short version: on Linux the walk is the floor (~0.40s for 4.2M entries, at the kernel's statx cost) and the tree build is hidden behind it on parallel::SHARDS threads. On macOS and Windows the walk is the whole scan β€” macOS waits on 4 KiB metadata reads and is fastest at six workers β€” so SHARDS is 1 there and any serial work after the walk shows directly in the scan time. --bench-stage sharded is the app's path; pipeline is the single-threaded build it replaced. Those are warm numbers. Cold (caches dropped) the walk is bound by reads in flight, one directory's inode and blocks per blocked worker, which is why Linux runs three workers a core, stats a directory in inode order, walks children smallest inode first, and as root reads the directories' blocks ahead through the device (linux::dirblocks, ext4 only β€” DUSCAPE_DIRBLOCKS_DEVICE=<file> forces the path for testing). As root on ext4 the whole walk reads the device instead (ext4.rs, roadmap step 2: cold 1.7x the kernel walk); --no-device-read compares; docs/probes/bench-diskus.sh measures warm and cold against diskus β€” see "Cold cache" in the doc. Anything you change must keep sharded's totals identical to pipeline's β€” that comparison is the correctness check, not just the speed one. On Windows the floor is a fixed kernel and filter-driver cost per directory handle (3Γ— on the system volume); opening by file id, closing off the walker threads and skipping the last listing call were all measured and none helped β€” read the 2026-09-24 section before trying them again.

Modifying treemap layout

  • Core algorithm: common/src/tiles/treemap.rs; the grid it lays out in is Grid
  • The desktop viewers lay out in pixels, so the tile count follows the window: measure a change with DUSCAPE_LAYOUT_PATH='E:\' cargo test --release -p duscape-viewer --test layout_speed -- --ignored --nocapture (the board and nesting at three window sizes; 2026-09-27 on E:, 240k entries: 11k nested tiles laid out in 5 ms at 2560Γ—1400 pt, 1.5x; C:\Windows: 26k in 24 ms; the flat 87k-file C:\ProgramData\Dell\SARemediation\SystemRepair\Snapshots\Backup: 23k tiles and 61k specks in 28 ms) and, on Windows, DUSCAPE_PAINT_TIMES (4k tiles painted in 13–17 ms, what 250 took before the pixel grid; the 87k-file folder in 13–19 ms)
  • Tile rendering: viewers/tui/src/ui/grid/ (terminal), viewers/windows/src/win/paint.rs, viewers/macos/src/mac/draw.rs (treemap)
  • Adjust HEIGHT_WIDTH_RATIO, MINIMUM_HEIGHT, MINIMUM_WIDTH constants (the terminal's Grid), or MIN_TILE_PIXELS in viewers/shared (the windows')
  • Entries below the minimum tile size are never dropped: they fold into the "small files" corner (in the terminal a box filled with β–«s β€” not β–‘, which many terminals draw two cells wide β€” in the terminal's own colours, drawn over what is there, since it can lie over the last tile's cells), clamped by SMALL_FILES_MINIMUM_WIDTH/HEIGHT so it stays visible even when the hidden entries round to zero cells
  • Why the layout's work is bounded by the screen, not the folder (largest_in_folder ranks only what can get a tile, Nesting caps at what the area holds at the least tile, the corner ranks only as many as it has pixels): the goals' 60 fps relayout has to hold on a folder of a million entries as on one of ten. What the screen cannot show at once becomes a second pass (Viewer::finish_second_pass), not a slower frame

Releases

The binaries deploy.yml builds are the canonical ones (docs/packaging.md): every package holds them byte for byte, never a build of its own β€” the deb and rpm (packaging/linux/nfpm.yaml) and the Windows installer (installer/duscape.nsi, Ubuntu's makensis) are made in the job that built the binary, from the same files as the tarball or zip. The release adds SHA256SUMS and a build-provenance attestation per file, what a manual self-update would check. Keep the asset names stable: they are what such an updater asks for. macOS is built there too, on macos-latest (build-macos), so every platform's download is a CI build. A v* tag runs deploy.yml. It builds duscape-<tag>-<target>.tar.gz for x86_64-unknown-linux-musl (musl-gcc) and aarch64-unknown-linux-musl (cargo zigbuild, zig 0.13.0), and duscape-<tag>-x86_64-pc-windows-gnu.zip (cargo zigbuild, against the Universal C Runtime: only DLLs Windows 10 carries), each duscape being the terminal viewer and the window; the zip has duscape-windows.exe beside it, the window alone and windows subsystem, for a shortcut to start with no console flashing before Windows 11 24H2. The Linux binaries are fully static, so they have no glibc floor and run on Alpine and busybox; the job checks it, and that duscape.exe is console subsystem and duscape-windows.exe is not. macOS has a job of its own on macos-latest (linking AppKit needs a Mac): make mac-app makes the universal binary and Duscape.app (viewers/macos/Info.plist) β€” a bare binary opened from Finder runs in Terminal, so Finder's way to the window is the bundle β€” then checks both architectures, no AppKit in the load commands, the signature, and a scan; it ships duscape-<tag>-universal-apple-darwin.tar.gz (the binary taken from inside the signed bundle, since codesign on the bundle rewrites it) and Duscape-<tag>-macos.zip (ditto, which keeps the signature). Signed ad hoc, not notarised: Gatekeeper asks before a downloaded copy's first start. One job then publishes every archive: matrix jobs that each create the release race. The repository's Actions permission must allow actions from outside it (actions/checkout…): set to local actions only, every run fails to start. The version is the workspace's (Cargo.toml), with the path dependencies' version beside it.

  • Build settings are chosen by measured speed first (the performance goals), size second:
  • opt-level = "z": the release profile is size-optimised for the monolithic viewer binaries, shaving 455 KiB (βˆ’17.5%) off the binary (down to ~2.14 MB) under fat LTO (codegen-units = 1, panic = "abort", strip = true) while maintaining ~917k–1M+ entries/s scan throughput (see docs/security.md). Earlier single-threaded Linux benchmarks showed "s" faster on synthetic tree-build micro-benchmarks (docs/scan-performance.md), but in practice "z" remains well within the interactive budget. With lto = true a per-crate opt-level does nothing, the final codegen uses the top level's. --profile profiling is the release with symbols, for samplers. PGO (make pgo) is worth 2–3% wall, 6–8% CPU, and is not in the release pipeline; thin LTO is slower than fat.
  • Allocator: musl builds use jemalloc (tikv-jemallocator, 64-bit musl only). musl's own malloc made the scan 7x slower and mimalloc 2x. Do not swap it without rerunning the --bench-stage sharded comparison in docs/scan-performance.md. glibc builds use the system allocator.
  • aarch64 page size: jemalloc fixes its page size at build time. aarch64 builds set JEMALLOC_SYS_WITH_LG_PAGE=16, so the binary also runs on 16K- and 64K-page kernels.
  • Licences: jemalloc is BSD-2-Clause and linked in, so its COPYING ships in each tarball as LICENSE-jemalloc.
  • zig as the musl C compiler without zigbuild: cc-rs passes a Rust --target= that zig rejects, and zig's debug-mode UBSan traps in jemalloc (tests die with SIGILL). Filter the flag and pass -fno-sanitize=undefined, or just use cargo zigbuild, which does both.

Quality

What is measured, where the limit is, and what to do when a change crosses it. make quality prints the live figures; make coverage the test coverage.

  • Function size and complexity. cargo clippy warns β€” and CI, with -D warnings, fails β€” on a function over 100 lines or of cognitive complexity over 25 (clippy.toml; the lints are turned on for every crate by [workspace.lints]). Split the function, or when its length is the honest shape of the work (a widget drawn top to bottom, a listing decoded entry by entry) put #[allow(clippy::too_many_lines)] // quality debt: <why> on it. Those markers are the debt register, which make quality lists; do not add one without the reason, and take one off when you split the function. Measured on all three targets, since each viewer's code is compiled on its platform alone.
  • Tests. cargo test --workspace passes on Linux (CI) and on Windows and macOS; a fixture that needs something the machine lacks (symlink creation on Windows without Developer Mode, a sparse file on a filesystem that makes none) skips with a comment saying so, never fails and never asserts less than it did. Tests are platform-correct, not platform-skipped: a path is built with Path::join, a quoted path with quote_path_for_shell, a sparse file with os::set_sparse.
  • unsafe. Every unsafe block has a // SAFETY: comment above it saying what is upheld; make quality counts the blocks per crate and those without one, which is zero.
  • Coverage. make coverage (cargo llvm-cov). The viewers that are stubs on the platform measuring show as uncovered; the row to read is the crate changed. Baseline, 2026-09-26, on Windows: 70.6% of lines and 74.4% of functions in all β€” common 88.7%, viewers/tui 76.2%, viewers/shared 74.0%, scanners 65.4% (its Linux walkers are not compiled there), viewers/windows 7.1% (GDI and Win32; what it decides is in viewers/shared, and tested).
  • Dependencies and spelling. cargo deny check (licences) and typos, in CI.
  • Speed. The performance goals at the top are a quality measure like the others: a change that touches the walk, the layout or the paint says what it measured (--benchmark, tests/layout_speed.rs, DUSCAPE_PAINT_TIMES) in its commit, and one that makes a frame slower either finds the time back or moves the new work to a second pass.

CI Checks (must pass)

  • cargo test --workspace
  • cargo test -p libduscape -p duscape --target x86_64-unknown-linux-musl
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • cargo deny check
  • typos check
  • fixtures/fs/run.sh (fs-fixtures.yml)

File Size Reference

Regenerated by hand from wc -l when this file is touched; make quality prints the live figures.

File Purpose
viewers/tui/src/lib.rs ~480 lines β€” which viewer (front), terminal setup, thread/channel setup
viewers/tui/src/app/mod.rs ~1420 lines β€” the TUI's state machine
viewers/tui/src/preview.rs ~1300 lines β€” preview thread, kitty/sixel/half-block output, detection
viewers/windows/src/win/mod.rs ~1440 lines β€” the Windows window: input β†’ Viewer, threads, messages, the start-up timeline
viewers/windows/src/win/paint.rs ~1320 lines β€” drawing by Viewer::layout: pixels into a DIB section, GDI text
viewers/shared/src/state.rs ~2580 lines β€” the desktop viewers' shared state, no toolkit; the free-space view and its toggle
viewers/shared/src/deleting.rs ~300 lines β€” a delete on a thread of its own: its outcome, its box's words and layout
viewers/shared/src/state/tween.rs ~180 lines β€” tiles sliding from one steady layout to the next
viewers/macos/src/mac/view.rs ~1610 lines β€” the macOS viewer's view, events and commands
viewers/linux/src/wayland.rs ~1030 lines β€” the Wayland backend: shm, xdg-shell, seat, clipboard
viewers/linux/src/app.rs ~1300 lines β€” the Linux viewer's loop, keys, mouse, dialogs, context menu, title bar
viewers/linux/src/draw.rs ~1060 lines β€” the Linux viewer's painting: the tree, the nesting, the menu, the dialogs
viewers/linux/src/x11.rs ~550 lines β€” the X11 backend: window, events, PutImage, keymap, clipboard
viewers/linux/src/xkb.rs ~360 lines β€” the xkb keymap reader
common/src/tiles/board.rs ~530 lines β€” tile nav/zoom, steady relayouts, the free and unscanned space's strip
common/src/tiles/treemap.rs ~560 lines β€” squarify, in a Grid; the steady layout (Plan)
common/src/tiles/nested.rs ~910 lines β€” the nesting, steady or not
common/src/model/files/file_tree.rs ~630 lines β€” folder tree, hard-link accounting, the build profile
scanners/src/lib.rs ~770 lines β€” walker selection, parallel build, environment
scanners/src/portable.rs ~260 lines β€” the portable walk on std::fs: the BSDs, the benchmark's baseline
scanners/src/linux.rs ~720 lines β€” Linux getdents64/statx walker, inode order; linux/ ~1190 more: mounts, filesystems, btrfs, reflinks, block prefetch, the fstatat fallback
scanners/src/macos.rs ~1140 lines β€” macOS getattrlistbulk walker, APFS clones
scanners/src/disk_image.rs ~330 lines β€” macOS: a mounted disk image's file, through IOKit
scanners/src/windows.rs ~940 lines β€” Windows bulk-listing walker
viewers/tui/src/bench/mod.rs ~480 lines β€” --benchmark harness
viewers/dos/DUSCAPE.ASM ~4700 lines β€” the MS-DOS viewer, one instruction a line
viewers/dos/SOFTFP.ASM ~810 lines β€” IEEE doubles on a 286
viewers/dos/PREVIEW.ASM ~1300 lines β€” its previews: text, blocks, the palette
scanners/src/mft.rs ~1630 lines β€” NTFS read from its master file table: the parser, the running totals for the view, the tree, and the volume read (its probe, the live and seeding threads)
scanners/src/cache/sweep.rs ~210 lines β€” the saved scans kept to what can be used, within a room
scanners/src/cache.rs ~1290 lines β€” the saved scan: the trimmed format, the recorder, the stream as saved, the replay with the log's changes applied
scanners/src/fsevents.rs ~410 lines β€” macOS's change log through CoreServices, dlopened
scanners/src/fill.rs ~170 lines β€” the fill pass over the folders a saved scan trimmed
scanners/src/snapshots.rs ~620 lines β€” a volume's local snapshots read against the live volume: the narrowed walk, the tree; snapshots/ ~760 more: macOS, the change log, extents
common/src/snapshots.rs ~100 lines β€” the snapshots' virtual folder: its name, what is noted, descriptions
viewers/tui/src/ui/display.rs ~360 lines β€” the frame: what every mode shows, each mode's modal, the nesting's cache
viewers/tui/src/ui/grid/rectangle_grid.rs ~220 lines β€” the terminal's treemap: tiles, the nesting, corners, highlight frames
common/src/scan/mod.rs ~1270 lines β€” the scan protocol: options, entries, whom they are for, issues, the outline, the focus
common/src/scan/places.rs ~290 lines β€” --issues' failures by where, rolled up into a tree
common/src/archive.rs ~430 lines β€” zip archives as folders: the central directory, an entry unpacked in memory
scanners/src/archives.rs ~140 lines β€” the archives' pass: the ones on screen read, largest first
common/src/nas.rs ~190 lines β€” the folders a NAS (or macOS, Windows) keeps for itself, by name: left out, described