chore: apply requested changes
This commit is contained in:
@@ -392,12 +392,29 @@ Ensure the JSON is valid and properly formatted.`;
|
||||
0
|
||||
);
|
||||
let nextId = maxPreservedId + 1;
|
||||
const normalizedGeneratedSubtasks = processedGeneratedSubtasks.map(
|
||||
(st) => ({
|
||||
...st,
|
||||
id: nextId++
|
||||
const idMapping = new Map();
|
||||
const normalizedGeneratedSubtasks = processedGeneratedSubtasks
|
||||
.map((st) => {
|
||||
const originalId = st.id;
|
||||
const newId = nextId++;
|
||||
idMapping.set(originalId, newId);
|
||||
return {
|
||||
...st,
|
||||
id: newId
|
||||
};
|
||||
})
|
||||
);
|
||||
.map((st) => ({
|
||||
...st,
|
||||
dependencies: (st.dependencies || []).map((dep) => {
|
||||
if (typeof dep !== 'string' || !dep.startsWith(`${task.id}.`)) {
|
||||
return dep;
|
||||
}
|
||||
const [, siblingIdPart] = dep.split('.');
|
||||
const originalSiblingId = Number.parseInt(siblingIdPart, 10);
|
||||
const remappedSiblingId = idMapping.get(originalSiblingId);
|
||||
return remappedSiblingId ? `${task.id}.${remappedSiblingId}` : dep;
|
||||
})
|
||||
}));
|
||||
|
||||
// Update task with preserved subtasks + newly generated ones
|
||||
task.subtasks = [...preservedSubtasks, ...normalizedGeneratedSubtasks];
|
||||
@@ -406,7 +423,7 @@ Ensure the JSON is valid and properly formatted.`;
|
||||
updatedTask: task,
|
||||
regenerated: true,
|
||||
preserved: preservedSubtasks.length,
|
||||
generated: processedGeneratedSubtasks.length
|
||||
generated: normalizedGeneratedSubtasks.length
|
||||
};
|
||||
} catch (error) {
|
||||
log(
|
||||
|
||||
Reference in New Issue
Block a user