diff --git a/apps/server/src/handlers/task/task.create_project.handler.ts b/apps/server/src/handlers/task/task.create_project.handler.ts index 585e83c..9e39853 100644 --- a/apps/server/src/handlers/task/task.create_project.handler.ts +++ b/apps/server/src/handlers/task/task.create_project.handler.ts @@ -194,13 +194,16 @@ export class TaskCreateProjectHandler { const createdTaskIds: string[] = []; const subtaskMapping: Record = {}; // Map subtask IDs to task IDs + // Calculate cascading priorities with -5 decrement + let currentPriority = input.priority - 5; // Start 5 below parent task + // First pass: Create all tasks and build mapping for (const subtask of decomposeResult.decomposition.subtasks) { try { - // Create a task for each subtask (dependencies will be updated later) + // Create a task for each subtask with cascading priority const subtaskResult = await registry.executeHandler("task.create", { text: subtask.description, - priority: Math.max(10, input.priority - 10), // Slightly lower priority than parent + priority: Math.max(5, currentPriority), // Ensure minimum priority of 5 metadata: { type: "subtask", projectId: projectId, @@ -218,6 +221,9 @@ export class TaskCreateProjectHandler { createdTaskIds.push(subtaskResult.id); subtaskMapping[subtask.id] = subtaskResult.id; + // Decrement priority for next task + currentPriority -= 5; + // Store subtask context as attachment await registry.executeHandler("task.create_attachment", { taskId: subtaskResult.id,