Skip to content

fix(site/src/pages/AISettingsPage/ModelsPage): disable Update model until form is dirty#26684

Merged
tracyjohnsonux merged 2 commits into
mainfrom
fix/update-model-button-dirty
Jun 25, 2026
Merged

fix(site/src/pages/AISettingsPage/ModelsPage): disable Update model until form is dirty#26684
tracyjohnsonux merged 2 commits into
mainfrom
fix/update-model-button-dirty

Conversation

@tracyjohnsonux

Copy link
Copy Markdown
Contributor

The Update model button on /ai/settings/models/:modelId was enabled on mount even when the form had not been edited, so it was possible to submit an unchanged update. This matches the Provider form behavior already established in #25551 by gating submit on form.dirty when editing.

Changes

  • ModelForm.tsx adds (!isEditing || form.dirty) to the canSubmit predicate so Update is disabled until the user changes a field. Add/duplicate flows are unaffected because their existing model.trim().length > 0 requirement already enforces user input.
  • ModelForm.stories.tsx tightens EditSaveSubmits to assert the disabled-on-mount and enabled-after-edit transitions, and adds EditUpdateDisabledUntilDirty covering the case where the user reverts an edit back to the original value.

Verification

  • pnpm exec biome check src/pages/AISettingsPage/ModelsPage/components/ModelForm.tsx src/pages/AISettingsPage/ModelsPage/components/ModelForm.stories.tsx: clean
  • pnpm exec tsc -p . --noEmit: clean
  • pnpm test:storybook --project=chromium src/pages/AISettingsPage/ModelsPage: 21/21 stories pass (including the two new dirty-state stories)
  • make pre-commit via the project git hooks: passed (lint/ts, lint/go, lint/emdash, lint/agents, lint/check-scopes, build, all green)

Note

🤖 This PR was written by Coder Agents on behalf of @tracyjohnsonux

…ntil form is dirty

The Update model button on /ai/settings/models/:modelId was enabled on
mount even when the form had not been edited, so it was possible to
submit an unchanged update. Match the Provider form behavior (PR #25551)
by gating the submit on form.dirty when editing.

Add a dirty-state Storybook story and tighten EditSaveSubmits to assert
the disabled-on-mount and enabled-after-edit transitions.
@tracyjohnsonux

Copy link
Copy Markdown
Contributor Author

I didn't address the enable/disable getting auto applied. Changing that means we'll have to update the rest at the same time. Its also outside of the form box. So I believe for now its fine. With the toast notification. We can address in next round if needed.

Comment on lines +233 to +236
// In edit mode the form starts pre-populated with the saved values, so
// without a dirty check the Update button would be enabled on mount.
// Require at least one change before allowing submit, matching the
// behavior of the Provider form (see PR #25551).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comments not needed, pls delete before merge

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, removed in 4728ad3.

@tracyjohnsonux tracyjohnsonux enabled auto-merge (squash) June 25, 2026 00:55
@tracyjohnsonux tracyjohnsonux merged commit 0f47314 into main Jun 25, 2026
30 of 31 checks passed
@tracyjohnsonux tracyjohnsonux deleted the fix/update-model-button-dirty branch June 25, 2026 01:01
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants