fix: convert InputVar type to a discriminated union with slider and switch variants#820
Merged
chrispcampbell merged 7 commits intomainfrom May 4, 2026
Merged
Conversation
…slider and switch variants
Drop the optional rendering metadata (step, reversed, units, format, slidersActiveWhenOff/On) that check-core itself doesn't read. These fields are properly the concern of consumers like model-explorer and will live in an extended bundle format defined elsewhere. Also fix the template-bundle Input type to use SliderInputVar directly (via intersection) since interfaces can't extend a union.
Two related cleanups for code that branches on `InputVar.kind`: - For switch inputs, use the convention that `at-minimum` maps to the switch's `offValue` and `at-maximum` maps to its `onValue`, instead of erroring out (or sorting min/max with Math.min/max). This matches the long-standing en-roads-check-bundle behavior. - Prefer `switch (inputVar.kind)` over `if (inputVar.kind === 'slider')` / `if (inputVar.kind === 'switch')`, so that adding a new variant in the future surfaces all branches that need to handle it (and so searches for either kind name find every branch). Touches the mocks (mock-check-scenario, mock-resolved-types, mock-comparison-scenario), the position-resolution helpers in check-scenario.ts and comparison-resolver.ts, the comparison matrix filter in comparison-resolver.ts, and the per-input min/max scenario filter in plugin-check's template-tests.
Now that the at-min/at-max position resolution maps switches to off/on (instead of erroring), the matrix scenarios in check-core and plugin-check no longer need to filter switches out. This restores behavior where every input — slider or switch — gets its own at-min and at-max scenario. In template-tests, the per-input min/max equality check is now expressed via a small `valueAtPos` helper that returns minValue/maxValue for sliders and offValue/onValue for switches, so switch inputs are correctly skipped when their position value matches the default (already covered by the all-inputs-at-default scenario). Also includes the parallel cleanup in plugin-config/gen-inputs.ts: the `addInputVariable` call for switches now passes `offValue`/`onValue` directly as min/max, matching the convention used in sim-build.
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.
Fixes #819
See issue for details. This only affects the model-check packages. I also made a small related change in the plugin-config package to correct the mapping for switch off/on values to follow the conventions we use elsewhere.