MCPcopy Create free account
hub / github.com/Roy3838/Observer / handleRunCode

Function handleRunCode

app/src/components/EditAgent/useEditAgentModalLogic.ts:330–365  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

328
329 /* run code */
330 const handleRunCode = async () => {
331 if (isRunningCode || !testResponse) return;
332 setIsRunningCode(true);
333 setTestOutput((p) => 'SYSTEM: executing code...\\n' + p);
334 const buf: string[] = [];
335 const origLog = console.log;
336 console.log = (...a: unknown[]) => {
337 buf.push(a.map(String).join(' '));
338 origLog.apply(console, a);
339 };
340 const listener = (e: LogEntry) =>
341 buf.push(`[${LogLevel[e.level].toUpperCase()}] ${e.message}`);
342 Logger.addListener(listener);
343 try {
344 await postProcess(agentId || 'test-agent', testResponse, agentCode, 'test-iteration');
345 setTestOutput(
346 (p) =>
347 buf.join('\\n') +
348 (buf.length ? '\\n' : '') +
349 'SYSTEM: code finished\\n' +
350 p
351 );
352 } catch (e) {
353 setTestOutput(
354 (p) =>
355 buf.join('\\n') +
356 (buf.length ? '\\n' : '') +
357 `ERROR: ${e instanceof Error ? e.message : String(e)}\\n` +
358 p
359 );
360 } finally {
361 Logger.removeListener(listener);
362 console.log = origLog;
363 setIsRunningCode(false);
364 }
365 };
366
367 /* save agent */
368 const handleSave = () => {

Callers

nothing calls this directly

Calls 5

postProcessFunction · 0.90
pushMethod · 0.80
applyMethod · 0.80
addListenerMethod · 0.45
removeListenerMethod · 0.45

Tested by

no test coverage detected