Skip to content
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

Add ability to specify add-on store metadata URL from within NVDA #17099

Merged
merged 34 commits into from
Sep 5, 2024

Conversation

SaschaCowley
Copy link
Member

@SaschaCowley SaschaCowley commented Sep 2, 2024

Link to issue number:

Closes #14974

Summary of the issue:

The add-on store metadata URL is currently hard-coded in NVDA. This presents problems for users who are unable to use the default URL for any reason. This particularly affects users in the People's Republic of China, many of whom are unable to access the add-on store at an acceptable speed. A community add-on exists to work around this, but a means of specifying a mirror directly within NVDA is considered a better approach.

Description of user facing changes

Added a text box in Add-on store settings that allows users to specify the URL to use for the add-on store. Added slightly more helpful wording to add-on store errors that encourages users to check the metadata URL if there are issues accessing the add-on store and a custom URL is in use.

Description of development approach

Added a config key, addonStore.baseURL, to hold the URL of the server to contact for add-on store data. Added a control to the settings dialog that is populated by and populates this config item. Removed addonStore.BASE_URL in favour of a private constant which holds the default base URL. Added a private function, addonStore.network._getBaseURL, which gets the custom URL if one is set, or the default otherwise. Modified addonStore.dataManager, refactoring the DisplayableError code into a helper function and adding some troubleshooting steps to the messages that NVDA shows when showing errors.

Testing strategy:

Tested accessing the add-on store with no mirror set, with an invalid mirror set, and with no internet access.

Known issues with pull request:

The settings dialog makes a best effort at normalizing the URL. However, URLs with incompatible protocols or other issues that will cause them to fail with the Add-on Store are not checked for. Users will see a message asking them to check the mirror URL if contacting the store fails and a mirror is in use.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Summary by CodeRabbit

  • New Features

    • Introduced a new option for users to specify a metadata mirror URL for the add-on store, enhancing flexibility and performance.
    • Added a settings dialog text box for entering the metadata mirror URL.
  • Bug Fixes

    • Improved error handling with new user suggestions when fetching add-on data fails.
  • Documentation

    • Updated user guide to include details on the new "Metadata Mirror" feature.
    • Revised changes documentation to reflect updates in the add-on store's configuration capabilities.
  • Chores

    • Removed the hardcoded BASE_URL, allowing for a more dynamic configuration model.

@XLTechie
Copy link
Collaborator

XLTechie commented Sep 2, 2024 via email

@cary-rowen
Copy link
Contributor

Thank you for this work.
Is it possible to allow users to customize the URL used for updates.
The Chinese community mirror add-on currently does this.

Alternatively, the feature should be placed in a more general settings category rather than just an add-on store.

@SaschaCowley SaschaCowley marked this pull request as ready for review September 2, 2024 06:24
@SaschaCowley SaschaCowley requested review from a team as code owners September 2, 2024 06:24
Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes introduce a new feature allowing users to specify a customizable metadata mirror URL for the add-on store. This enhancement addresses accessibility issues for users in regions with restricted access to the standard NV Access Add-on Store server. Additionally, the codebase has been refactored to improve error handling and URL management, ensuring better configurability and maintainability.

Changes

Files Change Summary
source/addonStore/dataManager.py Added methods for improved error handling and user suggestions when fetching add-on data fails.
source/addonStore/network.py Renamed BASE_URL to _DEFAULT_BASE_URL, added _getBaseURL() for dynamic URL retrieval.
source/config/configSpec.py Introduced a new configuration option baseURL for user-defined base URL in the add-on store.
source/config/validators.py Added _validate_url function as a placeholder for future URL validation logic.
source/gui/settingsDialogs.py Implemented a text box for entering the metadata mirror URL in the settings dialog.
user_docs/en/changes.md Documented the new feature for specifying a metadata mirror URL and changes to the base URL handling.
user_docs/en/userGuide.md Added a section detailing the new "Metadata Mirror" feature for user configuration.

Assessment against linked issues

Objective Addressed Explanation
Add an option to customize the mirror URL of metadata (#14974)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@SaschaCowley
Copy link
Member Author

@XLTechie, @cary-rowen the ability to specify an update mirror is planned as well. My plan was to do it in a separate PR so as to keep both PRs small.

@XLTechie note that these URLs are stored separately in NVDA, and I was not planning to merge them at present.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Outside diff range, codebase verification and nitpick comments (2)
source/addonStore/network.py (1)

53-57: Approve the addition of _getBaseURL() function with a minor suggestion.

The new _getBaseURL() function correctly implements the logic for retrieving a custom base URL from the configuration or falling back to the default value. This aligns well with the new customizable URL feature.

Consider adding a brief docstring to explain the function's purpose and return value. For example:

def _getBaseURL() -> str:
	"""
	Retrieve the base URL for the add-on store.
	Returns the user-configured URL if set, otherwise the default URL.
	"""
	if url := conf["addonStore"]["baseURL"]:
		return url
	return _DEFAULT_BASE_URL
user_docs/en/changes.md (1)

Line range hint 5-7: Consider adding release date.

The "Important notes" section is useful, but consider adding the release date for version 2024.1 to provide context for users.

source/addonStore/dataManager.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
@cary-rowen
Copy link
Contributor

NVDACN Mirror Add-on: https://github.com/nvdacn/NVDAUpdateMirror

@SaschaCowley
Copy link
Member Author

@cary-rowen thanks for this; I've actually been using your add-on as a guide for what needs changing :)

Copy link
Member

@seanbudd seanbudd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @SaschaCowley - the approach looks good, mostly UX feedback that it would be good to hear from @Qchristensen on

source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/config/configSpec.py Outdated Show resolved Hide resolved
source/addonStore/network.py Outdated Show resolved Hide resolved
source/config/validators.py Outdated Show resolved Hide resolved
source/addonStore/dataManager.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
user_docs/en/changes.md Outdated Show resolved Hide resolved
user_docs/en/changes.md Outdated Show resolved Hide resolved
user_docs/en/userGuide.md Outdated Show resolved Hide resolved
user_docs/en/userGuide.md Outdated Show resolved Hide resolved
@SaschaCowley SaschaCowley marked this pull request as ready for review September 3, 2024 07:48
source/addonStore/dataManager.py Outdated Show resolved Hide resolved
source/gui/__init__.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Outdated Show resolved Hide resolved
source/gui/settingsDialogs.py Show resolved Hide resolved
source/gui/settingsDialogs.py Show resolved Hide resolved
@SaschaCowley SaschaCowley marked this pull request as draft September 3, 2024 23:20
source/gui/guiHelper.py Outdated Show resolved Hide resolved
@SaschaCowley SaschaCowley marked this pull request as ready for review September 4, 2024 01:59
@SaschaCowley SaschaCowley marked this pull request as draft September 5, 2024 02:27
@SaschaCowley SaschaCowley marked this pull request as ready for review September 5, 2024 02:27
Copy link
Member

@Qchristensen Qchristensen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reads well, great work Sascha!

@SaschaCowley SaschaCowley merged commit f38e623 into master Sep 5, 2024
4 checks passed
@SaschaCowley SaschaCowley deleted the i14974 branch September 5, 2024 23:14
@github-actions github-actions bot added this to the 2025.1 milestone Sep 5, 2024
SaschaCowley added a commit that referenced this pull request Sep 23, 2024
…7151)

Related to #17099 

Summary of the issue:
The NVDA update check URL is currently hard-coded in NVDA. This presents problems for users who are unable to use the default URL for any reason. This particularly affects users in the People's Republic of China, many of whom are unable to access the  update check server at an acceptable speed. A community add-on exists to work around this, but a means of specifying a mirror directly within NVDA is considered a better approach.

Description of user facing changes
Added controls similar to the speech synthesizer or braille display controls to NVDA's general settings page that allow the user to change the update server in use.
Added slightly more helpful wording to update check errors that encourages users to check the mirror URL if there are issues accessing the update check server and a custom URL is in use.

Description of development approach
- Added a new string config item, `update.serverURL`, which defaults to the empty string.
- Added a private getter method to `updateCheck.py` which returns the configured URL if set, or the default otherwise. Made the `CHECK_URL` constant private since it is no-longer needed. Updated references to the constant to use the new getter, and to use f-strings rather than strf style substitutions.
- Changed `updateCheck.UpdateChecker._error` to return more helpful messages.
- Added a new class, `SetURLDialog`, to `gui.settingsDialogs`. This dialog allows for the input and testing of URLs, and saving them back to config. The dialog is flexible, with a view to using it for the mirror URL support in the Add-on Store added in #17099 .
- Modelled the new controls in the General page of NVDA's settings on the speech synth and braille display controls.
    - A difference is that I have chosen to populate the update mirror text box in the `onPanelActivated` method rather than in `makeSettings` to avoid code duplication between the first population and when populating after the mirror URL is changed.

Testing strategy:
Spoofed the NVDA version to 2024.1 stable by altering `buildVersion.py` and `versionInfo.py`. Tested checking for updates with:
- No mirror set
- No mirror set, but nvaccess.org redirected to localhost via the hosts file
- Mirror set to the NVDA-CN mirror, and nvaccess.org redirected to localhost via the hosts file
- Mirror set to example.com
- No mirror set and networking disabled
- Mirror set to a random string and networking disabled

Tested many scenarios in the new dialog to ensure it behaves as expected, including:
- Saving the same URL as in config (does nothing)
- Clearing the URL field (disables the test button)
- Typing in the URL field (enables the test button)
- Saving the empty string without testing it (does not prompt for test)
- Testing the URL when connected to the internet and the URL points to the NV Access NVDA update server (succeeds)
- Testing the URL when it points to an invalid URL (fails)
- Testing the URL when it points to a valid URL with no DNS records (fails)
- Testing a valid URL that points to a working but non-NVDA update server (fails)
- Testing a valid URL when offline (fails)
- Attempting to save an untested URL (warns but allows saving)
- Attempting to save a URL that failed the test (warns but allows saving)
- Attempting to save a URL that passed (succeeds)

Known issues with pull request:

The read-only URL text control line wraps, causing NVDA to sometimes only read part of the URL, and potentially causing odd visual layout.
The "Test..." button only performs a connection check. Connecting to a URL that returns invalid NVDA update data will still pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to the add-on store, allowing users to customize the mirror URL of metadata
7 participants