Skip to content

4638 fix(frontend): disable auto-coercion in text editor#4659

Open
IshaanAggrawal wants to merge 2 commits into
Agenta-AI:mainfrom
IshaanAggrawal:fix/4638-text-mode-no-type-coercion
Open

4638 fix(frontend): disable auto-coercion in text editor#4659
IshaanAggrawal wants to merge 2 commits 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: Removed auto-coercion from the TextEditor components in both the Testcase Drawer and the Playground variable cards. They now strictly pass raw strings without attempting to infer primitives.
Why was this change needed: Typing values like False or 5 while the selector was set to Text mode was incorrectly mutating the underlying variable type to boolean or number.
What problem does it solve: Fixes an issue in both the playground cards and the test case drawer where type chips would improperly update when the user intended for inputs to remain as plain strings.
Root cause: The text handlers in TestcaseDrillInFieldRenderer.tsx and VariableCard.tsx were using inferPrimitiveFromText() and coerceTextEdit() for default view modes, causing intended strings to auto-coerce.

Fixes #4638

Verified locally

  • Verified that all inputs (e.g. False, 5, true) remain strings when using the Text or Markdown view modes across both the Drawer and the Playground Cards.
  • Confirmed that type coercion (to boolean or number) still works perfectly when explicitly editing raw data in JSON or YAML modes.
  • Verified unused imports (inferPrimitiveFromText and coerceTextEdit) were cleaned up in TestcaseDrillInFieldRenderer.tsx and VariableCard.tsx.

Demo

Screen.Recording.2026-06-15.132631.mp4

QA follow-up

  • Open the playground test case drawer (or a playground variable card), 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.

@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.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

TestcaseDrillInFieldRenderer now coerces text edits using coerceTextEdit(inferLogicalType(value)); VariableCard's TextLeafEditor forwards raw text strings to onChange without coercion. Imports, comments, and callback dependency lists were updated accordingly.

Changes

Text edit coercion changes

Layer / File(s) Summary
Testcase: use coerceTextEdit with existing field type
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx
Replace inferPrimitiveFromText import with coerceTextEdit and inferLogicalType; destructure props to use value; update TextEditor.handleChange to call onChange(coerceTextEdit(next, inferLogicalType(value))) and include value in hook dependencies.
Playground VariableCard: forward raw text edits
web/packages/agenta-playground-ui/src/components/PlaygroundInputsBody/VariableCard.tsx
TextLeafEditor.handleChange stops coercing the editor string and instead updates local buffer and calls onChange(next) with the raw string; comments and useCallback deps were updated.

🎯 3 (Moderate) | ⏱️ ~20 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 accurately and concisely describes the main change: disabling auto-coercion in text editor components.
Linked Issues check ✅ Passed The changes fully address issue #4638 by removing auto-coercion from TextEditor components, ensuring Text/Markdown modes preserve strings while JSON/YAML modes still perform type coercion.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the auto-coercion issue in TestcaseDrillInFieldRenderer and VariableCard components, with no unrelated modifications.
Description check ✅ Passed The pull request description clearly relates to the changeset by explaining the specific changes (removing auto-coercion from TextEditor components), the issue being fixed (type chips improperly updating), and the files modified.

✏️ 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.

@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

🧹 Nitpick comments (1)
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx (1)

223-225: ⚡ Quick win

Update stale comment to match the new non-coercing behavior (Lines 223-225).

This comment says native type is preserved via inferPrimitiveFromText in TextEditor.handleChange, but that path was removed in this PR. Keeping this comment is misleading for future edits.

Proposed fix
-    // primitive values through TextEditor so the editor doesn't swap mid-typing.
-    // The native type is still preserved via inferPrimitiveFromText in
-    // TextEditor.handleChange, so the type chip stays accurate. Uncomment the
+    // primitive values through TextEditor so the editor doesn't swap mid-typing.
+    // Text/Markdown editors intentionally emit raw strings; native type coercion
+    // is only applied in explicit JSON/YAML code modes. Uncomment the

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ef79dad0-f0c4-4915-a3e3-0374f6af094d

📥 Commits

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

📒 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 f96576e to 65e1348 Compare June 12, 2026 09:39
@IshaanAggrawal IshaanAggrawal marked this pull request as ready for review June 12, 2026 10:37
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working Frontend labels Jun 12, 2026
@mmabrouk mmabrouk requested a review from ardaerzin June 12, 2026 10:46

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CleanShot.2026-06-12.at.13.49.18.mp4

I have tried this locally and it's quite flacky. Is it the same for you?

@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-playground-ui/src/components/PlaygroundInputsBody/VariableCard.tsx (1)

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

Remove unused import coerceTextEdit.

The coerceTextEdit function is imported but no longer used after removing the coercion logic from the TextLeafEditor.handleChange callback. Please remove this import for consistency with the cleanup performed in TestcaseDrillInFieldRenderer.tsx.

🧹 Proposed fix
 import {
     FormView,
     ViewTypeSelect,
     buildEmptyShapeFromSchema,
-    coerceTextEdit,
     inferLogicalType,
     isChatMessagesArray,
     parseJsonEdit,

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 578ce354-fdf1-4353-bd6c-70fc0cffa954

📥 Commits

Reviewing files that changed from the base of the PR and between 65e1348 and 11e3010.

📒 Files selected for processing (1)
  • web/packages/agenta-playground-ui/src/components/PlaygroundInputsBody/VariableCard.tsx

@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.

@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
@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
@IshaanAggrawal

IshaanAggrawal commented Jun 12, 2026

Copy link
Copy Markdown
Author

@mmabrouk Please check i have update the video

@IshaanAggrawal IshaanAggrawal requested a review from mmabrouk June 12, 2026 16:10

@mmabrouk mmabrouk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The behavior here is wrong. The rule is simple:

  1. If the mode is text or markdown -> we cannot change the type in this view. If it's 5 and a string, it will stay always a string,
  2. If the mode is json or yaml -> the type of the field can change according to what is edited in json. Meaning a string "true" after being edited to true will become a bool, and a number 5 after being edit to "5" will become a string
  3. Number and bools can only be seen as json or yaml. You don't have a text/markdown view for these.

@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch 2 times, most recently from 412c6e1 to e58d1c3 Compare June 13, 2026 06:50

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 964c1158-03f4-4217-be1d-852a329e6657

📥 Commits

Reviewing files that changed from the base of the PR and between 11e3010 and e58d1c3.

📒 Files selected for processing (2)
  • web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx
  • web/packages/agenta-playground-ui/src/components/PlaygroundInputsBody/VariableCard.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/packages/agenta-playground-ui/src/components/PlaygroundInputsBody/VariableCard.tsx

Comment thread web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx Outdated
@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch 2 times, most recently from a65dbf7 to bdcce3c Compare June 13, 2026 07:20
@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch from c3a0296 to a2e9150 Compare June 13, 2026 10:00
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 13, 2026
@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch from a586959 to a60bf3f Compare June 15, 2026 08:07
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 15, 2026
@IshaanAggrawal IshaanAggrawal force-pushed the fix/4638-text-mode-no-type-coercion branch from a60bf3f to 79ad2e5 Compare June 15, 2026 08:23
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 15, 2026
@IshaanAggrawal IshaanAggrawal requested a review from mmabrouk June 15, 2026 08:50
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:M This PR changes 30-99 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

3 participants