Task Management
Relevant source files
The following files were used as context for generating this wiki page: - [apps/web/core/types/schemas/task/task.schema.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/types/schemas/task/task.schema.ts) - [apps/web/core/hooks/organizations/teams/use-team-tasks.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/hooks/organizations/teams/use-team-tasks.ts) - [apps/mobile/app/services/hooks/features/use-team-tasks.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/mobile/app/services/hooks/features/use-team-tasks.ts) - [apps/web/app/[locale]/(main)/task/[id]/page.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/app/%5Blocale%5D/(main)/task/%5Bid%5D/page.tsx) - [apps/mobile/app/components/task/details-block/blocks/task-main-info.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/mobile/app/components/task/details-block/blocks/task-main-info.tsx) - [apps/web/core/components/tasks/task-input-kanban.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/tasks/task-input-kanban.tsx) - [apps/web/core/hooks/tasks/use-task-input.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/hooks/tasks/use-task-input.ts) - [apps/web/core/components/pages/task/title-block/task-title-block.tsx](httpshttps://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/task/title-block/task-title-block.tsx) - [apps/web/core/components/pages/task/details-section/blocks/task-secondary-info.tsx](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/components/pages/task/details-section/blocks/task-secondary-info.tsx) - [apps/web/core/stores/README.md](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/stores/README.md) - [apps/web/core/query/keys/index.ts](https://github.com/ever-co/ever-teams/blob/HEAD/apps/web/core/query/keys/index.ts)The Task Management system is a core feature of the Ever Teams platform, providing functionalities for creating, viewing, updating, and organizing tasks within teams and projects. It is implemented across both the web and mobile applications, with a shared data model but distinct hooks and UI components tailored for each platform. The system supports various task properties, including status, priority, size, issue type, and relationships like parent-child and epic-story hierarchies.
State management for tasks is handled globally using Jotai, ensuring a consistent and reactive user experience. Data fetching and mutations are managed by TanStack Query on the web platform, providing caching, optimistic updates, and data synchronization. The mobile platform uses a combination of custom hooks and MobX stores for state and data management.
Data Model (TTask)
The central data structure for the task management system is TTask, defined using Zod for schema validation. It includes base properties, self-referencing relationships, and associations with other entities like teams, members, and tags.
Sources: apps/web/core/types/schemas/task/task.schema.ts
ER Diagram
This diagram illustrates the TTask entity and its relationships with other entities.
Key Fields
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Unique identifier for the task. |
title | string | The title of the task. |
number | number | A unique, sequential number for the task within its scope. |
description | string | A detailed description of the task. |
status | ETaskStatusName | The current status of the task (e.g., 'open', 'closed'). |
priority | ETaskPriority | The priority level (e.g., 'Urgent', 'High', 'Medium', 'Low'). |
size | ETaskSize | The estimated size or complexity of the task. |
issueType | EIssueType | The type of issue (e.g., 'Task', 'Bug', 'Story', 'Epic'). |
startDate | Date | The planned start date for the task. |
dueDate | Date | The planned due date for the task. |
projectId | string | The ID of the project this task belongs to. |
parentId | string | The ID of the parent task, used for parent-child relationships. |
rootEpic | TTask | The root Epic task if this task is part of an Epic hierarchy. |
members | TEmployee[] | An array of employees assigned to the task. |
tags | TTag[] | An array of tags (labels) associated with the task. |
teams | TOrganizationTeam[] | An array of teams the task is associated with. |
Sources: apps/web/core/types/schemas/task/task.schema.ts:40-72
Core Logic and Hooks
The business logic for task management is encapsulated within custom hooks, with separate implementations for the web and mobile platforms.
Web: useTeamTasks Hook
This hook is the primary interface for interacting with tasks on the web application. It leverages Tanstack Query for data fetching, caching, and mutations, ensuring a robust and efficient data layer.
Sources: apps/web/core/hooks/organizations/teams/use-team-tasks.ts
Key Functions
| Function | Description |
|---|---|
teamTasksQuery | A useQuery instance to fetch all tasks for the active team. |
createTask | A useMutation wrapper to create a new task. It invalidates relevant queries on success. |
updateTask | A useMutation wrapper to update an existing task. It performs optimistic updates on the query cache. |
deleteTask | A useMutation wrapper to delete a task. |
getTaskById | Fetches a single task by its ID and updates the detailedTaskState atom. |
setActiveTask | Sets the currently active task for the user, updating both local state and the backend. |
updateTitle | A convenience function to update only the title of a task. |
handleStatusUpdate | Updates a specific property of a task, such as status, priority, or version. |
Sources: apps/web/core/hooks/organizations/teams/use-team-tasks.ts:119-493
Task Update Flow (Web)
The following diagram shows the sequence of events when a user updates a task's title on the web.
Mobile: useTeamTasks Hook
The mobile application has its own useTeamTasks hook, which uses MobX stores for state management and direct API requests for data manipulation.
Sources: apps/mobile/app/services/hooks/features/use-team-tasks.ts
Key Functions
| Function | Description |
|---|---|
useFetchAllTasks | A query hook that fetches all tasks and populates the teamTasks store. |
createNewTask | Creates a new task and then refetches the task list to update the UI. |
updateTask | Sends an update request to the API and refetches the task list. |
deleteTask | Deletes a task and filters it out from the local store. |
getTaskById | Fetches a single task by its ID and updates the detailedTask store. |
setActiveTeamTask | Updates the current user's active task on the backend and updates the local activeTask store. |
Sources: apps/mobile/app/services/hooks/features/use-team-tasks.ts:47-268
Task Lifecycle and Operations
Task Creation
Tasks can be created from various parts of the application, most notably the Kanban board or task input components. The process involves collecting user input for the title and other optional properties, and then calling the createTask function from the useTeamTasks hook.
Task Details View
Both web and mobile applications provide a detailed view for a single task, accessible via a unique URL (/task/[id]).
This diagram shows the component structure of the web task details page.
On page load, the getTaskById function is called to fetch the task data. If the task is found, it is rendered using a set of specialized components. If not, a "Task not found" message is displayed.
Sources: apps/web/app/[locale]/(main)/task/[id]/page.tsx:43-52
Task Relationships (Parent/Child & Epics)
The system supports hierarchical task relationships, which are crucial for project management.
- Issue Types: Tasks are categorized by
issueType, includingEpic,Story,Task, andBug. - Parent/Child: A task can have a
parentIdpointing to another task. This is used for general sub-tasking. - Epics and Stories:
- An
Epicis a top-level task type. - A
Storycan be a child of anEpic. ItsparentIdwill point to the Epic's ID. - A
TaskorBugcan be a child of aStoryor anEpic. TherootEpicfield provides a direct link back to the top-level Epic for easy navigation.
- An
The UI reflects these relationships. For example, the TaskTitleBlock component displays a badge for the parent task, which is a link to the parent's detail page. The TaskSecondaryInfo component provides a dropdown to select a parent Epic for a Story.
Sources: apps/web/core/types/schemas/task/task.schema.ts:24-32, 53, apps/web/core/components/pages/task/title-block/task-title-block.tsx:206-251, apps/web/core/components/pages/task/details-section/blocks/task-secondary-info.tsx:109-126
State Management
Global state for tasks is managed using Jotai. This includes the list of all tasks, the currently active task, and the task being viewed in detail.
tasksByTeamState: An atom holding all tasks for the currently active team.detailedTaskState: An atom for the task currently being viewed on thetask/[id]page.activeTeamTaskState: An atom representing the task the user is currently working on (tracked by the timer).
These atoms are consumed by various hooks and components to ensure the UI is always in sync with the application state.
Sources: apps/web/core/hooks/organizations/teams/use-team-tasks.ts:80, 82, apps/web/app/[locale]/(main)/task/[id]/page.tsx:28, apps/web/core/stores/README.md
Summary
The Task Management feature in Ever Teams is a well-structured system that separates concerns effectively between data models, state management, core logic, and UI components. It uses modern tools like Zod, Jotai, and TanStack Query to create a reliable and scalable foundation. The architecture supports distinct implementations for web and mobile while sharing a common data schema, and provides complex features like hierarchical task relationships, which are essential for effective project and work management.