Compare commits
1 Commits
docs/auto-
...
ralph/chor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
111e69aaa9 |
@@ -1,13 +1,5 @@
|
|||||||
# task-master-ai
|
# task-master-ai
|
||||||
|
|
||||||
## 0.27.2
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- [#1248](https://github.com/eyaltoledano/claude-task-master/pull/1248) [`044a7bf`](https://github.com/eyaltoledano/claude-task-master/commit/044a7bfc98049298177bc655cf341d7a8b6a0011) Thanks [@Crunchyman-ralph](https://github.com/Crunchyman-ralph)! - Fix set-status for subtasks:
|
|
||||||
- Parent tasks are now set as `done` when subtasks are all `done`
|
|
||||||
- Parent tasks are now set as `in-progress` when at least one subtask is `in-progress` or `done`
|
|
||||||
|
|
||||||
## 0.27.1
|
## 0.27.1
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -101,12 +101,7 @@ sidebarTitle: "CLI Commands"
|
|||||||
task-master set-status --id=1.1,1.2 --status=<status>
|
task-master set-status --id=1.1,1.2 --status=<status>
|
||||||
```
|
```
|
||||||
|
|
||||||
**Automatic Parent Status Management:**
|
When marking a task as "done", all of its subtasks will automatically be marked as "done" as well.
|
||||||
When updating subtask statuses, parent task statuses are automatically adjusted:
|
|
||||||
- When **all subtasks** are marked `done`, the parent task becomes `done`
|
|
||||||
- When **at least one subtask** is `in-progress` or `done`, the parent task becomes `in-progress`
|
|
||||||
|
|
||||||
When marking a parent task as "done", all of its subtasks will automatically be marked as "done" as well.
|
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
<Accordion title="Expand Tasks">
|
<Accordion title="Expand Tasks">
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ The MCP tools can be categorized in the same way as the core functionalities:
|
|||||||
- **`get_tasks`**: Lists all tasks.
|
- **`get_tasks`**: Lists all tasks.
|
||||||
- **`get_task`**: Shows the details of a specific task.
|
- **`get_task`**: Shows the details of a specific task.
|
||||||
- **`next_task`**: Shows the next task to work on.
|
- **`next_task`**: Shows the next task to work on.
|
||||||
- **`set_task_status`**: Sets the status of a task or subtask. When updating subtask statuses, parent task statuses are automatically adjusted based on subtask completion.
|
- **`set_task_status`**: Sets the status of a task or subtask.
|
||||||
|
|
||||||
### 3. Task Analysis and Expansion
|
### 3. Task Analysis and Expansion
|
||||||
|
|
||||||
|
|||||||
@@ -120,23 +120,6 @@ The `show` command:
|
|||||||
- Provides contextual action suggestions based on the task's state
|
- Provides contextual action suggestions based on the task's state
|
||||||
- Works with both regular tasks and subtasks (using the format taskId.subtaskId)
|
- Works with both regular tasks and subtasks (using the format taskId.subtaskId)
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
<Accordion title="Automatic Parent Status Management">
|
|
||||||
Task Master automatically manages parent task statuses based on subtask changes:
|
|
||||||
|
|
||||||
**Status Rules:**
|
|
||||||
- When **all subtasks** are marked as `done`, the parent task is automatically set to `done`
|
|
||||||
- When **at least one subtask** is `in-progress` or `done`, the parent task is automatically set to `in-progress`
|
|
||||||
- This ensures parent tasks accurately reflect the progress of their subtasks
|
|
||||||
|
|
||||||
**Example Workflow:**
|
|
||||||
1. Parent task starts as `pending`
|
|
||||||
2. First subtask marked `in-progress` → Parent becomes `in-progress`
|
|
||||||
3. Some subtasks completed (`done`) → Parent remains `in-progress`
|
|
||||||
4. All subtasks completed (`done`) → Parent automatically becomes `done`
|
|
||||||
|
|
||||||
This automation eliminates the need to manually update parent task statuses and ensures consistency across your task hierarchy.
|
|
||||||
</Accordion>
|
|
||||||
</AccordionGroup>
|
</AccordionGroup>
|
||||||
|
|
||||||
## Best Practices for AI-Driven Development
|
## Best Practices for AI-Driven Development
|
||||||
|
|||||||
@@ -3,31 +3,4 @@ title: "What's New"
|
|||||||
sidebarTitle: "What's New"
|
sidebarTitle: "What's New"
|
||||||
---
|
---
|
||||||
|
|
||||||
## Version 0.27.2 - Automatic Parent Status Management
|
An easy way to see the latest releases
|
||||||
|
|
||||||
### ✨ New Features
|
|
||||||
|
|
||||||
**Automatic Parent Status Management**
|
|
||||||
- Parent tasks now automatically update their status based on subtask progress
|
|
||||||
- When all subtasks are marked as `done`, the parent task automatically becomes `done`
|
|
||||||
- When at least one subtask is `in-progress` or `done`, the parent task automatically becomes `in-progress`
|
|
||||||
- This eliminates manual parent status updates and ensures task hierarchy consistency
|
|
||||||
|
|
||||||
### 🔧 How It Works
|
|
||||||
|
|
||||||
The new system tracks subtask status changes and intelligently updates parent statuses:
|
|
||||||
|
|
||||||
1. **Subtask Progress Tracking**: Each subtask status change triggers parent evaluation
|
|
||||||
2. **Smart Status Rules**: Parent status reflects the collective progress of all subtasks
|
|
||||||
3. **Seamless Integration**: Works automatically with existing `set-status` commands and MCP tools
|
|
||||||
|
|
||||||
### 📈 Benefits
|
|
||||||
|
|
||||||
- **Reduced Manual Work**: No need to manually update parent task statuses
|
|
||||||
- **Better Visibility**: Parent tasks accurately reflect overall progress
|
|
||||||
- **Consistency**: Eliminates mismatched parent/subtask status combinations
|
|
||||||
- **AI-Friendly**: Provides clearer status hierarchy for AI assistants
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
For a complete list of changes, see the [CHANGELOG.md](https://github.com/eyaltoledano/claude-task-master/blob/main/CHANGELOG.md).
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
## 0.25.3
|
|
||||||
|
|
||||||
### Patch Changes
|
|
||||||
|
|
||||||
- Updated dependencies [[`044a7bf`](https://github.com/eyaltoledano/claude-task-master/commit/044a7bfc98049298177bc655cf341d7a8b6a0011)]:
|
|
||||||
- task-master-ai@0.27.2
|
|
||||||
|
|
||||||
## 0.25.2
|
## 0.25.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"displayName": "TaskMaster",
|
"displayName": "TaskMaster",
|
||||||
"description": "A visual Kanban board interface for TaskMaster projects in VS Code",
|
"description": "A visual Kanban board interface for TaskMaster projects in VS Code",
|
||||||
"version": "0.25.3",
|
"version": "0.25.2",
|
||||||
"publisher": "Hamster",
|
"publisher": "Hamster",
|
||||||
"icon": "assets/icon.png",
|
"icon": "assets/icon.png",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -240,7 +240,7 @@
|
|||||||
"check-types": "tsc --noEmit"
|
"check-types": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"task-master-ai": "0.27.2"
|
"task-master-ai": "0.27.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
|
|||||||
78
output.txt
78
output.txt
File diff suppressed because one or more lines are too long
8
package-lock.json
generated
8
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "task-master-ai",
|
"name": "task-master-ai",
|
||||||
"version": "0.27.2",
|
"version": "0.27.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "task-master-ai",
|
"name": "task-master-ai",
|
||||||
"version": "0.27.2",
|
"version": "0.27.1",
|
||||||
"license": "MIT WITH Commons-Clause",
|
"license": "MIT WITH Commons-Clause",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"apps/*",
|
"apps/*",
|
||||||
@@ -357,9 +357,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apps/extension": {
|
"apps/extension": {
|
||||||
"version": "0.25.3",
|
"version": "0.25.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"task-master-ai": "0.27.2"
|
"task-master-ai": "0.27.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@dnd-kit/core": "^6.3.1",
|
"@dnd-kit/core": "^6.3.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "task-master-ai",
|
"name": "task-master-ai",
|
||||||
"version": "0.27.2",
|
"version": "0.27.1",
|
||||||
"description": "A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.",
|
"description": "A task management system for ambitious AI-driven development that doesn't overwhelm and confuse Cursor.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -3,17 +3,7 @@
|
|||||||
* This file defines the contract for all storage implementations
|
* This file defines the contract for all storage implementations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Task, TaskMetadata, TaskStatus } from '../types/index.js';
|
import type { Task, TaskMetadata } from '../types/index.js';
|
||||||
|
|
||||||
/**
|
|
||||||
* Result type for updateTaskStatus operations
|
|
||||||
*/
|
|
||||||
export interface UpdateStatusResult {
|
|
||||||
success: boolean;
|
|
||||||
oldStatus: TaskStatus;
|
|
||||||
newStatus: TaskStatus;
|
|
||||||
taskId: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for storage operations on tasks
|
* Interface for storage operations on tasks
|
||||||
@@ -64,19 +54,6 @@ export interface IStorage {
|
|||||||
tag?: string
|
tag?: string
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
|
|
||||||
/**
|
|
||||||
* Update task or subtask status by ID
|
|
||||||
* @param taskId - ID of the task or subtask (e.g., "1" or "1.2")
|
|
||||||
* @param newStatus - New status to set
|
|
||||||
* @param tag - Optional tag context for the task
|
|
||||||
* @returns Promise that resolves to update result with old and new status
|
|
||||||
*/
|
|
||||||
updateTaskStatus(
|
|
||||||
taskId: string,
|
|
||||||
newStatus: TaskStatus,
|
|
||||||
tag?: string
|
|
||||||
): Promise<UpdateStatusResult>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a task by ID
|
* Delete a task by ID
|
||||||
* @param taskId - ID of the task to delete
|
* @param taskId - ID of the task to delete
|
||||||
@@ -214,11 +191,6 @@ export abstract class BaseStorage implements IStorage {
|
|||||||
updates: Partial<Task>,
|
updates: Partial<Task>,
|
||||||
tag?: string
|
tag?: string
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
abstract updateTaskStatus(
|
|
||||||
taskId: string,
|
|
||||||
newStatus: TaskStatus,
|
|
||||||
tag?: string
|
|
||||||
): Promise<UpdateStatusResult>;
|
|
||||||
abstract deleteTask(taskId: string, tag?: string): Promise<void>;
|
abstract deleteTask(taskId: string, tag?: string): Promise<void>;
|
||||||
abstract exists(tag?: string): Promise<boolean>;
|
abstract exists(tag?: string): Promise<boolean>;
|
||||||
abstract loadMetadata(tag?: string): Promise<TaskMetadata | null>;
|
abstract loadMetadata(tag?: string): Promise<TaskMetadata | null>;
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ export class TaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update task status - delegates to storage layer which handles storage-specific logic
|
* Update task status
|
||||||
*/
|
*/
|
||||||
async updateTaskStatus(
|
async updateTaskStatus(
|
||||||
taskId: string | number,
|
taskId: string | number,
|
||||||
@@ -468,28 +468,49 @@ export class TaskService {
|
|||||||
|
|
||||||
// Use provided tag or get active tag
|
// Use provided tag or get active tag
|
||||||
const activeTag = tag || this.getActiveTag();
|
const activeTag = tag || this.getActiveTag();
|
||||||
|
|
||||||
const taskIdStr = String(taskId);
|
const taskIdStr = String(taskId);
|
||||||
|
|
||||||
try {
|
// TODO: For now, assume it's a regular task and just try to update directly
|
||||||
// Delegate to storage layer which handles the specific logic for tasks vs subtasks
|
// In the future, we can add subtask support if needed
|
||||||
return await this.storage.updateTaskStatus(
|
if (taskIdStr.includes('.')) {
|
||||||
taskIdStr,
|
throw new TaskMasterError(
|
||||||
newStatus,
|
'Subtask status updates not yet supported in API storage',
|
||||||
activeTag
|
ERROR_CODES.NOT_IMPLEMENTED
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the current task to get old status (simple, direct approach)
|
||||||
|
let currentTask: Task | null;
|
||||||
|
try {
|
||||||
|
// Try to get the task directly
|
||||||
|
currentTask = await this.storage.loadTask(taskIdStr, activeTag);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TaskMasterError(
|
throw new TaskMasterError(
|
||||||
`Failed to update task status for ${taskIdStr}`,
|
`Failed to load task ${taskIdStr}`,
|
||||||
ERROR_CODES.STORAGE_ERROR,
|
ERROR_CODES.TASK_NOT_FOUND,
|
||||||
{
|
{ taskId: taskIdStr },
|
||||||
operation: 'updateTaskStatus',
|
|
||||||
resource: 'task',
|
|
||||||
taskId: taskIdStr,
|
|
||||||
newStatus,
|
|
||||||
tag: activeTag
|
|
||||||
},
|
|
||||||
error as Error
|
error as Error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!currentTask) {
|
||||||
|
throw new TaskMasterError(
|
||||||
|
`Task ${taskIdStr} not found`,
|
||||||
|
ERROR_CODES.TASK_NOT_FOUND
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldStatus = currentTask.status;
|
||||||
|
|
||||||
|
// Simple, direct update - just change the status
|
||||||
|
await this.storage.updateTask(taskIdStr, { status: newStatus }, activeTag);
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
oldStatus,
|
||||||
|
newStatus,
|
||||||
|
taskId: taskIdStr
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,15 +5,9 @@
|
|||||||
|
|
||||||
import type {
|
import type {
|
||||||
IStorage,
|
IStorage,
|
||||||
StorageStats,
|
StorageStats
|
||||||
UpdateStatusResult
|
|
||||||
} from '../interfaces/storage.interface.js';
|
} from '../interfaces/storage.interface.js';
|
||||||
import type {
|
import type { Task, TaskMetadata, TaskTag } from '../types/index.js';
|
||||||
Task,
|
|
||||||
TaskMetadata,
|
|
||||||
TaskTag,
|
|
||||||
TaskStatus
|
|
||||||
} from '../types/index.js';
|
|
||||||
import { ERROR_CODES, TaskMasterError } from '../errors/task-master-error.js';
|
import { ERROR_CODES, TaskMasterError } from '../errors/task-master-error.js';
|
||||||
import { TaskRepository } from '../repositories/task-repository.interface.js';
|
import { TaskRepository } from '../repositories/task-repository.interface.js';
|
||||||
import { SupabaseTaskRepository } from '../repositories/supabase-task-repository.js';
|
import { SupabaseTaskRepository } from '../repositories/supabase-task-repository.js';
|
||||||
@@ -491,62 +485,6 @@ export class ApiStorage implements IStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update task or subtask status by ID - for API storage
|
|
||||||
*/
|
|
||||||
async updateTaskStatus(
|
|
||||||
taskId: string,
|
|
||||||
newStatus: TaskStatus,
|
|
||||||
tag?: string
|
|
||||||
): Promise<UpdateStatusResult> {
|
|
||||||
await this.ensureInitialized();
|
|
||||||
|
|
||||||
try {
|
|
||||||
const existingTask = await this.retryOperation(() =>
|
|
||||||
this.repository.getTask(this.projectId, taskId)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!existingTask) {
|
|
||||||
throw new Error(`Task ${taskId} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldStatus = existingTask.status;
|
|
||||||
if (oldStatus === newStatus) {
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the task/subtask status
|
|
||||||
await this.retryOperation(() =>
|
|
||||||
this.repository.updateTask(this.projectId, taskId, {
|
|
||||||
status: newStatus,
|
|
||||||
updatedAt: new Date().toISOString()
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// Note: Parent status auto-adjustment is handled by the backend API service
|
|
||||||
// which has its own business logic for managing task relationships
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
throw new TaskMasterError(
|
|
||||||
'Failed to update task status via API',
|
|
||||||
ERROR_CODES.STORAGE_ERROR,
|
|
||||||
{ operation: 'updateTaskStatus', taskId, newStatus, tag },
|
|
||||||
error as Error
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all available tags
|
* Get all available tags
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,11 +2,10 @@
|
|||||||
* @fileoverview Refactored file-based storage implementation for Task Master
|
* @fileoverview Refactored file-based storage implementation for Task Master
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { Task, TaskMetadata, TaskStatus } from '../../types/index.js';
|
import type { Task, TaskMetadata } from '../../types/index.js';
|
||||||
import type {
|
import type {
|
||||||
IStorage,
|
IStorage,
|
||||||
StorageStats,
|
StorageStats
|
||||||
UpdateStatusResult
|
|
||||||
} from '../../interfaces/storage.interface.js';
|
} from '../../interfaces/storage.interface.js';
|
||||||
import { FormatHandler } from './format-handler.js';
|
import { FormatHandler } from './format-handler.js';
|
||||||
import { FileOperations } from './file-operations.js';
|
import { FileOperations } from './file-operations.js';
|
||||||
@@ -282,156 +281,6 @@ export class FileStorage implements IStorage {
|
|||||||
await this.saveTasks(tasks, tag);
|
await this.saveTasks(tasks, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update task or subtask status by ID - handles file storage logic with parent/subtask relationships
|
|
||||||
*/
|
|
||||||
async updateTaskStatus(
|
|
||||||
taskId: string,
|
|
||||||
newStatus: TaskStatus,
|
|
||||||
tag?: string
|
|
||||||
): Promise<UpdateStatusResult> {
|
|
||||||
const tasks = await this.loadTasks(tag);
|
|
||||||
|
|
||||||
// Check if this is a subtask (contains a dot)
|
|
||||||
if (taskId.includes('.')) {
|
|
||||||
return this.updateSubtaskStatusInFile(tasks, taskId, newStatus, tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle regular task update
|
|
||||||
const taskIndex = tasks.findIndex((t) => String(t.id) === String(taskId));
|
|
||||||
|
|
||||||
if (taskIndex === -1) {
|
|
||||||
throw new Error(`Task ${taskId} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldStatus = tasks[taskIndex].status;
|
|
||||||
if (oldStatus === newStatus) {
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId: String(taskId)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks[taskIndex] = {
|
|
||||||
...tasks[taskIndex],
|
|
||||||
status: newStatus,
|
|
||||||
updatedAt: new Date().toISOString()
|
|
||||||
};
|
|
||||||
|
|
||||||
await this.saveTasks(tasks, tag);
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId: String(taskId)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update subtask status within file storage - handles parent status auto-adjustment
|
|
||||||
*/
|
|
||||||
private async updateSubtaskStatusInFile(
|
|
||||||
tasks: Task[],
|
|
||||||
subtaskId: string,
|
|
||||||
newStatus: TaskStatus,
|
|
||||||
tag?: string
|
|
||||||
): Promise<UpdateStatusResult> {
|
|
||||||
// Parse the subtask ID to get parent ID and subtask ID
|
|
||||||
const parts = subtaskId.split('.');
|
|
||||||
if (parts.length !== 2) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid subtask ID format: ${subtaskId}. Expected format: parentId.subtaskId`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [parentId, subIdRaw] = parts;
|
|
||||||
const subId = subIdRaw.trim();
|
|
||||||
if (!/^\d+$/.test(subId)) {
|
|
||||||
throw new Error(
|
|
||||||
`Invalid subtask ID: ${subId}. Subtask ID must be a positive integer.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const subtaskNumericId = Number(subId);
|
|
||||||
|
|
||||||
// Find the parent task
|
|
||||||
const parentTaskIndex = tasks.findIndex(
|
|
||||||
(t) => String(t.id) === String(parentId)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (parentTaskIndex === -1) {
|
|
||||||
throw new Error(`Parent task ${parentId} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const parentTask = tasks[parentTaskIndex];
|
|
||||||
|
|
||||||
// Find the subtask within the parent task
|
|
||||||
const subtaskIndex = parentTask.subtasks.findIndex(
|
|
||||||
(st) => st.id === subtaskNumericId || String(st.id) === subId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (subtaskIndex === -1) {
|
|
||||||
throw new Error(
|
|
||||||
`Subtask ${subtaskId} not found in parent task ${parentId}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const oldStatus = parentTask.subtasks[subtaskIndex].status || 'pending';
|
|
||||||
if (oldStatus === newStatus) {
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId: subtaskId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = new Date().toISOString();
|
|
||||||
|
|
||||||
// Update the subtask status
|
|
||||||
parentTask.subtasks[subtaskIndex] = {
|
|
||||||
...parentTask.subtasks[subtaskIndex],
|
|
||||||
status: newStatus,
|
|
||||||
updatedAt: now
|
|
||||||
};
|
|
||||||
|
|
||||||
// Auto-adjust parent status based on subtask statuses
|
|
||||||
const subs = parentTask.subtasks;
|
|
||||||
let parentNewStatus = parentTask.status;
|
|
||||||
if (subs.length > 0) {
|
|
||||||
const norm = (s: any) => s.status || 'pending';
|
|
||||||
const isDoneLike = (s: any) => {
|
|
||||||
const st = norm(s);
|
|
||||||
return st === 'done' || st === 'completed';
|
|
||||||
};
|
|
||||||
const allDone = subs.every(isDoneLike);
|
|
||||||
const anyInProgress = subs.some((s) => norm(s) === 'in-progress');
|
|
||||||
const anyDone = subs.some(isDoneLike);
|
|
||||||
if (allDone) parentNewStatus = 'done';
|
|
||||||
else if (anyInProgress || anyDone) parentNewStatus = 'in-progress';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Always bump updatedAt; update status only if changed
|
|
||||||
tasks[parentTaskIndex] = {
|
|
||||||
...parentTask,
|
|
||||||
...(parentNewStatus !== parentTask.status
|
|
||||||
? { status: parentNewStatus }
|
|
||||||
: {}),
|
|
||||||
updatedAt: now
|
|
||||||
};
|
|
||||||
|
|
||||||
await this.saveTasks(tasks, tag);
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
oldStatus,
|
|
||||||
newStatus,
|
|
||||||
taskId: subtaskId
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a task
|
* Delete a task
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user