Skip to content

fix(receive): keep a completed transfer on screen across rotation and tab switches - #9

Merged
BlackPool25 merged 1 commit into
mainfrom
fix/preserve-receive-state-rotation
Aug 3, 2026
Merged

BlackPool25 merged 1 commit into
mainfrom
fix/preserve-receive-state-rotation

Conversation

@BlackPool25

Copy link
Copy Markdown
Owner

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:

  • New ReceiveSessionController (a plain ChangeNotifier — no new dependency) holds the persistent session: phase, verified ReassemblyResult, SaveResult, error. The transient decode machinery (camera, FrameBuffer, reassembler, live stats) stays in the view, and the CameraController lifecycle is untouched (never disposed/recreated on rotation — that is the black-screen bug class).
  • AppShell owns the controller for its whole lifetime and injects it into every ReceiveView it builds, so the completed state survives the tab switch and the breakpoint body swap.
  • Process-death defense: restorationScopeId: app on MaterialApp + RestorationMixin on 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 (uses tester.restartAndRestore), and Receive → Send → Receive preserves the completed receive state in 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 test

  • Manually tested on: Flutter Android (tab-switch and rebuild survival verified in widget tests; camera lifecycle untouched)

Checklist

  • No wire-format/codec change
  • CHANGELOG / docs updated if user-facing
  • If AI-assisted, I reviewed and understood every line

…, 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.
@BlackPool25
BlackPool25 merged commit 8a9fe47 into main Aug 3, 2026
2 checks passed
@BlackPool25
BlackPool25 deleted the fix/preserve-receive-state-rotation branch August 3, 2026 08:56
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