Skip to content

Display an error text when ValueInput has invalid user input#257

Merged
hebasto merged 5 commits into
bitcoin-core:mainfrom
jarolrod:setting-error-state
Mar 6, 2023
Merged

Display an error text when ValueInput has invalid user input#257
hebasto merged 5 commits into
bitcoin-core:mainfrom
jarolrod:setting-error-state

Conversation

@jarolrod
Copy link
Copy Markdown
Contributor

@jarolrod jarolrod commented Feb 11, 2023

This allows for a ValueInput to signal when it currently has an invalid input from the user and display an error text to the user. In doing so, it is validating the input for the dbcache and threads settings; only writing to settings.json when there is valid input. Valid input for dbcache and thread is based on what are the minimum and maximum values the node will recognize for this. Proper validation for the prune setting will be handled in a future pr.

invalid dbcache & thread invalid prune
2023-02-22_00-53 2023-02-22_00-53_1

Windows
Intel macOS
Apple Silicon macOS
ARM64 Android

@jarolrod jarolrod mentioned this pull request Feb 11, 2023
@jarolrod jarolrod marked this pull request as draft February 11, 2023 17:43
@GBKS
Copy link
Copy Markdown
Contributor

GBKS commented Feb 13, 2023

We talked about this a bit on Slack, so just repeating my thoughts (IIRC). If we evaluate the validity of the input on each key stroke, it's pretty annoying if the layout changes. So it's better to evaluate it when the input field loses focus, and in that case, the layout reflow should be OK.

When entering nothing, a reset to the current value also makes sense.

A more helpful error text would be "Enter a value between X and Y".

Is it possible to use MB instead of MiB? I'd assume that more people know what MB are and might confuse MiB with the Men in Black.

@hebasto
Copy link
Copy Markdown
Member

hebasto commented Feb 16, 2023

based on #255

It has just been merged. Rebase?

@jarolrod jarolrod force-pushed the setting-error-state branch from 1e89928 to 00fac08 Compare February 17, 2023 07:39
@jarolrod
Copy link
Copy Markdown
Contributor Author

Updated from 1e89928 to 00fac08, compare

Changes: rebased to resolve conlicts

@jarolrod
Copy link
Copy Markdown
Contributor Author

Updated from 00fac08 to 8bfafde, compare

Changes: Addressed Review feedback

  • Validation happens on editing finished instead of every input keystroke
  • Display informative error text with what the valid values are

TODO in follow-ups:

  • Restrict the characters that can be input into the field, best option is inputMask
  • Restrict the width of the error text
  • Address review feedback that the default value or the value that options model has for a setting should be set if the user leaves a textinput in an empty state

@jarolrod jarolrod marked this pull request as ready for review February 22, 2023 06:02
@hebasto
Copy link
Copy Markdown
Member

hebasto commented Feb 22, 2023

based on #271

#271 has just been merged.

@jarolrod jarolrod force-pushed the setting-error-state branch from 8bfafde to d8cf8d0 Compare February 22, 2023 08:30
@jarolrod
Copy link
Copy Markdown
Contributor Author

Updated from 8bfafde to d8cf8d0, compare

Changes: rebased over main

@GBKS
Copy link
Copy Markdown
Contributor

GBKS commented Feb 27, 2023

Just tested it and I think the input validation needs a bit more work. While it worked well when I entered a low-ish number, I was able to instantly break the app by entering random text (or a really high number like 100 trillion).

image

@hebasto
Copy link
Copy Markdown
Member

hebasto commented Feb 27, 2023

based on #256

It has been just merged.

@jarolrod jarolrod force-pushed the setting-error-state branch from d8cf8d0 to a51820f Compare February 28, 2023 03:50
@jarolrod
Copy link
Copy Markdown
Contributor Author

Updated from from d8cf8d0 to a51820f, compare

changes: rebased over main

Validates that the input for these settings is not less or larger than
the allowed values. If so, displays an informational error text.
@jarolrod jarolrod force-pushed the setting-error-state branch from a51820f to 524decd Compare February 28, 2023 04:12
@jarolrod
Copy link
Copy Markdown
Contributor Author

Updated from a51820f to 524decd, compare

Changes: @GBKS your concerns should now be addressed here. I hadn't addressed those two points yet because I was thinking about what changes would be needed to ValueInput to allow for it to be used within the Proxy screen, but I'll leave that thinking to another PR.

  • Set a maximum input length of 5 to the ValueInput control. This is enough to enter a valid value for dbcache, threads, and prune target
  • Set an IntValidator without specifying the valid bottom or top values. What this does is it prevents any characters that are not numeric from being entered, while allowing a character like - to enter negative numbers (can be used in threads).

hebasto added a commit that referenced this pull request Mar 6, 2023
88a38a1 qml: Introduce Storage OptionButton that represents custom prune target (jarolrod)
1b2dde5 qml: expose currently loaded detailItem in InformationPage (jarolrod)
aacab2e qml: move setting of default prune setting into StorageOptions (jarolrod)
524decd qml: Validate input for dbcache, threads, and prune target settings (jarolrod)
317b1a5 qml: Expose minimum and maximum valid dbcache values (Jarol Rodriguez)
4eace03 qml: Expose minimum and maximum valid Script Verif Threads values (Jarol Rodriguez)
6440078 qml: Allow to show an error text below Setting header text (jarolrod)
195d8c5 qml: Allow to specify subtext color (jarolrod)

Pull request description:

  Based on #257 to not conflict

  This introduces a new OptionButton in StorageOptions that represents a custom prune target option. This is shown only when the user has gone into detailed settings and chosen a custom prune target.

  Additionally, this moves the logic of setting the default prune value from SettingsStorage into StorageOptions. It is the easy storage option button shown during onboarding that should set this. With the original logic, when onboarding is not shown because the user has already gone through it, the app will set prune to 2 gb again.

  | light | dark |
  | ----- | ---- |
  | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 36 PM" src="https://user-images.githubusercontent.com/23396902/216224800-6bda5263-2661-4eed-b550-7cdf94731408.png"> | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 16 PM" src="https://user-images.githubusercontent.com/23396902/216224815-8cdc3f36-6493-4d80-afc8-c4c26ddb2b5c.png"> |

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/245)
  [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/245)
  [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/245)
  [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/245)

ACKs for top commit:
  johnny9:
    ACK 88a38a1

Tree-SHA512: 931f79d4950476e74ebd24d5c9389f364e84ef199e4407e225f11792422be7b0acf4c0abd3cf3feb4f0b03d9a6b9c96af947dc6709249bc4857f7c3da66e7b80
@hebasto hebasto merged commit 524decd into bitcoin-core:main Mar 6, 2023
@hebasto
Copy link
Copy Markdown
Member

hebasto commented Mar 6, 2023

Merged as a part of #245.

johnny9 pushed a commit to johnny9/bitcoin-core-app that referenced this pull request Jul 4, 2025
7968ca9 qml: Introduce Storage OptionButton that represents custom prune target (jarolrod)
61b01e3 qml: expose currently loaded detailItem in InformationPage (jarolrod)
9c6a682 qml: move setting of default prune setting into StorageOptions (jarolrod)
d05ea90 qml: Validate input for dbcache, threads, and prune target settings (jarolrod)
a339e43 qml: Expose minimum and maximum valid dbcache values (Jarol Rodriguez)
a895163 qml: Expose minimum and maximum valid Script Verif Threads values (Jarol Rodriguez)
357a9a5 qml: Allow to show an error text below Setting header text (jarolrod)
390db68 qml: Allow to specify subtext color (jarolrod)

Pull request description:

  Based on bitcoin-core/gui-qml#257 to not conflict

  This introduces a new OptionButton in StorageOptions that represents a custom prune target option. This is shown only when the user has gone into detailed settings and chosen a custom prune target.

  Additionally, this moves the logic of setting the default prune value from SettingsStorage into StorageOptions. It is the easy storage option button shown during onboarding that should set this. With the original logic, when onboarding is not shown because the user has already gone through it, the app will set prune to 2 gb again.

  | light | dark |
  | ----- | ---- |
  | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 36 PM" src="https://user-images.githubusercontent.com/23396902/216224800-6bda5263-2661-4eed-b550-7cdf94731408.png"> | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 16 PM" src="https://user-images.githubusercontent.com/23396902/216224815-8cdc3f36-6493-4d80-afc8-c4c26ddb2b5c.png"> |

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/245)
  [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/245)
  [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/245)
  [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/245)

ACKs for top commit:
  johnny9:
    ACK 7968ca9

Tree-SHA512: 931f79d4950476e74ebd24d5c9389f364e84ef199e4407e225f11792422be7b0acf4c0abd3cf3feb4f0b03d9a6b9c96af947dc6709249bc4857f7c3da66e7b80
tx-signer450 added a commit to tx-signer450/gui-qml that referenced this pull request Oct 20, 2025
7968ca99b4489a0d55203b4e3ed36122dbf89fa9 qml: Introduce Storage OptionButton that represents custom prune target (jarolrod)
61b01e31c4810f8ef62997b3aeb1d717dad333ca qml: expose currently loaded detailItem in InformationPage (jarolrod)
9c6a682325ab2e04f54a74e1ffbd23dbf9152e7e qml: move setting of default prune setting into StorageOptions (jarolrod)
d05ea90ae6994da08c911167778a8f487b9ca6ac qml: Validate input for dbcache, threads, and prune target settings (jarolrod)
a339e4316193a1c7df017aec73565d4d4d2c29b1 qml: Expose minimum and maximum valid dbcache values (Jarol Rodriguez)
a895163aaaaa6290f6387cded39c00980403acef qml: Expose minimum and maximum valid Script Verif Threads values (Jarol Rodriguez)
357a9a569b7551791d4320bffb27cd4d4b3266b0 qml: Allow to show an error text below Setting header text (jarolrod)
390db68fa5f496717f5e542d93ee4dc203c30891 qml: Allow to specify subtext color (jarolrod)

Pull request description:

  Based on bitcoin-core/gui-qml#257 to not conflict

  This introduces a new OptionButton in StorageOptions that represents a custom prune target option. This is shown only when the user has gone into detailed settings and chosen a custom prune target.

  Additionally, this moves the logic of setting the default prune value from SettingsStorage into StorageOptions. It is the easy storage option button shown during onboarding that should set this. With the original logic, when onboarding is not shown because the user has already gone through it, the app will set prune to 2 gb again.

  | light | dark |
  | ----- | ---- |
  | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 36 PM" src="https://user-images.githubusercontent.com/23396902/216224800-6bda5263-2661-4eed-b550-7cdf94731408.png"> | <img width="752" alt="Screen Shot 2023-02-01 at 10 30 16 PM" src="https://user-images.githubusercontent.com/23396902/216224815-8cdc3f36-6493-4d80-afc8-c4c26ddb2b5c.png"> |

  [![Windows](https://img.shields.io/badge/OS-Windows-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/win64/insecure_win_gui.zip?branch=pull/245)
  [![Intel macOS](https://img.shields.io/badge/OS-Intel%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos/insecure_mac_gui.zip?branch=pull/245)
  [![Apple Silicon macOS](https://img.shields.io/badge/OS-Apple%20Silicon%20macOS-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/macos_arm64/insecure_mac_arm64_gui.zip?branch=pull/245)
  [![ARM64 Android](https://img.shields.io/badge/OS-Android-green)](https://api.cirrus-ci.com/v1/artifact/github/bitcoin-core/gui-qml/android/insecure_android_apk.zip?branch=pull/245)

ACKs for top commit:
  johnny9:
    ACK 7968ca99b4489a0d55203b4e3ed36122dbf89fa9

Tree-SHA512: 931f79d4950476e74ebd24d5c9389f364e84ef199e4407e225f11792422be7b0acf4c0abd3cf3feb4f0b03d9a6b9c96af947dc6709249bc4857f7c3da66e7b80
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.

3 participants