Extract fzt-core library and rebuild picker as a frontend #1

Open
opened 2026-04-06 10:54:52 -07:00 by nelsong6 · 0 comments
nelsong6 commented 2026-04-06 10:54:52 -07:00 (Migrated from github.com)

Context

Picker currently spawns fzt with a pre-generated YAML tree of the entire filesystem (via Everything). This doesn't scale — .git/objects, node_modules, and $Recycle.Bin directories consume the result limit (even at 50,000), and folder-only mode was generating empty YAML (fixed in insert_dir → insert_file on walker.rs:214).

The fundamental problem: fzt loads everything upfront, but file systems are too large for that. Picker needs lazy loading, which is architecturally different from fzt's current model.

Design Decision

fzt is actually two things: an engine (fuzzy scoring, tree navigation, ANSI rendering, scope management, keyboard handling) and a frontend (CLI tool that loads YAML/stdin upfront). Picker is a second frontend that shares the engine but has a fundamentally different data lifecycle.

fzt-core library extraction

Extract the engine into a reusable Go package (fzt-core) with a provider interface:

type TreeProvider interface {
    LoadChildren(path string) []TreeNode
}
  • YAML provider: loads the full tree into memory upfront (current behavior, used by CLI and homepage)
  • Directory provider: reads one directory at a time on scope push (used by picker)

The rendering, ANSI output, keyboard handling, scope navigation, cursor management — all shared. Only the data source differs.

Picker frontend behavior

  • Initial tree: drive roots only (C:, D:, etc.)
  • Focused path: pre-expand the path the calling app requested (e.g., C:\Users\upstairspc → walk and expand C: → Users → upstairspc → show immediate children)
  • Lazy loading: when user pushes scope into an unexpanded folder, read that directory from the filesystem
  • Scope back to drives: backspace/escape always allows navigating back up to the drive list
  • No Everything dependency: direct filesystem reads, not indexed queries
  • Exclude junk: skip .git, node_modules, $Recycle.Bin directories

New fzt parameter: --search-depth=N

  • --search-depth=1: search only matches within the current scope level (picker use case)
  • Omitted: infinite depth search (current default, used by CLI/homepage bookmarks)

Motivation

fzt is already used in three contexts — CLI (at/automate), WASM (homepage bookmarks), and picker (file dialog replacement). The library split makes it easy to build new frontends without fighting a monolith. Each new frontend reuses the visual layer and engine, only defining how data enters the system.

Bugs fixed in this session (already in working tree, not yet committed)

  • walker.rs:214: insert_dir → insert_file for folders_only mode (tree was empty because leaf directories had no files, so has_content() returned false)
  • walker.rs: added .git, $Recycle.Bin, node_modules exclusions to Everything query
  • walker.rs: bumped result limit from 10,000 to 50,000 (insufficient fix, superseded by this redesign)
## Context Picker currently spawns fzt with a pre-generated YAML tree of the entire filesystem (via Everything). This doesn't scale — `.git/objects`, `node_modules`, and `$Recycle.Bin` directories consume the result limit (even at 50,000), and folder-only mode was generating empty YAML (fixed in `insert_dir` → `insert_file` on walker.rs:214). The fundamental problem: fzt loads everything upfront, but file systems are too large for that. Picker needs lazy loading, which is architecturally different from fzt's current model. ## Design Decision fzt is actually two things: an **engine** (fuzzy scoring, tree navigation, ANSI rendering, scope management, keyboard handling) and a **frontend** (CLI tool that loads YAML/stdin upfront). Picker is a second frontend that shares the engine but has a fundamentally different data lifecycle. ### fzt-core library extraction Extract the engine into a reusable Go package (`fzt-core`) with a provider interface: ```go type TreeProvider interface { LoadChildren(path string) []TreeNode } ``` - **YAML provider**: loads the full tree into memory upfront (current behavior, used by CLI and homepage) - **Directory provider**: reads one directory at a time on scope push (used by picker) The rendering, ANSI output, keyboard handling, scope navigation, cursor management — all shared. Only the data source differs. ### Picker frontend behavior - **Initial tree**: drive roots only (C:, D:, etc.) - **Focused path**: pre-expand the path the calling app requested (e.g., `C:\Users\upstairspc` → walk and expand C: → Users → upstairspc → show immediate children) - **Lazy loading**: when user pushes scope into an unexpanded folder, read that directory from the filesystem - **Scope back to drives**: backspace/escape always allows navigating back up to the drive list - **No Everything dependency**: direct filesystem reads, not indexed queries - **Exclude junk**: skip `.git`, `node_modules`, `$Recycle.Bin` directories ### New fzt parameter: `--search-depth=N` - `--search-depth=1`: search only matches within the current scope level (picker use case) - Omitted: infinite depth search (current default, used by CLI/homepage bookmarks) ## Motivation fzt is already used in three contexts — CLI (`at`/automate), WASM (homepage bookmarks), and picker (file dialog replacement). The library split makes it easy to build new frontends without fighting a monolith. Each new frontend reuses the visual layer and engine, only defining how data enters the system. ## Bugs fixed in this session (already in working tree, not yet committed) - `walker.rs:214`: `insert_dir` → `insert_file` for `folders_only` mode (tree was empty because leaf directories had no files, so `has_content()` returned false) - `walker.rs`: added `.git`, `$Recycle.Bin`, `node_modules` exclusions to Everything query - `walker.rs`: bumped result limit from 10,000 to 50,000 (insufficient fix, superseded by this redesign)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/fzt-picker#1
No description provided.