Work: Filesystem
Started: 2025-01-04
Problem
Need a way to visualize filesystem folders in webseriously. Currently no database plugin exists that can scan a folder and represent files/folders as Things with navigable relationships.
Goal
Build DB_Filesystem plugin that:
- Takes a folder path as input
- Creates Things from files/folders
- Creates Relationships (parent→child folder structure)
- Each Thing gets a
linkTrait that opens the file via OS default app
Approach
Browser constraints:
- True "open in OS app" impossible from pure web app (security)
- File System Access API for folder reading (Chrome/Edge ~70% desktop)
- No Tauri/Electron—keep as web app
- Safari/Firefox users won't get folder picking (can still manually add files)
What we did
- Added
filesystemto T_Database andDB_Nameenums - Created
DB_Filesystem.tswith:- File System Access API integration
- Recursive folder scanning
- Thing creation per file/folder
- Relationship creation (contains)
- Link trait with file path (except for non-preview-able extensions)
- Helper methods:
readFileAsText,readFileAsDataURL,downloadFile,copyPath - Color coding by file extension
- Registered in
Databases.ts(db_forType + db_next_get cycle) - Fixed stale rootAncestry/root references after folder selection (clear caches in selectFolder)
- Created Preview.svelte component with full-screen overlay for file previews
- Added
T_Control.previewenum and preview stores toVisibility.ts - Styled preview buttons same as build notes (background, colors)
- Copy-path button for manual OS opening (copies to clipboard)
- Added
- Features
Widgetclick on root (no folder) → triggers folder pickerWidgetclick on file → shows preview + grabs ancestry (non-previewable just grabs)- In
D_Data, removefilesystemfromids_forDatabaseif isSupported returnsfalse - Arrow-right on a preview-able file also shows preview
- Fixed preview for files without link trait (Widget_Title uses
isPreviewable()directly) - Consolidated extension handling into enums (
T_Image_Extension,T_Text_Extension,preview_type_forFilename()) - Moved preview stores and
show_previewOf_file()fromVisibility.tstoFiles.ts - Renamed interfaces to
Snake_Caseper style guide - Remember last folder choice (
IndexedDBstoreshandle,fetch_allauto-restores,selectFoldersaves)
TODO
- [ ] Handle non-previewable files gracefully in UI
- [ ] Add more preview types (PDF, audio, video)