eed3806efb
Server: list_directory returns a directory_listing (path, home, parent, entries with is_dir/is_git_repo/hidden, truncated) confined to the server user's home subtree after cleaning and resolving symlinks, refusing pseudo filesystems and capping entries at 2000. Documented in docs/cli.md. App: "Choose folder…" in the create dialog opens a picker (full-screen page on phones, large dialog on wide windows, Material and Cupertino) with breadcrumbs, filter, Show hidden, git badges, dimmed files, recent folders, inline errors and "Start chat here". The probe app gains a folder fixture for captures.
46 lines
1.9 KiB
Go
46 lines
1.9 KiB
Go
package protocol
|
|
|
|
// Directory browsing for the chat folder picker. A client sends
|
|
// Message{Type: ListDirectory, ID: <opaque>, ListDirectory: &DirectoryListRequest{Path: ...}}
|
|
// and the server echoes the ID on a DirectoryListing reply. Listing is
|
|
// restricted to the server user's home directory subtree, returns names and
|
|
// kinds only (never file contents) and is bounded by DirectoryListingMaxEntries.
|
|
const (
|
|
ListDirectory = "list_directory"
|
|
DirectoryListing = "directory_listing"
|
|
)
|
|
|
|
// DirectoryListingMaxEntries caps the entries one directory_listing returns;
|
|
// a larger directory sets Truncated.
|
|
const DirectoryListingMaxEntries = 2000
|
|
|
|
// DirectoryListRequest is the list_directory body. Path is absolute or starts
|
|
// with "~" ("~" or "~/sub"); an omitted or empty path lists the home directory.
|
|
type DirectoryListRequest struct {
|
|
Path string `json:"path,omitempty"`
|
|
}
|
|
|
|
// DirectoryListingResult is the directory_listing reply. Path is the absolute,
|
|
// cleaned directory listed (expressed under Home), Parent is null at the home
|
|
// root, and Entries are directories first, then files, each group sorted
|
|
// case-insensitively. Files are listed by name only so a picker can show
|
|
// context; they are not selectable.
|
|
type DirectoryListingResult struct {
|
|
Path string `json:"path"`
|
|
Home string `json:"home"`
|
|
Parent *string `json:"parent"`
|
|
Entries []DirectoryEntry `json:"entries"`
|
|
Truncated bool `json:"truncated,omitempty"`
|
|
}
|
|
|
|
// DirectoryEntry is one listed name. IsDir is true only for a directory (or a
|
|
// symlink to one) that stays inside the home subtree; IsGitRepo marks a
|
|
// directory containing .git; Hidden marks a dot-name.
|
|
type DirectoryEntry struct {
|
|
Name string `json:"name"`
|
|
Path string `json:"path"`
|
|
IsDir bool `json:"is_dir"`
|
|
IsGitRepo bool `json:"is_git_repo"`
|
|
Hidden bool `json:"hidden"`
|
|
}
|