File tree sub-state: tree data, focus, and backing buffer.
Wraps the file-tree-related fields from EditorState into a single struct with query and mutation helpers. Includes inline editing state for new file, new folder, and rename operations.
Summary
Types
Inline editing state for creating files/folders or renaming entries.
Identity of the latest admitted filter request.
File tree sub-state.
Explicit presentation state for the file tree sidebar.
Functions
Accepts the current filter and leaves the narrowed tree visible.
Installs a current filter result prepared by a scheduler worker.
Atomically accepts a current refresh result or identifies why it cannot apply.
Collapses watcher lineage only for the latest exact successful request.
Publishes an immediate loading tree for a root scan without resolving entries.
Cancels inline editing, clearing the editing state back to nil.
Changes the watcher target to cleanup-only while retaining all known roots.
Clears a pending file tree clipboard operation.
Publishes an unfiltered loading tree while preserving filter-input disposition.
Closes the tree and clears the buffer.
Returns true when inline editing is active.
Marks the sidebar as failed with a displayable reason.
Terminalizes watcher retry correlation after the bounded attempt budget.
Reports a current filter failure while preserving recovery on the next query.
Finishes a current failed or canceled filter request without installing rows.
Finishes a failed or canceled current request without changing tree content.
Finishes watcher work without discarding cleanup candidates.
Marks the file tree as focused.
Returns true when the file tree is open and focused.
Hides the sidebar while keeping the loaded tree, backing buffer, and watchers.
Hides the file tree help overlay.
Returns true when the file tree has loaded data.
Marks the sidebar as loading.
Stores a pending file tree clipboard operation.
Opens the tree with the given data, buffer, and focused state.
Consumes a correlated debounce message and focuses the result on the live tree.
Reports a refresh failure while preserving the open tree interaction state.
Replaces the backing tree and refreshes the presentation status.
Replaces metadata on the current tree without changing topology status or refresh correlation.
Records one debounced request to refresh the open tree.
Returns the monotonic generation of the current root and watcher lineage.
Installs an empty failed root scan while retaining the requested root.
Correlates a bounded watcher synchronization retry.
Updates the project root associated with the file tree.
Replaces the tree data.
Reveals a previously hidden tree and refocuses it.
Enters inline editing mode at the given index.
Starts inline file tree filtering without resolving any rows.
Returns the explicit presentation status for the file tree.
Toggles the file tree help overlay.
Correlates the latest admitted filter request with its exact root and query.
Correlates an admitted typed refresh request with the root it scans.
Re-arms one pending refresh intent after scheduler admission pressure.
Correlates the latest admitted watcher synchronization request.
Marks the file tree as unfocused.
Updates the text being typed in the inline editor.
Publishes a loading filter transition without cache or filesystem calls.
Returns true when the sidebar is currently visible (loaded and not hidden).
Returns true when the explicit tree status should occupy the sidebar.
Returns the immutable watcher intent owned by this file tree.
Consumes only the current watcher retry timer.
Returns the tree width, preserving the last sidebar width while state-only payloads are visible.
Types
@type clipboard_mark() :: MingaEditor.State.FileTree.ClipboardMark.t()
@type clipboard_operation() :: MingaEditor.State.FileTree.ClipboardMark.operation()
@type editing() :: %{ index: non_neg_integer(), text: String.t(), type: editing_type(), original_name: String.t() | nil }
@type editing_type() :: :new_file | :new_folder | :rename
Inline editing state for creating files/folders or renaming entries.
When non-nil, the user is actively typing a filename in the tree.
The index is the visual position in the visible entry list where
the editing row appears. For new file/folder, this is the insertion
point. For rename, this is the entry being renamed.
Identity of the latest admitted filter request.
@type t() :: %MingaEditor.State.FileTree{ buffer: pid() | nil, clipboard_mark: clipboard_mark() | nil, editing: editing() | nil, filter_request: filter_request() | nil, filtering: boolean(), focused: boolean(), help_visible: boolean(), hidden: boolean(), original_root: String.t() | nil, project_root: String.t() | nil, refresh: MingaEditor.State.FileTree.Refresh.t(), tree: Minga.Project.FileTree.t() | nil, tree_status: tree_status(), tree_width: pos_integer(), watchers: MingaEditor.State.FileTree.Watchers.t() }
File tree sub-state.
@type tree_status() :: :hidden | :loading | :empty | :ready | {:error, String.t()}
Explicit presentation state for the file tree sidebar.
Functions
Accepts the current filter and leaves the narrowed tree visible.
@spec accept_filter_result( t(), String.t(), String.t(), reference(), MingaEditor.FileTree.FilterWalk.Result.t() ) :: {:accepted | :closed | :rerooted | :stale, t()}
Installs a current filter result prepared by a scheduler worker.
@spec accept_refresh_result( t(), String.t(), MingaEditor.State.FileTree.Refresh.request_token(), Minga.Project.FileTree.t() ) :: {:accepted | :closed | :rerooted | :stale, t()}
Atomically accepts a current refresh result or identifies why it cannot apply.
Collapses watcher lineage only for the latest exact successful request.
@spec begin_root_scan(t(), Minga.Project.FileTree.t(), :project | :reroot) :: t()
Publishes an immediate loading tree for a root scan without resolving entries.
Cancels inline editing, clearing the editing state back to nil.
Changes the watcher target to cleanup-only while retaining all known roots.
Clears a pending file tree clipboard operation.
Publishes an unfiltered loading tree while preserving filter-input disposition.
Closes the tree and clears the buffer.
Returns true when inline editing is active.
Marks the sidebar as failed with a displayable reason.
Terminalizes watcher retry correlation after the bounded attempt budget.
Reports a current filter failure while preserving recovery on the next query.
@spec finish_filter(t(), String.t(), String.t(), reference()) :: {:current | :closed | :rerooted | :stale, t()}
Finishes a current failed or canceled filter request without installing rows.
@spec finish_refresh( t(), String.t(), MingaEditor.State.FileTree.Refresh.request_token() ) :: {:current | :closed | :rerooted | :stale, t()}
Finishes a failed or canceled current request without changing tree content.
Finishes watcher work without discarding cleanup candidates.
Marks the file tree as focused.
Returns true when the file tree is open and focused.
Hides the sidebar while keeping the loaded tree, backing buffer, and watchers.
Toggling visibility off is a pure layout change: the render model still carries the full tree data so showing it again does not rebuild anything (#2626).
Hides the file tree help overlay.
Returns true when the file tree has loaded data.
A hidden-but-loaded tree is still loaded: the data, buffer, and watchers stay
alive so refresh handlers keep it fresh. This is intentionally NOT "is the
sidebar visible" — use visible?/1 for that. Mixing the two leaks the backing
buffer (see #2626).
Marks the sidebar as loading.
Stores a pending file tree clipboard operation.
@spec open(t(), Minga.Project.FileTree.t(), pid() | nil) :: t()
Opens the tree with the given data, buffer, and focused state.
@spec refresh_debounce_elapsed( t(), MingaEditor.State.FileTree.Refresh.debounce_token() ) :: {:ready, Minga.Project.FileTree.t(), t()} | {:closed | :stale, t()}
Consumes a correlated debounce message and focuses the result on the live tree.
Reports a refresh failure while preserving the open tree interaction state.
@spec replace_tree(t(), Minga.Project.FileTree.t()) :: t()
Replaces the backing tree and refreshes the presentation status.
@spec replace_tree_metadata(t(), Minga.Project.FileTree.t()) :: t()
Replaces metadata on the current tree without changing topology status or refresh correlation.
@spec request_refresh_debounce( t(), MingaEditor.State.FileTree.Refresh.debounce_token() ) :: {:scheduled | :already_scheduled, t()}
Records one debounced request to refresh the open tree.
@spec root_generation(t()) :: non_neg_integer()
Returns the monotonic generation of the current root and watcher lineage.
Installs an empty failed root scan while retaining the requested root.
@spec schedule_watcher_retry(t(), reference()) :: {pos_integer(), t()}
Correlates a bounded watcher synchronization retry.
Updates the project root associated with the file tree.
@spec set_tree(t(), Minga.Project.FileTree.t() | nil) :: t()
Replaces the tree data.
Reveals a previously hidden tree and refocuses it.
@spec start_editing(t(), non_neg_integer(), editing_type(), String.t()) :: t()
Enters inline editing mode at the given index.
For new file/folder, initial_text is empty. For rename,
initial_text is the current entry name.
Starts inline file tree filtering without resolving any rows.
@spec status(t()) :: tree_status()
Returns the explicit presentation status for the file tree.
Toggles the file tree help overlay.
Correlates the latest admitted filter request with its exact root and query.
@spec track_refresh_request( t(), String.t(), MingaEditor.State.FileTree.Refresh.request_token() ) :: t()
Correlates an admitted typed refresh request with the root it scans.
@spec track_refresh_retry(t(), MingaEditor.State.FileTree.Refresh.debounce_token()) :: {pos_integer(), t()}
Re-arms one pending refresh intent after scheduler admission pressure.
Correlates the latest admitted watcher synchronization request.
Marks the file tree as unfocused.
Updates the text being typed in the inline editor.
Publishes a loading filter transition without cache or filesystem calls.
Returns true when the sidebar is currently visible (loaded and not hidden).
@spec visible_status?(tree_status()) :: boolean()
Returns true when the explicit tree status should occupy the sidebar.
@spec watcher_intent(t()) :: MingaEditor.State.FileTree.Watchers.t()
Returns the immutable watcher intent owned by this file tree.
Consumes only the current watcher retry timer.
@spec width(t()) :: pos_integer()
Returns the tree width, preserving the last sidebar width while state-only payloads are visible.