From 1ae873949db6eda60da8bbd6e88156e32206641f Mon Sep 17 00:00:00 2001 From: NamHT4Devlop Date: Mon, 15 Jun 2026 19:12:50 +0700 Subject: [PATCH] fix: preserve string type when Text/Markdown view mode is selected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the view mode selector is set to Text or Markdown, values like 'False' or '42' should remain stored as strings. Type coercion (inferPrimitiveFromText) should only happen in the fallback case where no view mode is explicitly chosen — not when the user has deliberately picked a textual view. Adds noTypeInference prop to TextEditor and passes it for viewMode === 'text' and viewMode === 'markdown'. JSON and YAML modes already perform their own structured parsing through CodeEditor and are unaffected. Closes #4638 --- .../src/testcase/TestcaseDrillInFieldRenderer.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx b/web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx index ed7a6144f1..60671bb2b1 100644 --- a/web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx +++ b/web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx @@ -111,6 +111,7 @@ function TextEditor({ markdown, onChange, readOnly, + noTypeInference, }: { editorId: string value: unknown @@ -118,14 +119,19 @@ function TextEditor({ markdown?: boolean onChange: (value: unknown) => void readOnly?: boolean + noTypeInference?: boolean }) { // Auto-infer native types from typed text so number / boolean values // stop getting stored as strings. Anything that doesn't look exactly // like a clean number or boolean literal stays a string — see // inferPrimitiveFromText for the precise rules. + // + // When noTypeInference is true (Text or Markdown view mode), skip + // inference and store the raw string — the user explicitly chose a text + // view so values like "False" or "42" should remain strings. const handleChange = useCallback( - (next: string) => onChange(inferPrimitiveFromText(next)), - [onChange], + (next: string) => onChange(noTypeInference ? next : inferPrimitiveFromText(next)), + [onChange, noTypeInference], ) return ( @@ -250,6 +256,7 @@ export function TestcaseDrillInFieldRenderer({ markdown onChange={onChange} readOnly={!editable} + noTypeInference /> ) } @@ -262,6 +269,7 @@ export function TestcaseDrillInFieldRenderer({ displayValue={displayValue} onChange={onChange} readOnly={!editable} + noTypeInference /> ) }