fix: preserve string type when Text/Markdown view mode is selected in test case drawer#4705
Conversation
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
|
@NamHT4Devlop is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @NamHT4Devlop! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a ChangesTextEditor noTypeInference prop and usage
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Thanks for the contribution @NamHT4Devlop 🙌 We will take a look and review it as soon as possible. Thanks for helping improve Agenta! |
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:
TestcaseDrillInFieldRendererroutes all text-like views throughTextEditor, which callsinferPrimitiveFromTexton 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
noTypeInferenceprop toTextEditor. When the caller passesnoTypeInference, the change handler stores the raw string directly instead of running it throughinferPrimitiveFromText. The prop is set forviewMode === "text"andviewMode === "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
False→ stored as"False"(string). Type chip stays string.42→ stored as"42"(string). Type chip stays string.True→ stored as"True"(string).false→ stored asfalse(boolean). Existing JSON parsing behavior preserved.Added or updated tests
N/A — this behavior lives entirely in a rendered browser component (
inferPrimitiveFromTextitself already has well-defined pure-function behavior). Manual verification covers the reported scenarios.QA follow-up
False,True,0,42— verify the type chip shows string and the value is saved as a string.false— verify it is now stored as a boolean.Demo
Before: With the view mode set to Text, typing
Falsecauses the type chip to flip from string → boolean becauseinferPrimitiveFromTextruns 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.
Checklist
Closes #4638