Skip to content

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

fix(evals): make evaluation prompt read-only in view-only template mode (#13047) (#13137)

marliessophiec091da7c3d56
diff --git a/web/src/components/editor/CodeMirrorEditor.tsx b/web/src/components/editor/CodeMirrorEditor.tsx
index 87b46a0cec..44b11e6479 100644
--- a/web/src/components/editor/CodeMirrorEditor.tsx
+++ b/web/src/components/editor/CodeMirrorEditor.tsx
@@ -6,7 +6,12 @@ import CodeMirror, {
ViewPlugin,
type ViewUpdate,
} from "@uiw/react-codemirror";
-import { RangeSetBuilder, StateEffect, StateField } from "@codemirror/state";
+import {
+ EditorState,
+ RangeSetBuilder,
+ StateEffect,
+ StateField,
+} from "@codemirror/state";
import { SearchQuery, search, setSearchQuery } from "@codemirror/search";
import { json, jsonParseLinter } from "@codemirror/lang-json";
import { linter, type Diagnostic } from "@codemirror/lint";
@@ -428,6 +433,10 @@ export function CodeMirrorEditor({
}}
lang={mode === "json" ? "json" : undefined}
extensions={[
+ // Block document changes (including paste) when not editable; the
+ // `editable` DOM facet alone does not always prevent paste (see CM6
+ // EditorState.readOnly vs EditorView.editable).
+ ...(!editable ? [EditorState.readOnly.of(true)] : []),
searchHighlightingSupport,
search(),
// RTL/bidi support - must be early for proper line decoration