Skip to content

Conversation

@majiayu000
Copy link

@majiayu000 majiayu000 commented Dec 22, 2025

Summary

This PR fixes two related issues with number/integer inputs in the frontend:

  1. HTMLType typo fix: INTEGER input type was incorrectly mapped to htmlType: 'account' (which is not a valid HTML input type) instead of htmlType: 'number'.

  2. AnyOfField toggle fix: When a user cleared a number input field, the input would disappear because useAnyOfField checked for both null AND undefined in isEnabled. This PR changes it to only check for explicit null (set by toggle off), allowing undefined (empty input) to keep the field visible.

Root cause analysis

When a user cleared a number input:

  1. handleChange returned undefined (because v === "" ? undefined : Number(v))
  2. In useAnyOfField, isEnabled = formData !== null && formData !== undefined became false
  3. The input field disappeared

Fix

Changed useAnyOfField.tsx line 67:

- const isEnabled = formData !== null && formData !== undefined;
+ const isEnabled = formData !== null;

This way:

  • When toggle is OFF → formData is nullisEnabled is false (input hidden) ✓
  • When toggle is ON but input is cleared → formData is undefinedisEnabled is true (input visible) ✓

Test plan

  • Verified INTEGER inputs now render correctly with type="number"
  • Verified clearing a number input keeps the field visible
  • Verified toggling the nullable switch still works correctly

Fixes #11594

🤖 AI-assisted development disclaimer: This PR was developed with assistance from Claude Code.

@majiayu000 majiayu000 requested a review from a team as a code owner December 22, 2025 10:10
@majiayu000 majiayu000 requested review from kcze and majdyz and removed request for a team December 22, 2025 10:10
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Dec 22, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the platform/frontend AutoGPT Platform - Front end label Dec 22, 2025
@AutoGPT-Agent
Copy link

Thank you for fixing the INTEGER input type issue! This is definitely a needed correction since "account" is not a valid HTML input type.

However, I noticed an unrelated change in your PR that wasn't mentioned in the description:

- [Flag.CHAT]: true,
+ [Flag.CHAT]: false,

This change to disable the CHAT feature flag doesn't seem related to the input type fix described in the PR. Could you either:

  1. Remove this unrelated change from the PR, or
  2. Update your PR description to explain why this feature flag change is included

Once that's addressed, this PR should be ready to merge. The main fix looks good and will correctly fix integer input behavior.

@@ -51,7 +51,7 @@ export const TextInputWidget = (props: WidgetProps) => {
handleChange: (v: string) => (v === "" ? undefined : Number(v)),
},
[InputType.INTEGER]: {
htmlType: "account",
htmlType: "number",
Copy link
Contributor

@Abhi1992002 Abhi1992002 Dec 22, 2025

Choose a reason for hiding this comment

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

@majiayu000 We can’t solve this issue this way. To fix it properly, we need to allow empty values in the number input, and we also need to fix the anyOfField file so it doesn’t close the input when its value is null.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @Abhi1992002, thanks for the review!

I believe this PR actually addresses both points you mentioned:

  1. Allow empty values in number input: The handleChange function in TextInputWidget.tsx already handles this - when the input is empty (v === ""), it returns undefined instead of trying to convert an empty string to a number. This allows users to clear the number input.

  2. Fix anyOfField not closing when value is null: The change in useAnyOfField.tsx from formData !== null && formData !== undefined to just formData !== null means:

    • undefined (empty input) → field stays enabled ✓
    • null (explicitly toggled off) → field disabled ✓

The htmlType: "account"→"number" fix was also necessary because "account" is not a valid HTML input type.

Regarding the use-get-flag.ts comment - I don't see any changes to that file in this PR. Could you clarify what you meant?

Please let me know if I misunderstood your feedback!

@@ -48,7 +48,7 @@ const mockFlags = {
[Flag.AGENT_FAVORITING]: false,
[Flag.MARKETPLACE_SEARCH_TERMS]: DEFAULT_SEARCH_TERMS,
[Flag.ENABLE_PLATFORM_PAYMENT]: false,
[Flag.CHAT]: true,
[Flag.CHAT]: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

We don’t need it — you can remove it.

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 🚧 Needs work in AutoGPT development kanban Dec 22, 2025
@majiayu000 majiayu000 force-pushed the fix/number-input-boolean-flag branch from ecd1b12 to c9d7355 Compare December 22, 2025 11:28
@AutoGPT-Agent
Copy link

Thanks for this fix! The PR looks good and addresses an important issue with integer inputs.

Before we can merge:

  • Please check off the test plan items after confirming that integer input fields render correctly with the number input type and that number validation works properly.

This is a valuable fix that will ensure integer inputs have proper HTML semantics and validation. Once the test plan is completed, this should be ready to merge.

@majiayu000 majiayu000 force-pushed the fix/number-input-boolean-flag branch from c9d7355 to 1b5cd32 Compare December 22, 2025 15:09
@majiayu000
Copy link
Author

Addressed feedback: removed unrelated Flag.CHAT change from the branch and updated the test plan checkboxes.

… toggle

1. Fix INTEGER input htmlType from 'account' to 'number' (typo fix)
2. Fix useAnyOfField isEnabled logic to only check for explicit null
   - Previously checked for both null AND undefined, causing input to
     disappear when user cleared a number field
   - Now only checks for null (set by toggle off), allowing undefined
     (empty input) to keep the field visible

Fixes Significant-Gravitas#11594

Signed-off-by: majiayu000 <[email protected]>
@majiayu000 majiayu000 force-pushed the fix/number-input-boolean-flag branch from 1b5cd32 to af820a5 Compare December 24, 2025 17:02
@majiayu000 majiayu000 changed the title fix(frontend): correct INTEGER input htmlType from 'account' to 'number' fix(frontend): allow empty values in number inputs and fix AnyOfField toggle Dec 24, 2025
@majiayu000
Copy link
Author

CI Status Update

The test failures are in marketplace-agent.spec.ts E2E tests, which are unrelated to this PR's changes:

Failing tests:

  • Agent page details are visible
  • Download button functionality works
  • Add to library button works and agent appears in library

This PR's changes:

  • TextInputWidget.tsx: Fixed INTEGER input htmlType from 'account' to 'number'
  • useAnyOfField.tsx: Changed isEnabled logic to only check for explicit null, allowing empty input values (undefined) to keep the field visible

The failing tests are about the marketplace agent page functionality, not the input renderer components. Could a maintainer please re-run the failing tests?

@majiayu000
Copy link
Author

/rerun

@majiayu000
Copy link
Author

The 3 failing marketplace E2E tests (marketplace-agent...page-details-are-visible, marketplace-agent...button-functionality-works, marketplace-agent...agent-appears-in-library) appear to be flaky tests unrelated to this PR.

This PR only modifies:

  • useAnyOfField.tsx: Changed null check condition for isEnabled
  • TextInputWidget.tsx: Fixed typo accountnumber for htmlType

The failing tests are marketplace-related E2E tests that don't interact with the form widgets changed in this PR. Triggered a rerun to confirm.

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

Labels

platform/frontend AutoGPT Platform - Front end size/s

Projects

Status: 🚧 Needs work
Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants