Display project of tasks in tasks list - #13
Conversation
WalkthroughAdds conditional rendering of a project label per task by looking up task.project_id in app.projects and inserting "#<project.name>" (cyan) after task content and before the due date. Reorders due date to follow the project label. No changes to exported/public signatures. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/ui/components/tasks_list.rs (1)
89-94: Bug: tasks without sections aren’t filtered by the selected project.In a project view, “no-section” tasks from other projects are included. Filter by
project_idwhen populatingtasks_by_section.- for task in &app.tasks { - tasks_by_section - .entry(task.section_id.clone()) - .or_default() - .push(task); - } + for task in &app.tasks { + if task.project_id == *project_id { + tasks_by_section + .entry(task.section_id.clone()) + .or_default() + .push(task); + } + }
🧹 Nitpick comments (2)
src/ui/components/tasks_list.rs (2)
279-287: Avoid per-task O(n) project lookup; also hide the project tag when already in that project view.Precompute a project_by_id map once and use it here; additionally, suppress the tag in Project view to reduce noise.
Apply this localized change (assumes a precomputed
project_by_id: HashMap<String, &ProjectDisplay>is available in scope and passed into this function):- if let Some(project) = app.projects.iter().find(|p| p.id == task.project_id) { - line_spans.push(Span::raw(" ")); - line_spans.push(Span::styled( - format!("#{}", project.name), - Style::default().fg(Color::Cyan), - )); - } + let show_project = match app.sidebar_selection { + super::super::app::SidebarSelection::Project(index) => { + app.projects.get(index).map_or(true, |p| p.id != task.project_id) + } + _ => true, + }; + if show_project { + if let Some(project) = project_by_id.get(&task.project_id) { + line_spans.push(Span::raw(" ")); + line_spans.push(Span::styled( + format!("#{}", project.name), + Style::default().fg(Color::Cyan), + )); + } + }Outside this hunk, precompute and thread the map (minimal sketch):
use std::collections::HashMap; use crate::todoist::ProjectDisplay; // in create_task_list_items: let project_by_id: HashMap<String, &ProjectDisplay> = app.projects.iter().map(|p| (p.id.clone(), p)).collect(); // pass &project_by_id into create_task_item(...) and adjust its signature accordingly.Optional: dim the project tag for completed/deleted tasks to match content styling.
288-295: Make due-date styling context-aware (overdue/today/future) and fall back to deadline if no due.Improves readability and urgency signaling.
- if let Some(due_date) = &task.due { - line_spans.push(Span::raw(" ")); - line_spans.push(Span::styled( - due_date.clone(), - Style::default().fg(Color::Rgb(255, 165, 0)), // Orange color - )); - } + if let Some(due_date) = &task.due { + use chrono::NaiveDate; + let today = chrono::Utc::now().date_naive(); + let due_style = NaiveDate::parse_from_str(due_date, "%Y-%m-%d") + .map(|d| { + if d < today { + Style::default().fg(Color::Red) + } else if d == today { + Style::default().fg(Color::Rgb(255, 165, 0)) + } else { + Style::default().fg(Color::Gray) + } + }) + .unwrap_or_else(|_| Style::default().fg(Color::Rgb(255, 165, 0))); + line_spans.push(Span::raw(" ")); + line_spans.push(Span::styled(due_date.clone(), due_style)); + } else if let Some(deadline) = &task.deadline { + line_spans.push(Span::raw(" ")); + line_spans.push(Span::styled(deadline.clone(), Style::default().fg(Color::Gray))); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/ui/components/tasks_list.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/ui/components/tasks_list.rs (1)
src/todoist.rs (4)
TaskDisplay(30-45)ProjectDisplay(6-12)From(71-108)From(48-58)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Security Audit
Summary by CodeRabbit