Skip to content

Improvement of Task filtering status #3140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 20, 2025
Merged

Improvement of Task filtering status #3140

merged 5 commits into from
Jun 20, 2025

Conversation

Adinorio
Copy link
Collaborator

@Adinorio Adinorio commented Jun 20, 2025

Summary by CodeRabbit

  • New Features

    • Improved task and time tracking queries to include detailed task list statuses, board info, and enriched assignee data.
    • Task cards can now accept pre-fetched task lists to reduce loading times.
  • Bug Fixes

    • Enhanced error handling and user feedback when moving tasks, with improved loading state and notifications.
  • Refactor

    • Streamlined cache invalidation for tasks and related data for better consistency.
    • Centralized assignee transformation and cache management logic.
  • Documentation

    • Added clarifying comments to distinguish task board status types.

Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

Walkthrough

The changes introduce new utility functions for assignee transformation and cache invalidation, enhance the TaskCard to accept pre-fetched lists, and refactor task moving logic for better error handling and cache consistency. Task and time-tracking queries are updated to include status and archival fields, with improved filtering and data transformation.

Changes

File(s) Change Summary
apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx Enhanced TaskCard to accept optional availableLists prop, refactored move logic to use shared helper, improved error handling and loading state management.
apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts Extended task and list interfaces with archived and status fields, added special filtering for time-tracking requests, updated data transformation and query logic.
apps/web/src/lib/task-helper.ts Added transformAssignees and invalidateTaskCaches utilities, refactored moveTask to use new helper, removed debug logs, improved cache invalidation in hooks.
apps/web/src/lib/time-tracking-helper.ts Enhanced task query to include nested relations, filtered by status and archival, transformed results for easier access, deduplicated assignees, set explicit flags in returned data.
packages/types/src/primitives/TaskBoard.ts Added clarifying comments distinguishing TaskBoardStatus from similarly named types in the AI module; no code changes.

Sequence Diagram(s)

sequenceDiagram
    participant UI as TaskCard Component
    participant Helper as task-helper.ts
    participant API as API Route
    participant Query as React Query Client

    UI->>UI: Receives optional availableLists prop
    alt availableLists provided
        UI->>UI: Sets lists state directly
    else
        UI->>API: Fetches lists from API
    end

    UI->>Helper: Calls moveTask() on move action
    Helper->>API: Performs move mutation
    API-->>Helper: Returns result or error
    Helper->>UI: Throws error or returns success
    Helper->>Query: invalidateTaskCaches()
    Query-->>UI: Updates caches
    UI->>UI: Shows toast on error
Loading

Possibly related PRs

  • Add task statuses #3057: Refactors task list and card components to support list statuses and colors, updates task moving logic to handle archiving, and adds related hooks and types, directly relating to the enhanced status and moving logic in this PR.

Suggested labels

upskii

Poem

In the meadow where tasks hop and play,
New helpers bloom to clear the way.
Lists arrive with a gentle breeze,
Archival fields put minds at ease.
Assignees gather, caches renew—
A rabbit’s work, both neat and true!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@typescript-eslint/parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@typescript-eslint/parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

apps/web/src/lib/time-tracking-helper.ts

Oops! Something went wrong! :(

ESLint: 9.29.0

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@typescript-eslint/parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

  • 1 others
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch feat/tasks/fix-task-logic

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

Copy link

graphite-app bot commented Jun 20, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link

codecov bot commented Jun 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 120 lines in your changes missing coverage. Please review.

Project coverage is 0.80%. Comparing base (b5d64c7) to head (d5bd1ac).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...eb/src/app/api/v1/workspaces/[wsId]/tasks/route.ts 0.00% 41 Missing ⚠️
...(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx 0.00% 29 Missing ⚠️
apps/web/src/lib/time-tracking-helper.ts 0.00% 29 Missing ⚠️
apps/web/src/lib/task-helper.ts 0.00% 21 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3140      +/-   ##
==========================================
- Coverage    0.80%    0.80%   -0.01%     
==========================================
  Files        2554     2554              
  Lines      326716   326774      +58     
  Branches     3056     3056              
==========================================
  Hits         2623     2623              
- Misses     321912   321970      +58     
  Partials     2181     2181              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Adinorio, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refines how tasks are managed and displayed, particularly in the context of time tracking. It introduces a more robust and consistent approach to moving tasks between lists, ensuring that task completion status (archived/unarchived) is correctly managed based on the target list's status. Furthermore, it optimizes data fetching for time tracking by applying precise filters at the API level, guaranteeing that only active and relevant tasks are presented to the user, thereby improving the accuracy and usability of the time tracking feature.

Highlights

  • Task Completion Logic Refactor: Centralized the logic for moving tasks to completion by introducing a shared moveTask helper function. This ensures consistent handling of task archiving based on the target list's status (e.g., 'done' or 'closed' lists will archive the task).
  • Optimized Task List Fetching: Improved the TaskCard component to optionally receive availableLists as a prop, preventing redundant API calls to fetch task lists if the data is already available from a parent component.
  • Enhanced Task API Filtering for Time Tracking: Modified the task API endpoint (/api/v1/workspaces/[wsId]/tasks) to apply specific filters when requested for time tracking purposes. This ensures that only non-archived tasks from 'not_started' or 'active' lists are returned, providing a more accurate and relevant dataset for time tracking.
  • Improved Data Fetching for Time Tracking: Rewrote the task fetching query within time-tracking-helper.ts to explicitly join related tables (task lists, boards, assignees) and apply precise filters. This ensures that the time tracking view only displays tasks that are truly active and relevant for tracking time against.
  • Centralized Cache Invalidation: Introduced a new invalidateTaskCaches utility function to consistently invalidate relevant caches (tasks, task lists, and time tracking data) after task updates, ensuring UI consistency across the application.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request improves task filtering by status and enhances the time tracking feature. It introduces several changes, including adding status to the TaskList data structure, filtering tasks based on the list status, and updating the task card component to handle task completion. The changes also include refactoring some code for better consistency and adding comments for clarity.

@Adinorio Adinorio self-assigned this Jun 20, 2025
@Adinorio Adinorio requested a review from vhpx June 20, 2025 11:00
@Adinorio Adinorio marked this pull request as ready for review June 20, 2025 11:01
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (5)
apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx (2)

72-72: Good optimization to prevent redundant API calls.

This optional prop allows the parent component to pass pre-fetched lists, avoiding unnecessary network requests.


257-273: Improved consistency by using the shared moveTask helper.

The refactor to use the shared moveTask function ensures consistent logic and proper cache invalidation. The error handling with toast notifications provides good user feedback.

apps/web/src/lib/time-tracking-helper.ts (1)

232-243: Use the existing transformAssignees utility function.

This logic duplicates the transformAssignees function already available in task-helper.ts. Consider importing and using that function instead for consistency.

+import { transformAssignees } from '@/lib/task-helper';

-    assignees: task.assignees
-      ?.map((a: any) => ({
-        ...a.user,
-        // Extract email from nested user_private_details
-        email: a.user?.user_private_details?.[0]?.email || null,
-      }))
-      .filter(
-        (user: any, index: number, self: any[]) =>
-          user &&
-          user.id &&
-          self.findIndex((u: any) => u.id === user.id) === index
-      ) || [],
+    assignees: transformAssignees(task.assignees || []).map((user: any) => ({
+      ...user,
+      // Extract email from nested user_private_details  
+      email: user?.user_private_details?.[0]?.email || null,
+    })),
apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (2)

17-17: Consider adding documentation for the status field.

Adding comments to explain the possible status values would improve clarity for other developers.


178-179: Consider improving type safety in the assignee mapping.

Using proper type assertions instead of any would provide better type safety.

🧹 Nitpick comments (2)
apps/web/src/lib/time-tracking-helper.ts (1)

240-241: Simplify the conditional check using optional chaining.

The current logic can be simplified as suggested by the static analysis tool.

-          user &&
-          user.id &&
+          user?.id &&
apps/web/src/lib/task-helper.ts (1)

152-153: Simplify the conditional check using optional chaining.

The current logic can be simplified as suggested by the static analysis tool.

-        user &&
-        user.id &&
+        user?.id &&
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5d64c7 and 8e6187e.

📒 Files selected for processing (5)
  • apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx (6 hunks)
  • apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (7 hunks)
  • apps/web/src/lib/task-helper.ts (6 hunks)
  • apps/web/src/lib/time-tracking-helper.ts (2 hunks)
  • packages/types/src/primitives/TaskBoard.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
apps/web/src/lib/time-tracking-helper.ts

[error] 240-241: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

apps/web/src/lib/task-helper.ts

[error] 152-153: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🔇 Additional comments (4)
packages/types/src/primitives/TaskBoard.ts (1)

3-5: Excellent documentation improvement!

These clarifying comments effectively distinguish TaskBoardStatus from the AI module's TaskStatus, preventing potential developer confusion. Clear documentation like this is valuable for maintainability.

apps/web/src/lib/task-helper.ts (2)

147-156: Excellent utility function for code reuse.

The transformAssignees function centralizes assignee transformation logic, promoting consistency across the codebase. This is exactly what was needed to eliminate the duplicate logic in other files.


159-166: Great addition for consistent cache management.

The invalidateTaskCaches function ensures all related caches are invalidated together, improving data consistency after task operations. Including time-tracking data invalidation is particularly important for the PR's objectives.

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (1)

92-139: Excellent implementation of time tracking specific filtering.

The detection of time tracking requests and application of appropriate filters (non-archived tasks, active/not_started lists) aligns perfectly with the PR objectives. This ensures consistent data between the API and the time tracking helper.

- Filter time tracker API to exclude tasks from 'done' and 'closed' lists
- Update task movement logic to properly archive completed tasks
- Add proper cache invalidation for time tracker when tasks move
- Standardize task completion logic across components
- Refactor duplicate assignee transformation into shared utility
- Add documentation for task list status values
- Improve type safety with proper interface definitions

BREAKING CHANGE: Time tracker will no longer show tasks from completed lists
Resolves task status logic inconsistency where done tasks remained trackable
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (3)
apps/web/src/lib/time-tracking-helper.ts (1)

7-7: Excellent implementation addressing previous feedback.

The import and usage of transformAssignees directly addresses the past review comment about avoiding duplicated filter logic. This ensures consistent assignee processing across the application.

Also applies to: 233-233

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (2)

17-19: Well-documented interface extension with clear field usage.

The addition of the status field to TaskListData with comprehensive comments explaining possible values and usage context is excellent. This addresses the previous review feedback about documenting possible status values.


27-27: Good interface renaming and necessary field addition.

The rename from RawTaskData to TaskData is cleaner, and the archived field addition is essential for filtering archived tasks, as noted in previous reviews.

Also applies to: 37-37

🧹 Nitpick comments (1)
apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (1)

180-182: Improved type safety in assignee processing.

While the any types are still present, the explicit typing in the map function is clearer than before. The deduplication logic using Map is efficient and correct.

Consider creating a proper type for the assignee transformation to further improve type safety:

+interface ProcessedAssignee {
+  id: string;
+  display_name: string | null;
+  avatar_url: string | null;
+}

-            .map((a: any) => a.user)
-            .filter((u: any) => !!u?.id)
-            .reduce((uniqueUsers: Map<string, any>, user: any) => {
+            .map((a: TaskAssigneeData) => a.user)
+            .filter((u): u is ProcessedAssignee => !!u?.id)
+            .reduce((uniqueUsers: Map<string, ProcessedAssignee>, user: ProcessedAssignee) => {

Also applies to: 187-187

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e6187e and a770084.

📒 Files selected for processing (3)
  • apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (7 hunks)
  • apps/web/src/lib/task-helper.ts (6 hunks)
  • apps/web/src/lib/time-tracking-helper.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/src/lib/time-tracking-helper.ts (1)
apps/web/src/lib/task-helper.ts (1)
  • transformAssignees (147-155)
🪛 GitHub Check: codecov/patch
apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts

[warning] 17-19: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L17-L19
Added lines #L17 - L19 were not covered by tests


[warning] 27-27: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L27
Added line #L27 was not covered by tests


[warning] 37-37: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L37
Added line #L37 was not covered by tests


[warning] 93-95: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L93-L95
Added lines #L93 - L95 were not covered by tests


[warning] 111-111: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L111
Added line #L111 was not covered by tests


[warning] 115-115: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L115
Added line #L115 was not covered by tests


[warning] 135-142: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L135-L142
Added lines #L135 - L142 were not covered by tests


[warning] 162-162: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L162
Added line #L162 was not covered by tests


[warning] 172-172: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L172
Added line #L172 was not covered by tests


[warning] 176-176: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L176
Added line #L176 was not covered by tests


[warning] 180-182: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L180-L182
Added lines #L180 - L182 were not covered by tests


[warning] 187-187: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L187
Added line #L187 was not covered by tests

apps/web/src/lib/task-helper.ts

[warning] 147-155: apps/web/src/lib/task-helper.ts#L147-L155
Added lines #L147 - L155 were not covered by tests


[warning] 158-162: apps/web/src/lib/task-helper.ts#L158-L162
Added lines #L158 - L162 were not covered by tests


[warning] 164-165: apps/web/src/lib/task-helper.ts#L164-L165
Added lines #L164 - L165 were not covered by tests


[warning] 219-219: apps/web/src/lib/task-helper.ts#L219
Added line #L219 was not covered by tests


[warning] 511-511: apps/web/src/lib/task-helper.ts#L511
Added line #L511 was not covered by tests


[warning] 524-524: apps/web/src/lib/task-helper.ts#L524
Added line #L524 was not covered by tests


[warning] 536-536: apps/web/src/lib/task-helper.ts#L536
Added line #L536 was not covered by tests


[warning] 538-538: apps/web/src/lib/task-helper.ts#L538
Added line #L538 was not covered by tests

apps/web/src/lib/time-tracking-helper.ts

[warning] 7-7: apps/web/src/lib/time-tracking-helper.ts#L7
Added line #L7 was not covered by tests


[warning] 52-54: apps/web/src/lib/time-tracking-helper.ts#L52-L54
Added lines #L52 - L54 were not covered by tests


[warning] 74-81: apps/web/src/lib/time-tracking-helper.ts#L74-L81
Added lines #L74 - L81 were not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Prettier Check (23)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Verify generated types
🔇 Additional comments (8)
apps/web/src/lib/task-helper.ts (4)

157-165: Excellent centralization of cache invalidation logic.

The invalidateTaskCaches function properly handles cache consistency by invalidating all related query keys. The time tracking cache invalidation is especially important since task availability affects the time tracker.


184-186: Good documentation and consistent use of utility function.

The comments clearly explain the archival logic based on list status, and the refactoring to use transformAssignees improves code consistency.

Also applies to: 219-219


511-511: Clean parameter handling and improved cache management.

The underscore prefixes on unused parameters follow good conventions, and the switch to invalidateTaskCaches ensures comprehensive cache invalidation across related components.

Also applies to: 524-524, 536-538


146-155: ```shell
#!/bin/bash

Search for tests covering transformAssignees

rg "transformAssignees" -g "*.{test,spec}.{ts,tsx,js,jsx}" -n || echo "No tests found for transformAssignees"

Search for tests covering invalidateTaskCaches

rg "invalidateTaskCaches" -g "*.{test,spec}.{ts,tsx,js,jsx}" -n || echo "No tests found for invalidateTaskCaches"


</details>
<details>
<summary>apps/web/src/lib/time-tracking-helper.ts (2)</summary>

`52-81`: **Well-structured query with appropriate filtering for time tracking.**

The complex joins and filtering logic correctly identify available tasks for time tracking by:
- Filtering by workspace through board relation
- Excluding deleted and archived tasks  
- Restricting to active task lists ('not_started' or 'active')
- Including necessary nested data (assignees, board info)

---

`223-244`: **Comprehensive task transformation with proper data flattening.**

The transformation logic effectively:
- Flattens nested board/list properties for easier access
- Processes assignees consistently using the utility function
- Extracts email from nested private details
- Adds useful computed fields (`is_assigned_to_current_user`, `completed`)

</details>
<details>
<summary>apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (2)</summary>

`94-95`: **Smart conditional filtering logic for time tracking requests.**

The detection of time tracking requests (`limit=100` without specific filters) and subsequent application of appropriate filters is well-designed. This ensures the API returns only relevant tasks for time tracking while maintaining backward compatibility for other use cases.




Also applies to: 135-141

---

`111-111`: **Proper integration of new fields in query and response.**

The addition of `archived` and `status` fields to both the select query and response transformation ensures data consistency across the API.




Also applies to: 115-115, 162-162, 172-172, 176-176

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Adinorio and others added 3 commits June 20, 2025 19:15
- Add ProcessedAssignee interface for better type definitions
- Replace 'any' types with proper TypeScript interfaces
- Use type guards for safer runtime type checking
- Enhance assignee deduplication with strong typing
- Improve code maintainability and IDE support

The API now has comprehensive type safety for assignee data processing
while maintaining backward compatibility with existing functionality.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (5)
apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx (2)

72-72: Good optimization to prevent redundant API calls.

The optional availableLists prop allows parent components to pass pre-fetched task lists, avoiding unnecessary API requests when the data is already available.

Also applies to: 81-81


257-273: Update the comment about cache invalidation.

The moveTask function now handles cache invalidation internally through invalidateTaskCaches, making the comment about "manually invalidating queries" inaccurate.

-    // Use the standard moveTask function to ensure consistent logic
-    const supabase = createClient();
-    try {
-      await moveTask(supabase, task.id, targetCompletionList.id);
-      // Manually invalidate queries since we're not using the mutation hook
-      onUpdate();
+    // Use the standard moveTask function for consistent logic and cache management
+    const supabase = createClient();
+    try {
+      await moveTask(supabase, task.id, targetCompletionList.id);
+      onUpdate();
apps/web/src/lib/time-tracking-helper.ts (1)

235-235: Excellent use of the shared assignee transformation utility.

Using transformAssignees instead of the duplicated filtering logic maintains consistency and leverages the centralized implementation.

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (2)

23-25: Well-documented status field addition.

The comments clearly explain the possible status values and their purpose for time tracking, addressing the suggestion from previous reviews.


43-43: Necessary field addition for task lifecycle management.

The archived field enables proper filtering of tasks based on their completion/archival status.

🧹 Nitpick comments (3)
apps/web/src/lib/task-helper.ts (2)

146-156: Excellent refactoring to centralize assignee transformation logic.

The transformAssignees utility function effectively eliminates code duplication and provides consistent assignee processing across the application. The deduplication logic using findIndex is correct and efficient.

Consider adding unit tests for this utility function to improve coverage and prevent regressions:

describe('transformAssignees', () => {
  it('should extract and deduplicate user objects', () => {
    const assignees = [
      { user: { id: '1', display_name: 'User 1' } },
      { user: { id: '2', display_name: 'User 2' } },
      { user: { id: '1', display_name: 'User 1' } }, // duplicate
    ];
    const result = transformAssignees(assignees);
    expect(result).toHaveLength(2);
    expect(result.map(u => u.id)).toEqual(['1', '2']);
  });
});

158-166: Good centralization of cache invalidation logic.

The invalidateTaskCaches function ensures consistent cache invalidation across task-related operations. The inclusion of time-tracking data invalidation makes sense since task availability affects the time tracker.

Consider adding JSDoc documentation to clarify the function's purpose and parameters:

/**
 * Invalidates all task-related caches consistently
 * @param queryClient - React Query client instance
 * @param boardId - Optional board ID to scope invalidation
 */
export function invalidateTaskCaches(queryClient: any, boardId?: string) {
apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (1)

186-199: Improved assignee deduplication with better performance.

The Map-based approach using reduce is more efficient than the previous filter-based deduplication, especially for larger assignee lists. The explicit typing with ProcessedAssignee improves type safety.

Consider extracting this deduplication logic into a utility function to match the pattern established in task-helper.ts:

function deduplicateAssignees(assignees: TaskAssigneeData[]): ProcessedAssignee[] {
  return [
    ...assignees
      .map((a) => a.user)
      .filter((u): u is ProcessedAssignee => !!u?.id)
      .reduce((uniqueUsers: Map<string, ProcessedAssignee>, user: ProcessedAssignee) => {
        if (!uniqueUsers.has(user.id)) {
          uniqueUsers.set(user.id, user);
        }
        return uniqueUsers;
      }, new Map())
      .values(),
  ];
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee4aa5 and d5bd1ac.

📒 Files selected for processing (4)
  • apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx (7 hunks)
  • apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (8 hunks)
  • apps/web/src/lib/task-helper.ts (6 hunks)
  • apps/web/src/lib/time-tracking-helper.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/src/lib/time-tracking-helper.ts (1)
apps/web/src/lib/task-helper.ts (1)
  • transformAssignees (147-156)
🪛 GitHub Check: codecov/patch
apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx

[warning] 4-4: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L4
Added line #L4 was not covered by tests


[warning] 33-33: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L33
Added line #L33 was not covered by tests


[warning] 72-72: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L72
Added line #L72 was not covered by tests


[warning] 81-81: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L81
Added line #L81 was not covered by tests


[warning] 98-98: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L98
Added line #L98 was not covered by tests


[warning] 100-104: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L100-L104
Added lines #L100 - L104 were not covered by tests


[warning] 121-121: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L121
Added line #L121 was not covered by tests


[warning] 256-273: apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx#L256-L273
Added lines #L256 - L273 were not covered by tests

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts

[warning] 5-10: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L5-L10
Added lines #L5 - L10 were not covered by tests


[warning] 23-25: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L23-L25
Added lines #L23 - L25 were not covered by tests


[warning] 33-33: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L33
Added line #L33 was not covered by tests


[warning] 43-43: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L43
Added line #L43 was not covered by tests


[warning] 100-102: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L100-L102
Added lines #L100 - L102 were not covered by tests


[warning] 117-117: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L117
Added line #L117 was not covered by tests


[warning] 121-121: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L121
Added line #L121 was not covered by tests


[warning] 141-148: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L141-L148
Added lines #L141 - L148 were not covered by tests


[warning] 168-168: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L168
Added line #L168 was not covered by tests


[warning] 178-178: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L178
Added line #L178 was not covered by tests


[warning] 182-182: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L182
Added line #L182 was not covered by tests


[warning] 186-199: apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts#L186-L199
Added lines #L186 - L199 were not covered by tests

apps/web/src/lib/task-helper.ts

[warning] 147-154: apps/web/src/lib/task-helper.ts#L147-L154
Added lines #L147 - L154 were not covered by tests


[warning] 156-156: apps/web/src/lib/task-helper.ts#L156
Added line #L156 was not covered by tests


[warning] 159-163: apps/web/src/lib/task-helper.ts#L159-L163
Added lines #L159 - L163 were not covered by tests


[warning] 165-166: apps/web/src/lib/task-helper.ts#L165-L166
Added lines #L165 - L166 were not covered by tests


[warning] 220-220: apps/web/src/lib/task-helper.ts#L220
Added line #L220 was not covered by tests


[warning] 512-512: apps/web/src/lib/task-helper.ts#L512
Added line #L512 was not covered by tests


[warning] 525-525: apps/web/src/lib/task-helper.ts#L525
Added line #L525 was not covered by tests


[warning] 537-537: apps/web/src/lib/task-helper.ts#L537
Added line #L537 was not covered by tests


[warning] 539-539: apps/web/src/lib/task-helper.ts#L539
Added line #L539 was not covered by tests

apps/web/src/lib/time-tracking-helper.ts

[warning] 3-3: apps/web/src/lib/time-tracking-helper.ts#L3
Added line #L3 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Deploy-Preview
  • GitHub Check: Verify generated types
🔇 Additional comments (8)
apps/web/src/lib/task-helper.ts (3)

185-187: Clear documentation of task archival business logic.

The comments effectively explain how list status determines task archival state, making the business rules explicit and maintainable.


220-220: Good use of the centralized utility function.

Replacing inline assignee transformation with the transformAssignees utility maintains consistency and reduces code duplication.


537-539: Improved cache invalidation strategy.

Using invalidateTaskCaches instead of only invalidating the tasks cache ensures consistency across all related data, including time-tracking information.

apps/web/src/app/[locale]/(dashboard)/[wsId]/tasks/boards/[boardId]/task.tsx (1)

98-104: Efficient conditional data fetching.

The logic correctly uses prop-provided lists when available and only fetches from the API when necessary, improving performance and reducing network requests.

Also applies to: 121-121

apps/web/src/lib/time-tracking-helper.ts (2)

3-3: Good adoption of the centralized utility function.

Importing transformAssignees from the task helper ensures consistent assignee processing across the application.


52-83: Comprehensive query enhancement for time tracking.

The expanded query with nested relations (task lists, boards, assignees) and filtering by workspace, archival status, and list status provides all necessary data for time tracking functionality while maintaining performance with appropriate limits.

apps/web/src/app/api/v1/workspaces/[wsId]/tasks/route.ts (2)

5-9: Excellent addition of explicit typing for assignees.

The ProcessedAssignee interface improves type safety and clearly defines the structure of processed assignee data, replacing the previous any types.


100-102: Smart detection and filtering for time tracking requests.

The logic correctly identifies time tracking requests and applies appropriate filters to exclude archived tasks and include only tasks from active lists, ensuring data consistency with the time tracking helper.

Also applies to: 141-147

Copy link
Member

@vhpx vhpx left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @Adinorio.

@vhpx vhpx merged commit 8d75b3b into main Jun 20, 2025
19 checks passed
@vhpx vhpx deleted the feat/tasks/fix-task-logic branch June 20, 2025 11:38
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.

2 participants