Skip to content

Commit

Permalink
Correctly select workflow on first selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuettlerTNG committed Dec 19, 2024
1 parent 23959a0 commit 469f4cc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions WebUI/src/assets/js/store/imageGeneration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type ComfyUIApiWorkflow = z.infer<typeof ComfyUIApiWorkflowSchema>;

const DefaultWorkflowSchema = z.object({
name: z.string(),
displayPriority: z.number().optional(),
backend: z.literal('default'),
tags: z.array(z.string()),
requiredModels: z.array(RequiredModelSchema).optional(),
Expand Down Expand Up @@ -468,9 +469,10 @@ export const useImageGeneration = defineStore("imageGeneration", () => {
return activeWorkflow.value.backend;
},
set(newValue) {
activeWorkflowName.value = workflows.value
const sortedWorkflowsForBackend = workflows.value
.filter(w => w.backend === newValue)
.find(w => w.name === lastWorkflowPerBackend.value[newValue])?.name ?? workflows.value.find(w => w.backend === newValue)?.name ?? activeWorkflowName.value;
.sort((a, b) => (b.displayPriority ?? 0) - (a.displayPriority ?? 0))
activeWorkflowName.value = sortedWorkflowsForBackend.find(w => w.name === lastWorkflowPerBackend.value[newValue])?.name ?? sortedWorkflowsForBackend[0]?.name ?? activeWorkflowName.value;
}
});
const lastWorkflowPerBackend = ref<Record<Workflow['backend'], string | null>>({
Expand Down

0 comments on commit 469f4cc

Please sign in to comment.