Repository navigation
fix(receive): keep a completed transfer on screen across rotation and tab switches - #9
Merged
Merged
Conversation
…, breakpoint rebuilds, and process death The receive view's State was the sole owner of the session (phase, result, saved, verified, error), so tab switches and the 600dp breakpoint body swap disposed it and dropped the user back to the idle card; process death had no restoration anywhere. Move the persistent session state into an app-scoped ReceiveSessionController that the shell owns for its whole lifetime and passes into every ReceiveView it builds; the view writes every transition through to it and rehydrates from it on State creation. Add state restoration (RestorationMixin + MaterialApp restorationScopeId) so the saved-file metadata survives process death. The transient decode machinery (camera, FrameBuffer, reassembler, stats) stays view-owned and the camera lifecycle is untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & Why
Rotating the phone (or switching tabs) after receiving a file reset the app to the idle/home screen: all receive-session state lived in
_ReceiveViewState, which is disposed whenever the 600dp breakpoint swaps the shell layout (rotation) or the tab changes. There was also no state restoration at all, so a backgrounded-and-killed app lost everything.The receive session state now lives in an app-scoped controller:
ReceiveSessionController(a plainChangeNotifier— no new dependency) holds the persistent session: phase, verifiedReassemblyResult,SaveResult, error. The transient decode machinery (camera, FrameBuffer, reassembler, live stats) stays in the view, and theCameraControllerlifecycle is untouched (never disposed/recreated on rotation — that is the black-screen bug class).AppShellowns the controller for its whole lifetime and injects it into everyReceiveViewit builds, so the completed state survives the tab switch and the breakpoint body swap.restorationScopeId: apponMaterialApp+RestorationMixinon the receive view restore the saved-file metadata (name, method, uri) so the "File saved" card reappears after the app is killed in the background. The received bytes are not restorable and never re-enter the controller — the file is already on disk.How it was tested
New:
a completed receive survives a rebuild bound to the same controller (tab switch),a completed receive survives the 600dp breakpoint (rotation) rebuild,process death restores the saved card from restoration data(usestester.restartAndRestore), andReceive → Send → Receive preserves the completed receive statein the shell test. The rebuild tests fail on the previous code (the view resets to the idle card).cd flutter_app/rust && cargo build --lib && cd flutter_app && flutter analyze && flutter test— 113 tests pass.flutter analyze+flutter testManually tested on: Flutter Android (tab-switch and rebuild survival verified in widget tests; camera lifecycle untouched)
Checklist