_onSearchChanged fired on every keystroke and launched concurrent IMAP searches via unawaited(_runSearch(...)). A slower earlier search completing after a faster later search would overwrite _searchResults with stale data — causing the wrong email to open when tapping a result (issue #467).
Added a _searchGeneration counter in EmailListScreen (incremented on each search start). Results are only applied when generation == _searchGeneration, so any in-flight response from a superseded query is silently discarded.
Clearing the search field resets state immediately without waiting for pending requests.
Test plan
New test: tapping first of multiple search results opens the correct email — verifies the right EmailDetailScreen opens
New test: stale results from a slower concurrent search are discarded — uses a Completer to simulate out-of-order IMAP responses; confirms the newer result wins even after the stale one resolves
All 23 widget tests pass: fvm flutter test test/widget/
## Summary
- `_onSearchChanged` fired on every keystroke and launched concurrent IMAP searches via `unawaited(_runSearch(...))`. A slower earlier search completing after a faster later search would overwrite `_searchResults` with stale data — causing the wrong email to open when tapping a result (issue #467).
- Added a `_searchGeneration` counter in `EmailListScreen` (incremented on each search start). Results are only applied when `generation == _searchGeneration`, so any in-flight response from a superseded query is silently discarded.
- Clearing the search field resets state immediately without waiting for pending requests.
## Test plan
- [x] New test: *tapping first of multiple search results opens the correct email* — verifies the right `EmailDetailScreen` opens
- [x] New test: *stale results from a slower concurrent search are discarded* — uses a `Completer` to simulate out-of-order IMAP responses; confirms the newer result wins even after the stale one resolves
- [x] All 23 widget tests pass: `fvm flutter test test/widget/`
Refs #467
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
_onSearchChangedfired on every keystroke and launched concurrent IMAP searches viaunawaited(_runSearch(...)). A slower earlier search completing after a faster later search would overwrite_searchResultswith stale data — causing the wrong email to open when tapping a result (issue #467)._searchGenerationcounter inEmailListScreen(incremented on each search start). Results are only applied whengeneration == _searchGeneration, so any in-flight response from a superseded query is silently discarded.Test plan
EmailDetailScreenopensCompleterto simulate out-of-order IMAP responses; confirms the newer result wins even after the stale one resolvesfvm flutter test test/widget/Refs #467