From bcee5b75dda1c52e350860b0ec7faf854a5a901b Mon Sep 17 00:00:00 2001 From: Cedric Hurst Date: Fri, 2 Jan 2026 17:36:34 -0600 Subject: [PATCH] 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. --- .../modules/storage/adapters/file-storage/file-storage.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts b/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts index b25abdb6..7bdea0bb 100644 --- a/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts +++ b/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts @@ -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) {