Skip to content

feat(sort): add sorting flyouts and list sort indicators - #2029

Merged
l0gicgate merged 21 commits into
lgse:mainfrom
adamcbrewer:feat/1652-sort-submenus
Nov 3, 2026
Merged

l0gicgate merged 21 commits into
lgse:mainfrom
adamcbrewer:feat/1652-sort-submenus

Conversation

@adamcbrewer

@adamcbrewer adamcbrewer commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds sort flyouts based on option 3 in #1652. Name, Size, Modified and Type stay at the top. More sorting contains Extension, Created and Unsorted; Name order contains Natural and Alphabetical. Case-sensitive names and Folders first stay visible.

All rows align, including the default-sort actions. Closed submenu rows show their current value on the right in smaller, muted text. Selecting the active sort field again switches to Unsorted.

The menu stays open while options change, so several choices can be applied together. Checkmarks, submenu summaries and default-action visibility update in place. Mouse and keyboard activation both work; Escape or an outside click dismisses the menu. Changes made while a sort is still loading stay together. Reset to default cancels a pending choice, so a late response can't restore it.

In List view, Ctrl+3, Sort sits before Refresh with a gap between them. It shows a label when the visible column headers can't explain the active sort, including non-default Name comparison. Otherwise it stays icon-only. Unsorted has no label or header arrow. Ascending and Descending remain available in the menu for fields without a matching column.

Sort and name-comparison choices follow the existing default and per-folder preferences. The default action is now labelled "Apply as default sort", with translations updated in all thirteen languages.

Settled edge cases:

  • Unsorted restores discovery order, with stable folder grouping when Folders first is on.
  • Missing creation times go last in either direction.
  • Extension uses the final suffix: .tar.gz sorts under gz; .gitignore and extensionless files have no extension.
  • The selected name comparison also breaks ties under other sorts.

Random and transliteration are outside this first version. CodeScene was skipped at the owner's explicit request.

Visual evidence

screenrecording-2026-11-02_13-59-05.mp4

How to test

  1. Open Sort in Columns, Icons and List view. Choose Extension, then Alphabetical and Case-sensitive names without dismissing the menu. Check the live selections and parent summaries. Use Enter to activate a choice, Left to leave a flyout and arrow keys to move through the parent menu.
  2. Select the active sort field again. Check that it changes to Unsorted, then select another field. Dismiss the menu with Escape and, separately, an outside click.
  3. In List view, reverse Extension using Descending. Switch to Size, hide its column, then restore it. Try Alphabetical Name sorting and case sensitivity too.
  4. With remembered folder views enabled, change a sort and use Apply as default sort or Reset to default sort. Check that the menu stays open and its default actions update. Open the folder in another window and restart to check saved choices. Try the added sort chords in 10xer mode.

Expected result:

Selections update the same sort state across menus, column headers, shortcuts and saved preferences. The menu remains open through changes. Standard fields clear the More sorting summary; independent Name order settings remain visible. List labels explain sorts that visible headers can't represent, and header arrows appear only on matching fields. Saved choices follow the existing default and per-folder rules.

Related issue

Closes #1652

Add Extension, Created and Unsorted sorting with independent name comparison settings and saved folder/default choices.

Implement design option 3 from lgse#1652, with right-aligned submenu values and List indicators for sorts that visible column headers cannot explain.

Refs lgse#1652
@adamcbrewer
adamcbrewer marked this pull request as draft November 2, 2026 10:21
Keep submenu titles aligned with the main choices and reduce the visual weight of their selected values. Place the List sort control before Refresh with a gap.

Refs lgse#1652
Remove the empty indicator slot from plain sort actions as well as choices and submenu titles.

Refs lgse#1652
Switch to Unsorted when the checked sort field is selected again, so both primary and flyout choices can be turned off.

Refs lgse#1652
Update the action label and its translations in all supported languages.

Refs lgse#1652
Allow several choices before dismissing the menu with Escape or an outside click. Keep checkmarks, submenu summaries and default actions current while the menu is open.

Refs lgse#1652
Keep name options attached to the requested sort while metadata loads. Resetting to defaults supersedes that request so a late response cannot restore it.

Resolve the browser helper import conflict while retaining the back-history updates from main.

Refs lgse#1652
@adamcbrewer
adamcbrewer marked this pull request as ready for review November 2, 2026 14:29
Each sort menu build registered a Browser observer, and Browser keeps
observers until its tab closes, so every navigation and view rebuild
added another closure that ran on every browser event for the life of
the tab (the uptime slowdown fixed in lgse#2041). Track mapped menus in a
small registry instead and refresh them from the tab's existing event
dispatch when a sort finishes or a column reloads.

Refs lgse#1652
…epth

A sort stays pending after it applies, so once Columns replaced that
column with another folder, the next sort, name-order or default action
there started from the previous folder's request and saved it for the
new folder. Overlay a request only while it is still waiting to apply
to the folder it was made for.

Refs lgse#1652
Filesystems without birth times (NFS, SFTP) left every listed row's
creation time unknown, so a Created sort refilled the whole folder on
each load, file by file over the network for remote folders, and a
monitored change moved its row ahead of the filled ones.

Refs lgse#1652
…efault

List Extension and Created with the other fields and show Natural,
Alphabetical and Case-sensitive names under a Name order heading, so
no choice hides in a flyout that opens over the listing at the window
edge. Unsorted has no row: unchecking the active field already turns
sorting off. Drop the submenu summaries, their styling and the
submenu-only keyboard routing, and rename the QA scenario to match.

Refs lgse#1652
Native context menus open with a padded header row, so their contents only pad the bottom; the sort menu opens on a section title, which sat 8px closer to the top edge than its last row did to the bottom.

Refs lgse#1652
The test pressed Down 100 ms after switching to Icons and assumed the
grid already had several columns. On a loaded CI runner it had not been
laid out yet, so Down reached the second tile and the test failed; this
also failed lgse#2044's own CI. Wait until Down moves a whole row instead.
GTK 4.22, which CI uses, lays the fixture's tiles out about 450 px wide
in a 460 px grid, one per row, where GTK 4.24 fits two. Requiring Down
to pass the second tile therefore always failed on CI. Wait for the
tiles to be laid out, then use whichever row start Down reaches; with
one column Left from the second tile still must not enter the sidebar,
and the test still fails on both versions without lgse#2044's fix.
@adamcbrewer

Copy link
Copy Markdown
Contributor Author

@l0gicgate my agent dug into the remaining shard 2 failure in this CI run. Thought this might be useful for your agent to try, if you're still working on it.

The timeout is in a_chosen_folder_is_checked_off_the_ui_thread_while_the_chooser_stays_open, waiting for “copy to a folder that is gone: the chooser to say what is wrong”. The test injects a one-shot FolderStamp error for destination. A background folder probe can consume that error before destination validation gets it. The fixture folder actually exists, so validation can then succeed and the expected error never appears.

The unchanged test passed 10/10 isolated runs. Forcing a real LocalFileSource::probe_stamp between installing the error and confirming the chooser reproduced the exact CI timeout 3/3 times. That proves this ordering can cause the failure, though the CI logs don't identify which call consumed the error there.

The sample below keeps the simulated failure active until the fixture scope ends, and adds the background probe to the existing error cases as regression coverage. With it, the forced race passed 3/3 runs, all five chosen_destination tests passed, and all ten filesystem-probe tests passed. These ran through scripts/test-headless.py in the pinned container with a private display and session bus. The selections were:

./scripts/test-headless.py -- a_chosen_folder_is_checked_off_the_ui_thread_while_the_chooser_stays_open --test-threads=1
./scripts/test-headless.py -- ui::browser::transfer::tests::chosen_destination:: --test-threads=1
./scripts/test-headless.py -- adapters::local_operations::probes::tests:: --test-threads=1

This is a proof of concept against 6153e3a8, not a finished change. It still needs formatting, lint and broader validation, particularly as it touches the shared test helpers. Would you be able to have your agent test this approach? No branch changes have been pushed, and the local experiments have been removed from the checkout.

Sample patch for the agent to try
diff --git i/src/adapters/local_operations/tests/fs_quirks/kinds.rs w/src/adapters/local_operations/tests/fs_quirks/kinds.rs
index 9d9383fc..376ced29 100644
--- i/src/adapters/local_operations/tests/fs_quirks/kinds.rs
+++ w/src/adapters/local_operations/tests/fs_quirks/kinds.rs
@@ -261,6 +261,8 @@ pub(crate) struct Quirks {
     pub lost_reply: Vec<(Op, &'static str, Errno)>,
     /// Fails the matching call after skipping the given number of matches, once.
     pub fail: Vec<(Op, &'static str, usize, Errno)>,
+    /// Fails every matching call until the scope is dropped.
+    pub fail_always: Vec<(Op, &'static str, Errno)>,
     /// Runs once, before the matching call after skipping the given number of matches.
     pub before: Vec<(Op, &'static str, usize, Racer)>,
     /// Runs once, after the matching call after skipping the given number of matches, whether
diff --git i/src/adapters/local_operations/tests/fs_quirks/scope.rs w/src/adapters/local_operations/tests/fs_quirks/scope.rs
index 5df1fcfe..b16ca993 100644
--- i/src/adapters/local_operations/tests/fs_quirks/scope.rs
+++ w/src/adapters/local_operations/tests/fs_quirks/scope.rs
@@ -245,7 +245,14 @@ impl Scope {
         if let Some(mut racer) = self.log(call)? {
             racer();
         }
-        let fault = take_due(&mut self.state().quirks.fail, call.op, call.names);
+        let fault = {
+            let mut state = self.state();
+            take_due(&mut state.quirks.fail, call.op, call.names).or_else(|| {
+                state.quirks.fail_always.iter()
+                    .find(|(op, pattern, _)| *op == call.op && matches(pattern, call.names))
+                    .map(|(_, _, error)| *error)
+            })
+        };
         if let Some(errno) = fault {
             return Err(errno);
         }
diff --git i/src/ui/browser/transfer/tests/chosen_destination.rs w/src/ui/browser/transfer/tests/chosen_destination.rs
index b2f70e07..89539055 100644
--- i/src/ui/browser/transfer/tests/chosen_destination.rs
+++ w/src/ui/browser/transfer/tests/chosen_destination.rs
@@ -322,9 +322,9 @@ impl ChosenFolderCheck {
                         }
                     }),
                 )],
-                fail: match self.chosen {
+                fail_always: match self.chosen {
                     ChosenFolder::Failing(error, _) => {
-                        vec![(crate::adapters::FsOp::FolderStamp, "destination", 0, error)]
+                        vec![(crate::adapters::FsOp::FolderStamp, "destination", error)]
                     }
                     ChosenFolder::SlowToAnswer | ChosenFolder::WriteOnly => Vec::new(),
                 },
@@ -334,6 +334,25 @@ impl ChosenFolderCheck {
         (release, checked, scope)
     }
 
+    fn probe_before_accept(&self) {
+        let ChosenFolder::Failing(error, _) = self.chosen else {
+            return;
+        };
+        let answer = Rc::new(RefCell::new(None));
+        let observed = answer.clone();
+        let _probe = crate::services::FileSource::probe_stamp(
+            &crate::adapters::LocalFileSource,
+            Location::local(&self.destination),
+            Rc::new(move |result| { observed.replace(Some(result)); }),
+        );
+        wait_until(|| answer.borrow().is_some(), "a background stamp before destination validation");
+        assert!(match (error, answer.borrow().as_ref()) {
+            (rustix::io::Errno::NOENT, Some(crate::services::StampAnswer::Missing)) => true,
+            (rustix::io::Errno::IO, Some(crate::services::StampAnswer::Unreachable)) => true,
+            _ => false,
+        });
+    }
+
     fn last_started(&self) -> Started {
         self.view.browser().last_started_operation()
     }
@@ -418,6 +437,7 @@ fn a_chosen_folder_is_checked_off_the_ui_thread_while_the_chooser_stays_open() {
                 let (release, checked, _scope) = check.hold_the_folder_check();
                 let started = check.last_started();
 
+                check.probe_before_accept();
                 confirm_destination(&check.chooser_window);
 
                 wait_until(

…ed check

The chosen-folder check failed or held only the first stamp of the folder, which the chooser's own relocation, relist and freshness work could make first under load, so the check succeeded and the chooser closed. Inject into every unforced stamp of the case and pass over forced freshness stamps.
… widths

The animated case read the column after a fixed 280 ms, but its ticks wait for frames, which a loaded runner draws late, so the column was still mid-animation. Wait for the column to end at the saved width instead.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main at 978acc8 and again at 1d2e244. One conflict in src/ui/browser/pane_header.rs: main made the Back history menu build its rows when it opens (#2041), while this PR moved the sort menu into pane_header/sort_menu.rs. I kept main's fill_back_history and dropped the old sort menu body, which the PR had already moved.

Owner design changes. At the owner's request (lgse), the sort menu no longer uses flyouts:

  • Extension and Created now sit with Name, Size, Modified and Type.
  • Natural, Alphabetical and Case-sensitive names sit under a NAME ORDER heading.
  • Unsorted has no row; unchecking the active field already turns sorting off.
  • Apply as default sort is now Make default.
  • The menu's top inset now matches its bottom.

This replaces the option 3 flyout summaries from #1652. All thirteen catalogs, docs/preferences.md and the QA scenario (now additional-sort-choices) are updated.

Review against the description and #1652. The rest of the behaviour is confirmed:

  • Toggling the active field off goes to Unsorted.
  • The menu stays open; Escape or an outside click dismisses it.
  • Unsorted keeps discovery order, including across streamed batches and monitor inserts.
  • Missing creation times go last in both directions.
  • .tar.gz sorts under gz; dotfiles have no extension.
  • The name comparison breaks ties under every field.
  • The List label and Ascending/Descending appear for Extension and Created.
  • Name order and case sensitivity are saved with default and per-folder sorts.
  • The 10xer chords work.

There were no earlier review comments.

Fixes pushed

  • da15539 fix(sort): sync open sort menus without a browser observer per pane. Each sort menu build called Browser::observe, and those observers live until the tab closes. Every navigation or view rebuild added another closure run on every browser event (6 → 26 observers over 18 navigations), the same uptime slowdown perf(tabs): free closed tabs and stop re-encoding menu icons #2041 fixed. Open menus are now tracked while mapped and refreshed from the tab's existing event dispatch.
  • f9f5391 fix(sort): keep a finished sort from seeding the next folder at its depth. A sort stays pending after it applies. Once Columns showed another folder at that depth, the next sort, name-order or Make default there started from the previous folder's request and saved it for the new folder.
  • 8c3270c fix(sort): treat a missing birth time in full listings as unavailable. On filesystems without birth times (NFS, SFTP) every row stayed Unknown, so a Created sort refilled the whole folder on each load (one request per file for remote folders), and a monitored change jumped its row ahead of the filled ones.
  • 9de75c2, 6153e3a test(icons): Left-wrap test fixes. Main's new icons_left_wraps_row_starts_and_leaves_only_the_first_tile (fix(icons): wrap Left from a row start to the previous row #2044) required Down from the first tile to pass the second tile. In the pinned GTK 4.22 image used by CI, the fixture's tiles are about 450 px wide in a 460 px grid, one per row (GTK 4.24 fits two), so it always failed on CI, including fix(icons): wrap Left from a row start to the previous row #2044's own run. The test now waits for the tiles to be laid out and accepts whichever row start Down reaches. Run with fix(icons): wrap Left from a row start to the previous row #2044's fix reverted, it still fails in both the CI image and on GTK 4.24.
  • a9e5061 test(transfer): stop the chooser's background stamps from taking the injected check. a_chosen_folder_is_checked_off_the_ui_thread_while_the_chooser_stays_open injected its failure (and the slow-case hold) into only the first stamp of destination. The chooser's own relocation, relist and freshness work also stamps that folder; when one of those got there first under CI load, the real check succeeded, the copy went ahead and the "Choose an existing folder." error never appeared. It failed twice on this PR and once on fix(theme): apply desktop text scaling when D-Bus activated #2045. Forcing a chooser freshness check between installing the quirk and confirming reproduced it every time in the CI image. The test now injects into every unforced stamp of the case, and a new opt-in Quirks::skip_forced_stamps passes over forced freshness re-stamps, so the chooser never sees its own folder vanish. With the forced check, it passes; under CPU load in the CI image, 10/10.
  • 7d03390 test(columns): double_clicking_an_edge_autofits_the_column_and_saves_its_width read the animated column after a fixed 280 ms. Its ticks wait for frames, which a loaded runner draws late, so CI saw it mid-animation (328 vs 316). It now waits for the column to end at the saved width. Under CPU load in the CI image, the old version failed 10/10 and the new one passed 10/10.

Tests

  • No tautological tests were added. ui::preferences::folder_views::tests::saved_views_round_trip_through_the_state_file now round-trips a non-default per-folder name comparison.
  • New regressions, each failing without its fix:
    • ui::window::composition::tabs::tests::rebuilding_panes_adds_no_browser_observers
    • app::browser::tests::folder_sorts::a_finished_sort_does_not_carry_into_the_next_folder_at_its_depth
    • the full-listing case in adapters::local_files::tests::browse::streamed_creation_time_is_filled_before_created_sorting

Validation

  • ./scripts/test-headless.py (full suite, before the menu rework and the two later sort fixes): all 3,829 tests passed.
  • After later changes, ./scripts/test-headless.py -- app::browser:: app::navigation:: adapters::local_files:: i18n:: ui::browser::context_menu:: keyboard_dispatch::icon_motion portal_text_scale plus the new regressions: passed.
  • ./scripts/qa.sh --test-threads 6 additional-sort-choices tenxer-sort-chords-keep-cursor list-view-baseline sorting-by-size panel-wheel-routing delete-file-symlink-sizes-link shift-click-revisits-after-folder: 13/13 passed. additional-sort-choices and list-view-baseline were rerun on the final menu: 4/4 passed.
  • After the transfer test fix: ./scripts/test-headless.py adapters:: (1,092), ui::browser::transfer:: (101), app::browser::freshness:: (34) and ui::browser::columns:: (23) passed. keyboard_dispatch::reload_cursor::, the only other test failing on recent PRs, passed 5/5 under load in the CI image.
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy: clean.
  • The menu was checked by hand in qa-drive: the top and bottom insets are 15 px and 16 px.

Follow-ups outside this PR

  • Keyboard settings list the new chord rows as "Extension", "Created", … while the existing ones read "Sort by size". Giving them the same wording would mean new strings in all thirteen languages.

CI: all checks pass on 7d03390.

@l0gicgate
l0gicgate merged commit 62bbb16 into lgse:main Nov 3, 2026
11 checks passed
wmfeht pushed a commit to wmfeht/strata-feature-map that referenced this pull request Nov 4, 2026
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(sort): add strict alphabetical name order and Yazi-style sort options

2 participants