Skip to content

Fix speed inputs and random range validation (#61) - #66

Open
elgegeto wants to merge 4 commits into
NikolayIT:masterfrom
elgegeto:fix/issue-61-speed-input-validation
Open

elgegeto wants to merge 4 commits into
NikolayIT:masterfrom
elgegeto:fix/issue-61-speed-input-validation

Conversation

@elgegeto

Copy link
Copy Markdown

Summary

Fixes #61 by replacing the speed settings text boxes with Avalonia NumericUpDown controls bound to nullable decimal properties. This prevents empty numeric inputs from exposing internal .NET conversion errors, provides spinner buttons, and makes invalid ranges visible.

Changes

  • Convert both base speed inputs and the eight random min/max inputs to nullable decimal properties.
  • Prevent Add, Save defaults, Apply settings, and Start while an enabled speed or random range is invalid.
  • Validate non-negative speeds, whole-number random ranges, and min <= max only for enabled ranges.
  • Add concise speed unit and random-range explanations: per-tick jitter adds to the base speed; per-tracker-update randomness replaces it.
  • Clamp values when converting to persisted settings so disabled, unfinished inputs cannot overflow the existing integer settings.
  • Add a separate RatioMaster.App.Tests project with regression tests for clearing fields, inverted ranges, disabled ranges, fractional random speeds, change notifications, and value serialization.

Files worth reviewing

  • TorrentSettingsViewModel.cs: validation and decimal-to-core conversion
  • TorrentSettingsView.axaml: numeric controls and inline feedback
  • Add, settings, and torrent item ViewModels: command gating
  • RatioMaster.App.Tests: tests and solution registration

Testing

  • Added seven ViewModel regression tests, included in RatioMaster.slnx.
  • Local execution not yet available: no .NET 10 SDK in the current execution environment. CI is expected to run via the repository's Windows, Linux, and macOS GitHub Actions workflow.
  • UI layout should still be manually checked on macOS and with non-English locales; new inline explanations are currently in English and can be localized in a follow-up if desired.

This PR is initially a draft until CI and any required follow-up corrections have been reviewed.

Related issue: #61

…T#61)

Clearing a numeric input no longer converts an empty string to int/double. Validate only enabled random ranges and block add, save, apply, and start commands while speed settings are invalid.
…ikolayIT#61)

Replace speed text boxes with nullable decimal NumericUpDown controls. Explain kB/s random ranges and surface friendly validation messages. Test cleared values, reversed ranges, disabled ranges, notifications, and serialization.

Copy link
Copy Markdown
Author

Maintainer note: the initial Build GitHub Actions run for this fork PR is currently action_required, rather than a test failure. It appears to need an approval to run workflows for a first-time contributor.

I have not run .NET 10 locally (the SDK is unavailable in this execution environment), so I am not claiming that the new App ViewModel tests have passed. The PR includes seven regression tests and the existing Build workflow will compile and run them on Windows, Linux, and macOS once GitHub permits it.

I also kept the user-facing explanations in English for now; this is called out in the PR description because the application ships with other translations. Feedback on a preferred localization approach is welcome.

Please review the implementation and, if appropriate, approve the workflow run. Thanks!

@elgegeto
elgegeto marked this pull request as ready for review November 10, 2026 19:05
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.

Speed fields show .NET errors

1 participant