fix(FN-743): prevent duplicate comments from steeringComments merge in rowToTask

- Stop merging steeringComments into comments array in rowToTask to prevent duplication
- Add regression tests verifying comments and steeringComments remain separate
- Add changeset for the comments deduplication fix
This commit is contained in:
gsxdsm
2026-04-02 20:17:01 -07:00
parent dacd074700
commit 4d46b99460
3 changed files with 81 additions and 5 deletions

View File

@@ -193,11 +193,17 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
return sc && sc.length > 0 ? sc : undefined;
})(),
comments: (() => {
// Merge legacy steeringComments and comments into unified comments field
const legacySteering = fromJson<Array<{ id: string; text: string; createdAt: string; author: string }>>(row.steeringComments) || [];
const regularComments = fromJson<import("./types.js").TaskComment[]>(row.comments) || [];
const merged = [...legacySteering, ...regularComments];
return merged.length > 0 ? merged : undefined;
// Comments column already contains steering comments (addSteeringComment calls addComment).
// Do NOT merge steeringComments here — that caused duplication on every read-write cycle.
const c = fromJson<import("./types.js").TaskComment[]>(row.comments) || [];
// Deduplicate by id to recover from prior corruption
const seen = new Set<string>();
const deduped = c.filter(entry => {
if (seen.has(entry.id)) return false;
seen.add(entry.id);
return true;
});
return deduped.length > 0 ? deduped : undefined;
})(),
workflowStepResults: (() => { const w = fromJson<import("./types.js").WorkflowStepResult[]>(row.workflowStepResults); return w && w.length > 0 ? w : undefined; })(),
prInfo: fromJson<import("./types.js").PrInfo>(row.prInfo),