Skip to content

fix: improve location switching (cache refresh, debounce, accessibility)#267

Merged
Orinks merged 4 commits intodevfrom
fix/location-switch-bugs
Feb 8, 2026
Merged

fix: improve location switching (cache refresh, debounce, accessibility)#267
Orinks merged 4 commits intodevfrom
fix/location-switch-bugs

Conversation

@Orinks
Copy link
Owner

@Orinks Orinks commented Feb 8, 2026

Summary

Addresses multiple user-reported issues with location switching.

Bug Fixes

Performance

  • Instant location switching: Show cached weather data immediately when switching, then fetch fresh data in the background
  • Background cache pre-warming: After initial startup fetch, pre-warm cache for all other saved locations so subsequent switches are near-instant
  • 500ms debounce on rapid switching: Prevents API request storms when arrowing through the location list quickly
  • Generation counter: Stale fetch results from superseded requests are silently discarded, preventing UI flicker

Technical Details

  • refresh_weather_async(force_refresh=True) now supported for location-triggered refreshes
  • _fetch_generation counter ensures only the most recent fetch updates the UI
  • force_refresh bypasses the is_updating guard so location switches aren't blocked by in-flight requests
  • wx.Choice + EVT_CHOICE replaces wx.ComboBox(CB_READONLY) + EVT_COMBOBOX

Testing

  • All 911 tests passing, lint clean
  • Manual testing recommended for the wx.Choice change with NVDA

Fixes #264, helps diagnose #266, fixes #268

- Pass force_refresh=True to get_weather_data when location changes,
  ensuring fresh data instead of stale cached results
- Add logging when set_current_location fails to save, helping
  diagnose location persistence issues
- Fixes #264 (stale weather data after location switch)
- Helps diagnose #266 (location not persisting after restart)
…268)

wx.ComboBox with CB_READONLY doesn't fire EVT_COMBOBOX when using
arrow keys in collapsed state with screen readers (NVDA). Users had
to expand the dropdown and press Enter to change locations.

wx.Choice fires EVT_CHOICE on every selection change including
arrow key navigation, making location switching work intuitively
with screen readers.
- Show cached weather data immediately when switching locations,
  then refresh with fresh data in the background
- Pre-warm cache for all saved locations after initial startup fetch,
  so subsequent switches are instant
- Net effect: location switch goes from 2-5s (full API round-trip)
  to near-instant when cached data exists
- Add 500ms debounce timer on location change events so rapid arrow
  key presses only trigger one API fetch (for the final selection)
- Add generation counter to discard stale fetch results: if the user
  switches location again before a fetch completes, the old result
  is silently discarded instead of updating the UI
- Allow force_refresh fetches to proceed even when is_updating is set,
  preventing location switches from being blocked by in-flight fetches
@Orinks Orinks changed the title fix: force cache refresh when switching locations (#264, #266) fix: improve location switching (cache refresh, debounce, accessibility) Feb 8, 2026
@Orinks Orinks merged commit 841d1e2 into dev Feb 8, 2026
5 of 6 checks passed
@Orinks Orinks deleted the fix/location-switch-bugs branch February 8, 2026 03:11
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.

1 participant