Skip to content

Refactor update checks to directly query API and restore Alpha channel#46

Open
aryanchoudharypro wants to merge 3 commits intonvda-es:masterfrom
aryanchoudharypro:alpha
Open

Refactor update checks to directly query API and restore Alpha channel#46
aryanchoudharypro wants to merge 3 commits intonvda-es:masterfrom
aryanchoudharypro:alpha

Conversation

@aryanchoudharypro
Copy link
Copy Markdown

@aryanchoudharypro aryanchoudharypro commented Apr 4, 2026

what's changed?

This pull request brings back support for the "Alpha (snapshots)" channel and completely refactors how the add-on checks for updates. Instead of temporarily overriding the core NVDA version string to trick the standard update checker (which historically caused issues with portable copies), the add-on now directly queries the NV Access API.

Why is this necessary?

The previous workaround for fetching update info was brittle and relied on catching specific RuntimeError exceptions from the core updateCheck module. By making direct, localized HTTP requests to api.nvaccess.org using the requested versionType, the codebase is significantly cleaner, safer, and less prone to breaking NVDA's native update mechanics.

Key Changes:

  • Alpha Support: Added snapshot:alpha back to the UI and channel arrays.
  • Direct API Queries: Implemented urllib.request to securely fetch update payloads from the NV Access API without mutating buildVersion.version.
  • Thread Safety: Replaced direct UI modifications inside the update thread with wx.CallAfter(self.onChoice, None) to prevent wxWidgets thread crashes.
  • Graceful Parsing: Updated displayUpdateInfo to utilize getattr when checking properties on the UpdateInfo object, ensuring compatibility across different NVDA API versions.
  • Modernization: Switched from setDaemon(True) to .daemon = True to comply with modern Python 3 threading standards.
  • Cleanup: Improved the terminate method in GlobalPlugin to safely restore original updateCheck functions and remove settings panels without throwing exceptions.

- Added `snapshot:alpha` to available update channels.
- Replaced the version string manipulation workaround with direct API requests to `api.nvaccess.org/nvdaUpdateCheck`.
- Refactored `checkForUpdateReplacement` and `getAvailableUpdates` to parse native `UpdateInfo` responses.
- Improved GUI thread safety by utilizing `wx.CallAfter` for choice updates.
- Modernized thread daemonization (`.daemon = True`).
- Enhanced error handling and fallback property checking for update data.
- Streamlined `GlobalPlugin` initialization and termination logic.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the add-on’s update-checking logic to query the NV Access update API directly (instead of mutating NVDA’s version string) and restores support for the “Alpha (snapshots)” channel.

Changes:

  • Re-adds the snapshot:alpha channel option to the channel list and settings UI.
  • Replaces the prior updateCheck/version-string workaround with direct urllib calls to api.nvaccess.org.
  • Adjusts UI/thread interactions (e.g., wx.CallAfter) and update-info parsing for cross-version compatibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +204 to +215
elif updateVersionInfo == 1:
# TRANSLATORS: Message displayed when there are no updates available on the selected channel.
channelInfoText = _("Already updated")
elif self.thGetAvailableUpdates.is_alive():
# TRANSLATORS: Message displayed when retrieval of update information has not yet been completed.
channelInfo = _("searching update info")
else:
channelInfo = ""
if channels[self.channels.Selection] is None:
# TRANSLATORS: When disable updates has been selected, the current version information is displayed.
channelInfo = _("Current version: {version} build {version_build}").format(
version=buildVersion.version,
version_build=buildVersion.version_build,
)
self.channelInfo.Value = channelInfo
channelInfoText = _("searching update info")
elif channels[self.channels.Selection] is None:
# TRANSLATORS: When disable updates has been selected, the current version information is displayed.
channelInfoText = _("Current version: {version} build {version_build}").format(
version=buildVersion.version,
version_build=buildVersion.version_build,
)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

When the "Disable updates" option is selected, this code can still show "searching update info" while the background thread is running, because the disabled-option message is only set after the is_alive() branch. Consider prioritizing the disabled-option display regardless of background retrieval state so the UI reflects the user’s selection immediately.

Copilot uses AI. Check for mistakes.
aryanchoudharypro and others added 2 commits April 4, 2026 16:21
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

2 participants