Skip to content

[#4638] fix(frontend): Preserve string type when view mode is Text#4658

Closed
IshaanAggrawal wants to merge 1 commit into
Agenta-AI:mainfrom
IshaanAggrawal:fix/4638-text-mode-no-type-coercion
Closed

[#4638] fix(frontend): Preserve string type when view mode is Text#4658
IshaanAggrawal wants to merge 1 commit into
Agenta-AI:mainfrom
IshaanAggrawal:fix/4638-text-mode-no-type-coercion

Conversation

@IshaanAggrawal

@IshaanAggrawal IshaanAggrawal commented Jun 12, 2026

Copy link
Copy Markdown

Summary

What changed: TextEditor now respects the active viewMode. When the user explicitly selects "Text" or "Markdown" from the dropdown, it passes the raw string through without coercion.
Why was this change needed: Typing values like False or 5 in Text mode was incorrectly mutating the variable type.
What problem does it solve: Fixes an issue in the playground test case drawer where type chips would improperly update to boolean or number when the user intended for them to stay as strings.
Root cause: TextEditor.handleChange in TestcaseDrillInFieldRenderer.tsx was unconditionally calling inferPrimitiveFromText() on every keystroke, regardless of the view mode. Fixes #4638

Verified locally

  • Verified that with viewMode === "text" and viewMode === "markdown", all inputs (e.g. False, 5, true) remain strings.
  • Verified that with no explicit view mode (the fallback), auto-coercion still works correctly (e.g., false becomes boolean, 5 becomes number).
  • Ran a standalone test script confirming the guard logic works for text, markdown, and fallback modes.

##Demo
image

QA follow-up

  • Open the playground test case drawer, set a field selector to Text, and type False. The type chip should stay string and the stored value should be "False".
  • Do the same for 5, true, 0. All should remain strings.
  • Switch the selector to JSON, type false. The type chip should update to boolean.
  • Switch to YAML, type 5. The type chip should update to number.
  • Regression: open a testcase with no explicit view mode set (the fallback). Typing false or 5 should still auto-detect as boolean/number.

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

@IshaanAggrawal is attempting to deploy a commit to the agenta projects Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Jun 12, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 12, 2026
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

✅ Thanks @IshaanAggrawal! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon.

@dosubot dosubot Bot added bug Something isn't working Frontend labels Jun 12, 2026
@github-actions github-actions Bot added the incomplete-pr PR is missing required template sections or a demo recording label Jun 12, 2026
@github-actions github-actions Bot closed this Jun 12, 2026
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c98ee95-866c-4d2a-84c2-a112cc628a9d

📥 Commits

Reviewing files that changed from the base of the PR and between e343953 and f96576e.

📒 Files selected for processing (1)
  • web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • The test case editor now preserves raw text in text and markdown modes, forwarding exactly what you type without automatic type inference or coercion. Edits are kept unchanged when applied, preventing unexpected conversions and ensuring entered content appears and is saved exactly as entered.

Walkthrough

Removed primitive inference: inferPrimitiveFromText import deleted. TextEditor now forwards the raw edited string to onChange and its value parameter was renamed to reflect direct string handling.

Changes

TextEditor primitive inference removal

Layer / File(s) Summary
Remove inferPrimitiveFromText and forward raw string
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx
Deleted inferPrimitiveFromText import; adjusted TextEditor's value parameter name; updated handleChange to call onChange with the raw string instead of inferring/coercing a primitive.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 60.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: preserving string type when view mode is Text, which directly addresses the core issue being fixed.
Description check ✅ Passed The description thoroughly explains what changed, why it was needed, the root cause, and includes verification steps and QA procedures, all aligned with the changeset.
Linked Issues check ✅ Passed The PR directly addresses issue #4638 by removing type inference in Text mode and preserving raw string values, which matches the requirement that Text inputs should remain strings.
Out of Scope Changes check ✅ Passed All changes are scoped to TestcaseDrillInFieldRenderer.tsx and directly address the type coercion issue in Text/Markdown view modes without introducing unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot removed the incomplete-pr PR is missing required template sections or a demo recording label Jun 12, 2026
@github-actions github-actions Bot reopened this Jun 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx (1)

251-260: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Markdown path misses viewMode propagation, so coercion still occurs.

On Line 253, TextEditor is rendered for markdown mode, but viewMode is not passed. Because handleChange (Lines 129-135) only preserves raw strings when viewMode === "text" || viewMode === "markdown", this branch still runs inferPrimitiveFromText, breaking the markdown requirement.

Suggested fix
     if (viewMode === "markdown") {
         return (
             <TextEditor
                 editorId={editorId}
                 value={value}
                 displayValue={displayValue}
                 markdown
                 onChange={onChange}
                 readOnly={!editable}
+                viewMode={viewMode}
             />
         )
     }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f4df9985-b966-4384-91eb-bdd9cd947f9e

📥 Commits

Reviewing files that changed from the base of the PR and between a2e9150 and 202c160.

📒 Files selected for processing (1)
  • web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx

@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch from 01b7a58 to e343953 Compare June 12, 2026 08:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx (1)

223-227: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Inline comment no longer matches implementation.

This block says native typing is preserved via inferPrimitiveFromText in TextEditor.handleChange, but that path was removed. Please update/remove the comment to avoid future misreads.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 730b35dd-536e-4346-bf01-7500f8253148

📥 Commits

Reviewing files that changed from the base of the PR and between 202c160 and 01b7a58.

📒 Files selected for processing (1)
  • web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx

Comment on lines 125 to 128
const handleChange = useCallback(
(next: string) => onChange(inferPrimitiveFromText(next)),
(next: string) => onChange(next),
[onChange],
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Fallback coercion behavior was unintentionally removed.

handleChange now always emits strings, which breaks the documented fallback behavior when viewMode is unset (auto-coercion should still occur). This changes runtime behavior beyond text/markdown and can regress type chips/state for default mode.

Suggested fix
-import {parseCodeString, toCodeString} from "./codeFormat"
+import {inferPrimitiveFromText, parseCodeString, toCodeString} from "./codeFormat"
...
-    const handleChange = useCallback(
-        (next: string) => onChange(next),
-        [onChange],
-    )
+    const handleChange = useCallback(
+        (next: string) => {
+            const preserveAsString = viewMode === "text" || viewMode === "markdown"
+            onChange(preserveAsString ? next : inferPrimitiveFromText(next))
+        },
+        [onChange, viewMode],
+    )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const handleChange = useCallback(
(next: string) => onChange(inferPrimitiveFromText(next)),
(next: string) => onChange(next),
[onChange],
)
const handleChange = useCallback(
(next: string) => {
const preserveAsString = viewMode === "text" || viewMode === "markdown"
onChange(preserveAsString ? next : inferPrimitiveFromText(next))
},
[onChange, viewMode],
)

@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch from e343953 to f96576e Compare June 12, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Frontend size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text inputs in test case drawer auto-switch type

2 participants