-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SettingsQR: Final changes before official release #394
Conversation
* more docstrings * misc cleanup
As of commit f7c8213, I've taken a look at this; my thoughts: (tl;dr Nice Work!)
I did notice a few issues that were unexpected:
I was trying to make a SettingsQR out of this content:
Very nice work! I'm a big fan of this pr! |
Thank you, @jdlcdl, these are excellent notes! In the next few days I'll try to take a look at the unexpected/not ideal behaviors. |
Just food for thought, because it's crossed my mind recently. SettingsQR makes things so simple to do regularly w/o using persistent settings that I wonder: Should a load of SettingsQR EVER be allowed to set persistent_settings=True? I hope that this PR makes it into the next release. I'll argue to that end. |
src/seedsigner/models/settings.py
Outdated
@@ -47,42 +47,22 @@ def save(self): | |||
os.fsync(settings_file.fileno()) | |||
|
|||
|
|||
def update(self, new_settings: dict, disable_missing_entries: bool = True): | |||
def update(self, new_settings: dict, ): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this pr was submitted, pr-339 flow-tests framework has been merged.
In that pr, I was using the non-default "disabled_missing_entries=False" feature that is no longer present, so I'll be adjusting my test to setup in a one-by-one manner, otherwise this pr once merged would fail the test suite.
also, I think the trailing "," in the signature isn't intended, but I dont believe it's hurting anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing comma fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a sneaky trailing comma.
Since this pr was submitted, pr-339 flow-tests have been merged, and I had written a test that exploited the non-default boolean of "disabled_missing_entries=True" in settings.update(). This pr will fail tests because of this, but the fix is below: In tests/test_flows_seed.py's test_export_xpub_skip_non_option_flow() method: - self.settings.update({
- SettingsConstants.SETTING__SIG_TYPES: SettingsConstants.MULTISIG,
- SettingsConstants.SETTING__SCRIPT_TYPES: SettingsConstants.NESTED_SEGWIT,
- SettingsConstants.SETTING__COORDINATORS: SettingsConstants.COORDINATOR__SPECTER_DESKTOP,
- }, disable_missing_entries=False)
+ self.settings.set_value(SettingsConstants.SETTING__SIG_TYPES, [SettingsConstants.MULTISIG])
+ self.settings.set_value(SettingsConstants.SETTING__SCRIPT_TYPES, [SettingsConstants.NESTED_SEGWIT])
+ self.settings.set_value(SettingsConstants.SETTING__COORDINATORS, [SettingsConstants.COORDINATOR__SPECTER_DESKTOP]) |
In my summer-solstice comments, I'd mentioned that invalid settings entry values in a SettingsQR cause an exception that doesn't get raised, so users just fall back to MainMenu without understanding what happened... probably to retry the qrcode scan again and again (only geeky users who create invalid SettingsQRs). Sometimes even, the MainMenu doesn't get rendered and they're left with partial image of the scan, until they move around the MainMenu to repaint it. The last thing I want to do is break something major in a qr decoder, but I've made the following adjustment to models/decode.qr in SettingsQrDecoder.run() with hopes of seeing what the problem is. except Exception as e:
logger.exception(e)
- return DecodeQRStatus.INVALID
+ raise e which was provoked when trying to scan a SettingsQR with content of:
A similar change might also resolve my issue with trying to set qr_brightness in a SettingsQR, at least I'd know:
|
This pr plays well with pr #416 (maybe you should check it out?). |
Another comment I had made back in late June was: After a successful scan, if user uses the BACK button, they go into camera scan mode again, whereas I felt it would feel more natural (since it already succeeded and settings are updated) to land in the MainMenu. I've adjusted views/scan_views.py in ScanView.run() so that when self.decoder.is_settings, skip_current_view like so: elif self.decoder.is_settings:
from seedsigner.models.settings import Settings
settings = self.decoder.get_settings_data()
Settings.get_instance().update(new_settings=settings)
print(json.dumps(Settings.get_instance()._data, indent=4))
- return Destination(SettingsUpdatedView, {"config_name": self.decoder.get_settings_config_name()})
+ return Destination(SettingsUpdatedView, {"config_name": self.decoder.get_settings_config_name()}, skip_current_view=True) For a last nit-picky comment, but I'm not really sure, it could go either way: |
|
re: #394 (comment) Agreed. Now letting exceptions in the SettingsQR decoder bubble up to the UI, where possible. |
* Move post-SettingsQR View to settings_views.py * Improve ingestion cleaning to gracefully handle single-value `Settings.update()` entries for multi-select settings. * Improve Exception handling and onscreen error reporting during SettingsQR parsing. * move tests accordingly out of SettingsQR and into Settings.
ACK Tested |
I believe this should complete the last todo "Update the developer instructions and the git submodule to point to the main SeedSigner repo and its dev branch." in SeedSigner/seedsigner#394
SettingsQR has been quietly supported for a while, but this PR will fully promote SettingsQR to be a user-facing feature.
Two repos have to work hand-in-hand here:
Changes in this PR:
The expected SettingsQR format has been slightly tweaked.
Parsing them has been greatly simplified.
Missing settings (either in an onboard settings.json file or in a scanned SettingsQR) are now set to their default value. The only exception are hidden settings (e.g.
qr_brightness
); their values are preserved if they are already in the current settings.How to test
You can use the current public SettingsQR Generator as-is: https://seedsigner.github.io/seedsigner-settings-generator
It is in sync with the changes in this PR.
If you want to build the SettingsQR Generator locally, follow the instructions in the repo. Just note that there is a dependence on the SeedSigner repo and it is currently pointing to this branch in my fork.
Before the SettingsQR Generator is fully released, we must:
git
submodule to point to the main SeedSigner repo and itsdev
branch.