Skip to content

Display project of tasks in tasks list - #13

Merged
romaintb merged 1 commit into
mainfrom
enhance/display_project_of_a_task
Sep 2, 2025
Merged

Display project of tasks in tasks list#13
romaintb merged 1 commit into
mainfrom
enhance/display_project_of_a_task

Conversation

@romaintb

@romaintb romaintb commented Sep 2, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • Tasks now display their associated project as a cyan “#ProjectName” label next to the task content.
  • Style
    • Reordered task metadata so the due date appears after the project label for clearer readability.
    • Preserves existing display when a task has no associated project (no project label shown; due date still visible).

@romaintb romaintb self-assigned this Sep 2, 2025
@romaintb romaintb added the enhancement New feature or request label Sep 2, 2025
@coderabbitai

coderabbitai Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary
Task list rendering
src/ui/components/tasks_list.rs
Inserted conditional project label lookup and render (cyan “#<project.name>”) after task content; moved due date rendering to follow the project label; no changes when no project is found; no public API changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhance/display_project_of_a_task

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@romaintb
romaintb merged commit e5adc58 into main Sep 2, 2025
3 of 5 checks passed
@romaintb
romaintb deleted the enhance/display_project_of_a_task branch September 2, 2025 08:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id when populating tasks_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.

📥 Commits

Reviewing files that changed from the base of the PR and between 46f4937 and 8fd17cb.

📒 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

@coderabbitai coderabbitai Bot mentioned this pull request Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant