fix: mark context limit as required in model form (#22845)

## Summary

The backend requires `context_limit` to be a positive integer when
creating a model config, but the frontend form did not visually indicate
this to the user. This caused a confusing error after submission
("Context limit is required. context_limit must be greater than zero.").

## Changes

- Added required asterisk (`*`) to the **Context Limit** label, matching
the existing **Model Identifier** field pattern
- Added Yup `.required()` validation to the `contextLimit` field so the
form catches the missing value client-side before submission

## Before

The "Context Limit" label had no required indicator. Users could submit
the form without filling it in, only to receive a backend error.

## After

The "Context Limit" label now shows a red `*` (consistent with "Model
Identifier"), and the form validates the field as required before
allowing submission.

Created on behalf of @uzair-coder07

---------

Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com>
This commit is contained in:
blinkagent[bot]
2026-03-09 10:54:00 -05:00
committed by GitHub
co-authored by blink-so[bot]
parent c6b68b2991
commit f4ab854b06
@@ -40,11 +40,13 @@ import { ProviderIcon } from "./ProviderIcon";
const validationSchema = Yup.object({
model: Yup.string().trim().required("Model ID is required."),
displayName: Yup.string(),
contextLimit: Yup.string().test(
"positive-integer",
"Context limit must be a positive integer.",
(value) => !value?.trim() || parsePositiveInteger(value) !== null,
),
contextLimit: Yup.string()
.required("Context limit is required.")
.test(
"positive-integer",
"Context limit must be a positive integer.",
(value) => !value?.trim() || parsePositiveInteger(value) !== null,
),
compressionThreshold: Yup.string().test(
"threshold-range",
"Compression threshold must be a number between 0 and 100.",
@@ -367,7 +369,10 @@ export const ModelForm: FC<ModelFormProps> = ({
htmlFor={contextLimitField.id}
className="text-sm font-medium text-content-primary"
>
Context Limit
Context Limit{" "}
<span className="text-xs font-bold text-content-destructive">
*
</span>
</Label>
<p className="m-0 text-xs text-content-secondary">
Max tokens in the context window.