From eb6bb932f7b4d164245905d16e0b91f0808cb63e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 2 Nov 2025 18:49:02 +0000 Subject: [PATCH] Add dual sort modes: manual ordering and by due date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced task ordering with two sort options: 1. Manual Ordering (default): - User can drag/drop to reorder tasks - Order stored in task_order array in .listdata.json - Only manual changes update the file 2. By Due Date: - Tasks automatically sorted by due_date field - Tasks without due dates appear at end - task_order array ignored when in this mode Changes: - Added sort_order field to .listdata.json ("manual" or "by_due_date") - Added SortOrder enum to TaskList model - Clarified that Vec order depends on sort preference - Added set_sort_order() and get_sort_order() to repository API - Added CLI sort command to switch between modes - Removed confusing comment about .listdata.json being "in-memory" Example .listdata.json: { "sort_order": "manual", "task_order": ["uuid-1", "uuid-2", "uuid-3"] } CLI usage: bevy-tasks sort manual --list "Work" bevy-tasks sort by-due-date --list "Personal" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- PLAN.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/PLAN.md b/PLAN.md index 25edbdf..edd5d96 100644 --- a/PLAN.md +++ b/PLAN.md @@ -90,10 +90,15 @@ Task { TaskList { id: Uuid, title: String, // Derived from folder name - tasks: Vec, + tasks: Vec, // Ordered according to sort_order preference created_at: DateTime, updated_at: DateTime, - // Note: task_order stored in .listdata.json, not in memory model + sort_order: SortOrder, // How to sort: Manual or ByDueDate +} + +enum SortOrder { + Manual, // Use task_order from .listdata.json + ByDueDate, // Sort by due_date field (tasks without due dates at end) } AppConfig { @@ -134,6 +139,7 @@ AppConfig { "id": "list-uuid-1", "created_at": "2025-10-26T10:00:00Z", "updated_at": "2025-10-27T14:30:00Z", + "sort_order": "manual", "task_order": [ "task-uuid-1", "task-uuid-2", @@ -142,8 +148,15 @@ AppConfig { } ``` +**Sort Order Options**: +- `"manual"` - Tasks ordered by hand (uses `task_order` array) +- `"by_due_date"` - Tasks automatically sorted by due date (tasks without due dates appear at end) + +When `sort_order` is `"manual"`, the `task_order` array defines the sequence. When `sort_order` is `"by_due_date"`, tasks are sorted dynamically and `task_order` is ignored. + **Benefits**: -- **Ordering in list metadata**: Reordering tasks only touches `.listdata.json` +- **Two sort modes**: Manual ordering or automatic by due date +- **Ordering in list metadata**: Changing manual order only touches `.listdata.json` - **Portable lists**: Copy/move a list folder and its metadata stays with it - **Clean structure**: No nested hidden folders, just hidden files - **WebDAV-friendly**: Syncing a list syncs its metadata naturally @@ -179,6 +192,10 @@ impl TaskRepository { // Task ordering (modifies .listdata.json) pub fn reorder_task(&mut self, list_id: Uuid, task_id: Uuid, new_position: usize) -> Result<()>; pub fn get_task_order(&self, list_id: Uuid) -> Result>; + + // Sort preference (modifies .listdata.json) + pub fn set_sort_order(&mut self, list_id: Uuid, sort_order: SortOrder) -> Result<()>; + pub fn get_sort_order(&self, list_id: Uuid) -> Result; } pub trait Storage { @@ -262,6 +279,8 @@ tokio = { workspace = true } - [ ] CLI: `complete` command (mark done) - [ ] CLI: `delete` command (remove tasks) - [ ] CLI: `edit` command (modify tasks) +- [ ] Two sort modes: manual ordering and by due date +- [ ] CLI: `sort` command (switch between manual/by-due-date) - [ ] Comprehensive unit and integration tests (>80% coverage) ### CLI Usage Examples @@ -283,6 +302,10 @@ bevy-tasks delete # Change folder location later bevy-tasks config set-folder ~/new/location + +# Sort order +bevy-tasks sort manual --list "Work" +bevy-tasks sort by-due-date --list "Personal" ``` ### Deliverables