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

Function handleRunCode

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

Source from the content-addressed store, hash-verified

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