feat(apollo-wind): add maxRef to slider for dynamic max from another field#707
Merged
Conversation
…field
Slider's `max` was a static number. To support cases where the upper
bound depends on another field (e.g. an LLM model picker selecting a
model with its own token cap), add an optional `maxRef: { fromField,
fallback }` to SliderFieldMetadata.
When `maxRef` is set, the slider watches the referenced field via
useFormContext and uses the watched value as max if it is a finite
positive number; otherwise `fallback`. If the resolved max drops below
the current form value, the value is clamped via onChange. Static
`max` and the historical default of 100 remain unchanged.
snuziale
approved these changes
May 15, 2026
CalinaCristian
approved these changes
May 15, 2026
david-rios-uipath
approved these changes
May 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SliderFieldMetadata.maxwas a static number — fine for fixed ranges (e.g.temperature: 0..1) but a poor fit when the upper bound depends on another field. The motivating case: an agent'smaxTokenPerResponseslider should cap at the selected model'smaxTokens, but the available models (and their token caps) only exist at runtime.This PR adds an additive, back-compat
maxRefoption that lets the slider read itsmaxfrom another form field at render time.Changes
form-schema.ts— AddsFieldRefinterface andSliderFieldMetadata.maxRef?: FieldRef. Existing staticmax?: numberis untouched, so consumers using the plain numeric form keep working with no migration.field-renderer.tsx— Extracts thecase 'slider'body into aSliderFieldsub-component (slider needs hooks now). It callsuseFormContext().watch(maxRef.fromField)and resolves max as: watched value if finite and positive →maxRef.fallback→ staticmax→ 100. If the resolved max drops below the current form value (e.g. user switches to a model with a lower cap), the value is clamped viaonChange.field-renderer.test.tsx— 6 new tests covering static max, default fallback, maxRef resolution, watched-field-missing fallback, watched-field-non-numeric fallback, and maxRef precedence over static max.Usage
Test plan
pnpm exec tsc --noEmit— cleanpnpm test(apollo-wind) — 909 passed (was 903; +6 new)pnpm lint— no new diagnostics introducedmax: 100slider still renders identically (covered by existing tests but worth a manual eyeball in Storybook)