diff --git a/src/main/workers/team-fs-worker.ts b/src/main/workers/team-fs-worker.ts index d7ad69b4..5e4571d0 100644 --- a/src/main/workers/team-fs-worker.ts +++ b/src/main/workers/team-fs-worker.ts @@ -774,9 +774,9 @@ function restorePersistentTaskProjectionShape( owner: typeof task.owner === 'string' ? task.owner : undefined, createdBy: typeof task.createdBy === 'string' ? task.createdBy : undefined, status, - workIntervals: Array.isArray(task.workIntervals) ? task.workIntervals : undefined, - reviewIntervals: Array.isArray(task.reviewIntervals) ? task.reviewIntervals : undefined, - historyEvents: Array.isArray(task.historyEvents) ? task.historyEvents : undefined, + workIntervals: normalizeWorkIntervals(task), + reviewIntervals: normalizeReviewIntervals(task), + historyEvents: normalizeHistoryEvents(task), blocks: Array.isArray(task.blocks) ? task.blocks : undefined, blockedBy: Array.isArray(task.blockedBy) ? task.blockedBy : undefined, related: Array.isArray(task.related) @@ -785,7 +785,7 @@ function restorePersistentTaskProjectionShape( createdAt: typeof task.createdAt === 'string' ? task.createdAt : undefined, updatedAt: typeof task.updatedAt === 'string' ? task.updatedAt : undefined, projectPath: typeof task.projectPath === 'string' ? task.projectPath : undefined, - comments: Array.isArray(task.comments) ? task.comments : undefined, + comments: normalizeComments(task), needsClarification: task.needsClarification === 'lead' || task.needsClarification === 'user' ? task.needsClarification diff --git a/test/main/services/team/TeamFsWorker.integration.test.ts b/test/main/services/team/TeamFsWorker.integration.test.ts index 9655d0ae..47b065ce 100644 --- a/test/main/services/team/TeamFsWorker.integration.test.ts +++ b/test/main/services/team/TeamFsWorker.integration.test.ts @@ -593,15 +593,27 @@ describe('team-fs-worker integration', () => { subject: 'Persisted subject', status: 'pending', createdAt: '2026-05-02T12:00:00.000Z', + workIntervals: [{ startedAt: '2026-05-02T12:00:00.000Z' }], + reviewIntervals: [{ reviewer: 'alice', startedAt: '2026-05-02T12:30:00.000Z' }], + comments: [ + { + id: 'comment-1', + author: 'alice', + text: 'Looks good', + createdAt: '2026-05-02T12:45:00.000Z', + }, + ], }), 'utf8' ); const firstWorker = createWorker(workerPath); + let firstTasks: unknown[] = []; let firstTaskKeys: string[] = []; try { const first = await callGetAllTasks(firstWorker, tasksBase, projectionCacheBase); expect(first.tasks[0]).toMatchObject({ teamName, subject: 'Persisted subject' }); + firstTasks = first.tasks; firstTaskKeys = Object.keys(first.tasks[0] as Record); expect(first.diag?.cacheMisses).toBe(1); expect(first.diag?.persistentCacheWrites).toBe(1); @@ -616,6 +628,7 @@ describe('team-fs-worker integration', () => { expect(Object.keys(second.tasks[0] as Record)).toEqual( firstTaskKeys ); + expect(second.tasks).toEqual(firstTasks); expect(second.diag?.cacheHits).toBe(0); expect(second.diag?.cacheMisses).toBe(0); expect(second.diag?.persistentCacheLoads).toBe(1);