Repository navigation
fix(settings): clamp number settings to their field's range before saving - #634
Conversation
…ving apply_settings_changes cast Seek Duration, Like Animation Frames, Table Scroll Padding and the small-terminal sizes with a bare `as`, so 256 frames wrapped to 0 and blocked the next launch, and -1 ms saved as u32::MAX. Clamp each value to the range of its target type first, the way the volume increment arm already does. Fixes LargeModGames#594 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: LargeModGames/spotatui/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughSettings application now clamps five numeric values to their supported ranges before conversion. Tests cover values below and above those ranges. The Unreleased changelog documents the fix. ChangesSettings value clamping
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The settings values are bounded before saving, and no merge-blocking issue is identified. Normal checks remain appropriate. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change makes saved numeric settings respect their field ranges without adding a new settings entrypoint or changing the stored field types. No security concern was identified in the affected path. Restart behavior was not manually verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Fixes #594. The five arms in
apply_settings_changesnow clamp to their target type before the cast, as the issue lists:seek_milliseconds:clamp(0, u32::MAX)like_animation_frames:clamp(1, u8::MAX)table_scroll_padding:clamp(0, u16::MAX)small_terminal_width/small_terminal_height:clamp(1, u16::MAX)The clamp lives in
settings_apply.rs, so the GUI'sAction::SaveSettingspath gets it too. The fatal check inuser_config.rsis untouched.Tests:
like_animation_frames_above_255_saves_as_255_not_zero,negative_seek_duration_saves_as_zero, and the optionalu16_settings_above_their_range_save_as_the_maximum(65536 for width and padding).Testing
cargo fmt --all -- --check: cleancargo clippy --no-default-features --features telemetry,tui -- -D warnings: cleancargo test --no-default-features --features telemetry,tui: 1284 passed, 0 failedcargo test --no-default-features --features telemetry,tui settings_apply: 4 passedmax(1) as u8andas u32arms, the two required tests fail.Additional notes
I checked this through
apply_settings_changesonly. I didn't do the manual "type 256 in Settings, save, restart" run from the issue.This is one of five small PRs I opened together (#602, #603, #594, #595, #599). Each changelog entry sits at a different spot in
[Unreleased]so they merge without conflicts in any order.Written with AI coding assistants: the fix was drafted by Codex, then extracted onto its own branch, checked against the issue and re-tested by Claude Code.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation