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

Function processModulesBatch

yaml-flow-editor/src/App.tsx:244–288  ·  view source on GitHub ↗
(startIndex: number)

Source from the content-addressed store, hash-verified

242
243 const BATCH_SIZE = 10;
244 const processModulesBatch = (startIndex: number) => {
245 try {
246 const endIndex = Math.min(startIndex + BATCH_SIZE, moduleContents.length);
247 const batch = moduleContents.slice(startIndex, endIndex);
248
249 const newUploaded = batch.map((c) => {
250 try {
251 const template = parseModuleYaml(c.content, c.path);
252 return { path: c.path, content: c.content, template };
253 } catch (e) {
254 console.warn(`Failed to parse module ${c.path}:`, e);
255 return {
256 path: c.path,
257 content: c.content,
258 template: {
259 name: c.path.split('/').pop()?.replace(/\.(yaml|yml)$/i, '') || 'Module',
260 path: c.path,
261 description: 'Failed to parse',
262 goal: '',
263 defaultParams: {},
264 workflow: [],
265 },
266 };
267 }
268 });
269
270 if (newUploaded.length > 0) {
271 setUploadedModules((prev) => {
272 const byPath = new Map(prev.map((m) => [m.path, m]));
273 newUploaded.forEach((u) => byPath.set(u.path, u));
274 return Array.from(byPath.values());
275 });
276 }
277
278 if (endIndex < moduleContents.length) {
279 if (typeof requestIdleCallback !== 'undefined') {
280 requestIdleCallback(() => processModulesBatch(endIndex), { timeout: 50 });
281 } else {
282 setTimeout(() => processModulesBatch(endIndex), 10);
283 }
284 }
285 } catch (e) {
286 console.error('Error in processModulesBatch:', e);
287 }
288 };
289
290 setTimeout(() => {
291 try {

Callers 1

App.tsxFile · 0.85

Calls 1

parseModuleYamlFunction · 0.90

Tested by

no test coverage detected