Fix multi-account switching during authentication and auto-sync - #169
Merged
Merged
Conversation
Prioritize explicit account selections over in-flight authentication on the main and search screens. Add regression tests for multi-account switching and include the Gradle priority setting. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Share a cancellation-safe initialization handoff between Main and Search, finish scheduling when WorkManager reaches a terminal state, and cover rapid account changes with auto-sync enabled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Account selections can still be dropped when initialization is active in the other view model.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Improves account-switch handoffs during authentication and ensures auto-sync scheduling terminates correctly.
Changes:
- Serializes rapid account selections with cancellation-safe handoffs.
- Stops waiting after WorkManager reaches a terminal state.
- Adds Robolectric coverage and WorkManager test support.
| File | Description |
|---|---|
AccountInitialization.kt |
Adds account-initialization handoff helper. |
MainViewModel.kt |
Uses handoff and terminal sync state. |
SearchViewModel.kt |
Applies handoff to search authentication. |
AccountSelectionViewModelTest.kt |
Adds account-switch regressions. |
app/build.gradle.kts |
Adds WorkManager testing dependency. |
libs.versions.toml |
Defines WorkManager testing artifact. |
gradle.properties |
Lowers Gradle process priority. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Cancel and join an in-flight initializer when the modal account picker returns a new choice from another screen. Refresh the main drawer account on resume, and cover picker handoff with deterministic Robolectric tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.


Summary
AuthAccountInitializernow tracks all in-flight initializations and cancels/joins running and queued predecessors before an explicit selection; a real sync remains fail-fast. The redundant ViewModel-level waiting helper was removed.Validation
:app:testDebugUnitTestand:app:ktlintCheckpassed locally. The A → queued X → B cancellation test failed before the fix and passed after it.SearchSurfacesUiTestcould not find the "Settings" drawer menu. Its check appears green because the test step usescontinue-on-error; the earlier PR run reported the same UI-test failure, and the pre-PR master run had startup Compose-hierarchy failures.