Skip to content

fix(web): handle string booleans and mode variants in schedule-picker widget#228

Merged
ChuckBuilds merged 4 commits intomainfrom
fix/schedule-picker-boolean-coercion
Jan 30, 2026
Merged

fix(web): handle string booleans and mode variants in schedule-picker widget#228
ChuckBuilds merged 4 commits intomainfrom
fix/schedule-picker-boolean-coercion

Conversation

@ChuckBuilds
Copy link
Copy Markdown
Owner

@ChuckBuilds ChuckBuilds commented Jan 30, 2026

Summary

  • Fixed schedule-picker checkbox not working correctly when config had string boolean values
  • Fixed mode selection not working when config stored per-day instead of per_day

Changes

  1. Added coerceToBoolean helper - Properly handles boolean, string ("true", "1", "on"), and other value types with whitespace trimming
  2. Added normalizeMode helper - Handles both per_day and per-day variants (hyphen vs underscore)
  3. Applied fixes to both main schedule and per-day enabled fields

Test plan

  • Load schedule page with dim schedule enabled in config
  • Verify checkbox reflects the correct state
  • Toggle checkbox and save, reload and verify state persists
  • Switch between Global and Per-Day modes, save, reload and verify mode persists
  • Test with string "true"/"false" values in config
  • Test with "per-day" (hyphen) mode value in config

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Schedule picker now exposes public methods for accessing default schedules and normalizing schedule values.
  • Improvements

    • Enhanced input value interpretation to be more flexible and forgiving when handling schedule configurations.
    • Clarified default behavior for day-level enabled states when not explicitly provided.

✏️ Tip: You can customize this high-level summary in your review settings.

Chuck and others added 3 commits January 30, 2026 14:29
The normalizeSchedule function used strict equality (===) to check the
enabled field, which would fail if the config value was a string "true"
instead of boolean true. This could cause the checkbox to always appear
unchecked even when the setting was enabled.

Added coerceToBoolean helper that properly handles:
- Boolean true/false (returns as-is)
- String "true", "1", "on" (case-insensitive) → true
- String "false" or other values → false

Applied to both main schedule enabled and per-day enabled fields.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

The PR enhances the schedule-picker widget by introducing helper functions for robust type coercion (coerceToBoolean) and mode normalization (normalizeMode). These helpers refactor normalizeSchedule() for more forgiving input interpretation, and two methods are exposed as part of the public API: getDefaultSchedule() and normalizeSchedule().

Changes

Cohort / File(s) Summary
Schedule Picker Widget Enhancement
web_interface/static/v3/js/widgets/schedule-picker.js
Added coerceToBoolean() and normalizeMode() helper functions to robustly handle type conversion and mode normalization. Refactored normalizeSchedule() to use these helpers for enabled states and mode handling. Exposed getDefaultSchedule() and normalizeSchedule() as public widget methods.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hop, hop, scheduling we go,
With booleans that bend and modes that flow,
Helpers that coerce with gentle care,
Public APIs now shared with flair!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: handling string booleans and mode variants in the schedule-picker widget, which aligns perfectly with the core fixes implemented.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/schedule-picker-boolean-coercion

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.

@ChuckBuilds ChuckBuilds merged commit 7e98fa9 into main Jan 30, 2026
1 check passed
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.

1 participant