Skip to content

fix: preserve string type when Text/Markdown view mode is selected in test case drawer#4705

Open
NamHT4Devlop wants to merge 1 commit into
Agenta-AI:mainfrom
NamHT4Devlop:fix/4638-text-input-type-auto-switch
Open

fix: preserve string type when Text/Markdown view mode is selected in test case drawer#4705
NamHT4Devlop wants to merge 1 commit into
Agenta-AI:mainfrom
NamHT4Devlop:fix/4638-text-input-type-auto-switch

Conversation

@NamHT4Devlop

@NamHT4Devlop NamHT4Devlop commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix text inputs in the test case drawer auto-switching type when the view mode selector is set to Text or Markdown.

Root cause: TestcaseDrillInFieldRenderer routes all text-like views through TextEditor, which calls inferPrimitiveFromText on every keystroke. This function converts "False"false (boolean) and "42"42 (number) regardless of which view mode the user selected — so the type chip flips even when the user is in explicit Text mode.

Fix: Add a noTypeInference prop to TextEditor. When the caller passes noTypeInference, the change handler stores the raw string directly instead of running it through inferPrimitiveFromText. The prop is set for viewMode === "text" and viewMode === "markdown", where values should always be stored as strings because the user has explicitly chosen a textual view. The fallback path (no view mode set) and the code paths (viewMode === "json" / "yaml") are unaffected — those modes already rely on their own parsing logic.

Testing

Verified locally

  • Set a test case field to Text mode, type False → stored as "False" (string). Type chip stays string.
  • Set a test case field to Text mode, type 42 → stored as "42" (string). Type chip stays string.
  • Set a test case field to Markdown mode, type True → stored as "True" (string).
  • Switch to JSON mode, type false → stored as false (boolean). Existing JSON parsing behavior preserved.
  • Fallback mode (no explicit view mode selected) — type inference still runs. No regression.

Added or updated tests

N/A — this behavior lives entirely in a rendered browser component (inferPrimitiveFromText itself already has well-defined pure-function behavior). Manual verification covers the reported scenarios.

QA follow-up

  • Open the playground test case drawer.
  • Set a field's view mode to Text.
  • Enter False, True, 0, 42 — verify the type chip shows string and the value is saved as a string.
  • Switch the same field to JSON mode and type false — verify it is now stored as a boolean.

Demo

Before: With the view mode set to Text, typing False causes the type chip to flip from stringboolean because inferPrimitiveFromText runs unconditionally.

After: With Text or Markdown view mode selected, the value stays a string at all times. Type coercion only happens in the fallback (no explicit view mode) and in JSON/YAML editors.

Before/After comparison

Checklist

  • I have included a video or screen recording for UI changes, or marked Demo as N/A
  • Relevant tests pass locally
  • Relevant linting and formatting pass locally
  • I have signed the CLA, or I will sign it when the bot prompts me

Closes #4638

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 Agenta-AI#4638
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. Bug Report Something isn't working labels Jun 15, 2026
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

✅ Thanks @NamHT4Devlop! 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 15, 2026
@github-actions github-actions Bot closed this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 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: 5545ab3c-56c3-4963-81f6-35a69835f89e

📥 Commits

Reviewing files that changed from the base of the PR and between 56dc00e and 1ae8739.

📒 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
    • Fixed an issue where text values were being automatically converted to other data types when entered in markdown and text view modes. Text input in these modes now remains as typed strings without automatic type conversion.

Walkthrough

Adds a noTypeInference?: boolean prop to the TextEditor component. The handleChange callback conditionally skips inferPrimitiveFromText and passes through the raw string when the flag is set. TestcaseDrillInFieldRenderer passes noTypeInference to TextEditor in the markdown and text view mode branches.

Changes

TextEditor noTypeInference prop and usage

Layer / File(s) Summary
TextEditor prop, handler guard, and text/markdown mode wiring
web/packages/agenta-entity-ui/src/testcase/TestcaseDrillInFieldRenderer.tsx
TextEditor props type gains noTypeInference?: boolean; handleChange skips inferPrimitiveFromText when the flag is true, passing the raw string value instead. Both the markdown and text viewMode branches pass noTypeInference to TextEditor.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

✨ 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 15, 2026
@github-actions github-actions Bot reopened this Jun 15, 2026
@bekossy

bekossy commented Jun 15, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution @NamHT4Devlop 🙌 We will take a look and review it as soon as possible. Thanks for helping improve Agenta!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Report Something isn't working 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