// ZPWR-FILE-BROWSER — SHARED MULTI-PANE FILE BROWSER

shared GUI component · host-agnostic vanilla-JS front end · pure-Rust fs_* crate (34 functions) · 35 #[tauri::command] wrappers behind the tauri feature · staticlib C ABI behind the capi feature · one source of truth for all four apps

Report GitHub
// Color scheme

>_ZPWR-FILE-BROWSER

One browser, every app, host-provided filesystem. The shared multi-pane file browser behind the MenkeTechnologies GUI stack, extracted from Audio-Haxor so it backs every app from a single source of truth. The front end is host-agnostic — each host supplies the filesystem backend (the window.zfbHost fs-command contract) and a few UI utilities. Same panes, sorting, resizable columns, fuzzy filter, color labels, tree sidebar, context menu and previews everywhere. The optional Rust crate ships those filesystem operations as pure functions, faithfully ported from the Audio-Haxor backend.

Four hosts, one component

Audio-Haxor · traderview · ztranslator (Tauri / Rust)enable the crate's tauri feature and register zpwr_file_browser::commands::fs_* in tauri::generate_handler![…], or implement the fs commands directly as #[tauri::command]s on the host IPC object
zpwr-daw (JUCE / C++)implement the fs commands as WebView native functions, or enable the crate's capi feature, link the staticlib, and drive every fs op through the shipped C ABI entry fb_invoke(cmd, args_json) (header include/zpwr_file_browser.h, mirroring zpwr-embed-terminal)

The front end calls the same invoke names everywhere; only the host-side backend differs.

Rust core (crate/)

crate/ (package zpwr-file-browser) holds the filesystem logic faithfully ported from Audio-Haxor: 34 pure pub async fn filesystem functions with no Tauri types, so the crate is usable in any context. Enable the tauri cargo feature to also compile zpwr_file_browser::commands — 35 thin #[tauri::command] wrappers (one per pure fn, plus fb_watcher_set), each named with the exact invoke name the front end calls. The features are additive: a plain cargo build (no features) keeps the crate Tauri-free. For non-Tauri (JUCE) hosts, the capi feature compiles zpwr_file_browser::ffi — a staticlib C ABI whose single entry fb_invoke(cmd, args_json) dispatches by name into the same pure fns and returns a JSON envelope.

zpwr-file-browser = { path = "…/zpwr-file-browser/crate", features = ["tauri"] }
.manage(zpwr_file_browser::commands::watcher_state())
.invoke_handler(tauri::generate_handler![
    zpwr_file_browser::commands::fs_list_dir,
    zpwr_file_browser::commands::fs_copy_path,
    zpwr_file_browser::commands::fb_watcher_set,
    // … all the rest
])

Directory watcher

The crate also bundles the File Browser directory watcher, faithfully ported from Audio-Haxor's fb_watcher.rs: zpwr_file_browser::fb_watcher::WatcherSession is a framework-agnostic, notify-based, non-recursive, 300 ms-debounced single-directory watcher. session.watch(dir, on_change) canonicalizes dir, starts the watch, fires on_change(canonical) on each debounced change, and returns the canonical path; session.stop() tears down. Under the tauri feature, commands::fb_watcher_set wires that callback to AppHandle::emit("file-browser-change", { "dir": canonical }) — the exact event and payload the front end consumes; construct the managed state with commands::watcher_state().

Front end features

Panes & columnsmulti-pane layout; sortable + resizable columns; per-pane flex widths; tree sidebar
Filterfzf-style fuzzy filter with matched-char highlight (via the host's shared fzfMatch)
Organizecolor labels, context menu, base CRUD (create / rename / copy / trash / delete), duplicate, alias
Previewtext / hex / image quicklook + preview pane; git status badges
Compare & searchdedup, directory compare, unified diff, recursive grep
Metadatahash, extended attributes, disk usage, folder size, chmod, symlink retarget
Archive & opencompress / extract (.zip, .tar, .tar.gz, .tgz, .7z), open in default app / editor / terminal
Livefs-change watch — the directory reloads on debounced changes

Backend contract (each host implements)

The front end calls these on the host IPC object (window.zfbHost.*). A host using a different IPC object can alias it: window.zfbHost = myBackend. Every method returns a Promise. A host that does not support an optional capability should resolve to an empty/neutral value (not throw) so the row or preview degrades gracefully.

listDirectory(path, showHidden) · fsListSubdirs(path)list entries; child dirs for the tree sidebar
getHomeDir() · fsGetInfo(path)initial path; stat / details
fsCreateDir · fsCreateFile · fsTouchcreate
renameFile · fsCopyPathrename / copy
moveToTrash · deleteFiledelete
fsChmod · fsSymlinkRetargetperms / symlink
fsFolderSize · fsDiskUsagesizes
fsReadHead · fsReadHeadBytes · fsReadFileBase · fsReadFileBytesread previews
fsGrep · fsFindDuplicates · fsCompareDirs · fsDiffsearch / compare
fsHash · fsXattrs · fsGitStatusmetadata
fsCompress · fsExtractarchive
openFileDefault · fsOpenTerminalopen
fbWatcherSet(paths)live fs-change watch

Host UI utilities (globals the front end expects)

The front end uses these as globals; the host must define them (most apps already have them):

prefsshared prefs store (getItem/setItem); persists pane count, paths, active pane, per-pane flex widths, column widths, sort state (same contract as the embedded terminal)
fzfMatch(query, text)shared fuzzy matcher; powers the filter's matched-char highlight
escapeHtml · t / toastFmt (i18n) · showToast · shortcutTipsmall UI helpers

Mounting

1Include file-browser.css (link or inline) and the #tabFiles markup from file-browser.html in the host's tab system
2Load webui/file-browser.js as a classic script after the host utilities + IPC object exist
3Expose the fs commands on window.zfbHost (or alias your backend to it)

Tauri hosts sync these assets into their served frontend/ via a copy script (copy-file-browser.mjs, mirroring copy-embed-terminal.mjs); JUCE hosts embed them via juce_add_binary_data and serve by basename.

Layout

webui/file-browser.jsthe browser front end (base CRUD + generic file-manager only); loaded as a classic script
webui/file-browser.cssthe .fb-* / fileBrowser / .file-* rule set (extracted)
webui/file-browser.htmlthe file-browser tab pane markup (#tabFiles); the host mounts it where its tab system expects the files pane
crate/src/lib.rsthe 34 pure fs_* functions + return types + format_size
crate/src/commands.rsthe 35 thin #[tauri::command] wrappers (tauri feature only)
crate/src/fb_watcher.rsthe framework-agnostic WatcherSession
crate/src/ffi.rsthe staticlib C ABI — fb_invoke / fb_string_free (capi feature only)

The GUI stack

zpwr-file-browser is a shared component of the MenkeTechnologies GUI applications. Browse the rest via the MenkeTechnologiesMeta umbrella repo:

  • Audio-Haxor — Tauri v2 desktop app; the file browser was extracted from here
  • traderview — Tauri v2 market / charting app
  • ztranslator — Tauri v2 translation / protocol-bridge app
  • zpwr-daw — JUCE / C++ DAW arranger (WebView host)
  • zpwr-embed-terminal — the sibling shared embedded-terminal component