fix: use type-coerced ID matching in FileStorage subtask metadata preservation

Use String(st.id) === String(updatedSubtask.id) instead of strict
equality to handle type mismatches (AI may return string IDs vs numeric).
Also add title-based fallback matching.

Addresses CodeRabbit duplicate comment about FileStorage ID matching.
This commit is contained in:
Cedric Hurst
2026-01-02 17:36:34 -06:00
committed by Ralph Khreish
parent 2a347dae27
commit bcee5b75dd

View File

@@ -380,8 +380,11 @@ export class FileStorage implements IStorage {
let mergedSubtasks = updates.subtasks;
if (updates.subtasks && existingTask.subtasks) {
mergedSubtasks = updates.subtasks.map((updatedSubtask) => {
// Type-coerce IDs for comparison; fall back to title match if IDs don't match
const originalSubtask = existingTask.subtasks?.find(
(st) => st.id === updatedSubtask.id
(st) =>
String(st.id) === String(updatedSubtask.id) ||
(updatedSubtask.title && st.title === updatedSubtask.title)
);
// Preserve original subtask's metadata if it exists
if (originalSubtask?.metadata) {