Skip to content

feat(browser): add a Tree view mode and align view names with Finder - #321

Open
spandan11106 wants to merge 3 commits into
lgse:mainfrom
spandan11106:feat/315-tree-view
Open

spandan11106 wants to merge 3 commits into
lgse:mainfrom
spandan11106:feat/315-tree-view

Conversation

@spandan11106

Copy link
Copy Markdown
Collaborator

Description

The view switcher named the Miller columns "List", the icon grid "Grid" and the table "Explorer", none of which is what those views are called elsewhere. The labels are now Columns, Icons and List. The BrowserMode variants keep their names, so this is a user-facing rename only.

Adds a fourth presentation, Tree: one vertical pane whose folders expand in place with a disclosure chevron, indented by depth. Its root level mirrors the browser's active column, so selection, inline rename, the item context menu, cut styling and drag and drop behave exactly as they do in List. Rows inside an expanded branch belong to directories the navigation state does not own, so the view lists them through Browser::list_directory and orders them with Browser::sorted_entries — listing budgets, sort order and the hidden-file rule stay in the application layer. Every branch is dropped when the pane's column reloads, so changing the sort or toggling hidden files never leaves a stale listing behind.

Keyboard: /l expands the focused folder (and activates it when there is nothing to expand), /h collapses it, then walks to the parent row, then leaves the directory. / and k/j move through the flattened tree rather than skipping expanded children.

Known limits, both because a row below the root level has no position in the browser's active column: rows inside an expanded branch are not part of the multi-selection the rest of the app acts on, and right-clicking one shows the folder menu rather than the item menu. Clicking, expanding, opening and quick preview all work on them. Worth a follow-up once selection can address entries by location.

Visual evidence

Tree mode, collapsed:

Tree view with folders collapsed

Tree mode, with alpha and alpha/nested expanded:

Tree view with nested folders expanded

How to test

  1. Build and run Strata over a directory with a few levels of nesting, for example cargo run -- ~/Projects.
  2. Open the appearance menu (the toolbar's list icon) and confirm the modes now read Columns, Icons, List, Tree, with the check mark on the mode you are in.
  3. Choose Tree, then click the chevron beside a folder, and the chevron beside a folder inside it.
  4. Focus a row and press , , and .
  5. Toggle hidden files with Ctrl+H and change the sort from the pane header, both while a branch is expanded.
  6. Quit and reopen Strata.

Expected result: folders expand and collapse in place with their children indented one level further and sorted with folders first; arrow keys expand, collapse and move through the flattened tree; hidden files appear and disappear at every level, and a sort change reorders expanded branches too; Strata reopens in Tree mode. Switching to Columns, Icons and List still works as before.

Related issue

Closes #315

The view switcher named the Miller columns "List", the icon grid "Grid" and
the table "Explorer", which is not what those views are called anywhere else.
Rename the labels to Columns, Icons and List; the `BrowserMode` variants keep
their names so the change stays user-facing.

Add a fourth presentation, Tree: one vertical pane whose folders expand in
place, indented by depth. Its root level mirrors the browser's active column,
so selection, renames, the item menu and drag and drop keep working there.
Rows inside an expanded branch belong to directories the navigation state does
not own, so the view loads them through `Browser::list_directory` and orders
them with `Browser::sorted_entries`, keeping listing budgets, sort order and
the hidden-file rule in the application layer. Branches are dropped when the
pane's column reloads, so a sort or hidden-file change never leaves a stale
listing behind.
@spandan11106

Copy link
Copy Markdown
Collaborator Author

Sorry the above description does not have proper visuals. Here are some better one.

The name changes for the views :
image

Tree view does not support group by file types.

screenrecording-2026-09-05_03-52-20.mp4

@l0gicgate

Copy link
Copy Markdown
Contributor

@spandan11106, keyboard navigation crashes the changes here. Please fix.

Pressing Enter, Right or l in the tree aborted the process. `activate_focused`
held a shared borrow of the mode views while the tree called
`Browser::activate_in_place`, which emits synchronously; the observer then took
a mutable borrow of the same cell and panicked with "RefCell already borrowed"
inside a GTK callback, which cannot unwind.

The tree now reports what activating a row should do instead of doing it, so the
caller releases its borrow before the browser runs and emits.
@spandan11106

Copy link
Copy Markdown
Collaborator Author

Fixed in 4cc8bb1.

Root cause: BrowserView::activate_focused held a shared borrow of mode_views while the tree called Browser::activate_in_place, which emits synchronously. The observer then wanted a mutable borrow of the same cell, so it panicked with RefCell already borrowed inside a GTK callback — a extern "C" frame that cannot unwind, so the process aborted rather than unwound. It hit every activation in Tree mode: Enter always, and /l whenever there was nothing to expand (a file, or an already-expanded folder).

ViewState::handle → mode_views.borrow_mut()   <- panicked here
Browser::emit ← Browser::select ← activate_in_place ← tree::activate_position

The tree now returns what activating a row should do (TreeActivation) instead of doing it, so the caller drops its borrow before the browser runs and emits back into the mode views. Mouse activation goes through the same path, so there is one behaviour to reason about.

Verified by driving tree_step (Next, Expand, Next, Previous, Collapse, Collapse) and activate_focused directly in a running instance in Tree mode: it aborted at the first activation before the change and completes the whole sequence after it. Added unit coverage for the activation intent — root rows resolve to a column position, rows inside an expanded branch to their location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(browser): add Tree view mode and align view names with Finder

2 participants