Skip to content

Commit 338edcb

Browse files
committed
feat(workflows): add track and conditions filtering for workflow steps
Filter workflow steps based on selected track and conditions to customize execution
1 parent 0e64cb2 commit 338edcb

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/workflows/execution/run.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { debug, setDebugLogFile } from '../../shared/logging/logger.js';
1515
import {
1616
getTemplatePathFromTracking,
1717
getResumeStartIndex,
18+
getSelectedTrack,
19+
getSelectedConditions,
1820
} from '../../shared/workflows/index.js';
1921
import { registry } from '../../infra/engines/index.js';
2022
import { MonitoringCleanup } from '../../agents/monitoring/index.js';
@@ -98,15 +100,30 @@ export async function runWorkflow(options: RunWorkflowOptions = {}): Promise<voi
98100
// Get start index
99101
const startIndex = await getResumeStartIndex(cmRoot);
100102

103+
// Load track and conditions selections
104+
const selectedTrack = await getSelectedTrack(cmRoot);
105+
const selectedConditions = await getSelectedConditions(cmRoot);
106+
107+
// Filter steps by track and conditions
108+
const visibleSteps = template.steps.filter(step => {
109+
if (step.type !== 'module') return true;
110+
if (step.tracks?.length && selectedTrack && !step.tracks.includes(selectedTrack)) return false;
111+
if (step.conditions?.length) {
112+
const missing = step.conditions.filter(c => !(selectedConditions ?? []).includes(c));
113+
if (missing.length > 0) return false;
114+
}
115+
return true;
116+
});
117+
101118
// Count module steps for total
102-
const moduleSteps = template.steps.filter(s => s.type === 'module');
119+
const moduleSteps = visibleSteps.filter(s => s.type === 'module');
103120

104121
// Emit workflow started
105122
emitter.workflowStarted(template.name, moduleSteps.length);
106123

107124
// Pre-populate timeline
108125
let moduleIndex = 0;
109-
template.steps.forEach((step, stepIndex) => {
126+
visibleSteps.forEach((step, stepIndex) => {
110127
if (step.type === 'module') {
111128
const defaultEngine = registry.getDefault();
112129
const engineType = step.engine ?? defaultEngine?.metadata.id ?? 'unknown';
@@ -131,7 +148,7 @@ export async function runWorkflow(options: RunWorkflowOptions = {}): Promise<voi
131148
const runner = new WorkflowRunner({
132149
cwd,
133150
cmRoot,
134-
template,
151+
template: { ...template, steps: visibleSteps },
135152
emitter,
136153
startIndex,
137154
});

0 commit comments

Comments
 (0)