MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / processAllFiles

Function processAllFiles

yaml-flow-editor/src/App.tsx:1282–1417  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1280 };
1281
1282 const processAllFiles = () => {
1283 if (contents.length === 0) {
1284 console.warn('No valid YAML files found in folder');
1285 return;
1286 }
1287
1288 // Process files asynchronously to avoid blocking UI
1289 const processAsync = () => {
1290 try {
1291 // Parse all files to find main candidate
1292 const parsedList: Array<{ path: string; content: string; parsed: { name?: string; workflow?: unknown[] } | null }> = [];
1293
1294 const parseBatch = (startIndex: number) => {
1295 try {
1296 const endIndex = Math.min(startIndex + BATCH_SIZE, contents.length);
1297 const batch = contents.slice(startIndex, endIndex);
1298
1299 // Parse this batch
1300 batch.forEach((c) => {
1301 try {
1302 parsedList.push({
1303 path: c.path,
1304 content: c.content,
1305 parsed: yamlLib.load(c.content) as { name?: string; workflow?: unknown[] } | null,
1306 });
1307 } catch (e) {
1308 console.warn(`Failed to parse ${c.path}:`, e);
1309 parsedList.push({
1310 path: c.path,
1311 content: c.content,
1312 parsed: null,
1313 });
1314 }
1315 });
1316
1317 // Continue with next batch or finish
1318 if (endIndex < contents.length) {
1319 if (typeof requestIdleCallback !== 'undefined') {
1320 requestIdleCallback(() => parseBatch(endIndex), { timeout: 100 });
1321 } else {
1322 setTimeout(() => parseBatch(endIndex), 0);
1323 }
1324 } else {
1325 // All parsed, now find main candidate and process
1326 findMainAndProcess();
1327 }
1328 } catch (e) {
1329 console.error('Error in parseBatch:', e);
1330 // Still try to process what we have
1331 if (parsedList.length > 0) {
1332 findMainAndProcess();
1333 }
1334 }
1335 };
1336
1337 const findMainAndProcess = () => {
1338 try {
1339 const withWorkflow = parsedList.filter(

Callers 1

readNextBatchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected