feat(filepicker): add support for abstracted filesystem io/fs.FS [v2]#954
Open
dolmen wants to merge 1 commit intocharmbracelet:mainfrom
Open
feat(filepicker): add support for abstracted filesystem io/fs.FS [v2]#954dolmen wants to merge 1 commit intocharmbracelet:mainfrom
dolmen wants to merge 1 commit intocharmbracelet:mainfrom
Conversation
Add an optional io/fs.FS to filepicker's model to allow to browse an abstracted filesystem instead of the full filesystem exposed by the 'os' package. To resolve symlinks we use io/fs.ReadLink introduced with Go 1.25, but fallback to an internal implementation if the FS doesn't implement it. By the way, references to os types and constants (which nowadays are aliases to same symbols in io/fs) are replaced: os.Mode*, os.DirEntry. Fixes charmbracelet#815. Replaces charmbracelet#759.
This was referenced Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an optional
io/fs.FStofilepicker's model to allow to browse an abstracted filesystem as an alternative to the full filesystem exposed by theospackage.The filepicker API is extended (and generalized thanks to io/fs.FS), without any breaking change.
This allows for example to browse limited a subdirectory by using
os.Root(go1.24+):Fixes #815.
Replaces #759 (which was for v1).
Discussion: #886.
Full support of symlinks is implemented. To resolve symlinks we use io/fs.ReadLink introduced with Go 1.25, but fallback to an internal implementation if the FS doesn't implement it.
By the way, references to
ostypes and constants which are aliases to same symbols inio/fsare replaced:os.Mode*,os.DirEntry.Example
See package github.com/dolmen-go/iofs-shell.
Runnable example:
$ go run github.com/dolmen-go/iofs-shell/examples/browse-zip@main <file>.zipTo use my fork right now:
$ go mod edit -replace=charm.land/bubbles/v2=github.com/dolmen-go/bubbles.fork/v2@v2.1.1-0.20260413112845-8dad07786efcCONTRIBUTING.md.