Skip to content

fix(ui): keep a form editor's Save current when code sets a field #5260

Closed

Description

@tale-code-bot

Summary

Split off #5182, which fixed this for the embedding model section only.

useFormEditor takes Save's validity from react-hook-form's stored formState.isValid (packages/ui/src/components/editor/use-form-editor.ts:237). That stored value goes stale in two cases:

  • A handler changes a value with setValue without shouldValidate, after RHF has already judged the form, for example after a field's own onChange. RHF does not run the schema again.
  • A save fails its schema. A failed handleSubmit writes the errors but leaves isValid as it was.

An audit of the eight other editors that call setValue this way found two that show a wrong Save state today.

Everything below was read from the code at main 11aac22 with react-hook-form 7.72.1. None of it was reproduced in a browser or a test.

Object storage: Save is on while required fields are blank

File: services/platform/app/features/settings/data-residency/components/org-storage-section.tsx

  • Cause:
    • The Force path style toggle is written with setValue('forcePathStyle', checked, { shouldDirty: true }) (:604-607). It is not a registered input, so nothing runs the schema again.
    • The schema treats the untouched empty form as valid while no storage is configured (:259). Any other values make Region and Bucket required.
  • Steps:
    1. Use an organization with no storage connection.
    2. Turn the section on.
    3. Make Force path style the first edit.
  • Result:
    • The header's Save is on while Region and Bucket are blank.
    • A click refuses with "Fix the highlighted fields and try again" and marks Region and Bucket. Save stays on.
    • In a grouped save, the sections saved before this one are already saved when it fails.

Enterprise SSO: Save is off over valid values

File: services/platform/app/features/settings/enterprise-sso/components/enterprise-sso-form.tsx

  • Cause:
    • The protocol select calls field.onChange(next) first (:904), which judges the form as it stands.
    • Only then does setValue('displayName', …, { shouldDirty: true }) (:921-923) fill an empty or default name, and nothing judges the form again.
  • Steps:
    1. Start from an OIDC connection that is otherwise valid.
    2. Clear Display name. Save turns off, which is correct.
    3. Leave the field, so its "required" error shows.
    4. Switch between Generic OIDC and Entra ID, or from OAuth2 to either one.
  • Result:
    • The name is filled, but the stale "required" error stays under it.
    • Save stays off with no reason until the next edit or blur.
    • Switches that mount new inputs (to OAuth2 or SAML, or away from SAML) validate again and are not affected.
  • A timing case with the same cause:
    • The revealed client id is written with setValue('clientId', value, { shouldDirty: false }) (:659).
    • An edit made before the reveal returns judges the form with an empty client id.
    • Save then stays off, with no error anywhere, until the next edit.
    • Bug: delayed SSO client-ID loading overwrites a newer edit #3925 fixed the same reveal overwriting a newer edit; this is the validity side of that reveal.

Not affected

These use the same pattern, but the value they set cannot change validity:

  • settings/sandboxes/workspace-cleanup-editor.tsx
  • settings/governance/components/chat-tools-policy-editor.tsx
  • settings/governance/components/vision-model-editor.tsx
  • settings/governance/components/skill-sharing-policy-editor.tsx
  • projects/components/project-task-reviewer-section.tsx
  • projects/components/project-overview.tsx: only a stored icon or colour outside the allowed list could be affected, and no current write path stores one.

Constraints a change must respect

Related

Activity

  1. added
    bug
    agent-ready
    on Nov 1, 2026
  2. added a commit that references this issue on Nov 1, 2026
    61dbef2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions