fix: normalize task IDs to numbers on load to fix comparison issues
- Added normalizeTaskIds function to convert string IDs to numbers - Applied normalization in readJSON for all code paths - Fixed set-task-status, add-task, and move-task to normalize IDs when working with raw data - Exported normalizeTaskIds function for use in other modules - Added test case for string ID normalization 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed by
Ralph Khreish
parent
077cbb99de
commit
ef23beac0d
@@ -22,7 +22,8 @@ import {
|
||||
truncate,
|
||||
ensureTagMetadata,
|
||||
performCompleteTagMigration,
|
||||
markMigrationForNotice
|
||||
markMigrationForNotice,
|
||||
normalizeTaskIds
|
||||
} from '../utils.js';
|
||||
import { generateObjectService } from '../ai-services-unified.js';
|
||||
import { getDefaultPriority } from '../config-manager.js';
|
||||
@@ -69,6 +70,7 @@ function getAllTasks(rawData) {
|
||||
rawData[tagName] &&
|
||||
Array.isArray(rawData[tagName].tasks)
|
||||
) {
|
||||
normalizeTaskIds(rawData[tagName].tasks);
|
||||
allTasks = allTasks.concat(rawData[tagName].tasks);
|
||||
}
|
||||
}
|
||||
@@ -306,6 +308,8 @@ async function addTask(
|
||||
|
||||
// Find the highest task ID *within the target tag* to determine the next ID
|
||||
const tasksInTargetTag = rawData[targetTag].tasks;
|
||||
|
||||
normalizeTaskIds(tasksInTargetTag);
|
||||
const highestId =
|
||||
tasksInTargetTag.length > 0
|
||||
? Math.max(...tasksInTargetTag.map((t) => t.id))
|
||||
|
||||
Reference in New Issue
Block a user