Add boolean type to GUI field presets#354
Conversation
GUI field presets previously only accepted numeric values. Widen Preset.value to `number | boolean` so a preset can be a true/false choice. The button rendering (buttonsData) and binding flow (frameState) already coerce the preset value to its string form, so a boolean preset emits "true"/"false" as its binding value. Add tests covering the boolean preset render (true/false buttons) and the binding round-trip in both code paths. Closes #237 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
Walkthrough
ChangesBoolean preset value support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed due to a network error. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Rainlang has no boolean literal, so a dotrain #binding rebind value must be a valid rainlang literal. A boolean field preset was binding the string 'true'/'false', which the composer rejects as an invalid override. Convert a boolean preset value to '1' (true) / '0' (false) where the JS boolean is still typed, in getFieldPresetsButtons, so the value that reaches composition is a valid numeric rainlang literal. The button display text is unchanged. Non-zero is true in rainlang, matching how a flag binding such as amount-is-fast-exit is used as an if() condition. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

What
GUI field presets previously only supported numeric values (
Preset.value: number). This widens the preset value type tonumber | booleanso a field can offer a true/false preset choice.Changes
app/_types/yamlData.ts:Preset.valueis nownumber | boolean.getFieldPresetsButtonsinbuttonsData.ts) and the binding flow (getUpdatedFrameStateinframeState.ts) already coerce the preset value to its string form, so a boolean preset renders atrue/falsebutton and emits"true"/"false"as the binding value. The downstream binding consumers (SubmissionModal,CodemirrorModal) pass non-numeric binding values through unchanged, so the boolean string round-trips into the scenario bindings.Tests
__tests__/buttonsData.test.tsx: asserts boolean presets render astrue/falsebuttons (named and unnamed).__tests__/frameState.test.tsx: asserts atrue/falseboolean preset round-trips into the field binding.Mutation-validated: breaking the value-emit branch in both
buttonsData.tsandframeState.tsmakes the respective boolean test fail; restoring it makes them pass.Build, lint, format, and the full test suite (84 tests) are green.
Closes #237
Summary by CodeRabbit
New Features
Tests