Skip to content

Refactor todo view sorting to explicit mode enum#928

Merged
multiplex55 merged 1 commit intomasterfrom
codex/refactor-todo-sorting-in-todo_view_dialog
Mar 13, 2026
Merged

Refactor todo view sorting to explicit mode enum#928
multiplex55 merged 1 commit intomasterfrom
codex/refactor-todo-sorting-in-todo_view_dialog

Conversation

@multiplex55
Copy link
Copy Markdown
Owner

Motivation

  • Replace the ad-hoc boolean sort_by_priority with an explicit mode to make sorting behavior clearer and extendable.
  • Make sorting deterministic by adding stable tie-breakers so the displayed order is predictable across runs.
  • Replace the checkbox UI with an explicit selector so users can choose sort Priority or Name while keeping the existing filter behavior.

Description

  • Introduce enum TodoSortMode { Priority, Name } and replace TodoViewDialog.sort_by_priority: bool with sort_mode: TodoSortMode, defaulting to Priority in open() and open_edit().
  • Add a pure helper fn sorted_todo_indices(entries, filter, sort_mode) -> Vec<usize> that centralizes filtering and index-based sorting and preserves index indirection for edits/removals.
  • Implement deterministic tie-breakers: in Priority mode sort by priority (desc) then text.to_lowercase() (asc) then original index; in Name mode sort by text.to_lowercase() (asc) then priority (desc) then original index.
  • Replace the checkbox with an egui::ComboBox offering Priority and Name, and add unit tests in the existing #[cfg(test)] mod tests that exercise priority ordering, name ordering, stability/tie-breaks, and filter+sort interaction.

Testing

  • Ran cargo fmt --all which completed successfully.
  • Ran cargo test src::gui::todo_view_dialog -- --nocapture but the build/test run failed in this environment due to a system dependency error from alsa-sys (pkg-config / missing alsa.pc), so the new unit tests could not be executed here.

Codex Task

@multiplex55 multiplex55 merged commit 8012abd into master Mar 13, 2026
1 check passed
@multiplex55 multiplex55 deleted the codex/refactor-todo-sorting-in-todo_view_dialog branch March 25, 2026 23:51
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.

1 participant