fix: always replace builtin workflows with canonical definitions

The merge logic was preserving stale persisted versions of builtin
workflows, only overlaying orchestrationMode. This meant edge fixes
(like the handoff loop marking) never reached users who already had
the old version saved.

Builtin workflows are now fully replaced on load so fixes propagate
automatically. Custom (non-builtin) workflows are preserved as-is.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-04-06 23:41:00 +02:00
co-authored by Copilot
parent a68c9ee837
commit 3564df78d3
+1 -17
View File
@@ -41,28 +41,12 @@ import { readJsonFile, writeJsonFile } from '@main/persistence/jsonStore';
function mergeBuiltinWorkflows(existingWorkflows: WorkflowDefinition[]): WorkflowDefinition[] {
const builtinWorkflows = createBuiltinWorkflows(nowIso());
const builtinIds = new Set(builtinWorkflows.map((workflow) => workflow.id));
const existingMap = new Map(existingWorkflows.map((workflow) => [workflow.id, workflow]));
const mergedBuiltins = builtinWorkflows.map((builtin) => {
const existing = existingMap.get(builtin.id);
if (!existing) {
return builtin;
}
return normalizeWorkflowDefinition({
...existing,
settings: {
...existing.settings,
orchestrationMode: builtin.settings.orchestrationMode,
},
});
});
const customWorkflows = existingWorkflows
.filter((workflow) => !builtinIds.has(workflow.id))
.map(normalizeWorkflowDefinition);
return [...mergedBuiltins, ...customWorkflows];
return [...builtinWorkflows, ...customWorkflows];
}
function mergeWorkflowTemplates(existingTemplates: WorkflowTemplateDefinition[]): WorkflowTemplateDefinition[] {