Skip to content

feat: offline mode detection with local asset cache#117

Merged
SuperKali merged 10 commits into
mainfrom
feat/offline-mode-asset-cache
Mar 20, 2026
Merged

feat: offline mode detection with local asset cache#117
SuperKali merged 10 commits into
mainfrom
feat/offline-mode-asset-cache

Conversation

@SuperKali
Copy link
Copy Markdown
Member

Summary

  • Add connectivity monitoring (30s polling) with graceful UI degradation when offline
  • Implement local disk cache for board images, vendor logos, and API responses
  • Pre-populate all assets in background on app startup for instant rendering
  • Dedicated offline homepage layout with custom image and cached image options
  • Cache-first image loading across all components (base64 data URIs, cross-platform)

Changes

Backend (Rust)

  • picture_cache.rs — New module: ETag-based asset cache with conditional refresh, atomic metadata updates, background pre-population
  • images/mod.rs — API response saved to disk for offline board detection (atomic temp+rename writes)
  • commands/system.rscheck_connectivity command with static shared HTTP client
  • commands/scraping.rsget_cached_board_image / get_cached_vendor_logo commands serving base64 data URIs
  • Removed unused get_board_image_url command

Frontend (React/TypeScript)

  • useConnectivity hook — polls backend every 30s, optimistic default
  • Offline homepage — two-button layout (Custom Image + Cached Images) with offline badge in header
  • Cache-first loading in BoardModal, FlashProgress, useVendorLogos, CacheManagerModal
  • Resets API-dependent selections when going offline, shows reconnect toast on recovery
  • Detected Armbian boards in custom/cached images show full 4-step read-only layout

i18n — 6 new keys across all 18 languages

Testing

Tested on macOS ARM64 (M2 Pro) in dev environment.

Implement a disk-based cache for board images and vendor logos with
ETag-based conditional refresh. Assets are served cache-first with
background staleness checks after 24 hours.

- Store assets under {cache_dir}/assets/boards/ and vendors/
- Track ETags, Last-Modified, and URLs in meta.json
- Atomic metadata updates with mutex-protected read-modify-write
- Background pre-population of all assets on app startup
- Serve cached images as base64 data URIs for cross-platform support
- Semaphore-limited concurrency (5 parallel downloads)
- Path traversal protection on asset keys
Add check_connectivity Tauri command that performs a HEAD request
to the Armbian API with a 5-second timeout. Uses a static shared
HTTP client to avoid rebuilding on each 30-second poll cycle.
Save the armbian-images.json API response to disk after each
successful fetch. When the API is unreachable, fall back to the
cached copy. Uses atomic temp-file-plus-rename writes to prevent
partial reads from concurrent access.
Add get_cached_board_image and get_cached_vendor_logo Tauri commands
that serve cached assets as base64 data URIs. Register all new
commands and spawn background asset refresh on app startup.

Remove unused get_board_image_url command (replaced by cache-first
approach).
Add useConnectivity hook that polls the backend every 30 seconds
to detect online/offline state. Add IPC wrappers for connectivity
check, cached board images, and cached vendor logos. Remove unused
getBoardImageUrl wrapper.
Redesign the home page with context-aware layouts:
- Offline (no selection): show custom image and cached images buttons
  with compact offline badge in header
- Detected Armbian custom/cached image: show 4 read-only info buttons
- Generic custom image: show OS + Storage buttons only
- Normal flow: standard 4-step wizard

Hide MOTD tips when offline. Reset API-dependent selections when
connectivity is lost. Show reconnection toast on recovery.
Replace remote URL-based image loading with cache-first approach
across all components:
- BoardModal: load board thumbnails from local cache
- FlashProgress: load board image from cache
- useVendorLogos: load vendor logos from cache with remote fallback
- App.tsx: use cached board image for Armbian detection modal

Guard Armbian board detection when offline and support detected
boards in the cached image reuse flow.
Load board data optionally in CacheManagerModal — gracefully degrade
to filename-based metadata when the API is unreachable. Export
CacheManagerModal from settings barrel for standalone use in the
offline homepage layout.
Add translation keys across all 18 locale files:
- home.offlineBanner: offline warning message
- home.connectionRestored: reconnection toast
- home.offlineHint: offline layout description
- home.cachedImages: cached images button label
- home.changeCachedImage: change cached image button
- common.offline: compact offline badge label
Replace removed get_board_image_url reference with the new
get_cached_board_image and get_cached_vendor_logo commands.
@github-actions
Copy link
Copy Markdown

🧪 Test Builds

Version: 0.0.0-pr.117 | PR: #117 | Status: ready for testing

Platform Download
Linux x64 📦 .deb / .AppImage
Windows x64 📦 .exe
macOS ARM64 📦 .dmg
ℹ️ About these builds
  • 🔓 Public downloads via nightly.link (no GitHub login required)
  • ⚠️ Unsigned builds for testing purposes only
  • Expires in 7 days
  • 🔄 Updated on every push to this PR

@github-actions github-actions Bot added the status: ready for review Ready to be reviewed label Mar 19, 2026
@SuperKali
Copy link
Copy Markdown
Member Author

Tested on Windows 11, works as expected, @igorpecovnik i wait your confirm on Linux

@igorpecovnik
Copy link
Copy Markdown
Member

image

@SuperKali SuperKali merged commit 40ba59a into main Mar 20, 2026
@SuperKali SuperKali deleted the feat/offline-mode-asset-cache branch March 20, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready for review Ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants