fix(tasks): Ensure new task IDs are sequential within the target tag
Modified the ID generation logic in 'add-task.js' to calculate the next task ID based on the highest ID within the specified tag, rather than globally across all tags. This fixes a critical bug where creating a task in a new tag would result in a high, non-sequential ID, such as ID 105 for the first task in a tag.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"currentTag": "master",
|
||||
"lastSwitched": "2025-06-12T05:28:34.147Z",
|
||||
"currentTag": "gezo",
|
||||
"lastSwitched": "2025-06-13T04:23:16.760Z",
|
||||
"branchTagMapping": {},
|
||||
"migrationNoticeShown": true
|
||||
}
|
||||
@@ -6733,5 +6733,25 @@
|
||||
"updated": "2025-06-13T04:12:48.834Z",
|
||||
"description": "Tasks for master context"
|
||||
}
|
||||
},
|
||||
"gezo": {
|
||||
"tasks": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "Implement Cross-Tag Testing Framework",
|
||||
"description": "Create a testing framework that can execute and validate tasks across different tags or environments to ensure consistent behavior and compatibility.",
|
||||
"details": "Develop a comprehensive testing system that can handle task execution across multiple tags/environments. This includes: 1) Creating a tag-aware test runner that can identify and categorize tasks by their associated tags, 2) Implementing test isolation mechanisms to prevent cross-contamination between different tagged environments, 3) Building configuration management to handle different settings per tag (development, staging, production, feature branches), 4) Creating test data management strategies that work across tags, 5) Implementing result comparison and validation logic to ensure tasks behave consistently across different tags, 6) Adding logging and reporting capabilities to track test execution across tags, 7) Creating utilities for setup and teardown of tag-specific test environments, and 8) Implementing parallel execution capabilities to run tests across multiple tags simultaneously while maintaining isolation.",
|
||||
"testStrategy": "Verify the framework by: 1) Creating sample tasks with different tags and confirming they execute in isolation, 2) Testing configuration switching between tags and validating environment-specific settings are applied correctly, 3) Running identical test suites across multiple tags and comparing results for consistency, 4) Verifying parallel execution works without interference between tagged environments, 5) Testing error handling and cleanup when tests fail in specific tag contexts, 6) Validating logging captures tag-specific information correctly, 7) Confirming test data isolation prevents data leakage between tags, and 8) Performance testing to ensure the overhead of tag management doesn't significantly impact test execution time.",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "medium",
|
||||
"subtasks": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"created": "2025-06-13T04:19:20.029Z",
|
||||
"updated": "2025-06-13T04:25:03.833Z",
|
||||
"description": "Tag created on 6/13/2025"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,20 +265,27 @@ async function addTask(
|
||||
throw new Error(`Tag "${targetTag}" not found.`);
|
||||
}
|
||||
|
||||
// Ensure the target tag has a metadata object
|
||||
// Ensure the target tag has a tasks array and metadata object
|
||||
if (!rawData[targetTag].tasks) {
|
||||
rawData[targetTag].tasks = [];
|
||||
}
|
||||
if (!rawData[targetTag].metadata) {
|
||||
rawData[targetTag].metadata = {
|
||||
created: new Date().toISOString(),
|
||||
updated: new Date().toISOString(),
|
||||
description: ``
|
||||
};
|
||||
}
|
||||
|
||||
// Get a flat list of ALL tasks across ALL tags to calculate new ID and validate dependencies
|
||||
// Get a flat list of ALL tasks across ALL tags to validate dependencies
|
||||
const allTasks = getAllTasks(rawData);
|
||||
|
||||
// Find the highest task ID across all tags to determine the next ID
|
||||
// Find the highest task ID *within the target tag* to determine the next ID
|
||||
const tasksInTargetTag = rawData[targetTag].tasks;
|
||||
const highestId =
|
||||
allTasks.length > 0 ? Math.max(...allTasks.map((t) => t.id)) : 0;
|
||||
tasksInTargetTag.length > 0
|
||||
? Math.max(...tasksInTargetTag.map((t) => t.id))
|
||||
: 0;
|
||||
const newTaskId = highestId + 1;
|
||||
|
||||
// Only show UI box for CLI mode
|
||||
|
||||
@@ -650,18 +650,18 @@ async function tags(
|
||||
table.push(row);
|
||||
});
|
||||
|
||||
console.log(
|
||||
boxen(
|
||||
chalk.white.bold('Available Tags') +
|
||||
`\n\nCurrent Tag: ${chalk.green.bold(currentTag)}`,
|
||||
{
|
||||
padding: { top: 0, bottom: 1, left: 1, right: 1 },
|
||||
borderColor: 'blue',
|
||||
borderStyle: 'round',
|
||||
margin: { top: 1, bottom: 0 }
|
||||
}
|
||||
)
|
||||
);
|
||||
// console.log(
|
||||
// boxen(
|
||||
// chalk.white.bold('Available Tags') +
|
||||
// `\n\nCurrent Tag: ${chalk.green.bold(currentTag)}`,
|
||||
// {
|
||||
// padding: { top: 0, bottom: 1, left: 1, right: 1 },
|
||||
// borderColor: 'blue',
|
||||
// borderStyle: 'round',
|
||||
// margin: { top: 1, bottom: 0 }
|
||||
// }
|
||||
// )
|
||||
// );
|
||||
|
||||
console.log(table.toString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user