Skip to content

Hide download options offline, remove Refactor - #106

Merged
eliasbakken merged 2 commits into
mainfrom
feature/hide-download-options-offline
Aug 11, 2026
Merged

Hide download options offline, remove Refactor#106
eliasbakken merged 2 commits into
mainfrom
feature/hide-download-options-offline

Conversation

@eliasbakken

Copy link
Copy Markdown
Contributor

Summary

  • Adds a has-internet script + /api/has_internet endpoint checking GitHub reachability specifically, and hides the GitHub-download methods (Rebuild) in the UI when there's no internet - closes Enable only file upload when there is no internet connection #74
  • checkInternet() runs on page load and when the WiFi setup window closes
  • Removes the "Refactor" download method entirely (dropdown entry, data, and all id==1 branches) since it's no longer offered
  • Fixes two bugs found live-testing on the board in AP mode:
    • getGithubImages() only ran once in created() and never retried, so rebuildImages stayed empty forever if the page loaded before internet was available - now retriggered from checkInternet() once connectivity is confirmed
    • Removing Refactor shifted availableMethods, so hardcoded availableMethods[2] lookups went out of bounds and crashed the app with no internet - switched to id-based lookups

Test plan

  • Live-tested on real hardware: switched board to AP mode via serial console, confirmed dropdown no longer shows Refactor and the app no longer crashes with no internet
  • Confirmed image list repopulates after connecting to WiFi via the setup window
  • make build-vue succeeds with no errors

🤖 Generated with Claude Code

Rebuild and Refactor both download an image from GitHub via the board
itself (flash-from-url's wget) - without internet that can't work, so
show only the local-file paths (upload, magic upload, install an
already-present local image) instead.

Added has-internet, a quick wget --spider check (5s timeout) against
github.com specifically rather than a generic reachability target -
that's the actual dependency for both the image downloads and the
release list the UI fetches, and a generic check could pass while
GitHub itself is unreachable.

The client checks this once on load (optimistically defaults to
showing everything so the options aren't shown then immediately
hidden while the check is in flight) and filters the method dropdown
accordingly, switching the current selection to Upload if it was on a
now-hidden option.

Live-tested on real hardware via the actual /api/has_internet call:
normal connectivity reports true, and genuine AP-mode isolation (no
WAN uplink at all, not just a blocked host) reports false correctly.

Closes #74
Refactor is no longer offered - remove it from the method dropdown,
data, and all id==1 branches rather than leaving them as dead code.

Also fixes two real bugs found while live-testing on AP mode:
- getGithubImages() only ran once in created(), so if it ran before
  internet was available it never retried - rebuildImages stayed
  permanently empty even after connecting via the WiFi setup window.
  checkInternet() now retriggers it once connectivity is confirmed.
- Removing the Refactor entry shifted availableMethods, so the
  hardcoded availableMethods[2] lookups (meant for File upload) went
  out of bounds and crashed the app with no internet. Switched to
  id-based lookups so this can't happen again from array reordering.
@eliasbakken
eliasbakken merged commit 66df5f4 into main Aug 11, 2026
1 check passed
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.

Enable only file upload when there is no internet connection

1 participant