Skip to content

Add boolean type to GUI field presets#354

Open
thedavidmeister wants to merge 3 commits into
mainfrom
2026-06-14-issue-237
Open

Add boolean type to GUI field presets#354
thedavidmeister wants to merge 3 commits into
mainfrom
2026-06-14-issue-237

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What

GUI field presets previously only supported numeric values (Preset.value: number). This widens the preset value type to number | boolean so a field can offer a true/false preset choice.

Changes

  • app/_types/yamlData.ts: Preset.value is now number | boolean.
  • The render path (getFieldPresetsButtons in buttonsData.ts) and the binding flow (getUpdatedFrameState in frameState.ts) already coerce the preset value to its string form, so a boolean preset renders a true/false button 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 as true/false buttons (named and unnamed).
  • __tests__/frameState.test.tsx: asserts a true/false boolean preset round-trips into the field binding.

Mutation-validated: breaking the value-emit branch in both buttonsData.ts and frameState.ts makes 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

    • Added support for boolean preset values in field configurations, enabling users to define Enabled/Disabled options.
  • Tests

    • Added comprehensive test coverage for boolean preset rendering and state binding functionality.

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>
@thedavidmeister thedavidmeister self-assigned this Jun 14, 2026
@vercel

vercel Bot commented Jun 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rain-frame Ready Ready Preview, Comment Jun 19, 2026 5:25pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f94fc944-4df3-4fe2-9142-cdbde414f7bf

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7f5b3 and a771ae1.

📒 Files selected for processing (4)
  • __tests__/buttonsData.test.tsx
  • __tests__/frameState.test.tsx
  • app/_services/buttonsData.ts
  • app/_types/yamlData.ts

Walkthrough

Preset.value in yamlData.ts is widened from number to number | boolean. getFieldPresetsButtons in buttonsData.ts now maps boolean true to '1' and false to '0' instead of stringifying directly. Tests are added for both the button output and the getUpdatedFrameState frame binding.

Changes

Boolean preset value support

Layer / File(s) Summary
Preset type widening and boolean serialization
app/_types/yamlData.ts, app/_services/buttonsData.ts
Preset.value is widened to number | boolean, and getFieldPresetsButtons encodes boolean true/false as '1'/'0' instead of using default stringification.
Unit tests for boolean preset buttons and frame state
__tests__/buttonsData.test.tsx, __tests__/frameState.test.tsx
New tests verify that getFieldPresetsButtons emits '1'/'0' for boolean presets, and that getUpdatedFrameState binds pin-best-quote to '1' or '0' with no error.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: adding boolean type support to GUI field presets, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR fully addresses issue #237's requirement to add boolean type support to GUI presets, including type expansion, implementation in rendering/binding flows, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly aligned with adding boolean preset support: type definition update, implementation logic for value serialization, and focused test coverage with no extraneous modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-14-issue-237

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Boolean preset field control (named Enabled/Disabled presets plus bare true/false presets), rendered headlessly:

@thedavidmeister

Copy link
Copy Markdown
Contributor Author

screenshot

UI screenshot: boolean type GUI field preset.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add bool type to gui presets

1 participant