Expand description
Daemon-side directory inspection for the UI’s project picker (UI Phase-1).
Why: the UI is a thin client — no UI target (web OR Tauri) touches the
filesystem directly, so browsing the local disk to pick a project has to be
a daemon API. One call serves both the picker’s rendering (screen 7a’s
breadcrumb + per-entry git badge) and the three-state project binding
model (projectless → non-git dir → git repo).
What: list_dir, DirListing, DirEntryInfo, ListDirError, and
fs_browse::protocol::register (wires fs.list_dir onto a Router).
Test: fs_browse::tests::*, fs_browse::protocol::tests::*.
Daemon-side directory inspection for the UI’s project picker (UI Phase-1).
Why: the UI is a THIN CLIENT — “the UI communicates with the daemon; all UI
services talk to the daemon, the daemon provides all functionality”. No UI
target touches the local filesystem directly, including Tauri (which
technically could, but must not: doing so would make the Tauri build capable
of something the web build isn’t, forking the UI into two behaviours). So
“browse my disk to pick a project” has to be a daemon API, and this module
is it. One call serves both jobs the picker needs: rendering the folder list
(screen 7a — breadcrumb + a git badge per entry) AND feeding tcode’s
three-state project binding model (projectless → non-git dir → git repo),
because DirEntryInfo::is_git_repo is exactly the discriminator that model
keys on. A non-git directory is a FIRST-CLASS, supported state here, never an
error — #2728 removed the git-repo short-circuit precisely so tcode indexes
non-git working dirs, and #2747 extended that to temp dirs.
What: list_dir resolves a (possibly ~-relative) path, then returns a
DirListing — the resolved path, a tilde-collapsed display_path for the
breadcrumb, the parent for up-navigation, and the sorted entries, each
carrying name/path/is_dir/is_git_repo. Failures are the typed
ListDirError, distinguishable rather than stringly.
§No path guard here, deliberately — do not “fix” this
There is no denylist, allowlist, sandbox root, or permission layer on the
path argument, and that is a decision, not an oversight. tcode is a LOCAL
app: the daemon runs as the user, with the user’s own OS entitlements, so a
directory listing discloses nothing the user could not already get from ls
in their own shell. Decisively: the same API already exposes task.run,
which executes ARBITRARY CODE as the user. list_dir is strictly less
powerful than a capability sitting right beside it — guarding browse while
task.run is one method away is ceremony, not security. There is likewise no
macOS TCC permission-state machine: the app inherits whatever entitlements it
is granted, and an OS-level refusal surfaces as an ordinary typed error
(ListDirError::PermissionDenied) rather than a bespoke permission model.
Note for anyone reaching for a precedent: trusty-search’s
allow_sensitive_path (#2747) is NOT one. That guards INDEXING — file
CONTENT leaving the machine for an embedder — which is a categorically
different act from listing path names locally.
Test: fs_browse::tests::* (resolution, git-ness incl. the linked-worktree
.git-as-file shape, error distinguishability, 7a response shape).
Modules§
- mpm_
registry - Re-source the project-picker roster from trusty-mpm’s shared project registry (issue #3435).
- protocol
fs.*JSON-RPC method handlers — the daemon’s directory inspection surface.- roster
- Known-project roster discovery for the GUI’s workstream-first project-picker modal (issue #3365).
Structs§
- DirEntry
Info - A single entry in a
DirListing— one row of screen 7a’s picker. - DirListing
- The result of a successful
list_dir— everything screen 7a needs to render one view of the picker.
Enums§
- List
DirError - Why a
list_dircall failed, in distinguishable variants.
Functions§
- list_
dir - List
path, returning everything the picker needs to render it.