Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(evals): prevent code evaluator editor update loop (#16325)

cursor[bot]b6722c5b9cbd
diff --git a/web/src/features/evals/components/code-eval-template-form-body.tsx b/web/src/features/evals/components/code-eval-template-form-body.tsx
index ef98a59088..7df971301a 100644
--- a/web/src/features/evals/components/code-eval-template-form-body.tsx
+++ b/web/src/features/evals/components/code-eval-template-form-body.tsx
@@ -258,6 +258,12 @@ export function CodeEvalTemplateFormBody({
sourceCodeRef.current = sourceCode;
});
const handleSourceCodeChange = useCallback((value: string) => {
+ // CodeMirror's MutationObserver can echo the current document back through
+ // onChange while React is already committing the same value. Pushing that
+ // echo into form state nests setState until React hits max update depth.
+ if (value === sourceCodeRef.current) {
+ return;
+ }
sourceCodeRef.current = value;
onSourceCodeChangeRef.current(value);
}, []);