Repository navigation
Add disktree-web: browser dashboard for remote/headless machines - #16
Closed
marospekarik wants to merge 1 commit into
Closed
marospekarik wants to merge 1 commit into
marospekarik wants to merge 1 commit into
Conversation
disktree is a native GPUI app, so it needs a local GPU and display —
there is no way to point it at a remote server or view it over SSH/
Tailscale. This adds disktree-web, a small axum server that reuses
disktree-core (no UI dependency, already a plain library) to scan a
root and serve the tree lazily over HTTP, plus a static page that
lays it out as a squarified treemap in a <canvas>, mirroring the
native app's mosaic, category colours and reclaim hatching.
Design notes:
* The API is lazy by directory (`/api/node?crumbs=1,4`): each request
returns one node plus one level of children, not the whole subtree.
Serializing the full tree in one response does not scale — scanning
a home directory with a few million files produces roughly a
gigabyte of JSON, which locks up the browser tab before it can draw
anything. This was caught by actually running it against a real
home directory, not just a small test tree.
* The scan happens once at startup and is kept in memory
(`disktree_core::tree::Node` is `Clone`-free and not cheap to
re-walk); `Node::resolve` addresses it by crumb path, which is the
same crumb scheme `disktree-core::treemap` already uses.
* `disktree-core` needed no changes: it has no GPUI dependency by
design (see its module doc), so the new crate only adds a
presentation layer, same as `disktree-app` does.
* Bind with `--listen 0.0.0.0:PORT` to reach it over a private network
(e.g. Tailscale) instead of only localhost.
Usage:
cargo run -p disktree-web --release -- --listen 0.0.0.0:7878 ~
# then open http://<host>:7878/ from another machine
Verified: `cargo fmt --check`, `cargo clippy --release --all-targets
-- -D warnings` (zero warnings) and `cargo test --release` all pass
for disktree-core and disktree-web; the existing disktree-core test
suite (77 tests) is unaffected. Exercised end-to-end in a browser
against a real ~325 GB / 4.8M-file home directory: instant page load,
drill-down, breadcrumbs and totals all work, and the previous
whole-tree-JSON approach was confirmed broken the same way (971 MB
response, blank tab) before being replaced with the lazy API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
disktree is a native GPUI app, so it needs a local GPU and display. There is
no way to point it at a remote machine and view it over SSH/Tailscale/a
browser — you have to be physically at that machine's desktop.
Approach
Adds a new workspace crate,
disktree-web, that reusesdisktree-coreas-is (it already has no GPUI dependency by design — see its module doc)
and exposes it over HTTP:
axumserver scans a root once at startup and keeps thedisktree_core::tree::Nodetree in memory./api/node?crumbs=1,4returns one node plus one level of children,addressed the same way
disktree-core::treemapalready addresses tiles(crumb = child-index path from the root). This is lazy on purpose: an
earlier version of this PR serialized the whole tree in one response,
and on a real ~325 GB / 4.8M-file home directory that came out to about
971 MB of JSON, which locked up the browser tab before it could paint
anything. Fetching one level at a time keeps every response in the tens
of KB and sub-2ms.
crates/disktree-web/static/index.html) lays the currentlevel out as a squarified treemap in a
<canvas>(same algorithm familyas
disktree-core::treemap, reimplemented in JS since the browser can'tcall into the Rust layout code), with the same category colours and
reclaim hatching as the native app, plus breadcrumbs, click-to-drill-in,
and Escape/Backspace to go up.
disktree-coreis untouched — no changes needed there.Usage
Defaults to
$HOMEif no path is given, matchingdisktree's own default.--apparent-sizemirrors the native app's flag.Testing
cargo fmt --check,cargo clippy --release --all-targets -- -D warnings(zero warnings), andcargo test --releaseall pass fordisktree-coreanddisktree-web.disktree-coresuite (77 tests) is unaffected — nothing init changed.
directory: instant page load after the one-time scan, correct totals,
category colours, reclaim hatching, breadcrumb navigation, and
drill-down all work. Also reproduced and confirmed the whole-tree-JSON
approach failing the way described above, before switching to the lazy
per-node API.
disktree-app's window-harness tests (they need a realGPU/display); this PR doesn't touch that crate.
Out of scope
Marking/removal, git status, age-mode coloring, and keyboard parity with
the native app are not implemented — this is read-only viewing for a first
cut. Happy to follow up if there's interest.