Skip to content

fix(picker): remember sorting choices across chooser launches - #281

Closed
pedrosatin wants to merge 1 commit into
thisisgm:mainfrom
pedrosatin:fix/picker-sort-persistence
Closed

pedrosatin wants to merge 1 commit into
thisisgm:mainfrom
pedrosatin:fix/picker-sort-persistence

Conversation

@pedrosatin

@pedrosatin pedrosatin commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

flea --pick chooser dialogs, the ones browsers spawn for downloads and uploads, reset column sorting to Name ascending on every launch. The main window persists sort choices to ui.json, but requestSort() in ui/PickerWindow.qml only touched in-memory properties (backend.sortBy, backend.sortDesc). The portal process dies as soon as a file is picked or the dialog is cancelled. The next chooser request started from scratch and reloaded ui.json untouched.

requestSort() now records folderSorts for the active folder and updates the default sort leaf via ViewState, which persists the choice to ~/.local/state/flea/ui.json. The next chooser in the same folder reopens with the saved sort. Unvisited folders fall back to the saved default.

Related: #134 seeded the first picker listing from saved settings. #185 introduced the picker sort header, which was in-memory only until per-folder sorting landed in v0.3.7 (1a4fb969).

Changes:

  • ui/PickerWindow.qml: in requestSort(order), call backend.rememberFolderSort(win.path, order.key, order.desc) for non-Recent folders, and update the sort leaf with ViewState.changeLeaf (mtime maps to date). File stays at its 779-line budget.
  • tests/js/picker.js: unit test asserting requestSort records the folder sort and updates the ViewState sort leaf.

Verified with a three-process run driving PickerWindow.qml offscreen against flea --backend: after sorting dirA by Date descending, ui.json on disk held both the new default (date, reverse) and folderSorts[dirA]. A second process opened dirA already sorted by Date descending, and a third opened an unvisited dirB with the inherited default.

Suites and gates

tests/js.sh picker passed 384 checks including the new requestSort assertions. picker-header, picker-recent, picker-selection, picker-stall and picker-grid all pass. tools/flea-file-budget and tools/flea-qmllint-gate report 0 failures.

Summary by CodeRabbit

  • Improvements
    • Folder sort preferences are now saved and restored for non-Recent folders, including the selected sort order and direction.
    • Changing the sort order continues to refresh the folder listing.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d0bd7cb-d615-4e88-9b97-c09646a6f993

📥 Commits

Reviewing files that changed from the base of the PR and between a3c7508 and 0e03cda.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab2f894c-673c-4235-9356-a8f17a16fda1


📥 Commits

Reviewing files that changed from the base of the PR and between abb536e and a3c7508.



📒 Files selected for processing (2)
  • tests/js/picker.js
  • ui/PickerWindow.qml


Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The picker now saves non-Recent folder sort settings and updates the ViewState sort leaf. A test checks that descending mtime sorting is recorded as date with reverse: true.

Changes

Picker sort persistence

Layer / File(s) Summary
Save picker sort choices
ui/PickerWindow.qml, tests/js/picker.js
requestSort saves sort settings for non-Recent folders and updates the ViewState sort leaf. The test checks the saved folder sort and the mapped sort-leaf value.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: thisisgm



Merge Risk: ⚪ Minimal · up to a3c75

Saved sorting is available on a fresh chooser launch, and navigation within an open chooser intentionally keeps its current sort. No material merge risk was identified.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: persisting picker sorting choices across chooser launches.



✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

requestSort() records the folder's sort entry and updates the default
sort leaf in ViewState. A fresh chooser launch reopens with the chosen
order instead of resetting to Name ascending.
@pedrosatin
pedrosatin force-pushed the fix/picker-sort-persistence branch from a3c7508 to 0e03cda Compare October 11, 2026 01:10
@thisisgm

Copy link
Copy Markdown
Owner

merged as authored; the file picker remembers its sort (a3c7508, the same change as this PR's current head, v0.3.10). Thanks @pedrosatin! https://github.com/thisisgm/flea/releases/tag/v0.3.10

@thisisgm thisisgm closed this Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants