Understand the File Picker System architecture
mainThe File Picker System is an interactive TUI (Terminal User Interface) designed for granular file selection using directory grouping. It is built on @inquirer/core and manages two distinct types of state:
- UI State (
FilePickerStatesStore): Manages ephemeral navigation data likecaretPosition,expandLimits(how many files are visible in a directory), andisShowingFiles(pane visibility). This state persists as you navigate between categories. - Global Selection State: Manages what is actually being cleaned. It uses
selectedCategories(a Set of category names) andselectedFilesByCategory(a Map of category names to Sets of file paths).
The system uses a File Display Pipeline to transform raw scan results into a navigable list:
- Group by Directory: Items are grouped by parent directory and sorted by size (descending).
- Apply Expand Limits: Visibility limits are applied to each directory.
- Format Display Items: The list is flattened into a structure containing headers, file entries, and expand hints.