Skip to content

Suggest firmware updates and auto-open device info post-connect#488

Open
makermelissa-piclaw wants to merge 3 commits intocircuitpython:betafrom
makermelissa-piclaw:fix/issue-357-firmware-update-check
Open

Suggest firmware updates and auto-open device info post-connect#488
makermelissa-piclaw wants to merge 3 commits intocircuitpython:betafrom
makermelissa-piclaw:fix/issue-357-firmware-update-check

Conversation

@makermelissa-piclaw
Copy link
Copy Markdown
Contributor

@makermelissa-piclaw makermelissa-piclaw commented May 6, 2026

Refs #357.

Adds a small firmware-check helper 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.js parses CircuitPython version strings (e.g. 9.2.8, 10.0.0-alpha.1, 10.0.0-rc.0, plus a tolerant -dirty suffix) into a comparable structure.
  • It fetches the list of releases from 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.
  • It then applies the rules from Check if running latest firmware and suggest upgrade #357 to decide what to suggest:
    • If the user is on a development release:
      • Suggest the latest stable if it is newer than what they're on.
      • Suggest the latest dev release if it is newer than what they're on.
    • If the user is on a stable release:
      • Suggest a newer stable if any.
      • Suggest the latest dev release if any.
    • If only a stable release exists at all (no current dev), only the stable suggestion shows up.
  • Both DiscoveryModal and DeviceInfoModal now 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:

  • One-shot per connection session — silent reconnects do NOT re-pop the dialog.
  • Reset on actual disconnect via disconnectCallback.
  • Fire-and-forget so the rest of the post-connect flow (busy spinner, parameterized doc loading) isn't blocked while the user reads the info.
  • Gated on workflow.connectionStatus() so it doesn't try to open before the workflow has fully connected.

USBWorkflow.onConnected was also reordered to run super.onConnected(e) before loadEditor() — previously loadEditor ran while _connected was still CONNSTATE.partial, which would have made the new gate skip the dialog on USB.

Why GitHub releases?

circuitpython.org does 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

  • The suggestion box is rendered into a container that is empty by default, so the dialog layout doesn't shift if the API hasn't responded yet — and &:empty { display: none; } hides the container entirely if there's nothing to suggest.
  • API failures are non-fatal: a console warning is logged and the dialog renders unchanged.

Notes for review

  • Version comparison treats stable as ranked above any pre-release at the same X.Y.Z (e.g. 10.0.0 > 10.0.0-rc.0 > 10.0.0-beta.0 > 10.0.0-alpha.1).
  • Pre-release labels are ranked alpha < beta < rc and then by their numeric suffix.
  • The repo doesn't have a JS test setup, so I verified the parser/comparator and suggestion logic with a quick Node import of the module locally; happy to paste those checks as a comment or to add a tiny browser sketch if useful.

@makermelissa-piclaw
Copy link
Copy Markdown
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.

  • Trigger moved from checkConnected() (Web-only branch) into loadEditor(), which all three workflows already call after a successful connect.
  • A one-shot shownDeviceInfoForCurrentSession flag prevents silent reconnects from re-popping the dialog; the flag resets on disconnect.
  • Dialog is opened fire-and-forget so the post-connect spinner / parameterized doc loading isn't blocked while the user reads the info.
  • Removed the now-redundant explicit showInfo() calls in checkConnected() and the URL-backend bootstrap path.

@makermelissa-piclaw makermelissa-piclaw force-pushed the fix/issue-357-firmware-update-check branch from 274e5bf to 75a756e Compare May 6, 2026 19:23
@makermelissa-piclaw makermelissa-piclaw changed the base branch from main to beta May 6, 2026 19:23
@makermelissa-piclaw makermelissa-piclaw changed the title Suggest firmware updates in device info dialogs (closes #357) Suggest firmware updates and auto-open device info post-connect May 6, 2026
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.
@makermelissa-piclaw makermelissa-piclaw force-pushed the fix/issue-357-firmware-update-check branch from 75a756e to ffcc069 Compare May 6, 2026 19:27
@makermelissa makermelissa requested a review from tannewt May 6, 2026 19:29
@makermelissa
Copy link
Copy Markdown
Collaborator

I tested this locally.

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.

Check if running latest firmware and suggest upgrade

2 participants