2.8 KiB
2.8 KiB
R1b — runs controller request independence
Focused correctness fix on retained candidate 6b8d5ea. Files:
lib/features/runs/ui/runs_controller.dart,
test/features/runs/ui/runs_controller_test.dart.
Fixes
- List and detail requests now use independent generations (
_listGeneration,_detailGeneration).load(initialId)no longer bumps the detail generation thatselect(initialId)also advances, so bothloadinganddetailLoadingclear when the requests resolve. Manual list loads also no longer invalidate valid detail refreshes. - List resyncs (
_reloadList) capture and check a list generation, so a stale reply cannot overwrite a newerload(). Concurrent resync requests are coalesced into exactly one followup; a resync requested during a manual load runs after that load instead of being dropped. - Detail refreshes capture the current detail generation and selected run. Same-id refreshes keep the existing detail and are coalesced (in-flight plus one followup). Selecting a different run clears the previous detail instead of presenting it as the new run. Back/dispose invalidate pending replies, and stale requests cannot clear another generation's loading flags.
- Added
num? get selectedRunIdfor the native UI lane. All existing public methods and fields are preserved.
The existing 150 ms event debounce is retained; no polling or extra timers were introduced. File is 260 lines; the fix stays within the controller responsibility rather than fragmenting it.
Tests
Extended test/features/runs/ui/runs_controller_test.dart with regressions for:
load(initialId)resolves withloading == falseanddetailLoading == false.- Overlapping list loads with reversed completion order: newer reply wins.
- List resync leaves the selected detail request valid.
- Manual
load()does not invalidate an in-flight detail refresh. - Sparse unknown run events coalesce into one followup resync.
- A followup requested while a superseded resync is still marked in flight starts once that stale reply arrives instead of being stranded.
- Selected refresh coalescing (in-flight plus followup) and Back ignoring the pending reply.
- Choosing another run does not display the previous run's detail.
- Pending detail refresh is safe after dispose.
Existing six regression tests remain and pass.
Verification
/Users/alan/development/flutter/bin/flutter test test/features/runs/ui— 15 tests passed./Users/alan/development/flutter/bin/flutter test test/features/runs— 26 tests passed./Users/alan/development/flutter/bin/flutter analyze— no issues found.flutter build webnot run in this NONVISUAL controller slice; manager integration/UI review owns rendered and build acceptance.- Mobile remains unverified; no device or browser tools used.