Suggest firmware updates and auto-open device info post-connect#488
Open
makermelissa-piclaw wants to merge 3 commits intocircuitpython:betafrom
Open
Suggest firmware updates and auto-open device info post-connect#488makermelissa-piclaw wants to merge 3 commits intocircuitpython:betafrom
makermelissa-piclaw wants to merge 3 commits intocircuitpython:betafrom
Conversation
Contributor
Author
|
Pushed a follow-up commit that makes USB and BLE behave the same as Web: the Device Info dialog now auto-opens once after every fresh connect, so the firmware-update suggestion is visible without the user needing to click the Info button.
|
274e5bf to
75a756e
Compare
Adds js/common/firmware-check.js, a small helper that: - Parses CircuitPython version strings (stable + alpha/beta/rc pre-releases, including '-dirty' build suffixes) into a comparable structure. - Fetches the latest stable and the latest dev pre-release of CircuitPython from the adafruit/circuitpython GitHub releases API (cached per page load). - Computes which updates are worth surfacing for the device's current version, following the rules from circuitpython#357: * If the user is on a development release, suggest a newer stable and/or a newer dev release when available. * If the user is on a stable release, suggest a newer stable and/or any newer dev release. Both DiscoveryModal and DeviceInfoModal now render those suggestions under the device info table with a link to the board's circuitpython.org download page (which only lists firmware that is actually built for that board). The container collapses when there is nothing to show, and any failure of the GitHub API call is non-fatal and silently leaves the dialog unchanged.
Previously, only the Web workflow opened the Device Info / Discovery dialog automatically after connecting. USB and BLE users had to click the Info button to see the firmware-update suggestion added in this PR. This change moves the post-connect 'show info' trigger into loadEditor() so all three workflows (Web / USB / BLE) behave the same way: connect once, see the dialog, see the firmware-update suggestion if any. To avoid spamming the dialog on silent reconnects, a one-shot flag (shownDeviceInfoForCurrentSession) tracks whether we've already shown it for the current connection; the flag is reset in disconnectCallback so a fresh connect always re-shows the dialog. The dialog is opened fire-and-forget so it doesn't block the rest of the post-connect flow. Removes the now-redundant explicit showInfo() calls in checkConnected() and the URL-backend bootstrap path.
In USBWorkflow.onConnected, loadEditor() was being called BEFORE super.onConnected() set _connected = CONNSTATE.connected. The new post-connect Device Info dialog trigger gates on connectionStatus(), which requires _connected == connected, so the dialog never opened for USB users. Reorder so super.onConnected() (which both flips the state flag and closes the connect dialog) runs first, then loadEditor() runs with connectionStatus() true. Also drop the redundant explicit connectDialog.close() call -- super.onConnected already closes it.
75a756e to
ffcc069
Compare
Collaborator
|
I tested this locally. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #357.
Adds a small
firmware-checkhelper and surfaces "newer firmware available" suggestions in the Discovery and Device Info modals, plus auto-opens the Device Info dialog after a fresh connect across all three workflows (Web / USB / BLE) so the suggestion is visible without needing to click the Info button.What it does
js/common/firmware-check.jsparses CircuitPython version strings (e.g.9.2.8,10.0.0-alpha.1,10.0.0-rc.0, plus a tolerant-dirtysuffix) into a comparable structure.api.github.com/repos/adafruit/circuitpython/releases(cached for the lifetime of the page) and picks the highest stable release and the highest dev pre-release.DiscoveryModalandDeviceInfoModalnow render those suggestions under the device info table, linking to the board's download page on circuitpython.org so the user gets the build that actually exists for their board.Post-connect dialog
Previously only the Web workflow auto-opened a dialog after connecting; USB/BLE users had to click the Info button to see device info (and now the firmware suggestion). This PR moves the post-connect "show info" trigger into
loadEditor()so all three workflows behave the same way:disconnectCallback.workflow.connectionStatus()so it doesn't try to open before the workflow has fully connected.USBWorkflow.onConnectedwas also reordered to runsuper.onConnected(e)beforeloadEditor()— previouslyloadEditorran while_connectedwas stillCONNSTATE.partial, which would have made the new gate skip the dialog on USB.Why GitHub releases?
circuitpython.orgdoes publish per-board builds via_data/files.json, but that file isn't exposed as a public endpoint. The GitHub releases API is CORS-friendly, doesn't require auth for low-volume reads, and is canonical for stable vs prerelease tags. Per-board availability is left to the deep-link to the board page, which only lists firmware that was actually built for that board.UX
&:empty { display: none; }hides the container entirely if there's nothing to suggest.Notes for review
10.0.0>10.0.0-rc.0>10.0.0-beta.0>10.0.0-alpha.1).alpha < beta < rcand then by their numeric suffix.