-
-
Notifications
You must be signed in to change notification settings - Fork 782
feat: Introduce Value Types for Context Fields #10026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new valueType property to context fields to restrict operators based on the field’s type, improving UI behavior and reducing configuration errors. Key changes include:
- Database migration and backend adjustments to support a new value_type column.
- Frontend modifications adding a dropdown for selecting a context field’s valueType and updating operator filtering.
- Updates to types, schemas, and reducer logic to map and propagate the new valueType.
Reviewed Changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/lib/openapi/spec/context-field-schema.ts | Added a new valueType property in the OpenAPI schema. |
src/lib/features/context/context.ts | Updated controller logic to map and validate valueType. |
src/lib/features/context/context-field-store.ts and context-field-store-type.ts | Added valueType support in DB row mapping and type definitions. |
frontend/src/* | Updated utilities, interfaces, and UI components (forms, constraint selectors, etc.) to include valueType and filter operators accordingly. |
frontend/src/component/common/NewConstraintAccordion/ConstraintOperatorSelect.tsx
Outdated
Show resolved
Hide resolved
@@ -57,11 +57,20 @@ export const contextFieldSchema = { | |||
}, | |||
legalValues: { | |||
description: | |||
'Allowed values for this context field schema. Can be used to narrow down accepted input', | |||
'Allowed values for this context field. Can be used to extend the context field schema', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change seems unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that I notice is that it may inadvertedly break backward compatibility. I think with these agents it becomes more relevant to have better guardrails and tests.
Maybe if it does a lint:fix at the end would output PRs in better shape
...dion/ConstraintAccordionEdit/ConstraintAccordionEditHeader/ConstraintAccordionEditHeader.tsx
Outdated
Show resolved
Hide resolved
Do you want to define a set of legal values for this | ||
context field? (optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of these improvements are impressive, making the UX clearer and more usable. Perhaps some UI dimension has to be adapted, but I'm sure the agent made this decision.
<Typography variant='body2' sx={{ mb: 1 }}> | ||
Do you want this context field to be sticky? (optional) | ||
</Typography> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, on the other hand, it got rid of the stickiness explanation and also modified the switch by removing the on/off label
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no clue why it changed this tbh. Seems like it was too eager. I will ask it to redo this.
...gy/FeatureStrategyConstraints/EditableConstraint/useEditableConstraint/constraint-reducer.ts
Outdated
Show resolved
Hide resolved
62c52d4
to
8ab0f30
Compare
8ab0f30
to
b2757e9
Compare
(Warning: This entire PR was implemented with Copilot Agent with Gemini 2.5 Pro model.)
feat: Introduce Value Types for Context Fields
This PR introduces the ability to define a specific
valueType
for context fields in Unleash. This enhancement allows the UI to display only relevant operators for a selected context field, improving user experience and reducing potential configuration errors.Problem
Previously, all operators were available for every context field, regardless of the field's intended data type. This could lead to confusion and the selection of incompatible operators (e.g., using a string operator on a date field).
Solution
We've added a new optional
valueType
property to context fields, which can be one of "String", "Number", "Semver", or "Date".valueType
is defined for a context field, the UI (specifically in constraint creation/editing) will now only show operators that are compatible with that type.valueType
is not set (i.e.,null
or undefined), all operators will continue to be available for that context field.valueType
upon creation of new context fields.Key Changes
1. Database
2. Backend (
src/lib
)3. Frontend Core Logic (
frontend/src
)4. Frontend UI & State Management (
frontend/src/component
)useContextForm.ts
: AddedvalueType
to the form state, initialization logic, and included it in the submission payload.ContextForm.tsx
: Added aSelect
dropdown for choosing thevalueType
when creating or editing a context field.CreateUnleashContext.tsx
&EditContext.tsx
: Updated to passvalueType
and its setter to theContextForm
.ConstraintOperatorSelect.tsx
(incommon/NewConstraintAccordion
andfeature/FeatureStrategy
): Modified to accept acontextFieldType
prop and filter the displayed operators usinggetOperatorsForContextFieldType
.ProjectActionsFilterItem.tsx
: Fetches the context definition to determine and pass thecontextFieldType
to the operator select.EditableConstraint.tsx
:contextFieldType
of the selected context field.contextFieldType
andallOperators
to itsConstraintOperatorSelect
component.constraint-reducer.ts
(inuseEditableConstraint
):valueType
.valueType
.currentTime
context field and transitions to/from date-type fields to ensure appropriate date operators are selected.ContextList.tsx
: Updated to display thevalueType
of each context field in the list.Commits
The changes were implemented across two commits:
feat: Add value_type to context_fields table
(Database migration)feat: Implement context field value types
(Backend and frontend implementation)This feature aims to make strategy constraint configuration more intuitive and robust.
Images of the new feature in action:
CRUD context fields with new valueType option:

Use with a feature flag:

